update after stop build
All checks were successful
All checks were successful
This commit is contained in:
48
vendor/symfony/var-exporter/Internal/LazyObjectState.php
vendored
Normal file
48
vendor/symfony/var-exporter/Internal/LazyObjectState.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\VarExporter\Internal;
|
||||
|
||||
/**
|
||||
* Keeps the state of lazy objects.
|
||||
*
|
||||
* As a micro-optimization, this class uses no type declarations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class LazyObjectState
|
||||
{
|
||||
public ?\Closure $initializer = null;
|
||||
public object $realInstance;
|
||||
public object $cloneInstance;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
if (isset($this->cloneInstance)) {
|
||||
try {
|
||||
$this->realInstance = $this->cloneInstance;
|
||||
} finally {
|
||||
unset($this->cloneInstance);
|
||||
}
|
||||
} elseif (isset($this->realInstance)) {
|
||||
$this->realInstance = clone $this->realInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
if ('realInstance' !== $name) {
|
||||
throw new \BadMethodCallException(\sprintf('No such property "%s::$%s"', self::class, $name));
|
||||
}
|
||||
|
||||
return $this->realInstance = ($this->initializer)();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user