8000 [PropertyInfo] Implement PHP 8.4 support for isAllowedProperty · symfony/symfony@64feb8d · GitHub
[go: up one dir, main page]

Skip to content

Commit 64feb8d

Browse files
committed
[PropertyInfo] Implement PHP 8.4 support for isAllowedProperty
1 parent 9a51d26 commit 64feb8d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,24 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
713713
return false;
714714
}
715715

716+
// PHP 8.4: Asymmetric Visibility and Property Hooks
717+
$hasAsymmetricVisibilityCapability = method_exists($reflectionProperty, 'isPrivateSet')
718+
&& method_exists($reflectionProperty, 'isProtectedSet')
719+
&& method_exists($reflectionProperty, 'isVirtual')
720+
&& method_exists($reflectionProperty, 'hasHook');
721+
722+
if ($hasAsymmetricVisibilityCapability) {
723+
// If the property is virtual and has no setter, it's not writable.
724+
if ($writeAccessRequired && $reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) {
725+
return false;
726+
}
727+
728+
// If the property has private or protected setter, it's not writable
729+
if ($writeAccessRequired && ($reflectionProperty->isPrivateSet() || $reflectionProperty->isProtectedSet())) {
730+
return false;
731+
}
732+
}
733+
716734
return (bool) ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags);
717735
} catch (\ReflectionException) {
718736
// Return false if the property doesn't exist

0 commit comments

Comments
 (0)
0