Skip to content

fix: PHP 8.1+ null parameter deprecation warnings in Generator.php#477

Open
sysmonf wants to merge 1 commit intoezyang:masterfrom
sysmonf:fix/generator-null-deprecation
Open

fix: PHP 8.1+ null parameter deprecation warnings in Generator.php#477
sysmonf wants to merge 1 commit intoezyang:masterfrom
sysmonf:fix/generator-null-deprecation

Conversation

@sysmonf
Copy link

@sysmonf sysmonf commented Feb 8, 2026

Add null coalescing operator (?? '') to prevent deprecation warnings on PHP 8.1-8.4 and TypeError on PHP 8.5+ when null is passed to built-in string functions.

Of note, htmlpurifier was ran on tens of thousands of html code using PHP 8.5, and this is all the deprecation errors we noted on PHP 8.5.

Changes:

  • generateAttributes(): strpos(), strcspn(), strlen() with null $value
  • escape(): htmlspecialchars() with null $string
  • Flash compat: $token->attr['name'] / $token->attr['value'] may not exist

Add null coalescing operator (?? '') to prevent deprecation warnings
on PHP 8.1-8.4 and TypeError on PHP 8.5+ when null is passed to
built-in string functions.

Changes:
- generateAttributes(): strpos(), strcspn(), strlen() with null $value
- escape(): htmlspecialchars() with null $string
- Flash compat: $token->attr['name'] / $token->attr['value'] may not exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant