Skip to content

PHP8.1 Deprecation Passing Null to String Function#2137

Merged
MarkBaker merged 3 commits intoPHPOffice:masterfrom
oleibman:null81
Jun 5, 2021
Merged

PHP8.1 Deprecation Passing Null to String Function#2137
MarkBaker merged 3 commits intoPHPOffice:masterfrom
oleibman:null81

Conversation

@oleibman
Copy link
Collaborator

@oleibman oleibman commented Jun 2, 2021

For each of the files in this PR, one or more statements can pass a null to string functions like strlower. This is deprecated in PHP8.1, and, when deprecated messages are enabled, causes many tests to error out. In every case, use coercion to pass null string rather than null.

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

oleibman added 2 commits June 2, 2021 06:06
For each of the files in this PR, one or more statements can pass a null to string functions like strlower. This is deprecated in PHP8.1, and, when deprecated messages are enabled, causes many tests to error out. In every case, use coercion to pass null string rather than null.
@MarkBaker MarkBaker self-requested a review June 4, 2021 12:52
@MarkBaker
Copy link
Member

Idly wondering how much overhead it would add to the calculation engine to use Reflection to read the method signature, and pass in any appropriate default value as defined in that signature if an argument had been left blank, rather than sending a null value to the method.... that way, any null values received by the method could only be the result of a null value cell or an explicit null argument

It might be worth an experiment, to see how much overhead it might add in terms of performance... I'll have a go sometime in the coming weeks, just to see if it works out

@MarkBaker MarkBaker merged commit a340240 into PHPOffice:master Jun 5, 2021
@MarkBaker
Copy link
Member

Spent the weekend working on this as PR #2143 (PR Is still in draft, because I want to clean up the code a bit). It works well, and with the change any null value passed to a function implementation is a genuine null, and not an empty argument... empty arguments are pre-populated with the defined default values for the argument.

I still need to run some performance tests, but the overhead doesn't seem excessive

@oleibman oleibman deleted the null81 branch July 1, 2021 15:56
BlackyTay pushed a commit to BlackyTay/PhpSpreadsheet that referenced this pull request Aug 8, 2025
For each of the files in this PR, one or more statements can pass a null to string functions like strlower. This is deprecated in PHP8.1, and, when deprecated messages are enabled, causes many tests to error out. In every case, use coercion to pass null string rather than null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants