Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Hydrator.php

function Hydrator::getPropertyScopes

12 calls to Hydrator::getPropertyScopes()
Hydrator::hydrate in vendor/symfony/var-exporter/Hydrator.php
Sets the properties of an object, including private and protected ones.
LazyGhostTrait::__get in vendor/symfony/var-exporter/LazyGhostTrait.php
LazyGhostTrait::__isset in vendor/symfony/var-exporter/LazyGhostTrait.php
LazyGhostTrait::__set in vendor/symfony/var-exporter/LazyGhostTrait.php
LazyGhostTrait::__unset in vendor/symfony/var-exporter/LazyGhostTrait.php

... See full list

File

vendor/symfony/var-exporter/Internal/Hydrator.php, line 251

Class

Hydrator
@author Nicolas Grekas <p@tchwork.com>

Namespace

Symfony\Component\VarExporter\Internal

Code

public static function getPropertyScopes($class) : array {
    $propertyScopes = [];
    $r = new \ReflectionClass($class);
    foreach ($r->getProperties() as $property) {
        $flags = $property->getModifiers();
        if (\ReflectionProperty::IS_STATIC & $flags) {
            continue;
        }
        $name = $property->name;
        $readonlyScope = null;
        if (\ReflectionProperty::IS_PRIVATE & $flags) {
            if ($flags & \ReflectionProperty::IS_READONLY) {
                $readonlyScope = $class;
            }
            $propertyScopes["\x00{$class}\x00{$name}"] = $propertyScopes[$name] = [
                $class,
                $name,
                $readonlyScope,
                $property,
            ];
            continue;
        }
        if ($flags & \ReflectionProperty::IS_READONLY) {
            $readonlyScope = $property->class;
        }
        $propertyScopes[$name] = [
            $class,
            $name,
            $readonlyScope,
            $property,
        ];
        if (\ReflectionProperty::IS_PROTECTED & $flags) {
            $propertyScopes["\x00*\x00{$name}"] = $propertyScopes[$name];
        }
    }
    while ($r = $r->getParentClass()) {
        $class = $r->name;
        foreach ($r->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) {
            if (!$property->isStatic()) {
                $name = $property->name;
                $readonlyScope = $property->isReadOnly() ? $class : null;
                $propertyScopes["\x00{$class}\x00{$name}"] = [
                    $class,
                    $name,
                    $readonlyScope,
                    $property,
                ];
                $propertyScopes[$name] ??= [
                    $class,
                    $name,
                    $readonlyScope,
                    $property,
                ];
            }
        }
    }
    return $propertyScopes;
}
RSS feed
Powered by Drupal