We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f615b1a commit 2ac87fcCopy full SHA for 2ac87fc
src/Rules/Classes/ClassConstantRule.php
@@ -64,7 +64,11 @@ public function processNode(Node $node, Scope $scope): array
64
}
65
66
foreach ($constantNameScopes as $constantName => $constantScope) {
67
- $errors = array_merge($errors, $this->processSingleClassConstFetch($constantScope, $node, $constantName));
+ $errors = array_merge($errors, $this->processSingleClassConstFetch(
68
+ $constantScope,
69
+ $node,
70
+ (string) $constantName, // @phpstan-ignore cast.useless
71
+ ));
72
73
74
return $errors;
src/Rules/Methods/CallMethodsRule.php
@@ -47,7 +47,11 @@ public function processNode(Node $node, Scope $scope): array
47
48
49
foreach ($methodNameScopes as $methodName => $methodScope) {
50
- $errors = array_merge($errors, $this->processSingleMethodCall($methodScope, $node, $methodName));
+ $errors = array_merge($errors, $this->processSingleMethodCall(
51
+ $methodScope,
52
53
+ (string) $methodName, // @phpstan-ignore cast.useless
54
55
56
57
src/Rules/Methods/CallStaticMethodsRule.php
@@ -48,7 +48,11 @@ public function processNode(Node $node, Scope $scope): array
58
src/Rules/Variables/DefinedVariableRule.php
foreach ($variableNameScopes as $name => $variableScope) {
- $errors = array_merge($errors, $this->processSingleVariable($variableScope, $node, $name));
+ $errors = array_merge($errors, $this->processSingleVariable(
+ $variableScope,
+ (string) $name, // @phpstan-ignore cast.useless
tests/PHPStan/Analyser/AnalyserIntegrationTest.php
@@ -1570,6 +1570,20 @@ public function testBug12800(): void
1570
$this->assertNoErrors($errors);
1571
1572
1573
+ public function testBug12949(): void
1574
+ {
1575
+ // Fetching class constants with a dynamic name is supported only on PHP 8.3 and later
1576
+ if (PHP_VERSION_ID < 80300) {
1577
+ $this->markTestSkipped('Test requires PHP 8.3.');
1578
+ }
1579
+
1580
+ $errors = $this->runAnalyse(__DIR__ . '/data/bug-12949.php');
1581
+ $this->assertCount(3, $errors);
1582
+ $this->assertSame('Call to an undefined method object::0().', $errors[0]->getMessage());
1583
+ $this->assertSame('Call to an undefined static method object::0().', $errors[1]->getMessage());
1584
+ $this->assertSame('Access to undefined constant object::0.', $errors[2]->getMessage());
1585
1586
1587
/**
1588
* @param string[]|null $allAnalysedFiles
1589
* @return Error[]
tests/PHPStan/Analyser/data/bug-12949.php
@@ -0,0 +1,19 @@
1
+<?php
2
3
+namespace Bug12949;
4
5
+function doFoo():void {
6
+ $b = '0';
7
+ ${$b} = 1;
8
9
+ echo "";
10
+}
11
12
+function doBar(object $o):void {
13
14
+ $o->{$b}();
15
+ $o::{$b}();
16
+ echo $o::{$b};
17
18
19
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments