Skip to content

Commit c77a031

Browse files
committed
Explicit type casting to get us to PHPStan level 10! 🎉
1 parent fd1be07 commit c77a031

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 6
2+
level: 10
33

44
# Code to be analyzed
55
paths:

src/MarkupAssertionsTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function flattenAttributeArray(array $attributes)
246246
if (empty($value)) {
247247
$value = sprintf('[%s]', $key);
248248
} else {
249-
$value = sprintf('[%s="%s"]', $key, htmlspecialchars($value));
249+
$value = sprintf('[%s="%s"]', $key, htmlspecialchars((string) $value));
250250
}
251251
});
252252

@@ -270,10 +270,14 @@ private function getInnerHtmlOfMatchedElements($markup, $query)
270270

271271
// Loop through results and collect their innerHTML values.
272272
foreach ($results as $result) {
273+
if (!isset($result->firstChild)) {
274+
continue;
275+
}
276+
273277
$document = new \DOMDocument();
274278
$document->appendChild($document->importNode($result->firstChild, true));
275279

276-
$contents[] = trim(html_entity_decode($document->saveHTML()));
280+
$contents[] = trim(html_entity_decode((string) $document->saveHTML()));
277281
}
278282

279283
return implode(PHP_EOL, $contents);

0 commit comments

Comments
 (0)