@@ -211,69 +211,6 @@ public function testFilesWithIdenticalPhpDocsUsingDifferentAliases(): void
211211 $ this ->assertSame ('AliasCollisionNamespace2\Foo ' , $ doc2 ->getVarTags ()['x ' ]->getType ()->describe (VerbosityLevel::precise ()));
212212 }
213213
214- public function testNodeCallbackLikeRectorInfiniteRecursionSimulation (): void
215- {
216- self ::createReflectionProvider ();
217-
218- /** @var FileTypeMapper $fileTypeMapper */
219- $ fileTypeMapper = self ::getContainer ()->getByType (FileTypeMapper::class);
220-
221- // Use nikic/php-parser directly to parse the file
222- $ parserFactory = new \PhpParser \ParserFactory ();
223- $ parser = $ parserFactory ->createForNewestSupportedVersion ();
224- $ baseModelPath = __DIR__ . '/data/bug-9684/BaseModel.php ' ;
225- $ code = file_get_contents ($ baseModelPath );
226- if ($ code === false ) {
227- $ this ->fail ('Failed to read BaseModel.php ' );
228- }
229- $ ast = $ parser ->parse ($ code );
230- if (!is_array ($ ast )) {
231- $ this ->fail ('Failed to parse BaseModel.php ' );
232- }
233-
234- $ traitUsages = [];
235- $ nodeCallback = function (Node $ node ) use (&$ traitUsages , &$ nodeCallback ) {
236- if ($ node instanceof \PhpParser \Node \Stmt \TraitUse) {
237- foreach ($ node ->traits as $ trait ) {
238- $ traitUsages [] = $ trait ->toString ();
239- }
240- }
241-
242- foreach ($ node ->getSubNodeNames () as $ name ) {
243- $ subNode = $ node ->{$ name };
244- if (is_array ($ subNode )) {
245- foreach ($ subNode as $ child ) {
246- if ($ child instanceof \PhpParser \Node) {
247- $ nodeCallback ($ child );
248- }
249- }
250- } elseif ($ subNode instanceof \PhpParser \Node) {
251- $ nodeCallback ($ subNode );
252- }
253- }
254- };
255-
256- foreach ($ ast as $ astNode ) {
257- $ nodeCallback ($ astNode );
258- }
259-
260- // Simulate Rector's repeated trait processing
261- $ traitFile = __DIR__ . '/data/bug-9684/RecursiveTrait.php ' ;
262- foreach ($ traitUsages as $ traitName ) {
263- // Simulate Rector's use: both className and traitName set, repeatedly, as Rector does when walking traits
264- for ($ i = 0 ; $ i < 20 ; $ i ++) {
265- $ fileTypeMapper ->getResolvedPhpDoc (
266- $ traitFile ,
267- 'Bug9684 \\BaseModel ' ,
268- 'Bug9684 \\RecursiveTrait ' ,
269- null ,
270- null
271- );
272- }
273- }
274- $ this ->assertNotEmpty ($ traitUsages , 'Trait usages should be found ' );
275- }
276-
277214 public function testRecursiveTraitUsedInAnonymousClassDoesNotLoopIndefinitely (): void
278215 {
279216 self ::createReflectionProvider ();
0 commit comments