Fix type safety issues and logic bugs across multiple sniffs#49
Merged
dereuromark merged 1 commit intomasterfrom Mar 27, 2026
Merged
Fix type safety issues and logic bugs across multiple sniffs#49dereuromark merged 1 commit intomasterfrom
dereuromark merged 1 commit intomasterfrom
Conversation
- AbstractSniff: Fix array_search() returning 0 being treated as false - EnumCaseCasingSniff: Use mb_strtoupper/mb_substr for proper multibyte support - NoIsNullSniff: Fix wrong method call and add support for !== comparisons - NoInlineAssignmentSniff, PhpSapiConstantSniff, PreferCastOverFunctionSniff: Replace (int) casting of findNext/findPrevious with proper === false checks Add test coverage for NoIsNullSniff including trailing comparison cases.
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
Changes
Bug Fixes
AbstractSniff.phparray_search('src', ...)returning0was treated as falsy, incorrectly triggering the'tests'fallbackEnumCaseCasingSniff.phpucfirst()aftermb_strtolower()- now usesmb_strtoupper(mb_substr(...))for proper multibyte supportNoIsNullSniff.phpfindUnnecessaryLeadingComparisonStartinstead offindUnnecessaryTrailingComparisonEnd)NoIsNullSniff.phpfindUnnecessaryTrailingComparisonEnd()now properly handles!==comparisons (e.g.,is_null($x) !== true)(int)casting offindNext()/findPrevious()maskedfalsereturns - now uses proper=== falsechecksAffected Sniffs
AbstractSniffEnumCaseCasingSniffNoInlineAssignmentSniffNoIsNullSniffPhpSapiConstantSniffPreferCastOverFunctionSniffNew Tests
NoIsNullSniffTestwith 8 test cases covering:is_null()→=== null!is_null()→!== nulltrue === is_null(),false === is_null()is_null() === true/false,is_null() !== true/false