You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A promoted readonly parameter with an iterable<T> or Closure(…) docblock fails with "Cannot modify readonly property" #79
The same class without readonly, a promoted readonly array<int,T> and a promoted readonly iterablewithout a docblock all pass. Cause, from the shipped source: src/Internal/Ast/FunctionContractInjector.php → buildParamWrappers() injects $adapters = \TypePHP\Internal\RuntimeTypeChecker::wrapIterable(__METHOD__, 'adapters', $adapters, $this); for an iterable-typed parameter (isIterableCandidate(), and wrapCallable for a callable-typed one) and, when $param->isPromoted(), appends $this->adapters = $adapters; — a second write to a property the engine already initialised from the promotion, which PHP rejects for readonly.
Expected: a promoted readonly parameter is validated without a second assignment (validate the wrapped value and leave the promoted property as initialised, or initialise the property once from the wrapped value instead of relying on the promotion), or the wrapper is skipped for readonly promotions with a documented note.
Activity
rcalicdan commentedon Sep 18, 2026
@klunejko Hello, I released a patch (v0.10.5) and also fix the other issue earlier.. Enjoy.. Many Thanks for submitting critical bug reports.