Skip to content
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

Increase Psalm to level 2 #319

Merged

Conversation

jordisala1991
Copy link
Member

@jordisala1991 jordisala1991 commented May 3, 2022

.

@jordisala1991
Copy link
Member Author

Probably some of this should go to 1.x

@jordisala1991
Copy link
Member Author

The last psalm error makes no sense...

ERROR: PossibleRawObjectIteration - src/EventListener/ResizeFormListener.php:178:18 - Possibly undesired iteration over regular object ArrayAccess (see https://psalm.dev/208)
        foreach ($data as $name => $child) {

It looks like a bug to me, I have tried a lot of combinations and even adding an assert after those if does not make psalm happy

@jordisala1991 jordisala1991 marked this pull request as ready for review May 5, 2022 07:26
@jordisala1991
Copy link
Member Author

Probably some of this should go to 1.x

I answer to myself, yes it could make sense but a lot of errors are raised on 1.x due to deprecated code, I prefer to not invest time there.

@VincentLanglet
Copy link
Member

The last psalm error makes no sense...

ERROR: PossibleRawObjectIteration - src/EventListener/ResizeFormListener.php:178:18 - Possibly undesired iteration over regular object ArrayAccess (see https://psalm.dev/208)
        foreach ($data as $name => $child) {

It looks like a bug to me, I have tried a lot of combinations and even adding an assert after those if does not make psalm happy

Changing

if (!\is_array($data) && !$data instanceof \Traversable) {

to
is_iterable ?

Anyway, I didn't succeed to reproduce the error on psalm.dev ; can you ?
We could open an issue on psalm.

@jordisala1991
Copy link
Member Author

I couldnt reproduce it either.

@VincentLanglet
Copy link
Member

I couldnt reproduce it either.

I succeed reproducing a similar issue https://psalm.dev/r/c95d52a172
We could try to add psalm-trace, I think it will be ArrayAccess|array<array-key, mixed>.

Seems like the issue is that the variable is not considered as (Traversable&ArrayAccess)|array<array-key, mixed>.

@jordisala1991
Copy link
Member Author

To me it looks like a bug, should we suppress it for now?

@VincentLanglet
Copy link
Member

To me it looks like a bug, should we suppress it for now?

Sure, but we should open an issue on psalm and adding the link in the psalm-suppress IMHO.
Do you do it or should I do ?

@jordisala1991
Copy link
Member Author

To me it looks like a bug, should we suppress it for now?

Sure, but we should open an issue on psalm and adding the link in the psalm-suppress IMHO. Do you do it or should I do ?

vimeo/psalm#7928

Here it is.

@jordisala1991 jordisala1991 merged commit dfcb76e into sonata-project:2.x May 6, 2022
@jordisala1991 jordisala1991 deleted the feature/up-psalm-level-2 branch May 6, 2022 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants