symfony: Cannot assign Symfony\Component\VarDumper\Caster\CutStub to reference held by property ...
Symfony version(s) affected
6.2.4
Description
I have an error Cannot assign Symfony\Component\VarDumper\Caster\CutStub to reference held by property App\Entity\Preference::$distance of type ?App\Enum\DistanceEnum
I have a property in Entity:
#[ORM\Column(length: 255, nullable: true, enumType: DistanceEnum::class)]
private ?DistanceEnum $distance = null;
How to reproduce
With APP_ENV=dev
, I have the error.
With APP_ENV=prod
, I have no error.
Possible Solution
No response
Additional Context
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 29 (21 by maintainers)
Commits related to this issue
- PHP8.1の不具合による問題を修正 https://github.com/symfony/symfony/issues/49091 — committed to chihiro-adachi/ec-cube by chihiro-adachi 6 months ago
- bug #54072 [HttpKernel] Fix datacollector caster for reference object property (ebuildy) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [HttpKernel] Fix datacol... — committed to symfony/symfony by nicolas-grekas 3 months ago
- bug #54072 [HttpKernel] Fix datacollector caster for reference object property (ebuildy) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [HttpKernel] Fix datacol... — committed to symfony/http-kernel by nicolas-grekas 3 months ago
With this configuration, it’s works but we lose the functionality of the lazy ghost object
Looks like the following patch would fix that issue. Could you please submit it as a bugfix on branch 5.4 with a test case derived from your reproducer?
Well, if you want to use a version of PHP missing 2 years of bugfixes, feel free to find a way to reimplement VarDumper without being impacted by that PHP bug (but without loosing any of the features of the component). But for that bug, it will probably be very hard (anyway, anything that has
reimplement VarDumper
in its title will be hard, even without additional constraints). However, I don’t see any benefit for the Symfony core team spending that time instead of doing more useful work on Symfony.Please provide a reproducer that works on the latest version of PHP if you still experience the issue.
Please send this reproducer as a second test case on your upcoming PR and I’ll have a look?
You have to change your version of PHP as @nicolas-grekas said.
OK, I figured out the password 😅
I don’t reproduce. I think you’re affected by https://github.com/php/php-src/issues/8655
Please upgrade to the latest PHP 8.1
those are log messages, not a stack trace but at least, this gives the location of the error.
@nicolas-grekas shouldn’t we also exclude enums (like we exclude DateTimeInterface) the DataCollector fallback caster ? https://github.com/symfony/symfony/blob/e480a66395c3ef21fb9895a2b5a1fe6211e19456/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php#L67
However, I still don’t understand why this would assign it in the entity property.