From 187aeeeaf790f16ec0344acf7d432f781994e58d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Sep 2014 08:35:53 +0200 Subject: [PATCH] fixed CS --- UPGRADE-3.0.md | 6 +++-- .../Compiler/CheckDefinitionValidityPass.php | 21 ++++------------ .../Compiler/InlineServiceDefinitionsPass.php | 8 ++----- .../DependencyInjection/Definition.php | 24 ++++++++----------- .../DefinitionDecorator.php | 4 +--- .../DependencyInjection/Dumper/PhpDumper.php | 3 +-- .../Loader/YamlFileLoader.php | 2 +- 7 files changed, 23 insertions(+), 45 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index e108ceeed9..17417689ab 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -88,8 +88,10 @@ UPGRADE FROM 2.x to 3.0 ### DependencyInjection - * The methods `setFactoryClass()`, `setFactoryMethod()` and `setFactoryService()` have been removed in favor of `setFactory()`. - Services defined using YAML or XML use the same syntax as configurators. + * The methods `Definition::setFactoryClass()`, + `Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have + been removed in favor of `Definition::setFactory()`. Services defined using + YAML or XML use the same syntax as configurators. ### EventDispatcher diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php index fd14dabb91..ce89f24e18 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php @@ -42,35 +42,22 @@ class CheckDefinitionValidityPass implements CompilerPassInterface foreach ($container->getDefinitions() as $id => $definition) { // synthetic service is public if ($definition->isSynthetic() && !$definition->isPublic()) { - throw new RuntimeException(sprintf( - 'A synthetic service ("%s") must be public.', - $id - )); + throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id)); } // synthetic service has non-prototype scope if ($definition->isSynthetic() && ContainerInterface::SCOPE_PROTOTYPE === $definition->getScope()) { - throw new RuntimeException(sprintf( - 'A synthetic service ("%s") cannot be of scope "prototype".', - $id - )); + throw new RuntimeException(sprintf('A synthetic service ("%s") cannot be of scope "prototype".', $id)); } if ($definition->getFactory() && ($definition->getFactoryClass() || $definition->getFactoryService() || $definition->getFactoryMethod())) { - throw new RuntimeException(sprintf( - 'A service ("%s") can use either the old or the new factory syntax, not both.', - $id - )); + throw new RuntimeException(sprintf('A service ("%s") can use either the old or the new factory syntax, not both.', $id)); } // non-synthetic, non-abstract service has class if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) { if ($definition->getFactory() || $definition->getFactoryClass() || $definition->getFactoryService()) { - throw new RuntimeException(sprintf( - 'Please add the class to service "%s" even if it is constructed by a factory ' - .'since we might need to add method calls based on compile-time checks.', - $id - )); + throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); } throw new RuntimeException(sprintf( diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index 32b506f3ee..6c529ee8bd 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -64,14 +64,10 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface ); $configurator = $this->inlineArguments($container, array($definition->getConfigurator())); - $definition->setConfigurator( - $configurator[0] - ); + $definition->setConfigurator($configurator[0]); $factory = $this->inlineArguments($container, array($definition->getFactory())); - $definition->setFactory( - $factory[0] - ); + $definition->setFactory($factory[0]); } } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 85408764fd..920fd3bd57 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -58,13 +58,11 @@ class Definition } /** - * Sets a factory + * Sets a factory. * - * @param callable $factory The PHP callable to call or an array containing a Reference and a method to call + * @param string|array $factory A PHP function or an array containing a class/Reference and a method to call * * @return Definition The current instance - * - * @api */ public function setFactory($factory) { @@ -74,11 +72,9 @@ class Definition } /** - * Gets the factory . + * Gets the factory. * - * @return callable|array The PHP callable to call or an array containing a Reference and a method to call - * - * @api + * @return string|array The PHP function or an array containing a class/Reference and a method to call */ public function getFactory() { @@ -94,7 +90,7 @@ class Definition * @return Definition The current instance * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function setFactoryClass($factoryClass) { @@ -109,7 +105,7 @@ class Definition * @return string|null The factory class name * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function getFactoryClass() { @@ -124,7 +120,7 @@ class Definition * @return Definition The current instance * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function setFactoryMethod($factoryMethod) { @@ -174,7 +170,7 @@ class Definition * @return string|null The factory method name * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function getFactoryMethod() { @@ -189,7 +185,7 @@ class Definition * @return Definition The current instance * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function setFactoryService($factoryService) { @@ -204,7 +200,7 @@ class Definition * @return string|null The factory service id * * @api - * @deprecated Deprecated since version 2.5, to be removed in 3.0. + * @deprecated Deprecated since version 2.6, to be removed in 3.0. */ public function getFactoryService() { diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index 60e11a37bf..390147ea06 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -78,8 +78,6 @@ class DefinitionDecorator extends Definition /** * {@inheritdoc} - * - * @api */ public function setFactory($callable) { @@ -89,7 +87,7 @@ class DefinitionDecorator extends Definition } /** - * {@inheritDoc} + * {@inheritdoc} * * @api */ diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index fbd284d4b7..3e5de6cb82 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -529,7 +529,7 @@ class PhpDumper extends Dumper if (is_string($factory)) { $return[] = sprintf('@return object An instance returned by %s().', $factory); } elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) { - if (is_string($factory[0] || $factory[0] instanceof Reference)) { + if (is_string($factory[0]) || $factory[0] instanceof Reference) { $return[] = sprintf('@return object An instance returned by %s::%s().', (string) $factory[0], $factory[1]); } elseif ($factory[0] instanceof Definition) { $return[] = sprintf('@return object An instance returned by %s::%s().', $factory[0]->getClass(), $factory[1]); @@ -731,7 +731,6 @@ EOF; } return sprintf(" $return{$instantiation}%s(%s);\n", $callable, $arguments ? implode(', ', $arguments) : ''); - } elseif (null !== $definition->getFactoryMethod()) { if (null !== $definition->getFactoryClass()) { $class = $this->dumpValue($definition->getFactoryClass()); diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index a1f940200b..202ac138ed 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -196,7 +196,7 @@ class YamlFileLoader extends FileLoader if (isset($service['factory'])) { if (is_string($service['factory'])) { - if (strpos($service['factory'], ':')) { + if (strpos($service['factory'], ':')) { $parts = explode(':', $service['factory']); $definition->setFactory(array($this->resolveServices('@'.$parts[0]), $parts[1])); } else {