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

System error: "PhpParser\Node\Stmt\Foreach_::__construct(): Argument #2 ($valueVar) must be of type PhpParser\Node\Expr, null given #7654

Closed
scottybcoder opened this issue Dec 11, 2022 · 2 comments · Fixed by rectorphp/rector-src#3186
Labels

Comments

@scottybcoder
Copy link

Bug Report

[ERROR] Could not process "/home/dev4/public_html/modules/Forums/viewtopic.php" file, due to:
"System error: "PhpParser\Node\Stmt\Foreach_::_construct(): Argument #2 ($valueVar) must
be of type PhpParser\Node\Expr, null given, called in
vendor/rector/rector/rules/Php72/Rector/While
/WhileEachToForeachRector.php:97"
Run Rector with "--debug" option and post the report here: https://github.com/rectorphp/rector/issues/new". On line: 31

Minimal PHP Code Causing Issue

Mod: XData v1.0.3 START

      reset($poster_xd);
      while(list($code_name,) = each($poster_xd))
	  {
         /*$poster_xd[$code_name] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', 
	     "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $poster_xd[$code_name] . '<'), 1, -1));*/
	    $poster_xd[$code_name] = preg_replace($orig_word, $replacement_word, $poster_xd[$code_name]);
	  }

Mod: XData v1.0.3 END

Expected Behaviour

Convert to foreach,,,

@samsonasik
Copy link
Member

It seems reproduced at https://getrector.org/demo/68c74646-9414-4da0-a70c-e62df628c513 on WhileEachToForeachRector

@scottybcoder
Copy link
Author

It seems reproduced at https://getrector.org/demo/68c74646-9414-4da0-a70c-e62df628c513 on WhileEachToForeachRector

Thank you I will give that a try.

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

Successfully merging a pull request may close this issue.

2 participants