-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce @since tags in block-library/src/*/*.php files #59700
Conversation
Flaky tests detected in 9bf6c1868644024f75f08d5b5a3da7ffbf614f4a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8264199919
|
5121966
to
763dbb9
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
@@ -8,6 +8,8 @@ | |||
/** | |||
* Renders the `core/media-text` block on server. | |||
* | |||
* @since 6.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place I'm not sure about. These functions haven't been included in WordPress Core yet.
@@ -54,6 +56,8 @@ function render_block_core_media_text( $attributes, $content ) { | |||
|
|||
/** | |||
* Registers the `core/media-text` block renderer on server. | |||
* | |||
* @since 6.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only place I'm not sure about. These functions haven't been included in WordPress Core yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it in WordPress core, so that would be correct. The PHP file was added 5 days ago 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive detective work adding all missing @since
annotations. It must have taken some time to track down the proper versions. I'm not going to validate these numbers and will put trust in you and the collective knowledge of the community that can always follow-up to correct them 😄
The code looks good. I'm starting to get more familiar with PHP sniffs and more open to approve 😄
I left a comment with a suggestion to cover more files that I know we sync with WP core, but it isn't a blocker. In practice, it would require some changes to when to run is_experimantal_package
, as it only applies to the packages/block-library
. So maybe, another PR.
@@ -54,6 +56,8 @@ function render_block_core_media_text( $attributes, $content ) { | |||
|
|||
/** | |||
* Registers the `core/media-text` block renderer on server. | |||
* | |||
* @since 6.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it in WordPress core, so that would be correct. The PHP file was added 5 days ago 👍🏻
phpcs.xml.dist
Outdated
@@ -172,4 +172,8 @@ | |||
</property> | |||
</properties> | |||
</rule> | |||
<rule ref="Gutenberg.Commenting.FunctionCommentSinceTag"> | |||
<!-- The sniff ensures that functions have a valid @since tag but skips checking experimental packages. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
In another PR, we should also include /pacakages/block-serialization-default-parser/.+/*\.php$
.
There are two more special core blocks:
widgets/src/blocks/legacy-widget/index.php
widgets/src/blocks/widget-group/index.php
@youknowriad, what do we miss here? Should we discuss in a separate issue what else we could copy from Gutenberg to the core and put under more pressure to follow WP coding standards? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback, @gziolo. Your review is greatly appreciated.
I'd prefer to implement checking files in /pacakages/block-serialization-default-parser
and other folders in a follow-up issue as this would allow for incremental improvements while ensuring that the enforcement of @since
tags in the Block Library is already in place.
Follow-up issue: #59826
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is definitely another issue/PR. We better introduce these improvements gradually so we can start catching issues for covered files.
...hp/gutenberg-coding-standards/Gutenberg/Tests/Commenting/FunctionCommentSinceTagUnitTest.php
Show resolved
Hide resolved
.../php/gutenberg-coding-standards/Gutenberg/Sniffs/Commenting/FunctionCommentSinceTagSniff.php
Outdated
Show resolved
Hide resolved
What a detectives work! Great with progress on the @since-tag, and creating a sniff for it! Wow! 👏🏼 |
Awesome work here. |
2. Don't check for validness of the docblock. This sniff is not designed to do it.
bb34d07
to
236eb2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A custom sniff for enforcing @since
tags sounds really useful!
I definitely encourage you to contribute this to WPCS, as this is important for WordPress core as well and even plugins and themes. It's the right thing to do.
Thank you, @getdave!
Thank you for your suggestion, @swissspidy. |
@anton-vlasenko Yes obviously the sniffs would need to be made generic. In this instance for example there is no reason to include GB-specific stuff in it. I would just make the sniff enforce Agan, especially core itself would be really benefit from this and expanding the scope of the contribution would demonstrate the unity of the project instead of working in isolation. Just figured I'd chime in to share a core perspective here. If you don't have the capacity for this I totally understand of course, so maybe we can start with leaving a comment on that issue. |
Yes please 👍 The more we can unify the standards then the easier it will make syncing code from Gutenberg repo to the WP Core repo. Personally I feel like exploring these opportunities would be a great use of contributor time as - based on my experience in this cycle - I see we all spend too much time on resolving coding standards issues which should be automated. It's my opinion that we should consider them the same codebase in many ways. Therefore the more alignment we can bring the better. The more of this that is automated the better. Again I'd love to hear from folks on #59786. |
@swissspidy I will think about submitting this sniff to WPCS when it becomes more stable. You've made me reconsider my viewpoint on the matter, and I agree that Core could benefit from it. Thank you for sharing your thoughts. |
Thank you for sharing your thoughts, @getdave. I appreciate it. I will consider submitting this sniff to WPCS after #59826 is done. |
* Enforce @SInCE tags in block-library/src/*/*.php files Co-authored-by: anton-vlasenko <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: getdave <[email protected]>
What?
This PR introduces a new sniff called
FunctionCommentSinceTagSniff
to ensure that PHP functions have a valid@since
tag in the docblock.The sniff skips checking files in
__experimental
block-library packages.Fixes #55777.
Why?
@since
tags are helpful for tracking origins and how long things have been in Core.How?
FunctionCommentSinceTagSniff
within theGutenbergCS\Gutenberg\Sniffs\Commenting
namespace.FunctionCommentSinceTagSniff
sniff.block-library
functions so that they have valid@since
tags.Testing Instructions
block-library/src/*/*.php
without a@since
tag.Testing Instructions for Keyboard
Screenshots or Screencast