Skip to content

Commit a3b36bd

Browse files
authored
EntityNotFinalRule - only entities that are final on language level should be considered
1 parent 9d798be commit a3b36bd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/Rules/Doctrine/ORM/EntityNotFinalRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3434
if ($classReflection === null) {
3535
throw new \PHPStan\ShouldNotHappenException();
3636
}
37-
if (!$classReflection->isFinal()) {
37+
if (!$classReflection->isFinalByKeyword()) {
3838
return [];
3939
}
4040

tests/Rules/Doctrine/ORM/EntityNotFinalRuleTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function ruleProvider(): Iterator
4545
],
4646
];
4747

48+
yield 'final annotated entity' => [
49+
__DIR__ . '/data/FinalAnnotatedEntity.php',
50+
[],
51+
];
52+
4853
yield 'final non-entity' => [
4954
__DIR__ . '/data/FinalNonEntity.php',
5055
[],
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Rules\Doctrine\ORM;
4+
5+
use Doctrine\ORM\Mapping as ORM;
6+
7+
/**
8+
* @final
9+
* @ORM\Entity()
10+
*/
11+
class FinalAnnotatedEntity
12+
{
13+
/**
14+
* @ORM\Id()
15+
* @ORM\GeneratedValue()
16+
* @ORM\Column(type="integer")
17+
*
18+
* @var int
19+
*/
20+
private $id;
21+
22+
}

0 commit comments

Comments
 (0)