fix: Dont use mb_detect_encoding for mb_string function calls - #924
Merged
DannyvdSluijs merged 2 commits intoJul 24, 2026
Merged
Conversation
DannyvdSluijs
force-pushed
the
fix/923-Avoid-encoding-detection-for-mbstring-method
branch
from
July 16, 2026 18:39
607c794 to
72747ee
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Draft 3/4 string length validation to avoid mb_detect_encoding() during minLength/maxLength checks, addressing the nondeterminism reported in #923.
Changes:
- Remove
mb_detect_encoding()usage fromStringConstraint::strlen(), relying onmb_strlen()instead. - Drop the now-obsolete PHPStan baseline entry related to
mb_strlen()being called with astring|falseencoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/JsonSchema/Constraints/StringConstraint.php | Removes mb_detect_encoding() from string length calculation for Draft 3/4 validation. |
| phpstan-baseline.neon | Removes the baseline suppression that was only needed due to the previous mb_detect_encoding() return type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: DannyvdSluijs <618940+DannyvdSluijs@users.noreply.github.com>
DannyvdSluijs
deleted the
fix/923-Avoid-encoding-detection-for-mbstring-method
branch
July 24, 2026 09:56
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.
Description
Avoid
mb_detect_encodingfor draft 3 and 4 validationsRelated Issue
Fixes #923
Type of Change
Checklist
Additional Notes
All mb_string function calls use the default value
nullwhich results in the internal character encoding value being used which defaults to UTF-8 and allows for local overrides through setup.