Skip to content

Commit 7783969

Browse files
committed
changed getName() to name on all Reflection* object calls (fixes #4555, refs https://bugs.php.net/bug.php?id=61384)
1 parent 7938cf9 commit 7783969

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public function getServiceIds()
288288
$ids = array();
289289
$r = new \ReflectionClass($this);
290290
foreach ($r->getMethods() as $method) {
291-
if (preg_match('/^get(.+)Service$/', $method->getName(), $match)) {
291+
if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
292292
$ids[] = self::underscore($match[1]);
293293
}
294294
}

src/Symfony/Component/Form/Util/PropertyPath.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,19 @@ protected function &readProperty(&$objectOrArray, $property, $isIndex)
384384

385385
if ($reflClass->hasMethod($getter)) {
386386
if (!$reflClass->getMethod($getter)->isPublic()) {
387-
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $getter, $reflClass->getName()));
387+
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $getter, $reflClass->name));
388388
}
389389

390390
$result = $objectOrArray->$getter();
391391
} elseif ($reflClass->hasMethod($isser)) {
392392
if (!$reflClass->getMethod($isser)->isPublic()) {
393-
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $isser, $reflClass->getName()));
393+
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $isser, $reflClass->name));
394394
}
395395

396396
$result = $objectOrArray->$isser();
397397
} elseif ($reflClass->hasMethod($hasser)) {
398398
if (!$reflClass->getMethod($hasser)->isPublic()) {
399-
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $hasser, $reflClass->getName()));
399+
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $hasser, $reflClass->name));
400400
}
401401

402402
$result = $objectOrArray->$hasser();
@@ -405,15 +405,15 @@ protected function &readProperty(&$objectOrArray, $property, $isIndex)
405405
$result =& $objectOrArray->$property;
406406
} elseif ($reflClass->hasProperty($property)) {
407407
if (!$reflClass->getProperty($property)->isPublic()) {
408-
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));
408+
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));
409409
}
410410

411411
$result =& $objectOrArray->$property;
412412
} elseif (property_exists($objectOrArray, $property)) {
413413
// needed to support \stdClass instances
414414
$result =& $objectOrArray->$property;
415415
} else {
416-
throw new InvalidPropertyException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $reflClass->getName()));
416+
throw new InvalidPropertyException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $property, $getter, $isser, $reflClass->name));
417417
}
418418
} else {
419419
throw new InvalidPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you should write the property path as "[%s]" instead?', $property, $property));
@@ -486,7 +486,7 @@ protected function writeProperty(&$objectOrArray, $property, $singular, $isIndex
486486
$setter = 'set'.$this->camelize($property);
487487
if ($reflClass->hasMethod($setter)) {
488488
if (!$reflClass->getMethod($setter)->isPublic()) {
489-
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->getName()));
489+
throw new PropertyAccessDeniedException(sprintf('Method "%s()" is not public in class "%s"', $setter, $reflClass->name));
490490
}
491491

492492
$objectOrArray->$setter($value);
@@ -495,15 +495,15 @@ protected function writeProperty(&$objectOrArray, $property, $singular, $isIndex
495495
$objectOrArray->$property = $value;
496496
} elseif ($reflClass->hasProperty($property)) {
497497
if (!$reflClass->getProperty($property)->isPublic()) {
498-
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()"?', $property, $reflClass->getName(), $setter));
498+
throw new PropertyAccessDeniedException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()"?', $property, $reflClass->name, $setter));
499499
}
500500

501501
$objectOrArray->$property = $value;
502502
} elseif (property_exists($objectOrArray, $property)) {
503503
// needed to support \stdClass instances
504504
$objectOrArray->$property = $value;
505505
} else {
506-
throw new InvalidPropertyException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $reflClass->getName()));
506+
throw new InvalidPropertyException(sprintf('Neither element "%s" nor method "%s()" exists in class "%s"', $property, $setter, $reflClass->name));
507507
}
508508
} else {
509509
throw new InvalidPropertyException(sprintf('Cannot write property "%s" in an array. Maybe you should write the property path as "[%s]" instead?', $property, $property));
@@ -542,15 +542,15 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
542542
throw new InvalidPropertyException(sprintf(
543543
'The public method "%s" with exactly one required parameter was not found on class %s',
544544
$addMethod,
545-
$reflClass->getName()
545+
$reflClass->name
546546
));
547547
}
548548

549549
if (!$this->isAccessible($reflClass, $removeMethod, 1)) {
550550
throw new InvalidPropertyException(sprintf(
551551
'The public method "%s" with exactly one required parameter was not found on class %s',
552552
$removeMethod,
553-
$reflClass->getName()
553+
$reflClass->name
554554
));
555555
}
556556

@@ -579,7 +579,7 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
579579
'Found the public method "%s", but did not find a public "%s" on class %s',
580580
$addMethodFound ? $addMethod : $removeMethod,
581581
$addMethodFound ? $removeMethod : $addMethod,
582-
$reflClass->getName()
582+
$reflClass->name
583583
));
584584
}
585585
}

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete
114114
$attributes = $request->attributes->all();
115115
$arguments = array();
116116
foreach ($parameters as $param) {
117-
if (array_key_exists($param->getName(), $attributes)) {
118-
$arguments[] = $attributes[$param->getName()];
117+
if (array_key_exists($param->name, $attributes)) {
118+
$arguments[] = $attributes[$param->name];
119119
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
120120
$arguments[] = $request;
121121
} elseif ($param->isDefaultValueAvailable()) {
@@ -129,7 +129,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete
129129
$repr = $controller;
130130
}
131131

132-
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()));
132+
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));
133133
}
134134
}
135135

src/Symfony/Component/OptionsResolver/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,6 @@ static private function isEvaluatedLazily($value)
431431
return false;
432432
}
433433

434-
return __CLASS__ === $params[0]->getClass()->getName();
434+
return __CLASS__ === $params[0]->getClass()->name;
435435
}
436436
}

src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function getResolver()
200200
*/
201201
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
202202
{
203-
$name = strtolower(str_replace('\\', '_', $class->getName()).'_'.$method->getName());
203+
$name = strtolower(str_replace('\\', '_', $class->name).'_'.$method->name);
204204
if ($this->defaultRouteIndex > 0) {
205205
$name .= '_'.$this->defaultRouteIndex;
206206
}

src/Symfony/Component/Security/Acl/Resources/bin/generateSql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
}
4848

4949
$platform = $reflection->newInstance();
50-
$targetFile = sprintf(__DIR__.'/../schema/%s.sql', $platform->getName());
50+
$targetFile = sprintf(__DIR__.'/../schema/%s.sql', $platform->name);
5151
file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform)));
5252
}

src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function normalize($object, $format = null)
7474
$attributes = array();
7575
foreach ($reflectionMethods as $method) {
7676
if ($this->isGetMethod($method)) {
77-
$attributeName = lcfirst(substr($method->getName(), 3));
77+
$attributeName = lcfirst(substr($method->name, 3));
7878

7979
if (in_array($attributeName, $this->ignoredAttributes)) {
8080
continue;
@@ -108,7 +108,7 @@ public function denormalize($data, $class, $format = null)
108108

109109
$params = array();
110110
foreach ($constructorParameters as $constructorParameter) {
111-
$paramName = lcfirst($constructorParameter->getName());
111+
$paramName = lcfirst($constructorParameter->name);
112112

113113
if (isset($data[$paramName])) {
114114
$params[] = $data[$paramName];
@@ -118,7 +118,7 @@ public function denormalize($data, $class, $format = null)
118118
throw new RuntimeException(
119119
'Cannot create an instance of '.$class.
120120
' from serialized data because its constructor requires '.
121-
'parameter "'.$constructorParameter->getName().
121+
'parameter "'.$constructorParameter->name.
122122
'" to be present.');
123123
}
124124
}
@@ -182,8 +182,8 @@ private function supports($class)
182182
private function isGetMethod(\ReflectionMethod $method)
183183
{
184184
return (
185-
0 === strpos($method->getName(), 'get') &&
186-
3 < strlen($method->getName()) &&
185+
0 === strpos($method->name, 'get') &&
186+
3 < strlen($method->name) &&
187187
0 === $method->getNumberOfRequiredParameters()
188188
);
189189
}

src/Symfony/Component/Validator/Mapping/ClassMetadataFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public function getClassMetadata($class)
5353

5454
// Include constraints from the parent class
5555
if ($parent = $metadata->getReflectionClass()->getParentClass()) {
56-
$metadata->mergeConstraints($this->getClassMetadata($parent->getName()));
56+
$metadata->mergeConstraints($this->getClassMetadata($parent->name));
5757
}
5858

5959
// Include constraints from all implemented interfaces
6060
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
61-
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->getName()) {
61+
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
6262
continue;
6363
}
64-
$metadata->mergeConstraints($this->getClassMetadata($interface->getName()));
64+
$metadata->mergeConstraints($this->getClassMetadata($interface->name));
6565
}
6666

6767
$this->loader->loadClassMetadata($metadata);

src/Symfony/Component/Validator/Mapping/Loader/AnnotationLoader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(Reader $reader)
3333
public function loadClassMetadata(ClassMetadata $metadata)
3434
{
3535
$reflClass = $metadata->getReflectionClass();
36-
$className = $reflClass->getName();
36+
$className = $reflClass->name;
3737
$loaded = false;
3838

3939
foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
@@ -49,10 +49,10 @@ public function loadClassMetadata(ClassMetadata $metadata)
4949
}
5050

5151
foreach ($reflClass->getProperties() as $property) {
52-
if ($property->getDeclaringClass()->getName() == $className) {
52+
if ($property->getDeclaringClass()->name == $className) {
5353
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
5454
if ($constraint instanceof Constraint) {
55-
$metadata->addPropertyConstraint($property->getName(), $constraint);
55+
$metadata->addPropertyConstraint($property->name, $constraint);
5656
}
5757

5858
$loaded = true;
@@ -61,13 +61,13 @@ public function loadClassMetadata(ClassMetadata $metadata)
6161
}
6262

6363
foreach ($reflClass->getMethods() as $method) {
64-
if ($method->getDeclaringClass()->getName() == $className) {
64+
if ($method->getDeclaringClass()->name == $className) {
6565
foreach ($this->reader->getMethodAnnotations($method) as $constraint) {
6666
if ($constraint instanceof Constraint) {
67-
if (preg_match('/^(get|is)(.+)$/i', $method->getName(), $matches)) {
67+
if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) {
6868
$metadata->addGetterConstraint(lcfirst($matches[2]), $constraint);
6969
} else {
70-
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()));
70+
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));
7171
}
7272
}
7373

src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public function loadClassMetadata(ClassMetadata $metadata)
3434
$reflMethod = $reflClass->getMethod($this->methodName);
3535

3636
if (!$reflMethod->isStatic()) {
37-
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->getName(), $this->methodName));
37+
throw new MappingException(sprintf('The method %s::%s should be static', $reflClass->name, $this->methodName));
3838
}
3939

40-
if ($reflMethod->getDeclaringClass()->getName() != $reflClass->getName()) {
40+
if ($reflMethod->getDeclaringClass()->name != $reflClass->name) {
4141
return false;
4242
}
4343

0 commit comments

Comments
 (0)