[10.3.0] Fixed PHP 8.4 deprecated implicit nullable type #510
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes are against tag 10.3.0, which is used by the "Hubspot API" Drupal module version 3.
For reference, I've also opened a related issue here to address the module's own fix for nullable type deprecations.
Would you consider creating a dedicated branch for supporting this usage until the module adopts the latest version of hubspot-api-php? Given the number of changes in this pull request, you might want to make them yourselves on a proprietary branch instead of accepting this pull request.
The changes contained in this pull request were made with a regex search:
(?<=\s|\()(\w*)(?= \$\w* = null)With substitution:
?$1This turned implicit nullable type parameters like
Type $param = nullinto explicit ones like?Type $param = null.LE: The regex was run in VS Code which, turns out, has issues with look-behind expressions when a row contains more than one match, so I reapplied it with a perl command instead: (also, I improved the regex because it wasn't quite on point)
find . -type f -name '*.php' -print0 | xargs -0 perl -pi -e 's/(?<=\s|\()([\\\w]+\w+)(?=\s+\$\w+\s*=\s*null)/?$1/gi'