generator = new NullObjectGenerator(); } /** * @param object|string $instanceOrClassName the object to be wrapped or interface to transform to null object * @psalm-param RealObjectType|class-string $instanceOrClassName * * @psalm-return RealObjectType&NullObjectInterface * * @throws InvalidSignatureException * @throws MissingSignatureException * @throws OutOfBoundsException * * @psalm-template RealObjectType of object * @psalm-suppress MixedInferredReturnType We ignore type checks here, since `staticProxyConstructor` is not * interfaced (by design) */ public function createProxy($instanceOrClassName): NullObjectInterface { $className = is_object($instanceOrClassName) ? get_class($instanceOrClassName) : $instanceOrClassName; $proxyClassName = $this->generateProxy($className); /** * We ignore type checks here, since `staticProxyConstructor` is not interfaced (by design) * * @psalm-suppress MixedMethodCall * @psalm-suppress MixedReturnStatement */ return $proxyClassName::staticProxyConstructor(); } protected function getGenerator(): ProxyGeneratorInterface { return $this->generator; } }