Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 83 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
NamedNodeMap | |
0.00% |
0 / 83 |
|
0.00% |
0 / 10 |
1260 | |
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 / 4 |
|
0.00% |
0 / 1 |
12 | |||
__isset | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
offsetExists | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
offsetGet | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
90 | |||
offsetSet | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
30 | |||
offsetUnset | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
30 | |||
getIterator | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 |
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\Attr; |
9 | |
10 | trait NamedNodeMap { |
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\NamedNodeMap $this'; |
77 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
78 | switch ( $name ) { |
79 | case "length": |
80 | return $this->getLength(); |
81 | default: |
82 | break; |
83 | } |
84 | '@phan-var \Wikimedia\IDLeDOM\Helper\NamedNodeMap $this'; |
85 | // @var \Wikimedia\IDLeDOM\Helper\NamedNodeMap $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\NamedNodeMap $this'; |
95 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
96 | switch ( $name ) { |
97 | case "length": |
98 | return true; |
99 | default: |
100 | break; |
101 | } |
102 | return false; |
103 | } |
104 | |
105 | /** |
106 | * @return int |
107 | */ |
108 | public function count(): int { |
109 | '@phan-var \Wikimedia\IDLeDOM\NamedNodeMap $this'; |
110 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
111 | return $this->getLength(); |
112 | } |
113 | |
114 | /** |
115 | * @param mixed $offset |
116 | * @return bool |
117 | */ |
118 | public function offsetExists( $offset ): bool { |
119 | return $this->offsetGet( $offset ) !== null; |
120 | } |
121 | |
122 | /** |
123 | * @param mixed $offset |
124 | * @return mixed |
125 | */ |
126 | #[\ReturnTypeWillChange] |
127 | public function offsetGet( $offset ) { |
128 | '@phan-var \Wikimedia\IDLeDOM\NamedNodeMap $this'; |
129 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
130 | if ( is_numeric( $offset ) ) { |
131 | return $this->item( $offset ); |
132 | } elseif ( is_string( $offset ) ) { |
133 | return $this->getNamedItem( $offset ); |
134 | } |
135 | $trace = debug_backtrace(); |
136 | while ( |
137 | count( $trace ) > 0 && |
138 | $trace[0]['function'] !== "offsetGet" && |
139 | $trace[0]['function'] !== "offsetExists" |
140 | ) { |
141 | array_shift( $trace ); |
142 | } |
143 | while ( |
144 | count( $trace ) > 1 && ( |
145 | $trace[1]['function'] === "offsetGet" || |
146 | $trace[1]['function'] === "offsetExists" |
147 | ) ) { |
148 | array_shift( $trace ); |
149 | } |
150 | trigger_error( |
151 | 'Undefined property' . |
152 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset . |
153 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
154 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
155 | E_USER_NOTICE |
156 | ); |
157 | return null; |
158 | } |
159 | |
160 | /** |
161 | * @param mixed $offset |
162 | * @param mixed $value |
163 | */ |
164 | public function offsetSet( $offset, $value ): void { |
165 | '@phan-var \Wikimedia\IDLeDOM\NamedNodeMap $this'; |
166 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
167 | if ( is_numeric( $offset ) ) { |
168 | /* Fall through */ |
169 | } elseif ( is_string( $offset ) ) { |
170 | /* Fall through */ |
171 | } |
172 | $trace = debug_backtrace(); |
173 | while ( |
174 | count( $trace ) > 0 && |
175 | $trace[0]['function'] !== "offsetSet" |
176 | ) { |
177 | array_shift( $trace ); |
178 | } |
179 | trigger_error( |
180 | 'Undefined property' . |
181 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset . |
182 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
183 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
184 | E_USER_NOTICE |
185 | ); |
186 | } |
187 | |
188 | /** |
189 | * @param mixed $offset |
190 | */ |
191 | public function offsetUnset( $offset ): void { |
192 | '@phan-var \Wikimedia\IDLeDOM\NamedNodeMap $this'; |
193 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
194 | if ( is_numeric( $offset ) ) { |
195 | /* Fall through */ |
196 | } elseif ( is_string( $offset ) ) { |
197 | /* Fall through */ |
198 | } |
199 | $trace = debug_backtrace(); |
200 | while ( |
201 | count( $trace ) > 0 && |
202 | $trace[0]['function'] !== "offsetUnset" |
203 | ) { |
204 | array_shift( $trace ); |
205 | } |
206 | trigger_error( |
207 | 'Undefined property' . |
208 | ' via ' . ( $trace[0]['function'] ?? '' ) . '(): ' . $offset . |
209 | ' in ' . ( $trace[0]['file'] ?? '' ) . |
210 | ' on line ' . ( $trace[0]['line'] ?? '' ), |
211 | E_USER_NOTICE |
212 | ); |
213 | } |
214 | |
215 | /** |
216 | * @return \Iterator<Attr> Value iterator returning Attr items |
217 | */ |
218 | public function getIterator(): \Iterator { |
219 | '@phan-var \Wikimedia\IDLeDOM\NamedNodeMap $this'; |
220 | // @var \Wikimedia\IDLeDOM\NamedNodeMap $this |
221 | for ( $i = 0; $i < $this->getLength(); $i++ ) { |
222 | yield $this->item( $i ); |
223 | } |
224 | } |
225 | |
226 | } |