changed getName() to name on all Reflection* object calls (fixes #4555, refs https://bugs.php.net/bug.php?id=61384)

This commit is contained in:
Fabien Potencier 2012-06-12 13:59:42 +02:00
parent 27100ba4eb
commit ba16a51d37
10 changed files with 29 additions and 29 deletions

View File

@ -230,7 +230,7 @@ class Registry implements RegistryInterface
{ {
$proxyClass = new \ReflectionClass($class); $proxyClass = new \ReflectionClass($class);
if ($proxyClass->implementsInterface('Doctrine\ORM\Proxy\Proxy')) { if ($proxyClass->implementsInterface('Doctrine\ORM\Proxy\Proxy')) {
$class = $proxyClass->getParentClass()->getName(); $class = $proxyClass->getParentClass()->name;
} }
foreach ($this->entityManagers as $id) { foreach ($this->entityManagers as $id) {

View File

@ -274,7 +274,7 @@ class Container implements ContainerInterface
$ids = array(); $ids = array();
$r = new \ReflectionClass($this); $r = new \ReflectionClass($this);
foreach ($r->getMethods() as $method) { foreach ($r->getMethods() as $method) {
if (preg_match('/^get(.+)Service$/', $method->getName(), $match)) { if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
$ids[] = self::underscore($match[1]); $ids[] = self::underscore($match[1]);
} }
} }

View File

@ -290,13 +290,13 @@ class PropertyPath implements \IteratorAggregate
if ($reflClass->hasMethod($getter)) { if ($reflClass->hasMethod($getter)) {
if (!$reflClass->getMethod($getter)->isPublic()) { if (!$reflClass->getMethod($getter)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $getter, $reflClass->getName())); throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $getter, $reflClass->name));
} }
return $object->$getter(); return $object->$getter();
} elseif ($reflClass->hasMethod($isser)) { } elseif ($reflClass->hasMethod($isser)) {
if (!$reflClass->getMethod($isser)->isPublic()) { if (!$reflClass->getMethod($isser)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $isser, $reflClass->getName())); throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $isser, $reflClass->name));
} }
return $object->$isser(); return $object->$isser();
@ -305,7 +305,7 @@ class PropertyPath implements \IteratorAggregate
return $object->$property; return $object->$property;
} elseif ($reflClass->hasProperty($property)) { } elseif ($reflClass->hasProperty($property)) {
if (!$reflClass->getProperty($property)->isPublic()) { if (!$reflClass->getProperty($property)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $property, $reflClass->getName(), $getter, $isser)); throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $property, $reflClass->name, $getter, $isser));
} }
return $object->$property; return $object->$property;
@ -313,7 +313,7 @@ class PropertyPath implements \IteratorAggregate
// needed to support \stdClass instances // needed to support \stdClass instances
return $object->$property; return $object->$property;
} else { } else {
throw new InvalidPropertyException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $reflClass->getName())); throw new InvalidPropertyException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $reflClass->name));
} }
} }
} }
@ -341,7 +341,7 @@ class PropertyPath implements \IteratorAggregate
if ($reflClass->hasMethod($setter)) { if ($reflClass->hasMethod($setter)) {
if (!$reflClass->getMethod($setter)->isPublic()) { if (!$reflClass->getMethod($setter)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->getName())); throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->name));
} }
$objectOrArray->$setter($value); $objectOrArray->$setter($value);
@ -350,7 +350,7 @@ class PropertyPath implements \IteratorAggregate
$objectOrArray->$property = $value; $objectOrArray->$property = $value;
} elseif ($reflClass->hasProperty($property)) { } elseif ($reflClass->hasProperty($property)) {
if (!$reflClass->getProperty($property)->isPublic()) { if (!$reflClass->getProperty($property)->isPublic()) {
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()"?', $property, $reflClass->getName(), $setter)); throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()"?', $property, $reflClass->name, $setter));
} }
$objectOrArray->$property = $value; $objectOrArray->$property = $value;
@ -358,7 +358,7 @@ class PropertyPath implements \IteratorAggregate
// needed to support \stdClass instances // needed to support \stdClass instances
$objectOrArray->$property = $value; $objectOrArray->$property = $value;
} else { } else {
throw new InvalidPropertyException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $reflClass->getName())); throw new InvalidPropertyException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $reflClass->name));
} }
} else { } else {
$objectOrArray[$property] = $value; $objectOrArray[$property] = $value;

View File

@ -110,8 +110,8 @@ class ControllerResolver implements ControllerResolverInterface
$attributes = $request->attributes->all(); $attributes = $request->attributes->all();
$arguments = array(); $arguments = array();
foreach ($parameters as $param) { foreach ($parameters as $param) {
if (array_key_exists($param->getName(), $attributes)) { if (array_key_exists($param->name, $attributes)) {
$arguments[] = $attributes[$param->getName()]; $arguments[] = $attributes[$param->name];
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) { } elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
$arguments[] = $request; $arguments[] = $request;
} elseif ($param->isDefaultValueAvailable()) { } elseif ($param->isDefaultValueAvailable()) {
@ -125,7 +125,7 @@ class ControllerResolver implements ControllerResolverInterface
$repr = $controller; $repr = $controller;
} }
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->getName())); throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name));
} }
} }

View File

@ -200,7 +200,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
*/ */
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
{ {
$name = strtolower(str_replace('\\', '_', $class->getName()).'_'.$method->getName()); $name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name);
if ($this->defaultRouteIndex > 0) { if ($this->defaultRouteIndex > 0) {
$name .= '_'.$this->defaultRouteIndex; $name .= '_'.$this->defaultRouteIndex;
} }

View File

@ -47,6 +47,6 @@ foreach ($finder as $file) {
} }
$platform = $reflection->newInstance(); $platform = $reflection->newInstance();
$targetFile = sprintf(__DIR__.'/../schema/%s.sql', $platform->getName()); $targetFile = sprintf(__DIR__.'/../schema/%s.sql', $platform->name);
file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform))); file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform)));
} }

View File

@ -46,7 +46,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
$attributes = array(); $attributes = array();
foreach ($reflectionMethods as $method) { foreach ($reflectionMethods as $method) {
if ($this->isGetMethod($method)) { if ($this->isGetMethod($method)) {
$attributeName = strtolower(substr($method->getName(), 3)); $attributeName = strtolower(substr($method->name, 3));
$attributeValue = $method->invoke($object); $attributeValue = $method->invoke($object);
if (null !== $attributeValue && !is_scalar($attributeValue)) { if (null !== $attributeValue && !is_scalar($attributeValue)) {
@ -73,7 +73,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
$params = array(); $params = array();
foreach ($constructorParameters as $constructorParameter) { foreach ($constructorParameters as $constructorParameter) {
$paramName = strtolower($constructorParameter->getName()); $paramName = strtolower($constructorParameter->name);
if (isset($data[$paramName])) { if (isset($data[$paramName])) {
$params[] = $data[$paramName]; $params[] = $data[$paramName];
@ -83,7 +83,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
throw new RuntimeException( throw new RuntimeException(
'Cannot create an instance of '.$class. 'Cannot create an instance of '.$class.
' from serialized data because its constructor requires '. ' from serialized data because its constructor requires '.
'parameter "'.$constructorParameter->getName(). 'parameter "'.$constructorParameter->name.
'" to be present.'); '" to be present.');
} }
} }
@ -147,8 +147,8 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer
private function isGetMethod(\ReflectionMethod $method) private function isGetMethod(\ReflectionMethod $method)
{ {
return ( return (
0 === strpos($method->getName(), 'get') && 0 === strpos($method->name, 'get') &&
3 < strlen($method->getName()) && 3 < strlen($method->name) &&
0 === $method->getNumberOfRequiredParameters() 0 === $method->getNumberOfRequiredParameters()
); );
} }

View File

@ -57,12 +57,12 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
// Include constraints from the parent class // Include constraints from the parent class
if ($parent = $metadata->getReflectionClass()->getParentClass()) { if ($parent = $metadata->getReflectionClass()->getParentClass()) {
$metadata->mergeConstraints($this->getClassMetadata($parent->getName())); $metadata->mergeConstraints($this->getClassMetadata($parent->name));
} }
// Include constraints from all implemented interfaces // Include constraints from all implemented interfaces
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
$metadata->mergeConstraints($this->getClassMetadata($interface->getName())); $metadata->mergeConstraints($this->getClassMetadata($interface->name));
} }
$this->loader->loadClassMetadata($metadata); $this->loader->loadClassMetadata($metadata);

View File

@ -32,7 +32,7 @@ class AnnotationLoader implements LoaderInterface
public function loadClassMetadata(ClassMetadata $metadata) public function loadClassMetadata(ClassMetadata $metadata)
{ {
$reflClass = $metadata->getReflectionClass(); $reflClass = $metadata->getReflectionClass();
$className = $reflClass->getName(); $className = $reflClass->name;
$loaded = false; $loaded = false;
foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) { foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
@ -46,10 +46,10 @@ class AnnotationLoader implements LoaderInterface
} }
foreach ($reflClass->getProperties() as $property) { foreach ($reflClass->getProperties() as $property) {
if ($property->getDeclaringClass()->getName() == $className) { if ($property->getDeclaringClass()->name == $className) {
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) { foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
if ($constraint instanceof Constraint) { if ($constraint instanceof Constraint) {
$metadata->addPropertyConstraint($property->getName(), $constraint); $metadata->addPropertyConstraint($property->name, $constraint);
} }
$loaded = true; $loaded = true;
@ -58,13 +58,13 @@ class AnnotationLoader implements LoaderInterface
} }
foreach ($reflClass->getMethods() as $method) { foreach ($reflClass->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() == $className) { if ($method->getDeclaringClass()->name == $className) {
foreach ($this->reader->getMethodAnnotations($method) as $constraint) { foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
if ($constraint instanceof Constraint) { if ($constraint instanceof Constraint) {
if (preg_match('/^(get|is)(.+)$/i', $method->getName(), $matches)) { if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) {
$metadata->addGetterConstraint(lcfirst($matches[2]), $constraint); $metadata->addGetterConstraint(lcfirst($matches[2]), $constraint);
} else { } else {
throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get" or "is".', $className, $method->getName())); throw new MappingException(sprintf('The constraint on "%s::%s" cannot be added. Constraints can only be added on methods beginning with "get" or "is".', $className, $method->name));
} }
} }

View File

@ -34,10 +34,10 @@ class StaticMethodLoader implements LoaderInterface
$reflMethod = $reflClass->getMethod($this->methodName); $reflMethod = $reflClass->getMethod($this->methodName);
if (!$reflMethod->isStatic()) { if (!$reflMethod->isStatic()) {
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->getName(), $this->methodName)); throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->name, $this->methodName));
} }
if ($reflMethod->getDeclaringClass()->getName() != $reflClass->getName()) { if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
return false; return false;
} }