mistake#352
Closed
dg wants to merge 2 commits into
Closed
Conversation
…s#338] The native `: mixed` return type was accidentally reintroduced on Container::__call() by 7cbe717 ("added missing native types"), reviving an incompatibility that had already been fixed once for nette/utils#315 (commit 40afa80). Nette\SmartObject::__call() in nette/utils intentionally declares no native return type (it stays untyped for BC). As long as nobody re-applies the trait, narrowing the inherited untyped __call() to `: mixed` is allowed and everything loads fine - which is why the test suite and Forms' own classes are unaffected. The fatal error appears only when a subclass extends Form/Container AND re-applies the SmartObject trait, e.g.: class MyForm extends Nette\Forms\Form { use Nette\SmartObject; } Then the trait's untyped __call() overrides the already-typed __call(): mixed, which PHP rejects as removing a return type: Declaration of Nette\SmartObject::__call(string $name, array $args) must be compatible with Nette\Forms\Container::__call(string $name, array $args): mixed Re-applying SmartObject on top of a class that already has it is an unusual, unexpected pattern, so the regression slipped through - but it happens in the wild (e.g. via downstream component classes), breaks on all PHP 8.1-8.5, and matches the report that 3.2.8 works but 3.2.9 does not. Dropping the native return type (keeping it in phpDoc) restores compatibility. A regression test covering the trait combination is added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.