@@ -189,23 +189,23 @@ protected function doXPath(?string $search, string $element, array $paths = [])
189189 $ path = '' ;
190190
191191 // By ID
192- if (! empty ($ selector ['id ' ])) {
193- $ path = empty ($ selector ['tag ' ])
192+ if (isset ($ selector ['id ' ])) {
193+ $ path = ($ selector ['tag ' ] === '' )
194194 ? "id( \"{$ selector ['id ' ]}\") "
195195 : "// {$ selector ['tag ' ]}[@id= \"{$ selector ['id ' ]}\"] " ;
196196 }
197197 // By Class
198- elseif (! empty ($ selector ['class ' ])) {
199- $ path = empty ($ selector ['tag ' ])
198+ elseif (isset ($ selector ['class ' ])) {
199+ $ path = ($ selector ['tag ' ] === '' )
200200 ? "//*[@class= \"{$ selector ['class ' ]}\"] "
201201 : "// {$ selector ['tag ' ]}[@class= \"{$ selector ['class ' ]}\"] " ;
202202 }
203203 // By tag only
204- elseif (! empty ( $ selector ['tag ' ]) ) {
204+ elseif ($ selector ['tag ' ] !== '' ) {
205205 $ path = "// {$ selector ['tag ' ]}" ;
206206 }
207207
208- if (! empty ($ selector ['attr ' ])) {
208+ if (isset ($ selector ['attr ' ])) {
209209 foreach ($ selector ['attr ' ] as $ key => $ value ) {
210210 $ path .= "[@ {$ key }= \"{$ value }\"] " ;
211211 }
@@ -231,7 +231,7 @@ protected function doXPath(?string $search, string $element, array $paths = [])
231231 /**
232232 * Look for the a selector in the passed text.
233233 *
234- * @return array
234+ * @return array{tag: string, id: string|null, class: string|null, attr: array<string, string>|null}
235235 */
236236 public function parseSelector (string $ selector )
237237 {
0 commit comments