-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.2: [Runtime][ErrorHandler] Don't mess with ini_set('assert.warning') [DependencyInjection] Fix fetching lazy non-shared services multiple times
- Loading branch information
Showing
7 changed files
with
239 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...fony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_public.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||
|
||
/** | ||
* @internal This class has been auto-generated by the Symfony Dependency Injection Component. | ||
*/ | ||
class Symfony_DI_PhpDumper_Service_Non_Shared_Lazy extends Container | ||
{ | ||
protected $parameters = []; | ||
|
||
public function __construct() | ||
{ | ||
$this->services = $this->privates = []; | ||
$this->methodMap = [ | ||
'foo' => 'getFooService', | ||
]; | ||
|
||
$this->aliases = []; | ||
} | ||
|
||
public function compile(): void | ||
{ | ||
throw new LogicException('You cannot compile a dumped container that was already compiled.'); | ||
} | ||
|
||
public function isCompiled(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
protected function createProxy($class, \Closure $factory) | ||
{ | ||
return $factory(); | ||
} | ||
|
||
/** | ||
* Gets the public 'foo' service. | ||
* | ||
* @return \Symfony\Component\DependencyInjection\Tests\Compiler\Foo | ||
*/ | ||
protected static function getFooService($container, $lazyLoad = true) | ||
{ | ||
$container->factories['foo'] ??= fn () => self::getFooService($container); | ||
|
||
if (true === $lazyLoad) { | ||
return $container->createProxy('FooGhost80f7cfc', static fn () => \FooGhost80f7cfc::createLazyGhost(static fn ($proxy) => self::getFooService($container, $proxy))); | ||
} | ||
|
||
static $include = true; | ||
|
||
if ($include) { | ||
include_once __DIR__.'/Fixtures/includes/foo_lazy.php'; | ||
|
||
$include = false; | ||
} | ||
|
||
return $lazyLoad; | ||
} | ||
} | ||
|
||
class FooGhost80f7cfc extends \Symfony\Component\DependencyInjection\Tests\Compiler\Foo implements \Symfony\Component\VarExporter\LazyObjectInterface | ||
{ | ||
use \Symfony\Component\VarExporter\LazyGhostTrait; | ||
|
||
private const LAZY_OBJECT_PROPERTY_SCOPES = []; | ||
} | ||
|
||
// Help opcache.preload discover always-needed symbols | ||
class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); | ||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); | ||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); |
88 changes: 88 additions & 0 deletions
88
...fony/Component/DependencyInjection/Tests/Fixtures/php/services_wither_lazy_non_shared.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Container; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; | ||
use Symfony\Component\DependencyInjection\Exception\RuntimeException; | ||
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||
|
||
/** | ||
* @internal This class has been auto-generated by the Symfony Dependency Injection Component. | ||
*/ | ||
class Symfony_DI_PhpDumper_Service_Wither_Lazy_Non_Shared extends Container | ||
{ | ||
protected $parameters = []; | ||
|
||
public function __construct() | ||
{ | ||
$this->services = $this->privates = []; | ||
$this->methodMap = [ | ||
'wither' => 'getWitherService', | ||
]; | ||
|
||
$this->aliases = []; | ||
} | ||
|
||
public function compile(): void | ||
{ | ||
throw new LogicException('You cannot compile a dumped container that was already compiled.'); | ||
} | ||
|
||
public function isCompiled(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function getRemovedIds(): array | ||
{ | ||
return [ | ||
'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo' => true, | ||
]; | ||
} | ||
|
||
protected function createProxy($class, \Closure $factory) | ||
{ | ||
return $factory(); | ||
} | ||
|
||
/** | ||
* Gets the public 'wither' autowired service. | ||
* | ||
* @return \Symfony\Component\DependencyInjection\Tests\Compiler\Wither | ||
*/ | ||
protected static function getWitherService($container, $lazyLoad = true) | ||
{ | ||
$container->factories['wither'] ??= fn () => self::getWitherService($container); | ||
|
||
if (true === $lazyLoad) { | ||
return $container->createProxy('WitherProxyDd381be', static fn () => \WitherProxyDd381be::createLazyProxy(static fn () => self::getWitherService($container, false))); | ||
} | ||
|
||
$instance = new \Symfony\Component\DependencyInjection\Tests\Compiler\Wither(); | ||
|
||
$a = ($container->privates['Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\Foo'] ??= new \Symfony\Component\DependencyInjection\Tests\Compiler\Foo()); | ||
|
||
$instance = $instance->withFoo1($a); | ||
$instance = $instance->withFoo2($a); | ||
$instance->setFoo($a); | ||
|
||
return $instance; | ||
} | ||
} | ||
|
||
class WitherProxyDd381be extends \Symfony\Component\DependencyInjection\Tests\Compiler\Wither implements \Symfony\Component\VarExporter\LazyObjectInterface | ||
{ | ||
use \Symfony\Component\VarExporter\LazyProxyTrait; | ||
|
||
private const LAZY_OBJECT_PROPERTY_SCOPES = [ | ||
'foo' => [parent::class, 'foo', null], | ||
]; | ||
} | ||
|
||
// Help opcache.preload discover always-needed symbols | ||
class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); | ||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); | ||
class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters