rectorphp / rector-doctrine

Rector upgrade rules for Doctrine
https://getrector.com
MIT License
54 stars 56 forks source link

[DOCTRINE_COLLECTION_22] constant to enum error for querybuilder #325

Open johanadivare opened 2 weeks ago

johanadivare commented 2 weeks ago

When i use DOCTRINE_COLLECTION_22 it will replace my Doctrine\\Common\\Collections\\Criteria::DESC to Doctrine\Common\Collections\Order::DESCbut this causes the following error:TypeError: Doctrine\ORM\QueryBuilder::orderBy(): Argument #2 ($order) must be of type ?string, Doctrine\Common\Collections\Order given, called in /srv/Repository/BlogRepository.php on line 103`

The replacement should actually be Doctrine\\Common\\Collections\\Order::DESC->value @julienfastre asked if this would maybe cause problems see: https://github.com/rectorphp/rector-doctrine/pull/297#issuecomment-1983489234

I think we should replace with the ->value call?

TomasVotruba commented 2 weeks ago

Thanks for reporting! Fix you suggest would be great 👍

julienfastre commented 2 weeks ago

Not sure its a good idea: as I remember, in issue https://github.com/rectorphp/rector-doctrine/issues/315, it was discussed that, maybe:

But any help for improving this is welcome :smile_cat:

TomasVotruba commented 2 weeks ago

@julienfastre Would it fix this bug? 🙏

julienfastre commented 2 weeks ago

I'll try to find some time next week or the week after, @TomasVotruba .