You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ANNOTATIONS_TO_ATTRIBUTES] Upgrading Assert\Range leads to error #8300
The Symfony / Sensio annotation to attribute upgrade works great, except for one BC break. It is up for debate whether annotations should be 100% BC with attributes.
Minimal PHP Code Causing Issue
## entity file/* * @Assert\Range( * min = 0, * max = 100, * minMessage = "Average discount must be at least {{ limit }}", * maxMessage = "Average discount must be less than {{ limit }}" * ) */
#[Assert\Range(minMessage: 'Average discount must be at least {{ limit }}', maxMessage: 'Average discount must be less than {{ limit }}', min: 0, max: 100)]
Expected Behaviour
But should be changed to notInRangeMessage instead. Without changing it, an exception will be thrown.
Maybe we can consider
always remove the values
merge the two messages to one message (replace {{limit}} with min or max
ask the developer on rector execution what to do
#[Assert\Range(notInRangeMessage: 'Average discount should be between {{ min }} and {{ max }}.', min: 0, max: 100)]
ANNOTATIONS_TO_ATTRIBUTES is working fine until Doctrine annotations gets involved, it then just hangs forever and the --debug option does not provide any message.
I found that this line in my Entity class caused problem:
use Doctrine\ORM\Mapping\Index as Index;
When I removed ' as Index' it suddenly started working fine.
Not sure if it is a bug.
We'll still need an isolated failing demo link from: http://getrector.com/demo,
that way we can reproduce the bug. Closing for now to avoid piling up more issue without demo link.
Feel free to create a new one with demo link, so we can see the issue ourselves and fix it 👍
We'll still need an isolated failing demo link from: http://getrector.com/demo, that way we can reproduce the bug. Closing for now to avoid piling up more issue without demo link.
Feel free to create a new one with demo link, so we can see the issue ourselves and fix it 👍
Recreating the issue is not possible on your test site as it depends on the libs it uses, still the output is not quite right, it just spits out 'use Doctrine\ORM\Mapping\Index;' on the top while leaving 'use Doctrine\ORM\Mapping\Index as Index;' as it is.
Activity
TomasVotruba commentedon Dec 3, 2023
Thank you for your report!
We'll need an isolated failing demo link from: http://getrector.com/demo,
that way we can reproduce the bug.
The smaller demo the better 👍
mindaugasvcs commentedon Dec 25, 2023
ANNOTATIONS_TO_ATTRIBUTES is working fine until Doctrine annotations gets involved, it then just hangs forever and the --debug option does not provide any message.
I found that this line in my Entity class caused problem:
use Doctrine\ORM\Mapping\Index as Index;
When I removed ' as Index' it suddenly started working fine.
Not sure if it is a bug.
TomasVotruba commentedon Dec 25, 2023
Thank you for your report!
We'll still need an isolated failing demo link from: http://getrector.com/demo,
that way we can reproduce the bug. Closing for now to avoid piling up more issue without demo link.
Feel free to create a new one with demo link, so we can see the issue ourselves and fix it 👍
mindaugasvcs commentedon Dec 25, 2023
Recreating the issue is not possible on your test site as it depends on the libs it uses, still the output is not quite right, it just spits out 'use Doctrine\ORM\Mapping\Index;' on the top while leaving 'use Doctrine\ORM\Mapping\Index as Index;' as it is.
TomasVotruba commentedon Dec 25, 2023
Could you share the demo link with minimal PHP code that is causing the troubles? Only that way we can start digging
mindaugasvcs commentedon Dec 25, 2023
https://getrector.com/demo/8669e371-05c9-477f-b32a-34ef1400bb99
TomasVotruba commentedon Dec 26, 2023
Thanks 👍
@samsonasik Could you look into this one? Seems use import is being added despite already existing one.
samsonasik commentedon Dec 26, 2023
The issue seems unrelated with import.
Alias name should be different with last name import in the namespace, it like doing useless alias:
which should not happen on the first place.
@mindaugasvcs we need reproducible repo that show the issue, with before after expected output
samsonasik commentedon Dec 26, 2023
I think the solution is you can just simply remove the useless alias:
as that useless, so I guess it is not a bug.
samsonasik commentedon Dec 26, 2023
I am closing it as it is not a bug, the alias name is same with last name, which should not happen on the first place.
samsonasik commentedon Dec 26, 2023
I created new special rule to remove useless alias in use statement as same with last name:
TomasVotruba commentedon Dec 26, 2023
@samsonasik Even better, thanks for the new rule 👍
github-actions commentedon Mar 15, 2026
This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.