Repository navigation
Build/QA: Retire parameterByRef.unusedType baseline - #14025
huzaifaalmesbah wants to merge 2 commits into
Conversation
…tf8_codepoint_span
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the UTF-8 output-type clarifications and related PHPStan suppression cleanup.
No open issues 🎉
What changed in this PR
This PR clarifies by-reference output types in WordPress’s UTF-8 compatibility helpers and removes the PHPStan suppressions those changes resolve.
Changes:
- Adds output-type annotations and keeps noncharacter detection strictly boolean.
- Deletes the
parameterByRef.unusedTypebaseline and removes two resolvedparameterByRef.typeerrors. - Adds UTF-8 scanner tests covering ASCII, noncharacters, and ordinary multibyte text.
| File | Description |
|---|---|
tests/phpunit/tests/compat/wpScanUtf8.php |
Adds scanner tests asserting boolean noncharacter results. |
tests/phpstan/baselines/parameterByRef.unusedType.neon |
Deletes the resolved baseline. |
tests/phpstan/baselines/parameterByRef.type.neon |
Removes two resolved boolean-type suppressions. |
src/wp-includes/compat-utf8.php |
Documents output types and replaces bitwise accumulation with boolean logic. |
phpstan.neon.dist |
Removes the deleted baseline’s include. |
Review effort: Balanced
|
@dmsnell could you review the AI review · |
…sts. `assertTrue()` and `assertFalse()` already check the boolean type.
|
@dmsnell following up on my Oct 31 request: could you review the AI review · |
| * @param int|null $max_bytes Stop scanning after this many bytes have been seen. | ||
| * @param int|null $max_code_points Stop scanning after this many code points have been seen. | ||
| * @param bool|null $has_noncharacters Set to indicate if scanned string contained noncharacters. | ||
| * @param-out bool $has_noncharacters |
There was a problem hiding this comment.
please verify that this doesn’t break the docs-generation. before we start changing @param declarations, we should ensure that the published docs page isn’t broken.
you can hopefully lean on dmsnell#29 to figure out how to preview the generation.
I see that this is an additional annotation beyond the @param, but it would be ideal to double-check first.
| * | ||
| * @ticket 65817 | ||
| */ | ||
| public function test_scan_string_without_noncharacters() { |
There was a problem hiding this comment.
this is a misleading title. it would be clearer to show variant cases of multi-byte UTF-8 code points and extended grapheme clusters, which would clarify the behavior of the function.
let’s use a data provider and show interesting cases, and then use mb_strlen( $text, 'UTF-8' ) inside an assertSame() to verify the counts.
this way we can cover two-, three-, and four-byte sequences, spans of invalid bytes (covering the maximal subpart behavior), ZWJ sequences, and grapheme clusters.
Description
In
src/wp-includes/compat-utf8.php, by-reference parameters in_wp_scan_utf8()(&$has_noncharacters) and_wp_utf8_codepoint_span()(&$found_code_points) accept nullable input defaults, but are always assigned non-null values on exit (boolandintrespectively).Additionally, in
_wp_scan_utf8(),$has_noncharacterswas previously accumulated using bitwise OR assignment (|=), which coerced the boolean variable into an integer (0or1). Switching to boolean accumulating assignment ($has_noncharacters = $has_noncharacters || ( ... )) ensures it remains strictly a boolean.This PR:
@param-out bool $has_noncharactersto_wp_scan_utf8().@param int|nulland adds@param-out int $found_code_pointsto_wp_utf8_codepoint_span().tests/phpstan/baselines/parameterByRef.unusedType.neonand updatesphpstan.neon.dist.tests/phpstan/baselines/parameterByRef.type.neon._wp_scan_utf8()and boolean noncharacter detection.Testing Instructions
composer phpstanlocally to confirm analysis passes with 0 errors.Trac ticket: https://core.trac.wordpress.org/ticket/65817
Use of AI Tools
AI assistance: Yes
Tool(s): Google Antigravity
Model(s): Gemini 3.8 Flash
Used for: Assisting with static analysis archaeology, PHPStan baseline synchronization, and diff preparation; all code and tests were manually reviewed, verified, and locally run by me.