Skip to content

mistake#352

Closed
dg wants to merge 2 commits into
v3.2from
fix-call-return-type
Closed

mistake#352
dg wants to merge 2 commits into
v3.2from
fix-call-return-type

Conversation

@dg

@dg dg commented Jun 16, 2026

Copy link
Copy Markdown
Member

No description provided.

dg added 2 commits June 5, 2026 20:38
…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.
Copilot AI review requested due to automatic review settings June 16, 2026 15:31

This comment was marked as resolved.

@dg dg closed this Jun 16, 2026
@dg dg changed the title Container: removed return type from __call() again [Closes nette/utils#338] mistake Jun 16, 2026
@dg dg deleted the fix-call-return-type branch June 16, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants