PropertyReadInfo.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. * @internal
  17. */
  18. final class PropertyReadInfo
  19. {
  20. public const TYPE_METHOD = 'method';
  21. public const TYPE_PROPERTY = 'property';
  22. public const VISIBILITY_PUBLIC = 'public';
  23. public const VISIBILITY_PROTECTED = 'protected';
  24. public const VISIBILITY_PRIVATE = 'private';
  25. private $type;
  26. private $name;
  27. private $visibility;
  28. private $static;
  29. private $byRef;
  30. public function __construct(string $type, string $name, string $visibility, bool $static, bool $byRef)
  31. {
  32. $this->type = $type;
  33. $this->name = $name;
  34. $this->visibility = $visibility;
  35. $this->static = $static;
  36. $this->byRef = $byRef;
  37. }
  38. /**
  39. * Get type of access.
  40. */
  41. public function getType(): string
  42. {
  43. return $this->type;
  44. }
  45. /**
  46. * Get name of the access, which can be a method name or a property name, depending on the type.
  47. */
  48. public function getName(): string
  49. {
  50. return $this->name;
  51. }
  52. public function getVisibility(): string
  53. {
  54. return $this->visibility;
  55. }
  56. public function isStatic(): bool
  57. {
  58. return $this->static;
  59. }
  60. /**
  61. * Whether this accessor can be accessed by reference.
  62. */
  63. public function canBeReference(): bool
  64. {
  65. return $this->byRef;
  66. }
  67. }