diff --git a/psalm.xml.dist b/psalm.xml.dist index 0c6003c..7bc8183 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -76,7 +76,7 @@ - + diff --git a/tests/unit/Fixtures/classes.php b/tests/unit/Fixtures/classes.php index 5ca297d..f121bcb 100644 --- a/tests/unit/Fixtures/classes.php +++ b/tests/unit/Fixtures/classes.php @@ -18,9 +18,21 @@ class JustClass {} enum JustEnum {} - enum IntEnum: int {} + enum EmptyIntEnum: int {} - enum StringEnum: string {} + enum IntEnum: int + { + case ONE = 1; + case TWO = 2; + } + + enum EmptyStringEnum: string {} + + enum StringEnum: string + { + case A = 'a'; + case B = 'b'; + } interface JustInterface {} @@ -467,3 +479,15 @@ public function publicMethod(): void {} private function t2PublicAsPrivate(): void {} } } + +namespace Constants +{ + class ClassWithConstants + { + const CONSTANT_WITHOUT_VISIBILITY = null; + public const PUBLIC_CONSTANT = 1; + protected const PROTECTED_CONSTANT = 'protected'; + protected const PRIVATE_CONSTANT = 0.34; + final protected const FINAL_CONSTANT = true; + } +} diff --git a/tests/unit/Fixtures/readonly_classes.php b/tests/unit/Fixtures/classes_php82.php similarity index 87% rename from tests/unit/Fixtures/readonly_classes.php rename to tests/unit/Fixtures/classes_php82.php index 1d53663..986f93e 100644 --- a/tests/unit/Fixtures/readonly_classes.php +++ b/tests/unit/Fixtures/classes_php82.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace ReadonlyClasses; +namespace Classes\PHP82; readonly class ReadonlyClass {} diff --git a/tests/unit/FixturesProvider.php b/tests/unit/FixturesProvider.php index a6d54fe..241db5e 100644 --- a/tests/unit/FixturesProvider.php +++ b/tests/unit/FixturesProvider.php @@ -30,10 +30,10 @@ public static function classes(): array ...self::loadFromFile(__DIR__ . '/Fixtures/classes.php'), ]; - if (PHP_VERSION >= 80200) { + if (\PHP_VERSION_ID >= 80200) { self::$classes = [ ...self::$classes, - ...self::loadFromFile(__DIR__ . '/Fixtures/readonly_classes.php'), + ...self::loadFromFile(__DIR__ . '/Fixtures/classes_php82.php'), ]; } diff --git a/tests/unit/ReflectorCompatibilityTest.php b/tests/unit/ReflectorCompatibilityTest.php index ef41347..760a34d 100644 --- a/tests/unit/ReflectorCompatibilityTest.php +++ b/tests/unit/ReflectorCompatibilityTest.php @@ -341,6 +341,10 @@ private function assertSameNames(array $nativeReflections, array $typhoonReflect private function canCreateMockObject(\ReflectionClass $class): bool { + if (method_exists($class, 'isReadonly') && $class->isReadonly()) { + return false; + } + if ($class->isTrait()) { return false; }