Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/lib/PhpParser/Builder/Property.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | 1 <?php declare(strict_types=1); |
2 | 2 |
3 namespace PhpParser\Builder; | 3 namespace PhpParser\Builder; |
4 | 4 |
5 use PhpParser; | 5 use PhpParser; |
6 use PhpParser\BuilderHelpers; | |
6 use PhpParser\Node\Stmt; | 7 use PhpParser\Node\Stmt; |
7 | 8 |
8 class Property extends PhpParser\BuilderAbstract | 9 class Property implements PhpParser\Builder |
9 { | 10 { |
10 protected $name; | 11 protected $name; |
11 | 12 |
12 protected $flags = 0; | 13 protected $flags = 0; |
13 protected $default = null; | 14 protected $default = null; |
14 protected $attributes = array(); | 15 protected $attributes = []; |
15 | 16 |
16 /** | 17 /** |
17 * Creates a property builder. | 18 * Creates a property builder. |
18 * | 19 * |
19 * @param string $name Name of the property | 20 * @param string $name Name of the property |
20 */ | 21 */ |
21 public function __construct($name) { | 22 public function __construct(string $name) { |
22 $this->name = $name; | 23 $this->name = $name; |
23 } | 24 } |
24 | 25 |
25 /** | 26 /** |
26 * Makes the property public. | 27 * Makes the property public. |
27 * | 28 * |
28 * @return $this The builder instance (for fluid interface) | 29 * @return $this The builder instance (for fluid interface) |
29 */ | 30 */ |
30 public function makePublic() { | 31 public function makePublic() { |
31 $this->setModifier(Stmt\Class_::MODIFIER_PUBLIC); | 32 $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC); |
32 | 33 |
33 return $this; | 34 return $this; |
34 } | 35 } |
35 | 36 |
36 /** | 37 /** |
37 * Makes the property protected. | 38 * Makes the property protected. |
38 * | 39 * |
39 * @return $this The builder instance (for fluid interface) | 40 * @return $this The builder instance (for fluid interface) |
40 */ | 41 */ |
41 public function makeProtected() { | 42 public function makeProtected() { |
42 $this->setModifier(Stmt\Class_::MODIFIER_PROTECTED); | 43 $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED); |
43 | 44 |
44 return $this; | 45 return $this; |
45 } | 46 } |
46 | 47 |
47 /** | 48 /** |
48 * Makes the property private. | 49 * Makes the property private. |
49 * | 50 * |
50 * @return $this The builder instance (for fluid interface) | 51 * @return $this The builder instance (for fluid interface) |
51 */ | 52 */ |
52 public function makePrivate() { | 53 public function makePrivate() { |
53 $this->setModifier(Stmt\Class_::MODIFIER_PRIVATE); | 54 $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE); |
54 | 55 |
55 return $this; | 56 return $this; |
56 } | 57 } |
57 | 58 |
58 /** | 59 /** |
59 * Makes the property static. | 60 * Makes the property static. |
60 * | 61 * |
61 * @return $this The builder instance (for fluid interface) | 62 * @return $this The builder instance (for fluid interface) |
62 */ | 63 */ |
63 public function makeStatic() { | 64 public function makeStatic() { |
64 $this->setModifier(Stmt\Class_::MODIFIER_STATIC); | 65 $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC); |
65 | 66 |
66 return $this; | 67 return $this; |
67 } | 68 } |
68 | 69 |
69 /** | 70 /** |
72 * @param mixed $value Default value to use | 73 * @param mixed $value Default value to use |
73 * | 74 * |
74 * @return $this The builder instance (for fluid interface) | 75 * @return $this The builder instance (for fluid interface) |
75 */ | 76 */ |
76 public function setDefault($value) { | 77 public function setDefault($value) { |
77 $this->default = $this->normalizeValue($value); | 78 $this->default = BuilderHelpers::normalizeValue($value); |
78 | 79 |
79 return $this; | 80 return $this; |
80 } | 81 } |
81 | 82 |
82 /** | 83 /** |
85 * @param PhpParser\Comment\Doc|string $docComment Doc comment to set | 86 * @param PhpParser\Comment\Doc|string $docComment Doc comment to set |
86 * | 87 * |
87 * @return $this The builder instance (for fluid interface) | 88 * @return $this The builder instance (for fluid interface) |
88 */ | 89 */ |
89 public function setDocComment($docComment) { | 90 public function setDocComment($docComment) { |
90 $this->attributes = array( | 91 $this->attributes = [ |
91 'comments' => array($this->normalizeDocComment($docComment)) | 92 'comments' => [BuilderHelpers::normalizeDocComment($docComment)] |
92 ); | 93 ]; |
93 | 94 |
94 return $this; | 95 return $this; |
95 } | 96 } |
96 | 97 |
97 /** | 98 /** |
98 * Returns the built class node. | 99 * Returns the built class node. |
99 * | 100 * |
100 * @return Stmt\Property The built property node | 101 * @return Stmt\Property The built property node |
101 */ | 102 */ |
102 public function getNode() { | 103 public function getNode() : PhpParser\Node { |
103 return new Stmt\Property( | 104 return new Stmt\Property( |
104 $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, | 105 $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC, |
105 array( | 106 [ |
106 new Stmt\PropertyProperty($this->name, $this->default) | 107 new Stmt\PropertyProperty($this->name, $this->default) |
107 ), | 108 ], |
108 $this->attributes | 109 $this->attributes |
109 ); | 110 ); |
110 } | 111 } |
111 } | 112 } |