Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Arguments] Allow no default value on ArgumentAdderRector #5382

Merged
merged 4 commits into from Dec 23, 2023

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Dec 23, 2023

@joachim-n this should handle rectorphp/rector#8350
Closes rectorphp/rector#8350

with add ArgumentAdderWithoutDefaultValue value object for it.

@samsonasik
Copy link
Member Author

samsonasik commented Dec 23, 2023

@joachim-n it is implemented 🎉

For note, since no default value configured via ArgumentAdderWithoutDefaultValue, it can't fill gap on method call or static call, eg:

$obj = new SomeClass();
$obj->execute(); // can't fill here with default value.

as no value to refer since value is always required, so you need to fill manually yourself on the method call or static call after it fill the method itself.

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit a644d0d into main Dec 23, 2023
41 checks passed
@TomasVotruba TomasVotruba deleted the allow-to-add-argument-without-default-value branch December 23, 2023 19:42
@TomasVotruba
Copy link
Member

Looks good, thank you 👍

@samsonasik
Copy link
Member Author

@TomasVotruba @joachim-n I am thinking that default value for method/static call is still needed, to init the method arg after parameter added, I guess it can be:

$obj = new SomeClass();
-$obj->execute();
+$obj->execute([]);

so fatal error won't be shown, to differentiate, we probably need defaultArgOnCall property, wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants