Skip to content

Commit

Permalink
Guard array element access with isset() instead of @ in Emoji.php (
Browse files Browse the repository at this point in the history
…#84)

* Null-coalesce emoji lookup to false instead of muting

`@` prevents warnings from being printed, but it does not prevent them from being reported to debugger by Xdebug. Since most characters tend not to be emoji, the flood of notices sent to the debugger slows parsing to a crawl. Null-coalesce the element access to false instead.

(To think I almost discarded a perfectly good XLIFF library because I thought it was too 🐌 😉)

* Use `isset()` instead of `?? false` for PHP 5 compat
  • Loading branch information
rulatir authored Mar 22, 2024
1 parent ceadb0b commit 0e1770b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils/Emoji.php
Original file line number Diff line number Diff line change
Expand Up @@ -7459,7 +7459,7 @@ private static function generateReverseMap() {
public static function toEntity( $str ) {
$letters = preg_split( '//u', $str, null, PREG_SPLIT_NO_EMPTY );
foreach ( $letters as $letter ) {
if ( @self::$chmap[ $letter ] ) {
if ( isset ( self::$chmap[ $letter ] ) ) {
$str = str_replace( $letter, self::$chmap[ $letter ], $str );
}
}
Expand Down

0 comments on commit 0e1770b

Please sign in to comment.