Repository navigation
phan: Add Gutenberg global styles and font stub definitions - #52656
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
anomiex
left a comment
There was a problem hiding this comment.
Works. One comment inline, but not a blocker.
| 'lib/client-assets.php' => array( | ||
| 'lib/class-wp-theme-json-resolver-gutenberg.php' => array( | ||
| 'class' => array( | ||
| 'WP_Theme_JSON_Resolver_Gutenberg' => array( 'method' => array( 'clean_cached_data' ) ), |
There was a problem hiding this comment.
I note this class's documentation says
* This class is for internal core usage and is not supposed to be used by extenders (plugins and/or themes).
* This is a low-level API that may need to do breaking changes. Please,
* use gutenberg_get_global_settings, gutenberg_get_global_styles, and gutenberg_get_global_stylesheet instead.
*
* @since 5.8.0
* @access private
But it looks like #52653 only uses it in tests, so meh. For just the one function in some tests, I might be inclined to do a // @phan-suppress-next-line instead of actually stubbing the private class.
There was a problem hiding this comment.
That's not a bad idea, I'll get rid of it
Proposed changes
Extend the Gutenberg stub generator definitions to extract
gutenberg_get_global_settings(),gutenberg_get_global_styles(),gutenberg_print_font_faces(), andWP_Theme_JSON_Resolver_Gutenberg::clean_cached_data().This PR changes only
tools/stubs/gutenberg-stub-defs.php. After it lands, run the Update Phan stubs workflow on trunk (or wait for the scheduled run) and merge the resulting bot-owned generated-stubs PR. That provides the declarations needed by the Google Fonts follow-up without putting generated stub changes in a human-authored PR.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Run the stub generator with these definitions against the published Gutenberg plugin and direct its output to a temporary file. Confirm the output declares all three functions and the public static
clean_cached_data()method.Validated locally against Gutenberg 24.0.0 using Jetpack's stub generator:
git diff --checkpass for the definition change.No generated files or runtime code are changed, so no product changelog is needed.