File tree Expand file tree Collapse file tree 4 files changed +63
-1
lines changed
Expand file tree Collapse file tree 4 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 1010use PhpParser \Node \Expr \BinaryOp \Concat ;
1111use PhpParser \Node \Expr \ClassConstFetch ;
1212use PhpParser \Node \Expr \ConstFetch ;
13+ use PhpParser \Node \Name ;
1314use PhpParser \Node \Name \FullyQualified ;
1415use PhpParser \Node \Scalar \MagicConst \Dir ;
1516use PhpParser \Node \Scalar \MagicConst \File ;
@@ -185,7 +186,7 @@ private function getConstExprEvaluator(): ConstExprEvaluator
185186 }
186187
187188 // resolve "SomeClass::SOME_CONST"
188- if ($ expr instanceof ClassConstFetch) {
189+ if ($ expr instanceof ClassConstFetch && $ expr -> class instanceof Name ) {
189190 return $ this ->resolveClassConstFetch ($ expr );
190191 }
191192
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Core \Tests \Issues \Issue7536 ;
6+
7+ use Iterator ;
8+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
9+
10+ /**
11+ * @see https://github.com/rectorphp/rector/issues/7536
12+ */
13+ final class DynamicExprConstantTest extends AbstractRectorTestCase
14+ {
15+ /**
16+ * @dataProvider provideData()
17+ */
18+ public function test (string $ filePath ): void
19+ {
20+ $ this ->doTestFile ($ filePath );
21+ }
22+
23+ /**
24+ * @return Iterator<array<string>>
25+ */
26+ public function provideData (): Iterator
27+ {
28+ return $ this ->yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
29+ }
30+
31+ public function provideConfigFilePath (): string
32+ {
33+ return __DIR__ . '/config/configured_rule.php ' ;
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Core \Tests \Issues \Issue7536 \Fixture ;
4+
5+ use Symfony \Component \Form \FormInterface ;
6+
7+ class SkipDynamicClassConstFetch
8+ {
9+ private function pocMethod (FormInterface $ childType , FormInterface $ parentType )
10+ {
11+ $ parentType ->add (
12+ $ childType ->methodA (),
13+ $ childType ->methodB ()::class
14+ );
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Config \RectorConfig ;
6+ use Rector \Symfony \Rector \MethodCall \ChangeStringCollectionOptionToConstantRector ;
7+
8+ return static function (RectorConfig $ rectorConfig ): void {
9+ $ rectorConfig ->rule (ChangeStringCollectionOptionToConstantRector::class);
10+ };
You can’t perform that action at this time.
0 commit comments