Skip to content

Commit

Permalink
Merge pull request #1442 from kukulich/php84
Browse files Browse the repository at this point in the history
Compatibility with typed constants in PHP 8.4
  • Loading branch information
Ocramius authored Aug 3, 2024
2 parents 4780144 + 50a3e7d commit 7f16c80
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Reflection/Adapter/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
*/
final class ReflectionClass extends CoreReflectionClass
{
public const IS_READONLY = 65536;
/** @internal */
public const IS_READONLY_COMPATIBILITY = 65536;

public function __construct(private BetterReflectionClass|BetterReflectionEnum $betterReflectionClass)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Reflection/Adapter/ReflectionClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
*/
final class ReflectionClassConstant extends CoreReflectionClassConstant
{
public const IS_FINAL = 32;
/** @internal */
public const IS_FINAL_COMPATIBILITY = 32;

public function __construct(private BetterReflectionClassConstant|BetterReflectionEnumCase $betterClassConstantOrEnumCase)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Reflection/Adapter/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
/** @psalm-suppress PropertyNotSetInConstructor */
final class ReflectionProperty extends CoreReflectionProperty
{
public const IS_READONLY = 128;
/** @internal */
public const IS_READONLY_COMPATIBILITY = 128;

public function __construct(private BetterReflectionProperty $betterReflectionProperty)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/ReflectionClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ public function isFinal(): bool

public function isReadOnly(): bool
{
return ($this->modifiers & ReflectionClassAdapter::IS_READONLY) === ReflectionClassAdapter::IS_READONLY;
return ($this->modifiers & ReflectionClassAdapter::IS_READONLY_COMPATIBILITY) === ReflectionClassAdapter::IS_READONLY_COMPATIBILITY;
}

/**
Expand All @@ -1223,7 +1223,7 @@ private function computeModifiers(ClassNode|InterfaceNode|TraitNode|EnumNode $no

$modifiers = $node->isAbstract() ? CoreReflectionClass::IS_EXPLICIT_ABSTRACT : 0;
$modifiers += $node->isFinal() ? CoreReflectionClass::IS_FINAL : 0;
$modifiers += $node->isReadonly() ? ReflectionClassAdapter::IS_READONLY : 0;
$modifiers += $node->isReadonly() ? ReflectionClassAdapter::IS_READONLY_COMPATIBILITY : 0;

return $modifiers;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Reflection/ReflectionClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ public static function modifierProvider(): array
['ExampleClass', 0],
['AbstractClass', CoreReflectionClass::IS_EXPLICIT_ABSTRACT],
['FinalClass', CoreReflectionClass::IS_FINAL],
['ReadOnlyClass', ReflectionClassAdapter::IS_READONLY],
['ReadOnlyClass', ReflectionClassAdapter::IS_READONLY_COMPATIBILITY],
['ExampleTrait', 0],
];
}
Expand Down

0 comments on commit 7f16c80

Please sign in to comment.