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

Add @psalm-pure to the typeToString method #303

Conversation

luukvhoudt
Copy link
Contributor

When extending the Assert class it can be difficult to keep custom methods pure, especially when opting for the use of the Assert::typeToString method. This results in the following Psalm error at the call to the typetoString method:

ImpureMethodCall: Cannot call an impure method from a pure context

Currently there are two options to avoid the error:

  • Don't mark your custom method pure.
  • Suppress the ImpureMethodCall psalm error for your custom pure method.

Ideally you neither pick one of those options.

This PR fixes the error for good error by marking the Assert::typeToString method as @psalm-pure.

@shadowhand
Copy link
Collaborator

@luukvhoudt please rebase so that CI will run.

@shadowhand shadowhand self-requested a review October 16, 2024 14:11
Copy link
Collaborator

@shadowhand shadowhand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a rebase for CI fixes (see #304)

@luukvhoudt luukvhoudt force-pushed the fix-missing-psalm-pure-in-type-to-string-function branch from 7a4cbf8 to 25d8efc Compare October 17, 2024 07:28
@shadowhand shadowhand merged commit 3a544a3 into webmozarts:master Oct 17, 2024
11 checks passed
@shadowhand
Copy link
Collaborator

Thank you!

@luukvhoudt luukvhoudt deleted the fix-missing-psalm-pure-in-type-to-string-function branch October 17, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants