-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Open
Description
Symfony version(s) affected
7.3.0
Description
Generated stream readers filename depend on the type name:
private function getPath(Type $type, bool $decodeFromStream): string | |
{ | |
return \sprintf('%s%s%s.json%s.php', $this->streamReadersDir, \DIRECTORY_SEPARATOR, hash('xxh128', (string) $type), $decodeFromStream ? '.stream' : ''); | |
} |
That means adding or removing a property from an object won’t result in another stream reader being generated, and trying to decode such an object will fail.
This is only an issue in dev env when you will change files without refreshing caches.
How to reproduce
Given a Test
class
class Test
{
public int $id;
}
$test = $reader->read('{"id": 1, "foo": "bar"}'), Type::object(Test::class));
dump($test->id);
will correctly display 1
.
Now adding a public string $foo
property to Test
, displaying $test->foo
would result in
Typed property Test::$foo must not be accessed before initialization
Possible Solution
No response
Additional Context
No response
mtarld