Skip to content

Commit 7cae381

Browse files
committed
Fixed some potential typing errors.
1 parent c655227 commit 7cae381

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/htmldoc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ protected function htmlentities(string $html, string $charset) : string {
813813
for ($i = 1; $i < 256; $i++) {
814814
$str .= \chr($i);
815815
}
816-
$str = \mb_convert_encoding($str, \mb_internal_encoding(), $charset);
816+
$str = (string) \mb_convert_encoding($str, \mb_internal_encoding(), $charset);
817817

818818
// build html entities conversion map
819819
$replace = [];
@@ -825,7 +825,7 @@ protected function htmlentities(string $html, string $charset) : string {
825825
}
826826

827827
// convert entities
828-
$html = \mb_convert_encoding($html, 'HTML-ENTITIES');
828+
$html = (string) \mb_convert_encoding($html, 'HTML-ENTITIES');
829829
return \str_replace(\array_values($replace), \array_keys($replace), $html);
830830
}
831831
}

src/tokens/tag.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ public function parse(tokenise $tokens) : void {
204204
* @return array An array of parent tag names
205205
*/
206206
protected function getParentTagNames() : array {
207-
if (!$this->parenttags) {
207+
if (empty($this->parenttags)) {
208208
$this->parenttags = $this->parent ? $this->parent->getParentTagNames() : [];
209-
if ($this->tagName) {
209+
if ($this->tagName !== null) {
210210
$this->parenttags[] = \mb_strtolower($this->tagName);
211211
}
212212
}
@@ -363,7 +363,7 @@ protected function getIndex() : ?int {
363363
* @return void
364364
*/
365365
public function before(array $nodes) : void {
366-
if (($index = $this->getIndex()) !== null) {
366+
if ($this->parent !== null && ($index = $this->getIndex()) !== null) {
367367
$this->parent->append($nodes, $index);
368368
}
369369
}
@@ -375,7 +375,7 @@ public function before(array $nodes) : void {
375375
* @return void
376376
*/
377377
public function after(array $nodes) : void {
378-
if (($index = $this->getIndex()) !== null) {
378+
if ($this->parent !== null && ($index = $this->getIndex()) !== null) {
379379
$this->parent->append($nodes, $index + 1);
380380
}
381381
}

0 commit comments

Comments
 (0)