Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
6.45% |
4 / 62 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
StaticRangeInit | |
6.45% |
4 / 62 |
|
0.00% |
0 / 9 |
717.50 | |
0.00% |
0 / 1 |
_getMissingProp | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
_setMissingProp | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
__get | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
42 | |||
__isset | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
42 | |||
offsetExists | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
42 | |||
offsetGet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
offsetSet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
offsetUnset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
cast | |
44.44% |
4 / 9 |
|
0.00% |
0 / 1 |
2.69 |
1 | <?php |
2 | |
3 | // AUTOMATICALLY GENERATED. DO NOT EDIT. |
4 | // Use `composer build` to regenerate. |
5 | |
6 | namespace Wikimedia\IDLeDOM\Helper; |
7 | |
8 | use Wikimedia\IDLeDOM\Node; |
9 | |
10 | trait StaticRangeInit { |
11 | |
12 | // Underscore is used to avoid conflicts with DOM-reserved names |
13 | // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
14 | // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
15 | |
16 | /** |
17 | * Handle an attempt to get a non-existing property on this |
18 | * object. The default implementation raises an exception |
19 | * but the implementor can choose a different behavior: |
20 | * return null (like JavaScript), dynamically create the |
21 | * property, etc. |
22 | * @param string $prop the name of the property requested |
23 | * @return mixed |
24 | */ |
25 | protected function _getMissingProp( string $prop ) { |
26 | $trace = debug_backtrace(); |
27 | while ( |
28 | count( $trace ) > 0 && |
29 | $trace[0]['function'] !== "__get" |
30 | ) { |
31 | array_shift( $trace ); |
32 | } |
33 | trigger_error( |
34 | 'Undefined property' . |
35 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
36 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
37 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
38 | E_USER_NOTICE |
39 | ); |
40 | return null; |
41 | } |
42 | |
43 | /** |
44 | * Handle an attempt to set a non-existing property on this |
45 | * object. The default implementation raises an exception |
46 | * but the implementor can choose a different behavior: |
47 | * ignore the operation (like JavaScript), dynamically create |
48 | * the property, etc. |
49 | * @param string $prop the name of the property requested |
50 | * @param mixed $value the value to set |
51 | */ |
52 | protected function _setMissingProp( string $prop, $value ): void { |
53 | $trace = debug_backtrace(); |
54 | while ( |
55 | count( $trace ) > 0 && |
56 | $trace[0]['function'] !== "__set" |
57 | ) { |
58 | array_shift( $trace ); |
59 | } |
60 | trigger_error( |
61 | 'Undefined property' . |
62 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop . |
63 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
64 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
65 | E_USER_NOTICE |
66 | ); |
67 | } |
68 | |
69 | // phpcs:enable |
70 | |
71 | /** |
72 | * @param string $name |
73 | * @return mixed |
74 | */ |
75 | public function __get( string $name ) { |
76 | '@phan-var \Wikimedia\IDLeDOM\StaticRangeInit $this'; |
77 | // @var \Wikimedia\IDLeDOM\StaticRangeInit $this |
78 | switch ( $name ) { |
79 | case "startContainer": |
80 | return $this->getStartContainer(); |
81 | case "startOffset": |
82 | return $this->getStartOffset(); |
83 | case "endContainer": |
84 | return $this->getEndContainer(); |
85 | case "endOffset": |
86 | return $this->getEndOffset(); |
87 | default: |
88 | break; |
89 | } |
90 | '@phan-var \Wikimedia\IDLeDOM\Helper\StaticRangeInit $this'; |
91 | // @var \Wikimedia\IDLeDOM\Helper\StaticRangeInit $this |
92 | return $this->_getMissingProp( $name ); |
93 | } |
94 | |
95 | /** |
96 | * @param string $name |
97 | * @return bool |
98 | */ |
99 | public function __isset( string $name ): bool { |
100 | '@phan-var \Wikimedia\IDLeDOM\StaticRangeInit $this'; |
101 | // @var \Wikimedia\IDLeDOM\StaticRangeInit $this |
102 | switch ( $name ) { |
103 | case "startContainer": |
104 | return true; |
105 | case "startOffset": |
106 | return true; |
107 | case "endContainer": |
108 | return true; |
109 | case "endOffset": |
110 | return true; |
111 | default: |
112 | break; |
113 | } |
114 | return false; |
115 | } |
116 | |
117 | /** |
118 | * @param mixed $offset |
119 | * @return bool |
120 | */ |
121 | public function offsetExists( $offset ): bool { |
122 | switch ( $offset ) { |
123 | case "startContainer": |
124 | case "startOffset": |
125 | case "endContainer": |
126 | case "endOffset": |
127 | return true; |
128 | default: |
129 | break; |
130 | } |
131 | return false; |
132 | } |
133 | |
134 | /** |
135 | * @param mixed $offset |
136 | * @return mixed |
137 | */ |
138 | #[\ReturnTypeWillChange] |
139 | public function offsetGet( $offset ) { |
140 | return $this->$offset; |
141 | } |
142 | |
143 | /** |
144 | * @param mixed $offset |
145 | * @param mixed $value |
146 | */ |
147 | public function offsetSet( $offset, $value ): void { |
148 | $this->$offset = $value; |
149 | } |
150 | |
151 | /** |
152 | * @param mixed $offset |
153 | */ |
154 | public function offsetUnset( $offset ): void { |
155 | unset( $this->$offset ); |
156 | } |
157 | |
158 | /** |
159 | * Create a StaticRangeInit from an associative array. |
160 | * |
161 | * @param array|\Wikimedia\IDLeDOM\StaticRangeInit $a |
162 | * @return \Wikimedia\IDLeDOM\StaticRangeInit |
163 | */ |
164 | public static function cast( $a ) { |
165 | if ( $a instanceof \Wikimedia\IDLeDOM\StaticRangeInit ) { |
166 | return $a; |
167 | } |
168 | return new class( $a ) extends \Wikimedia\IDLeDOM\StaticRangeInit { |
169 | use StaticRangeInit; |
170 | |
171 | /** @var array */ |
172 | private $a; |
173 | |
174 | /** |
175 | * @param array $a |
176 | */ |
177 | public function __construct( $a ) { |
178 | $this->a = $a; |
179 | } |
180 | |
181 | /** |
182 | * @return Node |
183 | */ |
184 | public function getStartContainer() { |
185 | return $this->a["startContainer"]; |
186 | } |
187 | |
188 | /** |
189 | * @return int |
190 | */ |
191 | public function getStartOffset(): int { |
192 | return $this->a["startOffset"]; |
193 | } |
194 | |
195 | /** |
196 | * @return Node |
197 | */ |
198 | public function getEndContainer() { |
199 | return $this->a["endContainer"]; |
200 | } |
201 | |
202 | /** |
203 | * @return int |
204 | */ |
205 | public function getEndOffset(): int { |
206 | return $this->a["endOffset"]; |
207 | } |
208 | |
209 | }; |
210 | } |
211 | |
212 | } |