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

Make use of getArgs() #55

Merged
merged 2 commits into from
May 13, 2023
Merged

Make use of getArgs() #55

merged 2 commits into from
May 13, 2023

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented May 13, 2023

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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(...);
Copy link
Member

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

Copy link
Member

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
``

Copy link
Member

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

if ($funcCall->isFirstClassCallable()) {
return true;
}

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.

None yet

2 participants