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
Open

Make Token\Builder really readonly #1086

Slamdunk opened this issue Nov 12, 2024 · 2 comments

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants