8000 [PropertyAccess] BC break on getsetter order · Issue #37260 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[PropertyAccess] BC break on getsetter order #37260
Closed
@dragosprotung

Description

@dragosprotung

Symfony version(s) affected: 5.1.0+

Description

Prior to 5.1.0 the getsetter method was checked second after getter.
See https://github.com/symfony/symfony/blob/v5.0.9/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L479-L482 for prior logic.

After moving the logic into the PropertyInfo component get getsetter is checked after prefixed accessors.
See https://github.com/symfony/property-info/blob/master/Extractor/ReflectionExtractor.php#L239-L253

How to reproduce

Given the following class

class Order
{
    private array $payments = [];

    public function payments(): array
    {
        return $this->payments;
    }

    public function hasPayments(): bool
    {
        return count($this->payments) > 0;
    }
}

trying to access payments will return a boolean value instead of the the array by accessing the hasPayments() instead of the payments() method.

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