-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2da94f8
commit 753fc4d
Showing
4 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/PHPStan/Rules/Methods/data/simple-xml-element-child.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace SimpleXmlElementChild; | ||
|
||
class CustomXMLElement extends \SimpleXMLElement | ||
{ | ||
#[\Override] | ||
public function addChild(string $qualifiedName, ?string $value = null, ?string $namespace = null): ?static | ||
{ | ||
return parent::addChild($qualifiedName, $this->escapeInput($value), $namespace); | ||
} | ||
|
||
private function escapeInput(?string $value): ?string | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
return htmlspecialchars((string) normalizer_normalize($value), ENT_XML1, 'UTF-8'); | ||
} | ||
} |