-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
PHP 8.1 mb_substr deprecation message when setting cell value using setValueExplicit with a null string #2868
Comments
…ge (PHP 8.1) in StringHelper::substring()
…ecation message (PHP 8.1)
…ge (PHP 8.1) in StringHelper::substring()
…ge (PHP 8.1) in StringHelper::substring()
It raises the question of whether this should be resolved in PhpSpreadsheet or in user code. Should you be allowed to pass a non-string value (such as a null) to |
Good question. In this case, I used setValueExplicit(), which accepts I've now stumble upon this chapter of the documentation, which states :
Looking at So clearly, I have to fix this in my code ! my bad |
Hi! I discovered this deprecation message appears just under the hood of phpoffice/phpspreadshit with no any case to avoid it in our local code. So this problem and that PR is actual. Vote up for fix. |
If I do add validation checks here to ensure that the data value that you set matches the datatype that you have said it should be, then it will impact performance, and I will throw exceptions... IMO the end-user developer should be responsible for ensuring that the value matches the datatype when they use |
Passing null to parameter #1 ($string) of type string is deprecated |
So i think it' a good idea to just reanimate PR #2869 |
A very strange Xlsx file, certainly one created by MS Excel itself should never have a null value typed as a string... anyway it's done, I've fixed the deprecation notice, without causing any noticeable degradation of performance, and I have updated the documentation. |
Thanks for the fix. |
Oh, Mark, really sorry for your feelings! I just can try to understand how you tired "a bit". But, seriously, I can't agree with you - you are really cool, and your open source child is brilliant, I see, I'm firmly sure, and any kind of shit it absolutely not about here. Just forgive some bits of stupidity of MS Excel and other external soft :) Not only some legacy code of interstellar Voyagers, but even "modern" software often do some bullshit, just forgive them :) Thank you ! |
This is:
Happens when I use
$cell->setValueExplicit()
withnull
value and a string(ish) type cell. Using PHP 8.1What is the expected behavior?
No deprecation message, same as PHP <= 8.0
What is the current behavior?
Get message :
Deprecated: mb_substr(): Passing null to parameter #1 ($string) of type string is deprecated
What are the steps to reproduce?
Using PHP 8.1, run :
Output :
Does an issue affect all spreadsheet file formats?
Yes (format independent)
Which versions of PhpSpreadsheet and PHP are affected?
1.23.0 (previous versions not tested)
The text was updated successfully, but these errors were encountered: