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

StrvalToTypeCastRector crash with variadic param #7970

Closed
NicoImparfait opened this issue Jun 2, 2023 · 1 comment · Fixed by rectorphp/rector-src#4046
Closed

StrvalToTypeCastRector crash with variadic param #7970

NicoImparfait opened this issue Jun 2, 2023 · 1 comment · Fixed by rectorphp/rector-src#4046

Comments

@NicoImparfait
Copy link

Bug Report

Subject Details
Rector version e.g. v0.17.0 (invoke vendor/bin/rector --version)

Rector crash due to StrvalToTypeCastRector when using strval with variadic param

https://getrector.com/demo/bbbf6bbc-d903-4940-ae03-7b06782ffcde

  • on version 0.17.0 I have the following error:
"System error: "PhpParser\Node\Expr\Cast::__construct(): Argument #1 ($expr) must be of type
         PhpParser\Node\Expr, null given, called in
         vendor/rector/rector/rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php57"

  • from getrector (commit 7cde41), I have the following error:
"System error: "Undefined property: PhpParser\Node\VariadicPlaceholder::$value"

Minimal PHP Code Causing Issue

<?php

final class DemoFile
{
    public function run()
    {
      return array_map(strval(...), [1, 2, 3]);
    }
}

Expected Behaviour

<?php

final class DemoFile
{
    public function run()
    {
          return array_map(fn($arg) => (string) $arg, [1, 2, 3]);
    }
}
@samsonasik
Copy link
Member

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

Successfully merging a pull request may close this issue.

2 participants