From ba16a51d379d83b1bd681aa947bf0a5f8801a255 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 12 Jun 2012 13:59:42 +0200 Subject: [PATCH] changed getName() to name on all Reflection* object calls (fixes #4555, refs https://bugs.php.net/bug.php?id=61384) --- src/Symfony/Bundle/DoctrineBundle/Registry.php | 2 +- .../Component/DependencyInjection/Container.php | 2 +- src/Symfony/Component/Form/Util/PropertyPath.php | 14 +++++++------- .../HttpKernel/Controller/ControllerResolver.php | 6 +++--- .../Routing/Loader/AnnotationClassLoader.php | 2 +- .../Security/Acl/Resources/bin/generateSql.php | 2 +- .../Normalizer/GetSetMethodNormalizer.php | 10 +++++----- .../Validator/Mapping/ClassMetadataFactory.php | 4 ++-- .../Validator/Mapping/Loader/AnnotationLoader.php | 12 ++++++------ .../Mapping/Loader/StaticMethodLoader.php | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/Registry.php b/src/Symfony/Bundle/DoctrineBundle/Registry.php index 656829ffcb..a9a0440d5c 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Registry.php +++ b/src/Symfony/Bundle/DoctrineBundle/Registry.php @@ -230,7 +230,7 @@ class Registry implements RegistryInterface { $proxyClass = new \ReflectionClass($class); if ($proxyClass->implementsInterface('Doctrine\ORM\Proxy\Proxy')) { - $class = $proxyClass->getParentClass()->getName(); + $class = $proxyClass->getParentClass()->name; } foreach ($this->entityManagers as $id) { diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 6f0297bd2c..263f12c70a 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -274,7 +274,7 @@ class Container implements ContainerInterface $ids = array(); $r = new \ReflectionClass($this); 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]); } } diff --git a/src/Symfony/Component/Form/Util/PropertyPath.php b/src/Symfony/Component/Form/Util/PropertyPath.php index 529d3ce100..39180aca66 100644 --- a/src/Symfony/Component/Form/Util/PropertyPath.php +++ b/src/Symfony/Component/Form/Util/PropertyPath.php @@ -290,13 +290,13 @@ class PropertyPath implements \IteratorAggregate if ($reflClass->hasMethod($getter)) { 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(); } elseif ($reflClass->hasMethod($isser)) { 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(); @@ -305,7 +305,7 @@ class PropertyPath implements \IteratorAggregate return $object->$property; } elseif ($reflClass->hasProperty($property)) { 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; @@ -313,7 +313,7 @@ class PropertyPath implements \IteratorAggregate // needed to support \stdClass instances return $object->$property; } 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->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); @@ -350,7 +350,7 @@ class PropertyPath implements \IteratorAggregate $objectOrArray->$property = $value; } elseif ($reflClass->hasProperty($property)) { 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; @@ -358,7 +358,7 @@ class PropertyPath implements \IteratorAggregate // needed to support \stdClass instances $objectOrArray->$property = $value; } 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 { $objectOrArray[$property] = $value; diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index 56d0d6f141..8da79c1d4b 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -110,8 +110,8 @@ class ControllerResolver implements ControllerResolverInterface $attributes = $request->attributes->all(); $arguments = array(); foreach ($parameters as $param) { - if (array_key_exists($param->getName(), $attributes)) { - $arguments[] = $attributes[$param->getName()]; + if (array_key_exists($param->name, $attributes)) { + $arguments[] = $attributes[$param->name]; } elseif ($param->getClass() && $param->getClass()->isInstance($request)) { $arguments[] = $request; } elseif ($param->isDefaultValueAvailable()) { @@ -125,7 +125,7 @@ class ControllerResolver implements ControllerResolverInterface $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)); } } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 8af77b368f..5f292d4589 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -200,7 +200,7 @@ abstract class AnnotationClassLoader implements LoaderInterface */ 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) { $name .= '_'.$this->defaultRouteIndex; } diff --git a/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php b/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php index dc247d4596..86633f9ecd 100644 --- a/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php +++ b/src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php @@ -47,6 +47,6 @@ foreach ($finder as $file) { } $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))); } diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index c6bd56caf4..047c60d175 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -46,7 +46,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer $attributes = array(); foreach ($reflectionMethods as $method) { if ($this->isGetMethod($method)) { - $attributeName = strtolower(substr($method->getName(), 3)); + $attributeName = strtolower(substr($method->name, 3)); $attributeValue = $method->invoke($object); if (null !== $attributeValue && !is_scalar($attributeValue)) { @@ -73,7 +73,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer $params = array(); foreach ($constructorParameters as $constructorParameter) { - $paramName = strtolower($constructorParameter->getName()); + $paramName = strtolower($constructorParameter->name); if (isset($data[$paramName])) { $params[] = $data[$paramName]; @@ -83,7 +83,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer throw new RuntimeException( 'Cannot create an instance of '.$class. ' from serialized data because its constructor requires '. - 'parameter "'.$constructorParameter->getName(). + 'parameter "'.$constructorParameter->name. '" to be present.'); } } @@ -147,8 +147,8 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer private function isGetMethod(\ReflectionMethod $method) { return ( - 0 === strpos($method->getName(), 'get') && - 3 < strlen($method->getName()) && + 0 === strpos($method->name, 'get') && + 3 < strlen($method->name) && 0 === $method->getNumberOfRequiredParameters() ); } diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php index 42fa7d7976..cf8a35c41d 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php @@ -57,12 +57,12 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface // Include constraints from the parent class if ($parent = $metadata->getReflectionClass()->getParentClass()) { - $metadata->mergeConstraints($this->getClassMetadata($parent->getName())); + $metadata->mergeConstraints($this->getClassMetadata($parent->name)); } // Include constraints from all implemented interfaces foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) { - $metadata->mergeConstraints($this->getClassMetadata($interface->getName())); + $metadata->mergeConstraints($this->getClassMetadata($interface->name)); } $this->loader->loadClassMetadata($metadata); diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php index 2474dba79f..0286677cc9 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php @@ -32,7 +32,7 @@ class AnnotationLoader implements LoaderInterface public function loadClassMetadata(ClassMetadata $metadata) { $reflClass = $metadata->getReflectionClass(); - $className = $reflClass->getName(); + $className = $reflClass->name; $loaded = false; foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) { @@ -46,10 +46,10 @@ class AnnotationLoader implements LoaderInterface } foreach ($reflClass->getProperties() as $property) { - if ($property->getDeclaringClass()->getName() == $className) { + if ($property->getDeclaringClass()->name == $className) { foreach ($this->reader->getPropertyAnnotations($property) as $constraint) { if ($constraint instanceof Constraint) { - $metadata->addPropertyConstraint($property->getName(), $constraint); + $metadata->addPropertyConstraint($property->name, $constraint); } $loaded = true; @@ -58,13 +58,13 @@ class AnnotationLoader implements LoaderInterface } foreach ($reflClass->getMethods() as $method) { - if ($method->getDeclaringClass()->getName() == $className) { + if ($method->getDeclaringClass()->name == $className) { foreach ($this->reader->getMethodAnnotations($method) as $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); } 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)); } } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php index a74ffbb429..e8622d2f09 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php @@ -34,10 +34,10 @@ class StaticMethodLoader implements LoaderInterface $reflMethod = $reflClass->getMethod($this->methodName); 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; }