You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.5 KiB

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\VarDumper\Cloner;
  11. /**
  12. * Represents the main properties of a PHP variable.
  13. *
  14. * @author Nicolas Grekas <p@tchwork.com>
  15. */
  16. class Stub
  17. {
  18. public const TYPE_REF = 1;
  19. public const TYPE_STRING = 2;
  20. public const TYPE_ARRAY = 3;
  21. public const TYPE_OBJECT = 4;
  22. public const TYPE_RESOURCE = 5;
  23. public const STRING_BINARY = 1;
  24. public const STRING_UTF8 = 2;
  25. public const ARRAY_ASSOC = 1;
  26. public const ARRAY_INDEXED = 2;
  27. public $type = self::TYPE_REF;
  28. public $class = '';
  29. public $value;
  30. public $cut = 0;
  31. public $handle = 0;
  32. public $refCount = 0;
  33. public $position = 0;
  34. public $attr = [];
  35. private static $defaultProperties = [];
  36. /**
  37. * @internal
  38. */
  39. public function __sleep(): array
  40. {
  41. $properties = [];
  42. if (!isset(self::$defaultProperties[$c = static::class])) {
  43. self::$defaultProperties[$c] = get_class_vars($c);
  44. foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) {
  45. unset(self::$defaultProperties[$c][$k]);
  46. }
  47. }
  48. foreach (self::$defaultProperties[$c] as $k => $v) {
  49. if ($this->$k !== $v) {
  50. $properties[] = $k;
  51. }
  52. }
  53. return $properties;
  54. }
  55. }