Skip to content

Commit

Permalink
changed getName() to name on all Reflection* object calls (fixes symf…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 12, 2012
1 parent 7938cf9 commit 7783969
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/DependencyInjection/Container.php
Expand Up @@ -288,7 +288,7 @@ public function getServiceIds()
$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]);
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/Symfony/Component/Form/Util/PropertyPath.php
Expand Up @@ -384,19 +384,19 @@ protected function &readProperty(&$objectOrArray, $property, $isIndex)

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));
}

$result = $objectOrArray->$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));
}

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

$result = $objectOrArray->$hasser();
Expand All @@ -405,15 +405,15 @@ protected function &readProperty(&$objectOrArray, $property, $isIndex)
$result =& $objectOrArray->$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));
}

$result =& $objectOrArray->$property;
} elseif (property_exists($objectOrArray, $property)) {
// needed to support \stdClass instances
$result =& $objectOrArray->$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));
}
} else {
throw new InvalidPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you should write the property path as "[%s]" instead?', $property, $property));
Expand Down Expand Up @@ -486,7 +486,7 @@ protected function writeProperty(&$objectOrArray, $property, $singular, $isIndex
$setter = 'set'.$this->camelize($property);
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);
Expand All @@ -495,15 +495,15 @@ protected function writeProperty(&$objectOrArray, $property, $singular, $isIndex
$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;
} elseif (property_exists($objectOrArray, $property)) {
// 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 {
throw new InvalidPropertyException(sprintf('Cannot write property "%s" in an array. Maybe you should write the property path as "[%s]" instead?', $property, $property));
Expand Down Expand Up @@ -542,15 +542,15 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
throw new InvalidPropertyException(sprintf(
'The public method "%s" with exactly one required parameter was not found on class %s',
$addMethod,
$reflClass->getName()
$reflClass->name
));
}

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

Expand Down Expand Up @@ -579,7 +579,7 @@ private function findAdderAndRemover(\ReflectionClass $reflClass, $singular)
'Found the public method "%s", but did not find a public "%s" on class %s',
$addMethodFound ? $addMethod : $removeMethod,
$addMethodFound ? $removeMethod : $addMethod,
$reflClass->getName()
$reflClass->name
));
}
}
Expand Down
Expand Up @@ -114,8 +114,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete
$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()) {
Expand All @@ -129,7 +129,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete
$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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/OptionsResolver/Options.php
Expand Up @@ -431,6 +431,6 @@ static private function isEvaluatedLazily($value)
return false;
}

return __CLASS__ === $params[0]->getClass()->getName();
return __CLASS__ === $params[0]->getClass()->name;
}
}
Expand Up @@ -200,7 +200,7 @@ public function getResolver()
*/
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;
}
Expand Down
Expand Up @@ -47,6 +47,6 @@
}

$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)));
}
Expand Up @@ -74,7 +74,7 @@ public function normalize($object, $format = null)
$attributes = array();
foreach ($reflectionMethods as $method) {
if ($this->isGetMethod($method)) {
$attributeName = lcfirst(substr($method->getName(), 3));
$attributeName = lcfirst(substr($method->name, 3));

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

$params = array();
foreach ($constructorParameters as $constructorParameter) {
$paramName = lcfirst($constructorParameter->getName());
$paramName = lcfirst($constructorParameter->name);

if (isset($data[$paramName])) {
$params[] = $data[$paramName];
Expand All @@ -118,7 +118,7 @@ public function denormalize($data, $class, $format = null)
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.');
}
}
Expand Down Expand Up @@ -182,8 +182,8 @@ private function supports($class)
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()
);
}
Expand Down
Expand Up @@ -53,15 +53,15 @@ public function getClassMetadata($class)

// 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) {
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->getName()) {
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
continue;
}
$metadata->mergeConstraints($this->getClassMetadata($interface->getName()));
$metadata->mergeConstraints($this->getClassMetadata($interface->name));
}

$this->loader->loadClassMetadata($metadata);
Expand Down
Expand Up @@ -33,7 +33,7 @@ public function __construct(Reader $reader)
public function loadClassMetadata(ClassMetadata $metadata)
{
$reflClass = $metadata->getReflectionClass();
$className = $reflClass->getName();
$className = $reflClass->name;
$loaded = false;

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

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;
Expand All @@ -61,13 +61,13 @@ public function loadClassMetadata(ClassMetadata $metadata)
}

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));
}
}

Expand Down
Expand Up @@ -34,10 +34,10 @@ public function loadClassMetadata(ClassMetadata $metadata)
$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;
}

Expand Down

0 comments on commit 7783969

Please sign in to comment.