8000 [PropertyInfo] Implement PHP 8.4 support for getWriteVisiblityForProp… · symfony/symfony@e4d754f · GitHub
[go: up one dir, main page]

Skip to content

Commit e4d754f

Browse files
committed
[PropertyInfo] Implement PHP 8.4 support for getWriteVisiblityForProperty
1 parent 64feb8d commit e4d754f

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
@@ -969,6 +969,24 @@ private function getReadVisiblityForMethod(\ReflectionMethod $reflectionMethod):
969969

970970
private function getWriteVisiblityForProperty(\ReflectionProperty $reflectionProperty): string
971971
{
972+
// PHP 8.4: Property hooks
973+
if (method_exists($reflectionProperty, 'isVirtual') && method_exists($reflectionProperty, 'hasHook')) {
974+
if ($reflectionProperty->isVirtual() && !$reflectionProperty->hasHook(\PropertyHookType::Set)) {
975+
return PropertyWriteInfo::VISIBILITY_PRIVATE;
976+
}
977+
}
978+
979+
// PHP 8.4: Asymmetric visibility
980+
if (method_exists($reflectionProperty, 'isPrivateSet') && method_exists($reflectionProperty, 'isProtectedSet')) {
981+
if ($reflectionProperty->isPrivateSet()) {
982+
return PropertyWriteInfo::VISIBILITY_PRIVATE;
983+
}
984+
985+
if ($reflectionProperty->isProtectedSet()) {
986+
return PropertyWriteInfo::VISIBILITY_PROTECTED;
987+
}
988+
}
989+
972990
if ($reflectionProperty->isPrivate()) {
973991
return PropertyWriteInfo::VISIBILITY_PRIVATE;
974992
}

0 commit comments

Comments
 (0)
0