Fix PHP 8.1+ deprecation warnings for null parameters#755
Open
marcing wants to merge 1 commit intoitsgoingd:masterfrom
Open
Fix PHP 8.1+ deprecation warnings for null parameters#755marcing wants to merge 1 commit intoitsgoingd:masterfrom
marcing wants to merge 1 commit intoitsgoingd:masterfrom
Conversation
…ctions PHP 8.1 deprecated passing null to non-nullable string parameters of internal functions (strtoupper, explode, preg_match, ltrim, trim, in_array, str_replace, etc). This will become a TypeError in PHP 9.0. Fixed files: - Support/Vanilla/Clockwork.php: $_SERVER keys missing in CLI context - Request/IncomingRequest.php: null host passed to explode() - Request/ShouldCollect.php: null uri/method passed to preg_match/strtoupper - Request/Request.php: null query passed to ltrim in database query counters - DataSource/PhpDataSource.php: null host passed to trim - DataSource/LumenDataSource.php: null $_SERVER/$_POST values - DataSource/EloquentDataSource.php: null query passed to ltrim - Helpers/StackFilter.php: null frame properties passed to in_array Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
PHP 8.1 deprecated passing
nullto non-nullable string parameters of internal functions. These deprecations becomeTypeErrorin PHP 9.0.This PR adds null coalescing (
?? ''/?? null) to all call sites wherenullcan reach internal string/array functions:Support/Vanilla/Clockwork.php—$_SERVER['REQUEST_METHOD'],REQUEST_URI,HTTP_HOST,SERVER_NAME,SERVER_ADDRare undefined in CLI context, causing warnings inexplode()and downstream consumersRequest/IncomingRequest.php—$this->hostcan benull, passed toexplode()Request/ShouldCollect.php—$request->uripassed topreg_match(),$request->methodpassed tostrtoupper()Request/Request.php—$query['query']passed toltrim()in all 5 database query counter methodsDataSource/PhpDataSource.php—$hostpassed totrim()when falsy but not strictly null-checkedDataSource/LumenDataSource.php—$_POST['_method']passed tostrtoupper(),$_SERVER['REQUEST_URI']passed tostr_replace()DataSource/EloquentDataSource.php—$query['query']passed toltrim()Helpers/StackFilter.php— nullableStackFrameproperties (class,file,function,vendor) passed toin_array()Test plan
🤖 Generated with Claude Code