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

compatibility advice: must be of the type string, null given #3003

Closed
FFCZ opened this issue Aug 11, 2022 · 1 comment
Closed

compatibility advice: must be of the type string, null given #3003

FFCZ opened this issue Aug 11, 2022 · 1 comment

Comments

@FFCZ
Copy link

FFCZ commented Aug 11, 2022

question: when i load xlsx,a little error occurred

File : E:\htdocs\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Shared\StringHelper.php
Error : Argument 1 passed to PhpOffice\PhpSpreadsheet\Shared\StringHelper::strToLower() must be of the type string, null given,
Call : called in E:\htdocs\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Calculation\LookupRef\VLookup.php on line 71

original code
public static function strToLower(string $textValue): string { return mb_convert_case($textValue, MB_CASE_LOWER, 'UTF-8'); }
suggest improvements, support null, php >=7.1
public static function strToLower(?string $textValue): string { return mb_convert_case($textValue, MB_CASE_LOWER, 'UTF-8'); }
thank you !

@MarkBaker
Copy link
Member

Depending on the version of PhpSPreadsheet that you're running, this is fixed in VLookup.php where the value passed to StringHelper::strToLower() is explicitly cast to a string:

        $aLower = StringHelper::strToLower((string) $a[$firstColumn]);
        $bLower = StringHelper::strToLower((string) $b[$firstColumn]);

Duplicate of Issue #2934 resolved by PR #2939 (commit 4bf4278) and release in version 1.24.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants