Файл: vendor/symfony/var-exporter/Internal/LazyObjectState.php
Строк: 115
<?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 SymfonyComponentVarExporterInternal;
use SymfonyComponentVarExporterHydrator as PublicHydrator;
/**
* Keeps the state of lazy objects.
*
* As a micro-optimization, this class uses no type declarations.
*
* @internal
*/
class LazyObjectState
{
public const STATUS_UNINITIALIZED_FULL = 1;
public const STATUS_UNINITIALIZED_PARTIAL = 2;
public const STATUS_INITIALIZED_FULL = 3;
public const STATUS_INITIALIZED_PARTIAL = 4;
/**
* @var array<string, true>
*/
public readonly array $skippedProperties;
/**
* @var self::STATUS_*
*/
public int $status = 0;
public object $realInstance;
public function __construct(public readonly Closure|array $initializer, $skippedProperties = [])
{
$this->skippedProperties = $skippedProperties;
$this->status = is_array($initializer) ? self::STATUS_UNINITIALIZED_PARTIAL : self::STATUS_UNINITIALIZED_FULL;
}
public function initialize($instance, $propertyName, $propertyScope)
{
if (self::STATUS_INITIALIZED_FULL === $this->status) {
return self::STATUS_INITIALIZED_FULL;
}
if (is_array($this->initializer)) {
$class = $instance::class;
$propertyScope ??= $class;
$propertyScopes = Hydrator::$propertyScopes[$class];
$propertyScopes[$k = " $propertyScope