Server IP : 192.158.238.246 / Your IP : 3.138.197.104 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/cwd/plugins/wp-heyloyalty/vendor/sebastian/object-enumerator/src/ |
Upload File : |
<?php /* * This file is part of Object Enumerator. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianBergmann\ObjectEnumerator; use SebastianBergmann\RecursionContext\Context; /** * Traverses array structures and object graphs * to enumerate all referenced objects. */ class Enumerator { /** * Returns an array of all objects referenced either * directly or indirectly by a variable. * * @param array|object $variable * * @return object[] */ public function enumerate($variable) { if (!is_array($variable) && !is_object($variable)) { throw new InvalidArgumentException; } if (isset(func_get_args()[1])) { if (!func_get_args()[1] instanceof Context) { throw new InvalidArgumentException; } $processed = func_get_args()[1]; } else { $processed = new Context; } $objects = []; if ($processed->contains($variable)) { return $objects; } $processed->add($variable); if (is_array($variable)) { foreach ($variable as $element) { if (!is_array($element) && !is_object($element)) { continue; } $objects = array_merge( $objects, $this->enumerate($element, $processed) ); } } else { $objects[] = $variable; $reflector = new \ReflectionObject($variable); foreach ($reflector->getProperties() as $attribute) { $attribute->setAccessible(true); $value = $attribute->getValue($variable); if (!is_array($value) && !is_object($value)) { continue; } $objects = array_merge( $objects, $this->enumerate($value, $processed) ); } } return $objects; } }