Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Given for Type String in Capitalize #789

Closed
bhsmither opened this issue Aug 30, 2022 · 1 comment
Closed

Null Given for Type String in Capitalize #789

bhsmither opened this issue Aug 30, 2022 · 1 comment

Comments

@bhsmither
Copy link

In modifier.capitalize.php, an undefined argument may be provided for the $string argument.

PHP 8.1 complains about "Passing null to parameter of type string is deprecated."

This is the result of not having a default coded for Smarty variables using the capitalize modifier. Such as:

PHP:
if($variable) $Smarty->assign('VAR', $variable) // otherwise, not assigned
Template:
{$VAR|capitalize}

Suggest:

function smarty_modifier_capitalize($string = '', $uc_digits = false, $lc_rest = false)
@bhsmither
Copy link
Author

This doesn't work as well as planned.

If passing in an actual null, PHP does not use the (empty string) default.
Suggest to test for null and change to an empty string.

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

No branches or pull requests

1 participant