PropertyReadInfo.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\PropertyInfo;
  11. /**
  12. * The property read info tells how a property can be read.
  13. *
  14. * @author Joel Wurtz <jwurtz@jolicode.com>
  15. */
  16. final class PropertyReadInfo
  17. {
  18. public const TYPE_METHOD = 'method';
  19. public const TYPE_PROPERTY = 'property';
  20. public const VISIBILITY_PUBLIC = 'public';
  21. public const VISIBILITY_PROTECTED = 'protected';
  22. public const VISIBILITY_PRIVATE = 'private';
  23. public function __construct(
  24. private readonly string $type,
  25. private readonly string $name,
  26. private readonly string $visibility,
  27. private readonly bool $static,
  28. private readonly bool $byRef,
  29. ) {
  30. }
  31. /**
  32. * Get type of access.
  33. */
  34. public function getType(): string
  35. {
  36. return $this->type;
  37. }
  38. /**
  39. * Get name of the access, which can be a method name or a property name, depending on the type.
  40. */
  41. public function getName(): string
  42. {
  43. return $this->name;
  44. }
  45. public function getVisibility(): string
  46. {
  47. return $this->visibility;
  48. }
  49. public function isStatic(): bool
  50. {
  51. return $this->static;
  52. }
  53. /**
  54. * Whether this accessor can be accessed by reference.
  55. */
  56. public function canBeReference(): bool
  57. {
  58. return $this->byRef;
  59. }
  60. }