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

Use readonly class annotation where possible #593

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

Slamdunk
Copy link
Member

No description provided.

@@ -43,14 +43,13 @@

use function sprintf;

/** @immutable */
final class SessionMiddleware implements MiddlewareInterface
final readonly class SessionMiddleware implements MiddlewareInterface
Copy link
Member

Choose a reason for hiding this comment

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

Careful: readonly != @immutable. @immutable implies readonly + no side-effects.

Copy link
Member Author

@Slamdunk Slamdunk Oct 28, 2024

Choose a reason for hiding this comment

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

This is a sad naming choice from Psalm that hunted me since its introduction.
I know no other tool that treats readonly differently from @immutable

Copy link
Member

Choose a reason for hiding this comment

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

I also don't know of other tools that enforce immutability right now, which is why I keep sticking to psalm (for now) :P

Copy link
Member Author

Choose a reason for hiding this comment

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

Annotation restored with the more specific @psalm-immutable name

@Slamdunk Slamdunk added this to the 9.2.0 milestone Oct 28, 2024
@Slamdunk Slamdunk merged commit 1fd67b2 into psr7-sessions:9.2.x Oct 28, 2024
10 checks passed
@Slamdunk Slamdunk deleted the readonly branch October 28, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants