Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 57daadb

Browse filesBrowse files
[Di] Remove closure-proxy arguments
1 parent 3fc1189 commit 57daadb
Copy full SHA for 57daadb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner

41 files changed

+30
-733
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ EventDispatcher
127127
---------------
128128

129129
* The `ContainerAwareEventDispatcher` class has been deprecated.
130-
Use `EventDispatcher` with closure-proxy injection instead.
130+
Use `EventDispatcher` with closure factories instead.
131131

132132
Finder
133133
------

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ EventDispatcher
132132
---------------
133133

134134
* The `ContainerAwareEventDispatcher` class has been removed.
135-
Use `EventDispatcher` with closure-proxy injection instead.
135+
Use `EventDispatcher` with closure factories instead.
136136

137137
ExpressionLanguage
138138
------------------

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,6 @@ protected function formatClosure(\Closure $closure)
312312
{
313313
$r = new \ReflectionFunction($closure);
314314

315-
if (preg_match('#^/\*\* @closure-proxy ([^: ]++)::([^: ]++) \*/$#', $r->getDocComment(), $m)) {
316-
return sprintf('%s::%s', $m[1], $m[2]);
317-
}
318-
319315
return 'closure';
320316
}
321317
}

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Helper\Table;
1515
use Symfony\Component\Console\Style\SymfonyStyle;
1616
use Symfony\Component\DependencyInjection\Alias;
17-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1817
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1918
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
2019
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -343,9 +342,6 @@ protected function describeContainerDefinition(Definition $definition, array $op
343342
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
344343
} elseif ($argument instanceof IteratorArgument) {
345344
$argumentsInformation[] = sprintf('Iterator (%d element(s))', count($argument->getValues()));
346-
} elseif ($argument instanceof ClosureProxyArgument) {
347-
list($reference, $method) = $argument->getValues();
348-
$argumentsInformation[] = sprintf('ClosureProxy(Service(%s)::%s())', $reference, $method);
349345
} elseif ($argument instanceof Definition) {
350346
$argumentsInformation[] = 'Inlined Service';
351347
} else {

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

1414
use Symfony\Component\DependencyInjection\Alias;
15-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1615
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1716
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1817
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -444,11 +443,6 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom)
444443
foreach ($this->getArgumentNodes($argument->getValues(), $dom) as $childArgumentXML) {
445444
$argumentXML->appendChild($childArgumentXML);
446445
}
447-
} elseif ($argument instanceof ClosureProxyArgument) {
448-
list($reference, $method) = $argument->getValues();
449-
$argumentXML->setAttribute('type', 'closure-proxy');
450-
$argumentXML->setAttribute('id', (string) $reference);
451-
$argumentXML->setAttribute('method', $method);
452446
} elseif ($argument instanceof Definition) {
453447
$argumentXML->appendChild($dom->importNode($this->getContainerDefinitionDocument($argument, null, false, true)->childNodes->item(0), true));
454448
} elseif (is_array($argument)) {

‎src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor;
1313

1414
use Symfony\Component\DependencyInjection\Alias;
15-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1615
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1716
use Symfony\Component\DependencyInjection\ContainerBuilder;
1817
use Symfony\Component\DependencyInjection\Definition;
@@ -119,7 +118,6 @@ public static function getContainerDefinitions()
119118
new Reference('definition_1'),
120119
new Reference('definition_2'),
121120
)))
122-
->addArgument(new ClosureProxyArgument('definition1', 'get'))
123121
->setFactory(array('Full\\Qualified\\FactoryClass', 'get')),
124122
'definition_2' => $definition2
125123
->setPublic(false)

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.json
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@
6060
"type": "service",
6161
"id": "definition_2"
6262
}
63-
],
64-
[
65-
{
66-
"type": "service",
67-
"id": "definition1"
68-
},
69-
"get"
7063
]
7164
],
7265
"file": null,

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_arguments.xml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<argument type="service" id="definition_1"/>
2323
<argument type="service" id="definition_2"/>
2424
</argument>
25-
<argument type="closure-proxy" id="definition1" method="get"/>
2625
</definition>
2726
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerBuilder"/>
2827
</container>

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.json
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@
5858
"type": "service",
5959
"id": "definition_2"
6060
}
61-
],
62-
[
63-
{
64-
"type": "service",
65-
"id": "definition1"
66-
},
67-
"get"
6861
]
6962
],
7063
"file": null,
+21-22Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
---------------- -------------------------------------------
2-
 Option   Value 
3-
---------------- -------------------------------------------
4-
Service ID -
5-
Class Full\Qualified\Class1
6-
Tags -
7-
Public yes
8-
Synthetic no
9-
Lazy yes
10-
Shared yes
11-
Abstract yes
12-
Autowired no
13-
Autoconfigured no
14-
Factory Class Full\Qualified\FactoryClass
15-
Factory Method get
16-
 Arguments Service(definition2) 
17-
 %parameter% 
18-
 Inlined Service 
19-
 Array (3 element(s)) 
20-
 Iterator (2 element(s)) 
21-
 ClosureProxy(Service(definition1)::get())
22-
---------------- -------------------------------------------
1+
---------------- -----------------------------
2+
 Option   Value 
3+
---------------- -----------------------------
4+
Service ID -
5+
Class Full\Qualified\Class1
6+
Tags -
7+
Public yes
8+
Synthetic no
9+
Lazy yes
10+
Shared yes
11+
Abstract yes
12+
Autowired no
13+
Autoconfigured no
14+
Factory Class Full\Qualified\FactoryClass
15+
Factory Method get
16+
 Arguments Service(definition2) 
17+
 %parameter% 
18+
 Inlined Service 
19+
 Array (3 element(s)) 
20+
 Iterator (2 element(s))
21+
---------------- -----------------------------
2322

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.xml
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020
<argument type="service" id="definition_1"/>
2121
<argument type="service" id="definition_2"/>
2222
</argument>
23-
<argument type="closure-proxy" id="definition1" method="get"/>
2423
</definition>

‎src/Symfony/Component/DependencyInjection/Argument/ClosureProxyArgument.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Argument/ClosureProxyArgument.php
-50Lines changed: 0 additions & 50 deletions
This file was deleted.

‎src/Symfony/Component/DependencyInjection/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/CHANGELOG.md
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ CHANGELOG
2020
* added support for omitting the factory class name in a service definition if the definition class is set
2121
* deprecated case insensitivity of service identifiers
2222
* added "iterator" argument type for lazy iteration over a set of values and services
23-
* added "closure-proxy" argument type for turning services' methods into lazy callables
2423
* added file-wide configurable defaults for service attributes "public", "tags",
2524
"autowire" and "autoconfigure"
2625
* made the "class" attribute optional, using the "id" as fallback

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
-26Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection;
1313

1414
use Psr\Container\ContainerInterface as PsrContainerInterface;
15-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1615
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1716
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
1817
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
@@ -1161,31 +1160,6 @@ public function resolveServices($value)
11611160

11621161
return $count;
11631162
});
1164-
} elseif ($value instanceof ClosureProxyArgument) {
1165-
$parameterBag = $this->getParameterBag();
1166-
list($reference, $method) = $value->getValues();
1167-
if ('service_container' === $id = (string) $reference) {
1168-
$class = parent::class;
1169-
} elseif (!$this->hasDefinition($id) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
1170-
return;
1171-
} else {
1172-
$class = $parameterBag->resolveValue($this->findDefinition($id)->getClass());
1173-
}
1174-
if (!method_exists($class, $method = $parameterBag->resolveValue($method))) {
1175-
throw new InvalidArgumentException(sprintf('Cannot create closure-proxy for service "%s": method "%s::%s" does not exist.', $id, $class, $method));
1176-
}
1177-
$r = new \ReflectionMethod($class, $method);
1178-
if (!$r->isPublic()) {
1179-
throw new RuntimeException(sprintf('Cannot create closure-proxy for service "%s": method "%s::%s" must be public.', $id, $class, $method));
1180-
}
1181-
foreach ($r->getParameters() as $p) {
1182-
if ($p->isPassedByReference()) {
1183-
throw new RuntimeException(sprintf('Cannot create closure-proxy for service "%s": parameter "$%s" of method "%s::%s" must not be passed by reference.', $id, $p->name, $class, $method));
1184-
}
1185-
}
1186-
$value = function () use ($id, $method) {
1187-
return call_user_func_array(array($this->get($id), $method), func_get_args());
1188-
};
11891163
} elseif ($value instanceof Reference) {
11901164
$value = $this->get((string) $value, $value->getInvalidBehavior());
11911165
} elseif ($value instanceof Definition) {

‎src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
-32Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Dumper;
1313

1414
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
15-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1615
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1716
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1817
use Symfony\Component\DependencyInjection\Variable;
@@ -27,7 +26,6 @@
2726
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2827
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2928
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
30-
use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
3129
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface as ProxyDumper;
3230
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\NullDumper;
3331
use Symfony\Component\DependencyInjection\ExpressionLanguage;
@@ -67,7 +65,6 @@ class PhpDumper extends Dumper
6765
private $docStar;
6866
private $serviceIdToMethodNameMap;
6967
private $usedMethodNames;
70-
private $baseClass;
7168

7269
/**
7370
* @var \Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface
@@ -125,7 +122,6 @@ public function dump(array $options = array())
125122

126123
$this->classResources = array();
127124
$this->initializeMethodNamesMap($options['base_class']);
128-
$this->baseClass = $options['base_class'];
129125

130126
$this->docStar = $options['debug'] ? '*' : '';
131127

@@ -1465,34 +1461,6 @@ private function dumpValue($value, $interpolate = true)
14651461

14661462
return implode("\n", $code);
14671463
}
1468-
1469-
if ($value instanceof ClosureProxyArgument) {
1470-
list($reference, $method) = $value->getValues();
1471-
$method = substr($this->dumpLiteralClass($this->dumpValue($method)), 1);
1472-
1473-
if ('service_container' === (string) $reference) {
1474-
$class = $this->baseClass;
1475-
} elseif (!$this->container->hasDefinition((string) $reference) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
1476-
return 'null';
1477-
} else {
1478-
$class = substr($this->dumpLiteralClass($this->dumpValue($this->container->findDefinition((string) $reference)->getClass())), 1);
1479-
}
1480-
if (false !== strpos($class, '$') || false !== strpos($method, '$')) {
1481-
throw new RuntimeException(sprintf('Cannot dump definition for service "%s": dynamic class names or methods, and closure-proxies are incompatible with each other.', $reference));
1482-
}
1483-
if (!method_exists($class, $method)) {
1484-
throw new InvalidArgumentException(sprintf('Cannot create closure-proxy for service "%s": method "%s::%s" does not exist.', $reference, $class, $method));
1485-
}
1486-
$r = $this->container->getReflectionClass($class)->getMethod($method);
1487-
if (!$r->isPublic()) {
1488-
throw new InvalidArgumentException(sprintf('Cannot create closure-proxy for service "%s": method "%s::%s" must be public.', $reference, $class, $method));
1489-
}
1490-
$signature = preg_replace('/^(&?)[^(]*/', '$1', ProxyHelper::getSignature($r, $call));
1491-
1492-
$return = 'void' !== ProxyHelper::getTypeHint($r);
1493-
1494-
return sprintf("/** @closure-proxy %s::%s */ function %s {\n %s%s->%s;\n }", $class, $method, $signature, $return ? 'return ' : '', $this->dumpValue($reference), $call);
1495-
}
14961464
} finally {
14971465
list($this->definitionVariables, $this->referenceVariables, $this->variableCount) = $scope;
14981466
}

‎src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Dumper;
1313

14-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1514
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1615
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1716
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -302,11 +301,6 @@ private function convertParameters(array $parameters, $type, \DOMElement $parent
302301
} elseif ($value instanceof IteratorArgument) {
303302
$element->setAttribute('type', 'iterator');
304303
$this->convertParameters($value->getValues(), $type, $element, 'key');
305-
} elseif ($value instanceof ClosureProxyArgument) {
306-
list($reference, $method) = $value->getValues();
307-
$element->setAttribute('type', 'closure-proxy');
308-
$element->setAttribute('id', (string) $reference);
309-
$element->setAttribute('method', $method);
310304
} elseif ($value instanceof Reference) {
311305
$element->setAttribute('type', 'service');
312306
$element->setAttribute('id', (string) $value);

‎src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Yaml\Tag\TaggedValue;
1616
use Symfony\Component\DependencyInjection\Alias;
1717
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
18-
use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument;
1918
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
2019
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
2120
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -256,8 +255,6 @@ private function dumpValue($value)
256255
if ($value instanceof ArgumentInterface) {
257256
if ($value instanceof IteratorArgument) {
258257
$tag = 'iterator';
259-
} elseif ($value instanceof ClosureProxyArgument) {
260-
$tag = 'closure_proxy';
261258
} else {
262259
throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', get_class($value)));
263260
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.