Skip to content

Commit

Permalink
Allow to install with phpstan-extensions installer (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Aug 6, 2022
1 parent c998ea6 commit aa7c160
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,12 @@
"composer/package-versions-deprecated": true,
"phpstan/extension-installer": true
}
},
"extra": {
"phpstan": {
"includes": [
"phpstan-extension.neon"
]
}
}
}
6 changes: 3 additions & 3 deletions src/EventSubscriber/TranslatableEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ private function mapTranslation(ClassMetadataInfo $classMetadataInfo, ObjectMana
->getMethod('getTranslatableEntityClass')
->invoke(null);

/** @var ClassMetadataInfo $targetEntityClassMetadataInfo */
$targetEntityClassMetadataInfo = $objectManager->getClassMetadata($targetEntity);
/** @var ClassMetadataInfo $classMetadata */
$classMetadata = $objectManager->getClassMetadata($targetEntity);

$singleIdentifierFieldName = $targetEntityClassMetadataInfo->getSingleIdentifierFieldName();
$singleIdentifierFieldName = $classMetadata->getSingleIdentifierFieldName();

$classMetadataInfo->mapManyToOne([
'fieldName' => 'translatable',
Expand Down
23 changes: 7 additions & 16 deletions src/Model/Tree/TreeNodeMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function toJson(?Closure $prepare = null): string
public function toArray(?Closure $prepare = null, ?array &$tree = null): array
{
if ($prepare === null) {
$prepare = fn (TreeNodeInterface $node): string => (string) $node;
$prepare = static fn (TreeNodeInterface $node): string => (string) $node;
}

if ($tree === null) {
Expand Down Expand Up @@ -229,9 +229,8 @@ public function toArray(?Closure $prepare = null, ?array &$tree = null): array
public function toFlatArray(?Closure $prepare = null, ?array &$tree = null): array
{
if ($prepare === null) {
$prepare = function (TreeNodeInterface $treeNode) {
$prepare = static function (TreeNodeInterface $treeNode) {
$pre = $treeNode->getNodeLevel() > 1 ? implode('', array_fill(0, $treeNode->getNodeLevel(), '--')) : '';

return $pre . $treeNode;
};
}
Expand All @@ -251,36 +250,28 @@ public function toFlatArray(?Closure $prepare = null, ?array &$tree = null): arr
}

/**
* @param mixed $offset
* @param TreeNodeInterface $node
*/
public function offsetSet($offset, $node): void
public function offsetSet(mixed $offset, $node): void
{
/** @var TreeNodeInterface $this */
$node->setChildNodeOf($this);
}

/**
* @param mixed $offset
*/
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool
{
return isset($this->getChildNodes()[$offset]);
}

/**
* @param mixed $offset
*/
public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
unset($this->getChildNodes()[$offset]);
}

/**
* @param mixed $offset
* @return mixed
*/
public function offsetGet($offset)
public function offsetGet(mixed $offset)
{
return $this->getChildNodes()[$offset];
}
Expand All @@ -297,6 +288,6 @@ protected function getExplodedPath(): array

$path = explode($separator, $this->getRealMaterializedPath());

return array_filter($path, fn ($item): bool => $item !== '');
return array_filter($path, static fn ($item): bool => $item !== '');
}
}
4 changes: 2 additions & 2 deletions tests/ORM/UuidableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function testUuidLoading(): void

$this->entityManager->clear();

$uuidableRepository = $this->entityManager->getRepository(UuidableEntity::class);
$entityRepository = $this->entityManager->getRepository(UuidableEntity::class);

/** @var UuidableInterface $entity */
$entity = $uuidableRepository->find($id);
$entity = $entityRepository->find($id);

$this->assertNotNull($entity);
$this->assertInstanceOf(UuidInterface::class, $entity->getUuid());
Expand Down

0 comments on commit aa7c160

Please sign in to comment.