Skip to content

Commit

Permalink
EntityNotFinalRule - only entities that are final on language level s…
Browse files Browse the repository at this point in the history
…hould be considered
  • Loading branch information
DanielBadura authored May 20, 2021
1 parent 9d798be commit a3b36bd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/Doctrine/ORM/EntityNotFinalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
if ($classReflection === null) {
throw new \PHPStan\ShouldNotHappenException();
}
if (!$classReflection->isFinal()) {
if (!$classReflection->isFinalByKeyword()) {
return [];
}

Expand Down
5 changes: 5 additions & 0 deletions tests/Rules/Doctrine/ORM/EntityNotFinalRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public function ruleProvider(): Iterator
],
];

yield 'final annotated entity' => [
__DIR__ . '/data/FinalAnnotatedEntity.php',
[],
];

yield 'final non-entity' => [
__DIR__ . '/data/FinalNonEntity.php',
[],
Expand Down
22 changes: 22 additions & 0 deletions tests/Rules/Doctrine/ORM/data/FinalAnnotatedEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types = 1);

namespace PHPStan\Rules\Doctrine\ORM;

use Doctrine\ORM\Mapping as ORM;

/**
* @final
* @ORM\Entity()
*/
class FinalAnnotatedEntity
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*
* @var int
*/
private $id;

}

0 comments on commit a3b36bd

Please sign in to comment.