Просмотр исходного кода

bug #5783 StaticLambdaFixer - consider parent:: as a possible reference to $this (fancyweb)

This PR was squashed before being merged into the 2.19 branch.

Discussion
----------

StaticLambdaFixer - consider parent:: as a possible reference to $this

Commits
-------

1afc42430 StaticLambdaFixer - consider parent:: as a possible reference to $this
Dariusz Ruminski 3 лет назад
Родитель
Сommit
b15ab5ff32

+ 4 - 0
src/Fixer/FunctionNotation/StaticLambdaFixer.php

@@ -175,6 +175,10 @@ final class StaticLambdaFixer extends AbstractFixer
                     return true; // "$$a" case
                 }
             }
+
+            if ($tokens[$i]->equals([T_STRING, 'parent'], false)) {
+                return true; // parent:: case
+            }
         }
 
         return false;

+ 13 - 0
tests/Fixer/FunctionNotation/StaticLambdaFixerTest.php

@@ -227,6 +227,19 @@ $b = new Q();
 $b->abc();
 ',
             ],
+            [
+                '<?php
+
+                class A {}
+                class B extends A {
+                    public function foo()
+                    {
+                        $c = function () {
+                            return parent::foo();
+                        };
+                    }
+                }',
+            ],
         ];
     }