fixed CS
This commit is contained in:
parent
bd8531d2d8
commit
187aeeeaf7
@ -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
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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());
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user