Repository navigation
Build/QA: Retire empty.offset baseline - #14027
huzaifaalmesbah wants to merge 1 commit into
Conversation
|
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 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. |
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
No active review issues are identified for the array-type annotation and PHPStan baseline cleanup.
No open issues 🎉
What changed in this PR
This PR retires WordPress core’s PHPStan empty.offset baseline by documenting array types in internal pointers and video metadata handling. It changes static-analysis annotations and configuration without changing runtime logic.
Changes:
- Add array-type annotations for pointer registrations, required capabilities, and video metadata.
- Delete the
empty.offsetbaseline and remove its configuration include. - Remove the obsolete internal-pointers entry from the unreachable-code baseline.
| File | Description |
|---|---|
tests/phpstan/baselines/empty.offset.neon |
Delete the retired baseline. |
tests/phpstan/baselines/deadCode.unreachable.neon |
Remove the internal-pointers suppression. |
src/wp-admin/includes/media.php |
Document the video metadata array type. |
src/wp-admin/includes/class-wp-internal-pointers.php |
Document pointer and capability array types. |
phpstan.neon.dist |
Remove the deleted baseline’s include. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The source changes are analysis annotations only, and the array types match the existing pointer and metadata structures. Full PHPStan analysis passed locally on the reviewed head with its pinned dependencies. CI is green, Copilot found no active issues, and an SVN dry run applies all hunks. No additional PHPUnit tests are needed for these annotations.
AI review · gpt-6
Clarify pointer, metadata, and REST array types. Simplify equivalent Site Health, timezone, and upload checks while preserving the theme filter re-evaluation. Remove the resolved `empty.offset`, `booleanAnd.rightAlwaysTrue`, and `identical.alwaysTrue` baselines and the related unreachable-code entry. Developed in: #14027, #14031, #14032 Props huzaifaalmesbah. See #65817. git-svn-id: https://develop.svn.wordpress.org/trunk@65149 602fd350-edb4-49c9-b593-d223f7449a82
|
PR #14027 landed in https://core.trac.wordpress.org/changeset/65149 |
Clarify pointer, metadata, and REST array types. Simplify equivalent Site Health, timezone, and upload checks while preserving the theme filter re-evaluation. Remove the resolved `empty.offset`, `booleanAnd.rightAlwaysTrue`, and `identical.alwaysTrue` baselines and the related unreachable-code entry. Developed in: WordPress/wordpress-develop#14027, WordPress/wordpress-develop#14031, WordPress/wordpress-develop#14032 Props huzaifaalmesbah. See #65817. Built from https://develop.svn.wordpress.org/trunk@65149 git-svn-id: http://core.svn.wordpress.org/trunk@64298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
| * 'themes.php' => 'wp390_widgets' | ||
| * ) | ||
| */ | ||
| /** @var array<string, string|string[]> $registered_pointers */ |
There was a problem hiding this comment.
Nit: The @var could have been included with the existing comment:
diff --git a/src/wp-admin/includes/class-wp-internal-pointers.php b/src/wp-admin/includes/class-wp-internal-pointers.php
index 448e7af914..0e11d759a9 100644
--- a/src/wp-admin/includes/class-wp-internal-pointers.php
+++ b/src/wp-admin/includes/class-wp-internal-pointers.php
@@ -35,7 +35,7 @@ final class WP_Internal_Pointers {
* @param string $hook_suffix The current admin page.
*/
public static function enqueue_scripts( $hook_suffix ) {
- /*
+ /**
* Register feature pointers
*
* Format:
@@ -47,8 +47,9 @@ final class WP_Internal_Pointers {
* array(
* 'themes.php' => 'wp390_widgets'
* )
+ *
+ * @var array<string, string|string[]> $registered_pointers
*/
- /** @var array<string, string|string[]> $registered_pointers */
$registered_pointers = array(
// None currently.
);
@@ -60,7 +61,7 @@ final class WP_Internal_Pointers {
$pointers = (array) $registered_pointers[ $hook_suffix ];
- /*
+ /**
* Specify required capabilities for feature pointers
*
* Format:
@@ -72,8 +73,9 @@ final class WP_Internal_Pointers {
* array(
* 'wp390_widgets' => array( 'edit_theme_options' )
* )
+ *
+ * @var array<string, string[]> $caps_required
*/
- /** @var array<string, string[]> $caps_required */
$caps_required = array(
// None currently.
);| return false; | ||
| } | ||
|
|
||
| /** @var array<string, mixed> $metadata */ |
There was a problem hiding this comment.
This change seems to have masked a real bug. Namely, look below at this code:
wordpress-develop/src/wp-admin/includes/media.php
Lines 3746 to 3752 in 92bedc2
There is no nowhere between this if statement and the $metadata variable initialization that the created_timestamp key is set. So PHPStan was indeed flagging dead code. This is the change that should be made:
diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index 896af458eb..9f5b87ce85 100644
--- a/src/wp-admin/includes/media.php
+++ b/src/wp-admin/includes/media.php
@@ -3677,7 +3677,6 @@ function wp_read_video_metadata( $file ) {
return false;
}
- /** @var array<string, mixed> $metadata */
$metadata = array();
if ( ! defined( 'GETID3_TEMP_DIR' ) ) {
@@ -3751,12 +3750,9 @@ function wp_read_video_metadata( $file ) {
$metadata['audio'] = $data['audio'];
}
- if ( empty( $metadata['created_timestamp'] ) ) {
- $created_timestamp = wp_get_media_creation_timestamp( $data );
-
- if ( false !== $created_timestamp ) {
- $metadata['created_timestamp'] = $created_timestamp;
- }
+ $created_timestamp = wp_get_media_creation_timestamp( $data );
+ if ( false !== $created_timestamp ) {
+ $metadata['created_timestamp'] = $created_timestamp;
}
wp_add_id3_tag_data( $metadata, $data );There was a problem hiding this comment.
Agreed. The broad array<string, mixed> annotation hid the useful diagnostic: created_timestamp has not been set at that point, so the outer condition is redundant. I should have traced the assignment path instead of accepting the wider type. I’m reviewing #15303, including PHPStan and the existing media checks, as the follow-up.
AI review · gpt-6
Description
This PR resolves all occurrences of
empty.offsetin WordPress core and retires the baseline filetests/phpstan/baselines/empty.offset.neon:WP_Internal_Pointers::enqueue_scripts(),$registered_pointersis initialized as an empty array (array()) awaiting future feature pointers. PHPStan flaggedempty( $registered_pointers[ $hook_suffix ] )because$registered_pointerswas inferred as a closed empty array shapearray{}. Adding/** @var array<string, string|string[]> $registered_pointers */and/** @var array<string, string[]> $caps_required */documents the expected dictionary structure and avoids false positives and dead-code warnings.wp_read_video_metadata(),$metadatais dynamically built across several format checks. Inempty( $metadata[\x27created_timestamp\x27] ), PHPStan flagged that\x27created_timestamp\x27was not present in the closed array shape inferred from earlier keys. Adding/** @var array<string, mixed> $metadata */aligns withwp_read_audio_metadata()and reflects the open associative array structure.With these refined docblocks,
empty.offset.neonis completely emptied and deleted, and an obsoletedeadCode.unreachablebaseline entry forclass-wp-internal-pointers.phpis also retired.Testing Instructions
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: Researching static analysis reports, array shapes, and drafting initial baseline diffs; all logic, type declarations, and analysis results were manually investigated, verified, and run locally by me.