-
Notifications
You must be signed in to change notification settings - Fork 12
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
Make use of getArgs() #55
Conversation
rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php
Outdated
Show resolved
Hide resolved
rules/DowngradePhp73/Rector/FuncCall/SetCookieOptionsArrayToArgumentsRector.php
Show resolved
Hide resolved
@@ -118,24 +108,20 @@ private function composeNewArgs(FuncCall $funcCall): array | |||
{ | |||
$this->highestIndex = 1; | |||
|
|||
if (! $this->argsAnalyzer->isArgsInstanceInArgsPositions($funcCall->args, [0, 1, 2])) { | |||
if (count($funcCall->getArgs()) < 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, getArgs()
throw warning too early, see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think these asserts are never executed, never came across it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a fixture to covert it with (...) and is passed. Could you share a PR with failing test fixture?
I'll merge this, so we can iterate to improve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while downgrade rule always downgrade DowngradeFirstClassCallableSyntaxRector
early, this may cause jump rule which the args still a first class callable, that's wil cause error:
PHP Warning: Uncaught AssertionError: assert(!$this->isFirstClassCallable()) in php shell code:1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert is show or not depends on zend.assertions. setting, which default OFF on our CI.
|
||
function skipFirstClassCallable() | ||
{ | ||
$firstClassCallable = define(...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will show error when enable zend.assertion in CI https://www.php.net/manual/en/ini.core.php#ini.zend.assertions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the example setting assertion setting in console:
# disable
php > ini_set('zend.assertions', 0);
php > assert(true === false);
# enable
php > ini_set('zend.assertions', 1);
php > assert(true === false);
PHP Warning: Uncaught AssertionError: assert(true === false) in php shell code:1
Stack trace:
#0 php shell code(1): assert(false, 'assert(true ===...')
#1 {main}
thrown in php shell code on line 1
Warning: Uncaught AssertionError: assert(true === false) in php shell code:1
Stack trace:
#0 php shell code(1): assert(false, 'assert(true ===...')
#1 {main}
thrown in php shell code on line 1
``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, isFirstCallable()
already called on shouldSkip()
method, so it works
rector-downgrade-php/rules/DowngradePhp70/Rector/Expression/DowngradeDefineArrayConstantRector.php
Lines 86 to 88 in 86a937c
if ($funcCall->isFirstClassCallable()) { | |
return true; | |
} |
Ref rectorphp/rector-src#3822