-
Notifications
You must be signed in to change notification settings - Fork 16
Use $rawModelDataInput as construct function parameter name #55
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
Use $rawModelDataInput as construct function parameter name #55
Conversation
Hi, thanks for the report. I'd more likely rename the object property to $modelData to match the current function signature. Would you mind to change the MR? Then I'll merge it. Cheers |
yes, I will do it, happy to help :) |
4392d6f
to
37924b4
Compare
…phptpl Because when Symfony deserializer the object will not find the parameter value in the saved data and use the default parameter value(empty array). Then the model construct function will get error: `Typed property must not be accessed before initialization` since PHP 7.4 see: https://github.com/symfony/symfony/blob/44db49fb8f6d70c4341120a3f8f1b1a1a0dfa014/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L380 and https://github.com/symfony/symfony/blob/44db49fb8f6d70c4341120a3f8f1b1a1a0dfa014/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L355
37924b4
to
1472e51
Compare
Whoops, there were quite a few more places the variable name is used to access the values I didn't take into account. I've patched all occurrences in #56 and will merge it and tag a new version. Thanks again for the detailled report and the help! |
Change all occurrences of `rawModelDataInput` to `modelData` (compare #55)
@mikewolfxyou can you check if the current master works in the scenario? I've noticed the symfony serializer uses some kind of name normalizer. The reason for my question: the property is now named |
I tested yesterday, with the branch I created: just rename the local variable from
|
After digging deeper into the symfony serializer I've decided to take your first approach to rename the constructor parameter to Sorry for the back and forth while finding a solution for the issue 😄 I still wasn't able to reproduce the "typed property access" error inside the model. The generated models don't use typed properties independent of the used PHP version (at least currently. I'm planning to use different templates depending on the PHP version to be able to use more modern features inside the generated models). I've tagged version 0.22.0, which includes the renaming. |
Thank you for taking care of it :) |
Use $rawModelDataInput as construct function parameter name in Modelphptpl
The reason:
Because when Symfony deserializer the serialized object will not find the parameter value in the saved data and use the default parameter value(empty array).
Then the model construct function will get the error:
Typed property must not be accessed before initialization
since PHP 7.4, The error description and explanation: stackoverflowThe Symfony serializer:
see: https://github.com/symfony/symfony/blob/44db49fb8f6d70c4341120a3f8f1b1a1a0dfa014/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L380
and
https://github.com/symfony/symfony/blob/44db49fb8f6d70c4341120a3f8f1b1a1a0dfa014/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L355
How to reproduce the error: