Skip to content

[downgrade] Avoid skip $node->isFirstClassCallable() check when possible on DowngradePhp82+ on function downgrade, avoid function not downgraded #9367

@samsonasik

Description

@samsonasik

When we downgrade, but on target php 8.1+, first class callable feature is already exists.

Function replacement usage should use code snippets, like in:

https://github.com/rectorphp/rector-downgrade-php/blob/73e0dbb5437d07df74b01773c6db92720fe485a9/rules/DowngradePhp72/Rector/FuncCall/DowngradeStreamIsattyRector.php#L148

then remove the firstClassCallable() check to avoid function not exists on downgraded code.

Because first class callable is available on php 8.1+, so skip isFirstClassCallable() will cause invalid change when code available to be downgraded.

see https://3v4l.org/6sLa4

to avoid error on first class callable, the args should be used instead:

-$args = $node->getArgs();
+$args = $node->args;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions