Skip to content

fix: point PendingAwaitablePage's mixin at AwaitableWebpage - #306

Open
alies-dev wants to merge 1 commit into
pestphp:5.xfrom
alies-dev:fix/pending-page-mixin
Open

alies-dev wants to merge 1 commit into
pestphp:5.xfrom
alies-dev:fix/pending-page-mixin

Conversation

@alies-dev

@alies-dev alies-dev commented Nov 6, 2026 •

Copy link
Copy Markdown

PendingAwaitablePage is documented as @mixin Webpage|AwaitableWebpage. Static analysers can't use that:

visit('/')->click('Save'); // Psalm: UndefinedMagicMethod, result is mixed
visit('/')->page();        // Psalm and PHPStan: undefined method

Psalm ignores a union mixin entirely, and PHPStan only exposes methods that exist on both types, so AwaitableWebpage::page() is missing. At runtime __call() forwards every call to the AwaitableWebpage, which in turn forwards to Webpage.

Refs pestphp/pest#2021. Same change as #183, which was closed because the problem wasn't clear; the issue has a reproduction for both tools.

Solution

The mixin now names the class __call() really forwards to. AwaitableWebpage already mixes in Webpage, so every Webpage method still resolves, and page() resolves too. With Psalm 6.19, Psalm 7.0 and PHPStan 2.3 the undefined-method errors above are gone.

Fluent calls are still typed as Webpage rather than AwaitableWebpage; that comes from AwaitableWebpage's own mixin and is left for a separate change (see the issue). 4.x has the same docblock if you want it backported.

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.

1 participant