1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Don’t crash when conditionally defining classes with properties

This commit is contained in:
Brown 2020-03-09 14:24:19 -04:00
parent 04bcc32efb
commit 2c8688dd97
2 changed files with 9 additions and 3 deletions

View File

@ -1541,9 +1541,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
);
if (!$declaring_property_class) {
throw new \UnexpectedValueException(
'Cannot get declaring class for ' . $property_id
);
return;
}
$fq_class_name = $declaring_property_class;

View File

@ -525,6 +525,14 @@ class ClassTest extends TestCase
echo A::SOME_CONST;
}'
],
'noCrashOnClassExists' => [
'<?php
if (!class_exists(ReflectionGenerator::class)) {
class ReflectionGenerator {
private $prop;
}
}',
]
];
}