src/main/php/NewInstance.php
private static function forkTrait(\ReflectionClass $class): \ReflectionClass
    {
        $code = sprintf(
                "abstract class %sCallMapFork {\n"
                . "    use \%s;\n}",
                $class->getShortName(),
                $class->getName()
        );
        if ($class->inNamespace()) {
            $code = sprintf(
                    "namespace %s {\n%s}\n",
                    $class->getNamespaceName(),
                    $code
            );
        }

        try {
            $compile = self::$compile;
            $compile($code);
        } catch (\ParseError $pe) {
            throw new ProxyCreationFailure(
                    'Failure while creating forked trait instance of '
                    . $class->getName() . ': ' . $pe->getMessage(),
                    $pe
            );
        }

        return new \ReflectionClass($class->getName() . 'CallMapFork');
    }
private static function forkTrait(\ReflectionClass $class): \ReflectionClass
    {
        $code = sprintf(
                "abstract class %sCallMapFork {\n"
                . "    use \%s;\n}",
                $class->getShortName(),
                $class->getName()
        );
        if ($class->inNamespace()) {
            $code = sprintf(
                    "namespace %s {\n%s}\n",
                    $class->getNamespaceName(),
                    $code
            );
        }

        try {
            $compile = self::$compile;
            $compile($code);
        } catch (\ParseError $pe) {
            throw new ProxyCreationFailure(
                    'Failure while creating forked trait instance of '
                    . $class->getName() . ': ' . $pe->getMessage(),
                    $pe
            );
        }

        return new \ReflectionClass($class->getName() . 'CallMapFork');
    }
private static function forkTrait ( \ ReflectionClass $ class ) : \ ReflectionClass { $ code = sprintf ( "abstract class %sCallMapFork {\n" . "    use \%s;\n}" , $ class -> getShortName ( ) , $ class -> getName ( ) ) ; if ( $ class -> inNamespace ( ) ) { $ code = sprintf ( "namespace %s {\n%s}\n" , $ class -> getNamespaceName ( ) , $ code ) ; } try { $ compile = self :: $ compile ; $ compile ( $ code ) ; } catch ( \ ParseError $ pe ) { throw new ProxyCreationFailure ( 'Failure while creating forked trait instance of ' . $ class -> getName ( ) . ': ' . $ pe -> getMessage ( ) , $ pe ) ; } return new \ ReflectionClass ( $ class -> getName ( ) . 'CallMapFork' ) ; }
create an intermediate class for the trait so that any methods of the
trait become callable as parent

@param   \ReflectionClass  $class
@return  \ReflectionClass
@throws  ProxyCreationFailure
create an intermediate class for the trait so that any methods of the trait become callable as parent