10BC0 Merge branch '5.0' · symfony/symfony@4e5b153 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e5b153

Browse files
Merge branch '5.0'
* 5.0: [DependencyInjection] Fix binding tagged services to containers [ProxyManager] fix generating proxies for root-namespaced classes [DoctrineBridge] Cleanup 3.4 legacy [DI] skip looking for config class when the extension class is anonymous Fix typo Docs - Update debug section of UPGRADE guides for 4.4 and 5.0 versions. Fix invalid typehint for subject in is_granted Twig function [Dotenv] FIX missing getenv [HttpFoundation] fix pdo session handler for sqlsrv [HttpClient][Psr18Client] Remove Psr18ExceptionTrait [HttpKernel] ignore failuresgenerated by opcache.restrict_api
2 parents bd9dc7c + 582eb5c commit 4e5b153

File tree

16 files changed

+58
-30
lines changed

16 files changed

+58
-30
lines changed

UPGRADE-4.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Debug
1919
-----
2020

2121
* Deprecated the component in favor of the `ErrorHandler` component
22+
* Replace uses of `Symfony\Component\Debug\Debug` by `Symfony\Component\ErrorHandler\Debug`
2223

2324
Config
2425
------

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Debug
6060
-----
6161

6262
* Removed the component in favor of the `ErrorHandler` component
63+
* Replace uses of `Symfony\Component\Debug\Debug` by `Symfony\Component\ErrorHandler\Debug`
6364

6465
DependencyInjection
6566
-------------------

src/Symfony/Bridge/Doctrine/ManagerRegistry.php

Lines chang 4B92 ed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,13 @@ protected function resetService($name)
5454
}
5555
$manager->setProxyInitializer(\Closure::bind(
5656
function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) {
57-
if (isset($this->normalizedIds[$normalizedId = strtolower($name)])) { // BC with DI v3.4
58-
$name = $this->normalizedIds[$normalizedId];
59-
}
6057
if (isset($this->aliases[$name])) {
6158
$name = $this->aliases[$name];
6259
}
6360
if (isset($this->fileMap[$name])) {
6461< C02E code class="diff-text syntax-highlighted-line">
$wrappedInstance = $this->load($this->fileMap[$name]);
6562
} else {
66-
$method = $this->methodMap[$name] ?? 'get'.strtr($name, $this->underscoreMap).'Service'; // BC with DI v3.4
67-
$wrappedInstance = $this->{$method}(false);
63+
$wrappedInstance = $this->{$this->methodMap[$name]}(false);
6864
}
6965

7066
$manager->setProxyInitializer(null);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function getProxyFactoryCode(Definition $definition, string $id, string $
8181
public function getProxyCode(Definition $definition): string
8282
{
8383
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
84+
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
8485

8586
if (version_compare(self::getProxyManagerVersion(), '2.2', '<')) {
8687
$code = preg_replace(

src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class LazyServiceProjectServiceContainer extends Container
2121
}
2222
}
2323

24-
class stdClass_%s extends %SstdClass implements \ProxyManager\%s
24+
class stdClass_%s extends \stdClass implements \ProxyManager\%s
2525
{%a}%A

src/Symfony/Bridge/Twig/Extension/SecurityExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public function __construct(AuthorizationCheckerInterface $securityChecker = nul
3131
$this->securityChecker = $securityChecker;
3232
}
3333

34-
public function isGranted($role, object $object = null, string $field = null): bool
34+
/**
35+
* @param mixed $object
36+
*/
37+
public function isGranted($role, $object = null, string $field = null): bool
3538
{
3639
if (null === $this->securityChecker) {
3740
return false;

src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
15+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1516
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Definition;
@@ -126,8 +127,8 @@ protected function processValue($value, bool $isRoot = false)
126127
continue;
127128
}
128129

129-
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument) {
130-
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue)));
130+
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
131+
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, %s, %s, %s or ServiceLocatorArgument, %s given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue)));
131132
}
132133
}
133134

src/Symfony/Component/DependencyInjection/Extension/Extension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public function getAlias()
8181
public function getConfiguration(array $config, ContainerBuilder $container)
8282
{
8383
$class = \get_class($this);
84+
85+
if (false !== strpos($class, "\0")) {
86+
return null; // ignore anonymous classes
87+
}
88+
8489
$class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
8590
$class = $container->getReflectionClass($class);
8691

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveBindingsPassTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
16+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1617
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1718
use Symfony\Component\DependencyInjection\Compiler\AutowireRequiredMethodsPass;
1819
use Symfony\Component\DependencyInjection\Compiler\DefinitionErrorExceptionPass;
@@ -35,6 +36,7 @@ public function testProcess()
3536

3637
$bindings = [
3738
CaseSensitiveClass::class => new BoundArgument(new Reference('foo')),
39+
'Psr\Container\ContainerInterface $container' => new BoundArgument(new ServiceLocatorArgument([]), true, BoundArgument::INSTANCEOF_BINDING),
3840
'iterable $objects' => new BoundArgument(new TaggedIteratorArgument('tag.name'), true, BoundArgument::INSTANCEOF_BINDING),
3941
];
4042

@@ -49,7 +51,13 @@ public function testProcess()
4951
$pass = new ResolveBindingsPass();
5052
$pass->process($container);
5153

52-
$this->assertEquals([0 => new Reference('foo'), 1 => '123', 4 => new TaggedIteratorArgument('tag.name')], $definition->getArguments());
54+
$expected = [
55+
0 => new Reference('foo'),
56+
1 => '123',
57+
3 => new ServiceLocatorArgument([]),
58+
4 => new TaggedIteratorArgument('tag.name'),
59+
];
60+
$this->assertEquals($expected, $definition->getArguments());
5361
$this->assertEquals([['setSensitiveClass', [new Reference('foo')]]], $definition->getMethodCalls());
5462
}
5563

src/Symfony/Component/DependencyInjection/Tests/Fixtures/NamedArgumentsDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class NamedArgumentsDummy
1111
{
12-
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $interface, iterable $objects)
12+
public function __construct(CaseSensitiveClass $c, $apiKey, $hostName, ContainerInterface $container, iterable $objects)
1313
{
1414
}
1515

0 commit comments

Comments
 (0)
0