Skip to content

Commit b3c42c8

Browse files
committed
debug
1 parent 65143d1 commit b3c42c8

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/Reflection/ClassReflection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
use function array_unique;
6262
use function array_values;
6363
use function count;
64+
use function debug_backtrace;
6465
use function implode;
6566
use function in_array;
6667
use function is_bool;
@@ -69,6 +70,7 @@
6970
use function reset;
7071
use function sprintf;
7172
use function strtolower;
73+
use function var_dump;
7274

7375
/**
7476
* @api
@@ -1066,13 +1068,18 @@ public function getParentClassesNames(): array
10661068
public function hasConstant(string $name): bool
10671069
{
10681070
if (!$this->getNativeReflection()->hasConstant($name)) {
1071+
var_dump([
1072+
$this->displayName =>
1073+
debug_backtrace(0, 1),
1074+
]);
10691075
return false;
10701076
}
10711077

10721078
$reflectionConstant = $this->getNativeReflection()->getReflectionConstant($name);
10731079
if ($reflectionConstant === false) {
10741080
return false;
10751081
}
1082+
//var_dump($this->reflectionProvider->hasClass($reflectionConstant->getDeclaringClass()->getName()));
10761083

10771084
return $this->reflectionProvider->hasClass($reflectionConstant->getDeclaringClass()->getName());
10781085
}

src/Reflection/InitializerExprTypeResolver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
use function min;
9292
use function sprintf;
9393
use function strtolower;
94+
use function var_dump;
9495
use const INF;
9596

9697
#[AutowiredService]
@@ -2011,6 +2012,7 @@ function (Type $type, callable $traverse): Type {
20112012
continue;
20122013
}
20132014

2015+
//var_dump(compact('referencedClass'));
20142016
$constantClassReflection = $this->getReflectionProvider()->getClass($referencedClass);
20152017
if (!$constantClassReflection->hasConstant($constantName)) {
20162018
continue;
@@ -2022,6 +2024,7 @@ function (Type $type, callable $traverse): Type {
20222024
}
20232025

20242026
$resolvingName = sprintf('%s::%s', $constantClassReflection->getName(), $constantName);
2027+
20252028
if (array_key_exists($resolvingName, $this->currentlyResolvingClassConstant)) {
20262029
$types[] = new MixedType();
20272030
continue;
@@ -2078,6 +2081,7 @@ function (Type $type, callable $traverse): Type {
20782081
unset($this->currentlyResolvingClassConstant[$resolvingName]);
20792082
$types[] = $constantType;
20802083
}
2084+
var_dump([$constantName => $types]);
20812085

20822086
if (count($types) > 0) {
20832087
return TypeCombinator::union(...$types);

src/Type/ObjectType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,9 @@ public function hasConstant(string $constantName): TrinaryLogic
873873
if ($class === null) {
874874
return TrinaryLogic::createNo();
875875
}
876+
// var_dump([
877+
// $this->describe(VerbosityLevel::precise()) => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3),
878+
// ]);
876879

877880
return TrinaryLogic::createFromBoolean(
878881
$class->hasConstant($constantName),

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class NodeScopeResolverTest extends TypeInferenceTestCase
2626
*/
2727
private static function findTestFiles(): iterable
2828
{
29+
yield __DIR__ . '/nsrt/bug-x.php';
30+
return;
31+
2932
foreach (self::findTestDataFilesFromDirectory(__DIR__ . '/nsrt') as $testFile) {
3033
yield $testFile;
3134
}

0 commit comments

Comments
 (0)