Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Builder / Property.php
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Builder;
4
5 use PhpParser;
6 use PhpParser\BuilderHelpers;
7 use PhpParser\Node\Stmt;
8
9 class Property implements PhpParser\Builder
10 {
11     protected $name;
12
13     protected $flags = 0;
14     protected $default = null;
15     protected $attributes = [];
16
17     /**
18      * Creates a property builder.
19      *
20      * @param string $name Name of the property
21      */
22     public function __construct(string $name) {
23         $this->name = $name;
24     }
25
26     /**
27      * Makes the property public.
28      *
29      * @return $this The builder instance (for fluid interface)
30      */
31     public function makePublic() {
32         $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PUBLIC);
33
34         return $this;
35     }
36
37     /**
38      * Makes the property protected.
39      *
40      * @return $this The builder instance (for fluid interface)
41      */
42     public function makeProtected() {
43         $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PROTECTED);
44
45         return $this;
46     }
47
48     /**
49      * Makes the property private.
50      *
51      * @return $this The builder instance (for fluid interface)
52      */
53     public function makePrivate() {
54         $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_PRIVATE);
55
56         return $this;
57     }
58
59     /**
60      * Makes the property static.
61      *
62      * @return $this The builder instance (for fluid interface)
63      */
64     public function makeStatic() {
65         $this->flags = BuilderHelpers::addModifier($this->flags, Stmt\Class_::MODIFIER_STATIC);
66
67         return $this;
68     }
69
70     /**
71      * Sets default value for the property.
72      *
73      * @param mixed $value Default value to use
74      *
75      * @return $this The builder instance (for fluid interface)
76      */
77     public function setDefault($value) {
78         $this->default = BuilderHelpers::normalizeValue($value);
79
80         return $this;
81     }
82
83     /**
84      * Sets doc comment for the property.
85      *
86      * @param PhpParser\Comment\Doc|string $docComment Doc comment to set
87      *
88      * @return $this The builder instance (for fluid interface)
89      */
90     public function setDocComment($docComment) {
91         $this->attributes = [
92             'comments' => [BuilderHelpers::normalizeDocComment($docComment)]
93         ];
94
95         return $this;
96     }
97
98     /**
99      * Returns the built class node.
100      *
101      * @return Stmt\Property The built property node
102      */
103     public function getNode() : PhpParser\Node {
104         return new Stmt\Property(
105             $this->flags !== 0 ? $this->flags : Stmt\Class_::MODIFIER_PUBLIC,
106             [
107                 new Stmt\PropertyProperty($this->name, $this->default)
108             ],
109             $this->attributes
110         );
111     }
112 }