Skip to content

Commit aa7c160

Browse files
Allow to install with phpstan-extensions installer (#709)
1 parent c998ea6 commit aa7c160

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,12 @@
6767
"composer/package-versions-deprecated": true,
6868
"phpstan/extension-installer": true
6969
}
70+
},
71+
"extra": {
72+
"phpstan": {
73+
"includes": [
74+
"phpstan-extension.neon"
75+
]
76+
}
7077
}
7178
}

src/EventSubscriber/TranslatableEventSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ private function mapTranslation(ClassMetadataInfo $classMetadataInfo, ObjectMana
123123
->getMethod('getTranslatableEntityClass')
124124
->invoke(null);
125125

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

129-
$singleIdentifierFieldName = $targetEntityClassMetadataInfo->getSingleIdentifierFieldName();
129+
$singleIdentifierFieldName = $classMetadata->getSingleIdentifierFieldName();
130130

131131
$classMetadataInfo->mapManyToOne([
132132
'fieldName' => 'translatable',

src/Model/Tree/TreeNodeMethodsTrait.php

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function toJson(?Closure $prepare = null): string
197197
public function toArray(?Closure $prepare = null, ?array &$tree = null): array
198198
{
199199
if ($prepare === null) {
200-
$prepare = fn (TreeNodeInterface $node): string => (string) $node;
200+
$prepare = static fn (TreeNodeInterface $node): string => (string) $node;
201201
}
202202

203203
if ($tree === null) {
@@ -229,9 +229,8 @@ public function toArray(?Closure $prepare = null, ?array &$tree = null): array
229229
public function toFlatArray(?Closure $prepare = null, ?array &$tree = null): array
230230
{
231231
if ($prepare === null) {
232-
$prepare = function (TreeNodeInterface $treeNode) {
232+
$prepare = static function (TreeNodeInterface $treeNode) {
233233
$pre = $treeNode->getNodeLevel() > 1 ? implode('', array_fill(0, $treeNode->getNodeLevel(), '--')) : '';
234-
235234
return $pre . $treeNode;
236235
};
237236
}
@@ -251,36 +250,28 @@ public function toFlatArray(?Closure $prepare = null, ?array &$tree = null): arr
251250
}
252251

253252
/**
254-
* @param mixed $offset
255253
* @param TreeNodeInterface $node
256254
*/
257-
public function offsetSet($offset, $node): void
255+
public function offsetSet(mixed $offset, $node): void
258256
{
259257
/** @var TreeNodeInterface $this */
260258
$node->setChildNodeOf($this);
261259
}
262260

263-
/**
264-
* @param mixed $offset
265-
*/
266-
public function offsetExists($offset): bool
261+
public function offsetExists(mixed $offset): bool
267262
{
268263
return isset($this->getChildNodes()[$offset]);
269264
}
270265

271-
/**
272-
* @param mixed $offset
273-
*/
274-
public function offsetUnset($offset): void
266+
public function offsetUnset(mixed $offset): void
275267
{
276268
unset($this->getChildNodes()[$offset]);
277269
}
278270

279271
/**
280-
* @param mixed $offset
281272
* @return mixed
282273
*/
283-
public function offsetGet($offset)
274+
public function offsetGet(mixed $offset)
284275
{
285276
return $this->getChildNodes()[$offset];
286277
}
@@ -297,6 +288,6 @@ protected function getExplodedPath(): array
297288

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

300-
return array_filter($path, fn ($item): bool => $item !== '');
291+
return array_filter($path, static fn ($item): bool => $item !== '');
301292
}
302293
}

tests/ORM/UuidableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public function testUuidLoading(): void
2323

2424
$this->entityManager->clear();
2525

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

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

3131
$this->assertNotNull($entity);
3232
$this->assertInstanceOf(UuidInterface::class, $entity->getUuid());

0 commit comments

Comments
 (0)