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

self::class, parent::class and static::class are not correctly resolved into their corresponding strings #444

Closed
Ocramius opened this issue Sep 3, 2018 · 0 comments · Fixed by #472
Assignees
Labels
Milestone

Comments

@Ocramius
Copy link
Member

Ocramius commented Sep 3, 2018

Example:

<?php

declare(strict_types=1);

use Roave\BetterReflection\BetterReflection;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\SourceLocator\Type\StringSourceLocator;

require_once __DIR__ . '/vendor/autoload.php';

$foo = (new ClassReflector(
    new StringSourceLocator(
        <<<'PHP'
<?php

class Baz {
}

class Foo extends Baz {
    public $bar = self::class;
    public $baz = static::class;
    public $taz = parent::class;
}
PHP
        ,
        (new BetterReflection())->astLocator()
    )
))->reflect('Foo');

var_dump($foo->getDefaultProperties());

The output will be something like:

array(3) {
  'bar' =>
  string(4) "self"
  'baz' =>
  string(6) "static"
  'taz' =>
  string(6) "parent"
}

The expected output should be:

array(3) {
  'bar' =>
  string(4) "Foo"
  'baz' =>
  string(6) "Foo"
  'taz' =>
  string(6) "Baz"
}
@Ocramius Ocramius added the bug label Sep 3, 2018
@Ocramius Ocramius self-assigned this May 14, 2019
@Ocramius Ocramius added this to the 3.4.1 milestone May 14, 2019
@Ocramius Ocramius modified the milestones: 3.4.1, 3.5.0 May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant