Problem/Motivation
In D11.3.2 with PHP 8.4.17 I get this warning:
Deprecated function: Drupal\typogrify\SmartyPants::smartNumbers(): Implicitly marking parameter $ctx as nullable is deprecated, the explicit nullable type must be used instead in include() (line 576 of /xxx/drupal/vendor/composer/ClassLoader.php)
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | typogrify-3569369-1-php84-nullable-deprecation.patch | 2.57 KB | nickolaj |
Issue fork typogrify-3569369
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nickolajAdded explicit nullable type hints (`?string`) to all parameters in the `SmartyPants` class that have `NULL` as their default values.
Comment #5
benjifisher@promes, @nickolaj:
Thanks for reporting and working on this issue!
I made a merge request (MR) using the patch from #2. (I copied the extended commit message, but I am not sure it will be preserved when I merge the changes.) I notice a few problems when reviewing the changes:
When I search for
= NULL, I find one more function that should be updated:i18nQuotes(). (There are also two functions where the nullable object is already declared as nullable:smartNumbers()andsmartAbbreviation().) Or is there some reason not to updatei18nQuotes()?In
process(), the variable$ctxis used as an array, despite the@paramcomment. So it should be declared as?arrayand not?string. I think that is the only function where it is used, but I think we should always declare it as?arrayfor consistency.Finally, when we update the type declaration in a function declaration, I would like to update the
@paramcomment to match. That is, I would like to see@param string|null $attrand@param array|null $ctx.Comment #6
benjifisherI apologize for being impatient, but I decided to fix this myself (and then review it myself).
The automated tests catch some of the problems I noticed when reviewing the code. After my update, the tests pass.
I plan to fix this issue and then make a new release of the module.
Comment #8
benjifisher