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

Make Token\Builder really readonly #1086

Open
Slamdunk opened this issue Nov 12, 2024 · 2 comments · May be fixed by #1091
Open

Make Token\Builder really readonly #1086

Slamdunk opened this issue Nov 12, 2024 · 2 comments · May be fixed by #1091

Comments

@Slamdunk
Copy link
Collaborator

As reported by PHPStan 2, the current Token\Builder implementation is not really readonly:

https://github.com/lcobucci/jwt/actions/runs/11784435253/job/32823593891?pr=1085#step:9:50

All attributes must be accepted only in its constructor.
But we can't do that on a public constructor because we need the safeguards provided by its API.

The solution is to add a new static function new() method as the public constructor, make the constructor private, and only then apply the readonly attribute, hence the BC-break label here

@Slamdunk
Copy link
Collaborator Author

Hey @Ocramius, what are those googly eyes?

@Ocramius
Copy link
Collaborator

Just for myself / that I've already seen this :)

I agree with masking the public constructor BTW.

@Slamdunk Slamdunk linked a pull request Dec 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants