Skip to content

Commit f279267

Browse files
authored
Doctrine: Add ToolEvents to listener heuristic (#342)
1 parent 11c0156 commit f279267

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Provider/DoctrineUsageProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private function isLifecycleEventMethod(ReflectionMethod $method): bool
220220

221221
/**
222222
* Ideally, we would need to parse DIC xml to know this for sure just like phpstan-symfony does.
223-
* - see Doctrine\ORM\Events::*
223+
* - see Doctrine\ORM\Events::* and Doctrine\ORM\Tools\ToolEvents::*
224224
*/
225225
private function isProbablyDoctrineListener(string $methodName): bool
226226
{
@@ -236,7 +236,9 @@ private function isProbablyDoctrineListener(string $methodName): bool
236236
|| $methodName === 'preFlush'
237237
|| $methodName === 'onFlush'
238238
|| $methodName === 'postFlush'
239-
|| $methodName === 'onClear';
239+
|| $methodName === 'onClear'
240+
|| $methodName === 'postGenerateSchemaTable'
241+
|| $methodName === 'postGenerateSchema';
240242
}
241243

242244
private function hasAttribute(

tests/Rule/data/providers/doctrine.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function postUpdate(): void {}
5656

5757
public function postPersist(): void {}
5858

59+
public function postGenerateSchemaTable(): void {}
60+
61+
public function postGenerateSchema(): void {}
62+
5963
public function deadCode(): void // error: Unused Doctrine\OldListenerHeuristics::deadCode
6064
{
6165

0 commit comments

Comments
 (0)