annotate vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@13 1 <?php declare(strict_types=1);
Chris@0 2
Chris@0 3 namespace PhpParser\Node\Stmt;
Chris@0 4
Chris@0 5 use PhpParser\Node;
Chris@17 6 use PhpParser\Node\Identifier;
Chris@17 7 use PhpParser\Node\Name;
Chris@17 8 use PhpParser\Node\NullableType;
Chris@0 9
Chris@0 10 class Property extends Node\Stmt
Chris@0 11 {
Chris@0 12 /** @var int Modifiers */
Chris@0 13 public $flags;
Chris@0 14 /** @var PropertyProperty[] Properties */
Chris@0 15 public $props;
Chris@17 16 /** @var null|Identifier|Name|NullableType Type declaration */
Chris@17 17 public $type;
Chris@0 18
Chris@0 19 /**
Chris@0 20 * Constructs a class property list node.
Chris@0 21 *
Chris@17 22 * @param int $flags Modifiers
Chris@17 23 * @param PropertyProperty[] $props Properties
Chris@17 24 * @param array $attributes Additional attributes
Chris@17 25 * @param null|string|Identifier|Name|NullableType $type Type declaration
Chris@0 26 */
Chris@17 27 public function __construct(int $flags, array $props, array $attributes = [], $type = null) {
Chris@0 28 parent::__construct($attributes);
Chris@0 29 $this->flags = $flags;
Chris@0 30 $this->props = $props;
Chris@17 31 $this->type = \is_string($type) ? new Identifier($type) : $type;
Chris@0 32 }
Chris@0 33
Chris@13 34 public function getSubNodeNames() : array {
Chris@17 35 return ['flags', 'type', 'props'];
Chris@0 36 }
Chris@0 37
Chris@13 38 /**
Chris@13 39 * Whether the property is explicitly or implicitly public.
Chris@13 40 *
Chris@13 41 * @return bool
Chris@13 42 */
Chris@13 43 public function isPublic() : bool {
Chris@0 44 return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
Chris@0 45 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
Chris@0 46 }
Chris@0 47
Chris@13 48 /**
Chris@13 49 * Whether the property is protected.
Chris@13 50 *
Chris@13 51 * @return bool
Chris@13 52 */
Chris@13 53 public function isProtected() : bool {
Chris@0 54 return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
Chris@0 55 }
Chris@0 56
Chris@13 57 /**
Chris@13 58 * Whether the property is private.
Chris@13 59 *
Chris@13 60 * @return bool
Chris@13 61 */
Chris@13 62 public function isPrivate() : bool {
Chris@0 63 return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
Chris@0 64 }
Chris@0 65
Chris@13 66 /**
Chris@13 67 * Whether the property is static.
Chris@13 68 *
Chris@13 69 * @return bool
Chris@13 70 */
Chris@13 71 public function isStatic() : bool {
Chris@0 72 return (bool) ($this->flags & Class_::MODIFIER_STATIC);
Chris@0 73 }
Chris@17 74
Chris@13 75 public function getType() : string {
Chris@13 76 return 'Stmt_Property';
Chris@13 77 }
Chris@0 78 }