Skip to content

[PHP8.6] Handle crash on partial function application on PHP 8.6 scope set attribute - #9013

Merged
TomasVotruba merged 1 commit into
mainfrom
handle-crash-2
Nov 22, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
handle-crash-2

Conversation

@samsonasik

@samsonasik samsonasik commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9975
Ref https://getrector.com/demo/4e8969a4-8549-440d-8309-ec8bc83b6fde

Fixes crash:

Call to a member function setAttribute() on null

This patch only patch on target scope visitor when the issue happen so patch focused on the crash reported.

@samsonasik

Copy link
Copy Markdown
Member Author

Fixed 🎉 /c @CicerBro this is the smallest patch as possible per target crash :)

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

@samsonasik

Copy link
Copy Markdown
Member Author

partial function application seems can have Arg:

[
    Arg('hello'),
    ArgPlaceholder(),
    Arg(123),
]

so the real solution seems to loop the ->getRawArgs() and check if the target instance of Arg

@samsonasik

Copy link
Copy Markdown
Member Author

I tried check combination of Arg + ArgPlaceholder, check per-Arg seems need real usage first before going further to next patch, so I think fix one at a time is better.

@TomasVotruba This one ready for merge 👍

@TomasVotruba
TomasVotruba merged commit 15165a1 into main Nov 22, 2026
51 checks passed
@TomasVotruba
TomasVotruba deleted the handle-crash-2 branch November 22, 2026 17:14
@TomasVotruba

Copy link
Copy Markdown
Member

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Crash "Call to a member function setAttribute() on null" on PHP 8.6 partial function application (foo(?))

2 participants