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 https://github.com/lcobucci/jwt/labels/BC-break label here
As reported by PHPStan 2, the current
Token\Builder
implementation is not reallyreadonly
: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 thereadonly
attribute, hence the https://github.com/lcobucci/jwt/labels/BC-break label here