Repository navigation
docs: fix return type on gutenberg_get_typography_value_and_unit() - #68392
Conversation
27d00e2 to
0cbf68d
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This matches `wp_get_typography_value_and_unit()` in WordPress core, which has documented the return as `array|null` since r54260. Only the `@return` tag is synced: core has since reworked the function body, so its `@phpstan-*` shapes would not describe this implementation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Comment by Claude Opus 5.5 Trunk was merged in, and 54b0ed2 changes the This resolves the three |
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. 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:
Updated as activity occurs, without notifying anyone named here. Add the |
Replace `gutenberg_get_typography_value_and_unit()` with `wp_get_typography_value_and_unit()` as it stands in WordPress core after r62719, which added types to the function and refactored its parsing: * A fixed regular expression parses the value and unit, and the unit is then checked against the acceptable units with `in_array()`, rather than interpolating the units into the pattern unescaped. * The value is cast to a float. * `@phpstan-param` and `@phpstan-return` shapes are added, along with a native `?array` return type and an inline `@var` for the parsed options. The docblock and the `_doing_it_wrong()` message now match core as well, keeping Gutenberg's text domain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Comment by Claude Opus 5.5 Rather than syncing only the |
|
The only difference between the functions now: --- core.txt 2026-10-25 13:30:54
+++ gutenberg.txt 2026-10-25 13:30:38
@@ -21,11 +21,11 @@
* } $options
* @phpstan-return array{ value: float, unit: non-empty-string }|null
*/
-function wp_get_typography_value_and_unit( $raw_value, $options = array() ): ?array {
+function gutenberg_get_typography_value_and_unit( $raw_value, $options = array() ): ?array {
if ( ! is_string( $raw_value ) && ! is_int( $raw_value ) && ! is_float( $raw_value ) ) {
_doing_it_wrong(
__FUNCTION__,
- __( 'Raw size value must be a string, integer, or float.' ),
+ __( 'Raw size value must be a string, integer, or float.', 'gutenberg' ),
'6.1.0'
);
return null; |
What?
This PR fixes the PHPDoc return type for
gutenberg_get_typography_value_and_unit()to correctly indicate it may returnnull.Why?
While this issue was surfaced by PHPStan (via #66693) it can be remediated independently as part of #66598
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast