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

Avoiding double spaces (v2) #7837

Merged
merged 2 commits into from Apr 3, 2022
Merged

Avoiding double spaces (v2) #7837

merged 2 commits into from Apr 3, 2022

Conversation

ThomasLandauer
Copy link
Contributor

Second attempt of #7835

@AndrolGenhald Is there a test I can use as template? Can't find anything for InstancePropertyFetchAnalyzer.php...

@AndrolGenhald
Copy link
Collaborator

There doesn't seem to be a great place for it, I would probably just stick it in PropertyTypeTest.php since there are other tests for that issue in there, but if you see a better place for it that's fine too (test organization isn't the best, but it's also not terrible and it doesn't affect much so it hasn't been a priority).

Most tests just check the issue type, but there are some like here that also check the location and message ('error_message' is matched against the message that's displayed when running Psalm). In this case since the message itself is being tested I would either just include the relevant part of the message ('null variable of type') or do the entire message like the linked test, all that really matters is that it correctly tests the fix to make sure it doesn't get broken in the future.

I almost wouldn't bother asking for a test for a change like this, but since there's no linked issue and it's not immediately obvious to me in what case $stmt_var_id is blank, having a test here also serves as a sort of documentation so future contributors can look at the history and see what the fix is actually for.

There's also still a CS failure, that phpcs isn't able to auto-fix.

Sorry to make this so difficult!

@AndrolGenhald AndrolGenhald added the release:fix The PR will be included in 'Fixes' section of the release notes label Apr 2, 2022
@ThomasLandauer
Copy link
Contributor Author

In my case, $stmt_var_id was empty, when the code looked something like this:

$foo->getBar()->whatever

So before taking a look at the tests: If the purpose is just to inform contributors, what about adding a comment in the code instead?
Or I could try to create a reproducer and file an issue?

@AndrolGenhald
Copy link
Collaborator

So before taking a look at the tests: If the purpose is just to inform contributors, what about adding a comment in the code instead?
Or I could try to create a reproducer and file an issue?

I'll defer to @orklah on that since he's the maintainer, but we do tend to be less strict about testing issue messages, so filing an issue with a reproducer and linking it to the PR is probably fine in this case if it's less trouble (I guess I just think of adding a test as easier, but maybe that's because I'm more familiar with it).

@orklah
Copy link
Collaborator

orklah commented Apr 2, 2022

I'm fine without tests on that one. Note: double spaces happen when Psalm can't display the variable identifier. It happens for some convoluted expressions (like $foo->getBar()->whatever in this case). However, it's not just about display, it has an effect on assertions and probably other things so it's not easy to fix.

Can you just fix the CS issue please? :)

@ThomasLandauer
Copy link
Contributor Author

There you go :-)

@orklah orklah merged commit ab26e6b into vimeo:4.x Apr 3, 2022
@orklah
Copy link
Collaborator

orklah commented Apr 3, 2022

Thanks!

@ThomasLandauer ThomasLandauer deleted the pr-7835 branch April 3, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants