bobthecow/psysh

PHP-Scoper incorrectly scopes `\ReflectionClassConstant`

Closed this issue · 5 comments

ReflectionClassConstant::create tries to decide whether to create an instance of the actual \ReflectionClassConstant, or our ponyfill. When trying to re-enable PHP-Scoper it was incorrectly scoping that class name, which caused test failures:

    public static function create($class, $name)
    {
        if (\class_exists('_HumbugBox4f95cd3d5edb\\ReflectionClassConstant')) {
            return new \ReflectionClassConstant($class, $name);
        }
        return new self($class, $name);
    }

cc @theofidry

In this case, the ReflectionClassConstant bit is part of PsySH core and is in everything, not optionally just in compatibility builds.

This feels like it might be a bug in PHP Scoper, tbh. the original code was

if (\class_exists('\\ReflectionClassConstant')) {
  // ...

… which couldn't be anything but a reference to an internal class.

Hm indeed

@theofidry is there an easy way to work around this on our end while we're waiting for the issue in PHP Scoper to be resolved?

Yes, by relying on a patcher