Skip to content

ReflectionParameter::__toString should return FQCN symbols #9447

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

Closed
nicolas-grekas opened this issue Aug 29, 2022 · 2 comments
Closed

ReflectionParameter::__toString should return FQCN symbols #9447

nicolas-grekas opened this issue Aug 29, 2022 · 2 comments

Comments

@nicolas-grekas
Copy link
Contributor

nicolas-grekas commented Aug 29, 2022

Description

The following code:

namespace App;

class Foo
{
    public function baz(string $arg = new Foo() . Foo::BAR)
    {
    }
}

$r = new \ReflectionMethod(Foo::class, 'baz');

echo $r->getParameters()[0];

Resulted in this output:

Parameter #0 [ <optional> string $arg = new \App\Foo() . App\Foo::BAR ]

But I expected this output instead:

Parameter #0 [ <optional> string $arg = new \App\Foo() . \App\Foo::BAR ]

Originally reported at doctrine/common#983

PHP Version

8.1+

Operating System

No response

@Girgias
Copy link
Member

Girgias commented Aug 30, 2022

This also applies to PHP 8.0: https://3v4l.org/fVZOh

@iluuu1994 iluuu1994 self-assigned this Sep 1, 2022
@iluuu1994
Copy link
Member

iluuu1994 commented Sep 1, 2022

Worth noting the new case only works by chance because the fetch type overrides the ZEND_NAME_NOT_FQ flag:
https://3v4l.org/JXNPW

namespace App;

class Foo {
    public function bar(string $p = new parent)
    {
    }
}

$r = new \ReflectionMethod(Foo::class, 'bar');
echo $r->getParameters()[0];

Parameter #0 [ string $p = new namespace\parent() ]

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

No branches or pull requests

5 participants
@nikic @nicolas-grekas @iluuu1994 @Girgias and others