8000 [PropertyInfo] PropertyInfo is not compatible with PHP 8.4 property hooks · Issue #58556 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content 10000
[PropertyInfo] PropertyInfo is not compatible with PHP 8.4 property hooks #58556
Closed
@vudaltsov

Description

@vudaltsov

Symfony version(s) affected

7.1.4

Description

In PHP 8.4 we'll have virtual properties and asymmetric visibility.

PropertyInfo considers the following properties writable, although they are not:

final class Foo
{
    public private(set) bool $public_private_set;
    public protected(set) bool $public_protected_set;
    public bool $virtual_no_set_hook { get => true; }
}

A side note. Many Symfony components optimistically state that they are compatible with all future PHP versions (for instance, the PropertyInfo component has "require": { "php": ">=8.2" } in its composer.json). However, this case shows that they are not and cannot be. I've discussed, whether it is a BC break on PHP's side or it isn't, see https://externals.io/message/125772. Symfony should probably reconsider it's PHP constraints.

How to reproduce

https://github.com/vudaltsov/symfony-property-access-php84

Possible Solution

In PHP 8.4 a property is writable if

   $reflectionProperty->isPublic()
&& !$reflectionProperty->isReadonly()
&& !$reflectionProperty->isPrivateSet()
&& !$reflectionProperty->isProtectedSet()
&& (!$reflectionProperty->isVirtual() || $reflectionProperty->hasHook(PropertyHookType::Set))

See https://externals.io/message/125740.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0