Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.4] \Laravel\SerializableClosure\Serializers\Native fails on read-only virtual properties #107

Closed
tminich opened this issue Feb 11, 2025 · 0 comments · Fixed by #108

Comments

@tminich
Copy link

tminich commented Feb 11, 2025

Laravel Version

11.41.3

PHP Version

8.4.3

Database Driver & Version

No response

Description

Native tries to set property values in mapByReference. This fails for virtual properties that have no setter.

Virtual properties simply should be excluded from any serialization. By definition, they are derived values and should be reproducible from other serialized values.

Steps To Reproduce

use Laravel\SerializableClosure\Serializers\Native;

class Test
{
    public string $test {
        get => 'test';
    }

    public static function test_it(): string
    {
        $t = new Test();
        
        $clo = function () use ($t) {
            return $t;
        };

        $n = new Native(closure: $clo);

        return serialize(value: $n);
    }
}
Test::test_it();
PHP Error:  Property Test::$test is read-only in /var/www/html/vendor/laravel/serializable-closure/src/Serializers/Native.php on line 509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant