Debian Codegraph @

vendor/wikimedia/idle-dom/src/Helper/DOMTokenList.php

raw
1 <?php
2
3 // AUTOMATICALLY GENERATED. DO NOT EDIT.
4 // Use `composer build` to regenerate.
5
6 namespace Wikimedia\IDLeDOM\Helper;
7
8 trait DOMTokenList {
9
10 // Underscore is used to avoid conflicts with DOM-reserved names
11 // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
12 // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
13
14 /**
15 * Handle an attempt to get a non-existing property on this
16 * object. The default implementation raises an exception
17 * but the implementor can choose a different behavior:
18 * return null (like JavaScript), dynamically create the
19 * property, etc.
20 * @param string $prop the name of the property requested
21 * @return mixed
22 */
23 protected function _getMissingProp( string $prop ) {
24 $trace = debug_backtrace();
25 while (
26 count( $trace ) > 0 &&
27 $trace[0]['function'] !== "__get"
28 ) {
29 array_shift( $trace );
30 }
31 trigger_error(
32 'Undefined property' .
33 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop .
34 ' in ' . ( $trace[0]['file'] ?? '' ) .
35 ' on line ' . ( $trace[0]['line'] ?? '' ),
36 E_USER_NOTICE
37 );
38 return null;
39 }
40
41 /**
42 * Handle an attempt to set a non-existing property on this
43 * object. The default implementation raises an exception
44 * but the implementor can choose a different behavior:
45 * ignore the operation (like JavaScript), dynamically create
46 * the property, etc.
47 * @param string $prop the name of the property requested
48 * @param mixed $value the value to set
49 */
50 protected function _setMissingProp( string $prop, $value ): void {
51 $trace = debug_backtrace();
52 while (
53 count( $trace ) > 0 &&
54 $trace[0]['function'] !== "__set"
55 ) {
56 array_shift( $trace );
57 }
58 trigger_error(
59 'Undefined property' .
60 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $prop .
61 ' in ' . ( $trace[0]['file'] ?? '' ) .
62 ' on line ' . ( $trace[0]['line'] ?? '' ),
63 E_USER_NOTICE
64 );
65 }
66
67 // phpcs:enable
68
69 /**
70 * @param string $name
71 * @return mixed
72 */
73 public function __get( string $name ) {
74 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
75 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
76 switch ( $name ) {
77 case "length":
78 return $this->getLength();
79 case "value":
80 return $this->getValue();
81 default:
82 break;
83 }
84 '@phan-var \Wikimedia\IDLeDOM\Helper\DOMTokenList $this';
85 // @var \Wikimedia\IDLeDOM\Helper\DOMTokenList $this
86 return $this->_getMissingProp( $name );
87 }
88
89 /**
90 * @param string $name
91 * @return bool
92 */
93 public function __isset( string $name ): bool {
94 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
95 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
96 switch ( $name ) {
97 case "length":
98 return true;
99 case "value":
100 return true;
101 default:
102 break;
103 }
104 return false;
105 }
106
107 /**
108 * @param string $name
109 * @param mixed $value
110 */
111 public function __set( string $name, $value ): void {
112 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
113 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
114 switch ( $name ) {
115 case "value":
116 $this->setValue( $value );
117 return;
118 default:
119 break;
120 }
121 '@phan-var \Wikimedia\IDLeDOM\Helper\DOMTokenList $this';
122 // @var \Wikimedia\IDLeDOM\Helper\DOMTokenList $this
123 $this->_setMissingProp( $name, $value );
124 }
125
126 /**
127 * @param string $name
128 */
129 public function __unset( string $name ): void {
130 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
131 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
132 switch ( $name ) {
133 case "length":
134 break;
135 case "value":
136 break;
137 default:
138 return;
139 }
140 $trace = debug_backtrace();
141 while (
142 count( $trace ) > 0 &&
143 $trace[0]['function'] !== "__unset"
144 ) {
145 array_shift( $trace );
146 }
147 trigger_error(
148 'Undefined property' .
149 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $name .
150 ' in ' . ( $trace[0]['file'] ?? '' ) .
151 ' on line ' . ( $trace[0]['line'] ?? '' ),
152 E_USER_NOTICE
153 );
154 }
155
156 /**
157 * @return string
158 */
159 public function __toString(): string {
160 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
161 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
162 return $this->getValue();
163 }
164
165 /**
166 * @return int
167 */
168 public function count(): int {
169 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
170 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
171 return $this->getLength();
172 }
173
174 /**
175 * @param mixed $offset
176 * @return bool
177 */
178 public function offsetExists( $offset ): bool {
179 return $this->offsetGet( $offset ) !== null;
180 }
181
182 /**
183 * @param mixed $offset
184 * @return mixed
185 */
186 #[\ReturnTypeWillChange]
187 public function offsetGet( $offset ) {
188 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
189 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
190 if ( is_numeric( $offset ) ) {
191 return $this->item( $offset );
192 } elseif ( is_string( $offset ) ) {
193 /* Fall through */
194 }
195 $trace = debug_backtrace();
196 while (
197 count( $trace ) > 0 &&
198 $trace[0]['function'] !== "offsetGet" &&
199 $trace[0]['function'] !== "offsetExists"
200 ) {
201 array_shift( $trace );
202 }
203 while (
204 count( $trace ) > 1 && (
205 $trace[1]['function'] === "offsetGet" ||
206 $trace[1]['function'] === "offsetExists"
207 ) ) {
208 array_shift( $trace );
209 }
210 trigger_error(
211 'Undefined property' .
212 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset .
213 ' in ' . ( $trace[0]['file'] ?? '' ) .
214 ' on line ' . ( $trace[0]['line'] ?? '' ),
215 E_USER_NOTICE
216 );
217 return null;
218 }
219
220 /**
221 * @param mixed $offset
222 * @param mixed $value
223 */
224 public function offsetSet( $offset, $value ): void {
225 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
226 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
227 if ( is_numeric( $offset ) ) {
228 /* Fall through */
229 } elseif ( is_string( $offset ) ) {
230 /* Fall through */
231 }
232 $trace = debug_backtrace();
233 while (
234 count( $trace ) > 0 &&
235 $trace[0]['function'] !== "offsetSet"
236 ) {
237 array_shift( $trace );
238 }
239 trigger_error(
240 'Undefined property' .
241 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset .
242 ' in ' . ( $trace[0]['file'] ?? '' ) .
243 ' on line ' . ( $trace[0]['line'] ?? '' ),
244 E_USER_NOTICE
245 );
246 }
247
248 /**
249 * @param mixed $offset
250 */
251 public function offsetUnset( $offset ): void {
252 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
253 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
254 if ( is_numeric( $offset ) ) {
255 /* Fall through */
256 } elseif ( is_string( $offset ) ) {
257 /* Fall through */
258 }
259 $trace = debug_backtrace();
260 while (
261 count( $trace ) > 0 &&
262 $trace[0]['function'] !== "offsetUnset"
263 ) {
264 array_shift( $trace );
265 }
266 trigger_error(
267 'Undefined property' .
268 ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset .
269 ' in ' . ( $trace[0]['file'] ?? '' ) .
270 ' on line ' . ( $trace[0]['line'] ?? '' ),
271 E_USER_NOTICE
272 );
273 }
274
275 /**
276 * @return \Iterator<string> Value iterator returning string items
277 */
278 public function getIterator(): \Iterator {
279 '@phan-var \Wikimedia\IDLeDOM\DOMTokenList $this';
280 // @var \Wikimedia\IDLeDOM\DOMTokenList $this
281 for ( $i = 0; $i < $this->getLength(); $i++ ) {
282 yield $this->item( $i );
283 }
284 }
285
286 }