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 ad12093

Browse filesBrowse files
committed
Added type-hints to LazyProxy classes and interfaces.
1 parent 38b9b95 commit ad12093
Copy full SHA for ad12093

File tree

Expand file treeCollapse file tree

10 files changed

+9
-28
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+9
-28
lines changed

‎src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct()
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator)
41+
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator)
4242
{
4343
return $this->factory->createProxy(
4444
$this->factory->getGenerator()->getProxifiedClass($definition),

‎src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,14 @@ public function isProxyCandidate(Definition $definition): bool
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
51+
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode): string
5252
{
5353
$instantiation = 'return';
5454

5555
if ($definition->isShared()) {
5656
$instantiation .= sprintf(' $this->%s[%s] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', var_export($id, true));
5757
}
5858

59-
if (null === $factoryCode) {
60-
throw new \InvalidArgumentException(sprintf('Missing factory code to construct the service "%s".', $id));
61-
}
62-
6359
$proxyClass = $this->getProxyClassName($definition);
6460

6561
return <<<EOF

‎src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php
-11Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,6 @@ public function getPrivatePublicDefinitions()
109109
];
110110
}
111111

112-
/**
113-
* @expectedException \InvalidArgumentException
114-
* @expectedExceptionMessage Missing factory code to construct the service "foo".
115-
*/
116-
public function testGetProxyFactoryCodeWithoutCustomMethod()
117-
{
118-
$definition = new Definition(__CLASS__);
119-
$definition->setLazy(true);
120-
$this->dumper->getProxyFactoryCode($definition, 'foo');
121-
}
122-
123112
public function testGetProxyFactoryCodeForInterface()
124113
{
125114
$class = DummyClass::class;

‎src/Symfony/Bridge/ProxyManager/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/ProxyManager/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^7.2.9",
20-
"symfony/dependency-injection": "^4.4|^5.0",
20+
"symfony/dependency-injection": "^5.0",
2121
"ocramius/proxy-manager": "~2.1"
2222
},
2323
"require-dev": {

‎src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ interface InstantiatorInterface
3232
*
3333
* @return object
3434
*/
35-
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator);
35+
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator);
3636
}

‎src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/RealServiceInstantiator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class RealServiceInstantiator implements InstantiatorInterface
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function instantiateProxy(ContainerInterface $container, Definition $definition, $id, $realInstantiator)
29+
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator)
3030
{
3131
return $realInstantiator();
3232
}

‎src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/DumperInterface.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ public function isProxyCandidate(Definition $definition);
3030
/**
3131
* Generates the code to be used to instantiate a proxy in the dumped factory code.
3232
*
33-
* @param Definition $definition
34-
* @param string $id Service identifier
35-
* @param string $factoryCode The code to execute to create the service
36-
*
3733
* @return string
3834
*/
39-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode);
35+
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode);
4036

4137
/**
4238
* Generates the code for the lazy proxy.

‎src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/PhpDumper/NullDumper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function isProxyCandidate(Definition $definition): bool
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCode = null): string
36+
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode): string
3737
{
3838
return '';
3939
}

‎src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/LazyProxy/ProxyHelper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ProxyHelper
2121
/**
2222
* @return string|null The FQCN or builtin name of the type hint, or null when the type hint references an invalid self|parent context
2323
*/
24-
public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, $noBuiltin = false)
24+
public static function getTypeHint(\ReflectionFunctionAbstract $r, \ReflectionParameter $p = null, bool $noBuiltin = false)
2525
{
2626
if ($p instanceof \ReflectionParameter) {
2727
$type = $p->getType();

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/classes.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function isProxyCandidate(Definition $definition)
8888
return $definition->isLazy();
8989
}
9090

91-
public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null)
91+
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode)
9292
{
9393
return " // lazy factory for {$definition->getClass()}\n\n";
9494
}

0 commit comments

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