/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/ObjectMapper/ClassHierarchyTrait.php
56 строк
1 KB
Pascal CESCON
[ObjectMapper] Fix mapping of private properties from parent classes
16 июн 2026, 18:47
16 июн 2026, 18:47
1e1542f
Код
Авторство
О чём код?
<?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\ObjectMapper; /** * @internal */ trait ClassHierarchyTrait { /** * Returns all properties from a class including private properties from parent classes. * * @return \ReflectionProperty[] */ private function getAllProperties(\ReflectionClass $refl): array { $properties = []; $seenNames = []; do { foreach ($refl->getProperties() as $property) { $name = $property->getName(); if (isset($seenNames[$name])) { continue; } $seenNames[$name] = true; $properties[] = $property; } } while ($refl = $refl->getParentClass()); return $properties; } /** * Gets a property from a class or its parent hierarchy. */ private function getPropertyFromHierarchy(\ReflectionClass $refl, string $propertyName): ?\ReflectionProperty { do { if ($refl->hasProperty($propertyName)) { return $refl->getProperty($propertyName); } } while ($refl = $refl->getParentClass()); return null; } }