thephpleague / csv

CSV data manipulation made easy in PHP
https://csv.thephpleague.com
MIT License
3.34k stars 333 forks source link

Should we add support for property hooks in the package denormalization feature. #541

Open nyamsprod opened 2 hours ago

nyamsprod commented 2 hours ago

Feature Request

Q A
New Feature yes
BC Break yes

Issue

class UserIdentity
{ 
    public function __construct(
        private string $firstName,
        private string $lastName
    ) {
    }

    public string $fullName {
        get => $this->firstName . " " . $this->lastName;
        set {
            [$this->firstName, $this->lastName] = explode(' ', $value, 2);
        }
    }
}
nyamsprod commented 1 hour ago

Should the Deserialization feature of the package even try to work correctly with a class containing property hook ?

The current Deserialization mechanism is geared toward simple DTO. The moment you add Property hooks or any advanced feature in PHP to your class you are better of using a fully fledge Serializer package and there are many of them in PHP land. So should Property hook even be supported by the feature ?