-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php81] Skip always string if else DomElement on NullToStrictStringFu…
…ncCallArgRector (#5822)
- Loading branch information
1 parent
86eb512
commit 2b811af
Showing
2 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...ullToStrictStringFuncCallArgRector/Fixture/skip_always_string_if_else_dom_element.php.inc
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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture; | ||
|
||
final class SkipAlwaysStringIfElseDomElement { | ||
public function getTitle(string $html): string { | ||
$dom = new \DOMDocument(); | ||
$dom->loadHTML($html); | ||
$titleElement = $dom->getElementsByTagName('title')->item(0); | ||
if ($titleElement?->nodeValue !== null) { | ||
return trim($titleElement->nodeValue); | ||
} else { | ||
return 'Unnamed document'; | ||
} | ||
} | ||
} |
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