Skip to content

Commit 0253a68

Browse files
committed
[BE] Non-static methods cannot be used as static callables in PHP 8+
1 parent 2e02765 commit 0253a68

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

changelog-2.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ Bleeding edge (TODO move to other sections)
5757
* Check invalid PHPDocs in previously unchecked statement types (https://github.com/phpstan/phpstan-src/commit/9780d352f3264aac09ac7954f691de1877db8e01)
5858
* InvalidPHPStanDocTagRule in StubValidator (https://github.com/phpstan/phpstan-src/commit/9c2552b7e744926d1a74c1ba8fd32c64079eed61)
5959
* More precise `file()` flags args ([#2476](https://github.com/phpstan/phpstan-src/pull/2476), [#2482](https://github.com/phpstan/phpstan-src/pull/2482)), thanks @staabm!
60-
* Non-static methods cannot be used as static callables in PHP 8+ ([#2420](https://github.com/phpstan/phpstan-src/pull/2420)), thanks @staabm!
6160
* More precise `flock()` operation flags ([#2477](https://github.com/phpstan/phpstan-src/pull/2477)), thanks @staabm!
6261
* Rule for `call_user_func()` ([#2479](https://github.com/phpstan/phpstan-src/pull/2479)), thanks @staabm!
6362
* Analysis with zero files results in non-zero exit code (https://github.com/phpstan/phpstan-src/commit/46ff440648e62617df86aa74ba905ffa99897737), #9410
@@ -140,6 +139,7 @@ Improvements 🔧
140139
* Report invalid exclude paths in PHP config (https://github.com/phpstan/phpstan-src/commit/9718c14f1ffac81ba3d2bf331b4e8b4041a4d004)
141140
* Do not generalize template types, except when in `GenericObjectType` ([#2818](https://github.com/phpstan/phpstan-src/pull/2818), [#2821](https://github.com/phpstan/phpstan-src/pull/2821))
142141
* This fixes following **17 issues**: #8166, #8127, #7944, #7283, #6653, #6196, #9084, #8683, #8074, #7984, #7301, #7087, #5594, #5592, #9472, #9764, #10092
142+
* Non-static methods cannot be used as static callables in PHP 8+ ([#2420](https://github.com/phpstan/phpstan-src/pull/2420)), thanks @staabm!
143143

144144
Bugfixes 🐛
145145
=====================

src/Type/Constant/ConstantArrayType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Nette\Utils\Strings;
66
use PHPStan\Analyser\OutOfClassScope;
7-
use PHPStan\DependencyInjection\BleedingEdgeToggle;
87
use PHPStan\Internal\CombinationsHelper;
98
use PHPStan\Php\PhpVersion;
109
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
@@ -579,8 +578,7 @@ public function findTypeAndMethodNames(): array
579578
}
580579

581580
if (
582-
BleedingEdgeToggle::isBleedingEdge()
583-
&& $has->yes()
581+
$has->yes()
584582
&& !$phpVersion->supportsCallableInstanceMethods()
585583
) {
586584
$methodReflection = $type->getMethod($method->getValue(), new OutOfClassScope());

src/Type/Constant/ConstantStringType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Nette\Utils\Strings;
77
use PhpParser\Node\Name;
88
use PHPStan\Analyser\OutOfClassScope;
9-
use PHPStan\DependencyInjection\BleedingEdgeToggle;
109
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode;
1110
use PHPStan\PhpDocParser\Ast\Type\ConstTypeNode;
1211
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@@ -217,8 +216,7 @@ public function isCallable(): TrinaryLogic
217216
if ($classRef->hasMethod($matches[2])) {
218217
$method = $classRef->getMethod($matches[2], new OutOfClassScope());
219218
if (
220-
BleedingEdgeToggle::isBleedingEdge()
221-
&& !$phpVersion->supportsCallableInstanceMethods()
219+
!$phpVersion->supportsCallableInstanceMethods()
222220
&& !$method->isStatic()
223221
) {
224222
return TrinaryLogic::createNo();

0 commit comments

Comments
 (0)