Skip to content

Commit fcf1939

Browse files
committed
New behaviour around non-static methods used statically in callables only for bleeding edge
1 parent e035fc0 commit fcf1939

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎src/Type/Constant/ConstantArrayType.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Nette\Utils\Strings;
66
use PHPStan\Analyser\OutOfClassScope;
7+
use PHPStan\DependencyInjection\BleedingEdgeToggle;
78
use PHPStan\Internal\CombinationsHelper;
89
use PHPStan\Php\PhpVersion;
910
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
@@ -563,7 +564,11 @@ public function findTypeAndMethodNames(): array
563564
continue;
564565
}
565566

566-
if ($has->yes() && !$phpVersion->supportsCallableInstanceMethods()) {
567+
if (
568+
BleedingEdgeToggle::isBleedingEdge()
569+
&& $has->yes()
570+
&& !$phpVersion->supportsCallableInstanceMethods()
571+
) {
567572
$methodReflection = $type->getMethod($method->getValue(), new OutOfClassScope());
568573
if ($classOrObject->isString()->yes() && !$methodReflection->isStatic()) {
569574
continue;

‎src/Type/Constant/ConstantStringType.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Nette\Utils\Strings;
77
use PhpParser\Node\Name;
88
use PHPStan\Analyser\OutOfClassScope;
9+
use PHPStan\DependencyInjection\BleedingEdgeToggle;
910
use PHPStan\PhpDocParser\Ast\ConstExpr\QuoteAwareConstExprStringNode;
1011
use PHPStan\PhpDocParser\Ast\Type\ConstTypeNode;
1112
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
@@ -212,7 +213,11 @@ public function isCallable(): TrinaryLogic
212213
$classRef = $reflectionProvider->getClass($matches[1]);
213214
if ($classRef->hasMethod($matches[2])) {
214215
$method = $classRef->getMethod($matches[2], new OutOfClassScope());
215-
if (!$phpVersion->supportsCallableInstanceMethods() && !$method->isStatic()) {
216+
if (
217+
BleedingEdgeToggle::isBleedingEdge()
218+
&& !$phpVersion->supportsCallableInstanceMethods()
219+
&& !$method->isStatic()
220+
) {
216221
return TrinaryLogic::createNo();
217222
}
218223

0 commit comments

Comments
 (0)