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:
parent
04bcc32efb
commit
2c8688dd97
@ -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;
|
||||
|
@ -525,6 +525,14 @@ class ClassTest extends TestCase
|
||||
echo A::SOME_CONST;
|
||||
}'
|
||||
],
|
||||
'noCrashOnClassExists' => [
|
||||
'<?php
|
||||
if (!class_exists(ReflectionGenerator::class)) {
|
||||
class ReflectionGenerator {
|
||||
private $prop;
|
||||
}
|
||||
}',
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user