예제 #1
0
 /**
  * Generate a proxy from a class name
  *
  * @param string  $className
  * @param mixed[] $proxyOptions
  *
  * @return string proxy class name
  */
 protected function generateProxy($className, array $proxyOptions = [])
 {
     if (isset($this->checkedClasses[$className])) {
         return $this->checkedClasses[$className];
     }
     $proxyParameters = ['className' => $className, 'factory' => get_class($this), 'proxyManagerVersion' => Version::VERSION];
     $proxyClassName = $this->configuration->getClassNameInflector()->getProxyClassName($className, $proxyParameters);
     if (!class_exists($proxyClassName)) {
         $this->generateProxyClass($proxyClassName, $className, $proxyParameters, $proxyOptions);
     }
     $this->configuration->getSignatureChecker()->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters);
     return $this->checkedClasses[$className] = $proxyClassName;
 }
 private function generateProxyForSuperClass(ReflectionClass $class, ReflectionClass $superClass)
 {
     $cacheKey = $this->getSurrogateClassName($class, $superClass);
     if (isset($this->checkedClasses[$cacheKey])) {
         return $this->checkedClasses[$cacheKey];
     }
     $proxyParameters = ['cacheKey' => $cacheKey, 'factory' => get_class($this), 'proxyManagerVersion' => Version::VERSION];
     $proxyClassName = $this->configuration->getClassNameInflector()->getProxyClassName($cacheKey, $proxyParameters);
     if (!class_exists($proxyClassName)) {
         $baseClass = $this->getBaseClass($class, $superClass);
         $this->generateProxyClass($proxyClassName, $baseClass, $superClass, $proxyParameters);
     }
     $this->configuration->getSignatureChecker()->checkSignature(new ReflectionClass($proxyClassName), $proxyParameters);
     return $this->checkedClasses[$cacheKey] = $proxyClassName;
 }
예제 #3
0
 /**
  * @covers \ProxyManager\Configuration::getSignatureChecker
  * @covers \ProxyManager\Configuration::setSignatureChecker
  */
 public function testSetGetSignatureChecker()
 {
     $this->assertInstanceOf('ProxyManager\\Signature\\SignatureCheckerInterface', $this->configuration->getSignatureChecker());
     /* @var $signatureChecker \ProxyManager\Signature\SignatureCheckerInterface */
     $signatureChecker = $this->getMock('ProxyManager\\Signature\\SignatureCheckerInterface');
     $this->configuration->setSignatureChecker($signatureChecker);
     $this->assertSame($signatureChecker, $this->configuration->getSignatureChecker());
 }