X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdoctrine%2Fcommon%2Flib%2FDoctrine%2FCommon%2FProxy%2FProxyGenerator.php;h=df9b4be31feb22aaafb2ffa7603738516dd8b6e3;hp=62f4167f37cbfa6db6a70ab76f2e92d8d174787c;hb=5e458ff8cb4924fd5fa03b80d8edfcc52fe43479;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5 diff --git a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php index 62f4167f3..df9b4be31 100644 --- a/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php +++ b/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php @@ -256,10 +256,13 @@ class extends \ implements \verifyClassCanBeProxied($class); + preg_match_all('(<([a-zA-Z]+)>)', $this->proxyClassTemplate, $placeholderMatches); $placeholderMatches = array_combine($placeholderMatches[0], $placeholderMatches[1]); @@ -306,6 +309,22 @@ class extends \ implements \getReflectionClass()->isFinal()) { + throw InvalidArgumentException::classMustNotBeFinal($class->getName()); + } + + if ($class->getReflectionClass()->isAbstract()) { + throw InvalidArgumentException::classMustNotBeAbstract($class->getName()); + } + } + /** * Generates the proxy short class name to be used in the template. * @@ -777,7 +796,7 @@ EOT; $methods .= '&'; } - $methods .= $name . '(' . $this->buildParametersString($class, $method, $method->getParameters()) . ')'; + $methods .= $name . '(' . $this->buildParametersString($method->getParameters()) . ')'; $methods .= $this->getMethodReturnType($method); $methods .= "\n" . ' {' . "\n"; @@ -891,13 +910,11 @@ EOT; } /** - * @param ClassMetadata $class - * @param \ReflectionMethod $method * @param \ReflectionParameter[] $parameters * * @return string */ - private function buildParametersString(ClassMetadata $class, \ReflectionMethod $method, array $parameters) + private function buildParametersString(array $parameters) { $parameterDefinitions = []; @@ -905,7 +922,7 @@ EOT; foreach ($parameters as $param) { $parameterDefinition = ''; - if ($parameterType = $this->getParameterType($class, $method, $param)) { + if ($parameterType = $this->getParameterType($param)) { $parameterDefinition .= $parameterType . ' '; } @@ -913,11 +930,10 @@ EOT; $parameterDefinition .= '&'; } - if (method_exists($param, 'isVariadic') && $param->isVariadic()) { + if ($param->isVariadic()) { $parameterDefinition .= '...'; } - $parameters[] = '$' . $param->getName(); $parameterDefinition .= '$' . $param->getName(); if ($param->isDefaultValueAvailable()) { @@ -937,41 +953,13 @@ EOT; * * @return string|null */ - private function getParameterType(ClassMetadata $class, \ReflectionMethod $method, \ReflectionParameter $parameter) + private function getParameterType(\ReflectionParameter $parameter) { - if (method_exists($parameter, 'hasType')) { - if ( ! $parameter->hasType()) { - return ''; - } - - return $this->formatType($parameter->getType(), $parameter->getDeclaringFunction(), $parameter); - } - - // For PHP 5.x, we need to pick the type hint in the old way (to be removed for PHP 7.0+) - if ($parameter->isArray()) { - return 'array'; - } - - if ($parameter->isCallable()) { - return 'callable'; + if ( ! $parameter->hasType()) { + return null; } - try { - $parameterClass = $parameter->getClass(); - - if ($parameterClass) { - return '\\' . $parameterClass->getName(); - } - } catch (\ReflectionException $previous) { - throw UnexpectedValueException::invalidParameterTypeHint( - $class->getName(), - $method->getName(), - $parameter->getName(), - $previous - ); - } - - return null; + return $this->formatType($parameter->getType(), $parameter->getDeclaringFunction(), $parameter); } /** @@ -1000,7 +988,7 @@ EOT; function (\ReflectionParameter $parameter) { $name = ''; - if (method_exists($parameter, 'isVariadic') && $parameter->isVariadic()) { + if ($parameter->isVariadic()) { $name .= '...'; } @@ -1013,13 +1001,13 @@ EOT; } /** - * @Param \ReflectionMethod $method + * @param \ReflectionMethod $method * * @return string */ private function getMethodReturnType(\ReflectionMethod $method) { - if ( ! method_exists($method, 'hasReturnType') || ! $method->hasReturnType()) { + if ( ! $method->hasReturnType()) { return ''; } @@ -1033,7 +1021,7 @@ EOT; */ private function shouldProxiedMethodReturn(\ReflectionMethod $method) { - if ( ! method_exists($method, 'hasReturnType') || ! $method->hasReturnType()) { + if ( ! $method->hasReturnType()) { return true; } @@ -1052,7 +1040,7 @@ EOT; \ReflectionMethod $method, \ReflectionParameter $parameter = null ) { - $name = method_exists($type, 'getName') ? $type->getName() : (string) $type; + $name = (string) $type; $nameLower = strtolower($name); if ('self' === $nameLower) {