Skip to content

Commit

Permalink
[PHPStan]: generate baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Dec 30, 2024
1 parent 7b6b735 commit 3e4c557
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 348 deletions.
6 changes: 0 additions & 6 deletions tools/phpstan/baseline/level-0.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/duotone.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^One or more @param tags has an invalid name or invalid syntax\\.$#',
'count' => 4,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: class.notFound
'message' => '#^Call to static method get_stores\\(\\) on an unknown class WP_Style_Engine_CSS_Rules_Store_Gutenberg\\.$#',
Expand Down
60 changes: 0 additions & 60 deletions tools/phpstan/baseline/level-2.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
// identifier: binaryOp.invalid
'message' => '#^Binary operation "/" between string and 255 results in an error\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/block-supports/duotone.php',
];
$ignoreErrors[] = [
// identifier: method.void
'message' => '#^Result of method WP_HTML_Tag_Processor\\:\\:class_list\\(\\) \\(void\\) is used\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/layout.php',
];
$ignoreErrors[] = [
// identifier: binaryOp.invalid
'message' => '#^Binary operation "/" between string and 255 results in an error\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-duotone-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: staticClassAccess.privateMethod
'message' => '#^Unsafe call to private method WP_Theme_JSON_Gutenberg\\:\\:compute_spacing_sizes\\(\\) through static\\:\\:\\.$#',
Expand Down Expand Up @@ -61,30 +49,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @param has invalid value \\(WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data\\.\\)\\: Unexpected token "Class", expected variable at offset 148$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @param has invalid value \\(WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data\\.\\)\\: Unexpected token "Class", expected variable at offset 154$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @param has invalid value \\(WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data\\.\\)\\: Unexpected token "Class", expected variable at offset 155$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @param has invalid value \\(WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data\\.\\)\\: Unexpected token "Class", expected variable at offset 156$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: staticClassAccess.privateMethod
'message' => '#^Unsafe call to private method WP_Theme_JSON_Resolver_Gutenberg\\:\\:inject_variations_from_block_style_variation_files\\(\\) through static\\:\\:\\.$#',
Expand Down Expand Up @@ -115,12 +79,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: parameter.notFound
'message' => '#^PHPDoc tag @param references unknown parameter\\: \\$settings$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/block-bindings.php',
];
$ignoreErrors[] = [
// identifier: property.notFound
'message' => '#^Access to an undefined property WP_Token_Map\\:\\:\\$groups\\.$#',
Expand Down Expand Up @@ -151,24 +109,6 @@
'count' => 2,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/class-gutenberg-token-map-6-7.php',
];
$ignoreErrors[] = [
// identifier: property.notFound
'message' => '#^Access to an undefined property object\\:\\:\\$slug\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/compat.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @param has invalid value \\(\\[WP_Block_Template\\|null\\] \\$block_template The found block template, or null if there isn’t one\\.\\)\\: Unexpected token "\\|", expected \'\\]\' at offset 115$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/compat.php',
];
$ignoreErrors[] = [
// identifier: phpDoc.parseError
'message' => '#^PHPDoc tag @return has invalid value \\(\\[WP_Block_Template\\|null\\] The block template that was already found with the plugin property defined if it was registered by a plugin\\.\\)\\: Unexpected token "\\|", expected \'\\]\' at offset 223$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/compat.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method object\\:\\:set\\(\\)\\.$#',
Expand Down
49 changes: 36 additions & 13 deletions tools/phpstan/baseline/level-3.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/layout.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Function gutenberg_get_typography_value_and_unit\\(\\) should return array but returns null\\.$#',
'count' => 3,
'path' => __DIR__ . '/../../../lib/block-supports/typography.php',
];
$ignoreErrors[] = [
// identifier: return.empty
'message' => '#^Function _gutenberg_footnotes_force_filtered_html_on_import_filter\\(\\) should return string but empty return statement found\\.$#',
Expand All @@ -37,12 +31,42 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method WP_Theme_JSON_Resolver_Gutenberg\\:\\:get_block_data\\(\\) should return WP_Theme_JSON_Gutenberg but returns WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method WP_Theme_JSON_Resolver_Gutenberg\\:\\:get_core_data\\(\\) should return WP_Theme_JSON_Gutenberg but returns WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method WP_Theme_JSON_Resolver_Gutenberg\\:\\:get_user_data\\(\\) should return WP_Theme_JSON_Gutenberg but returns WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$blocks \\(WP_Theme_JSON_Gutenberg\\) does not accept WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$blocks \\(WP_Theme_JSON_Gutenberg\\) does not accept null\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$core \\(WP_Theme_JSON_Gutenberg\\) does not accept WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$core \\(WP_Theme_JSON_Gutenberg\\) does not accept null\\.$#',
Expand All @@ -55,6 +79,12 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$theme \\(WP_Theme_JSON_Gutenberg\\) does not accept WP_Theme_JSON\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: assign.propertyType
'message' => '#^Static property WP_Theme_JSON_Resolver_Gutenberg\\:\\:\\$theme \\(WP_Theme_JSON_Gutenberg\\) does not accept null\\.$#',
Expand Down Expand Up @@ -91,11 +121,4 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/experimental/media/class-gutenberg-rest-attachments-controller.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Function gutenberg_register_block_module_id\\(\\) should return string but returns false\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/experimental/script-modules.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
48 changes: 0 additions & 48 deletions tools/phpstan/baseline/level-4.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,12 @@
'count' => 1,
'path' => __DIR__ . '/../../../gutenberg.php',
];
$ignoreErrors[] = [
// identifier: nullCoalesce.offset
'message' => '#^Offset 1 on array\\{array\\<int, string\\>, array\\<int, non\\-empty\\-string\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/block-style-variations.php',
];
$ignoreErrors[] = [
// identifier: booleanAnd.alwaysFalse
'message' => '#^Result of && is always false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/duotone.php',
];
$ignoreErrors[] = [
// identifier: identical.alwaysFalse
'message' => '#^Strict comparison using \\=\\=\\= between 1 and float will always evaluate to false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/duotone.php',
];
$ignoreErrors[] = [
// identifier: booleanOr.alwaysTrue
'message' => '#^Result of \\|\\| is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/position.php',
];
$ignoreErrors[] = [
// identifier: booleanAnd.leftAlwaysTrue
'message' => '#^Left side of && is always true\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/block-supports/shadow.php',
];
$ignoreErrors[] = [
// identifier: booleanNot.alwaysFalse
'message' => '#^Negated boolean expression is always false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-duotone-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: smallerOrEqual.alwaysTrue
'message' => '#^Comparison operation "\\<\\=" between 0 and int\\<0, max\\>\\|false is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: if.alwaysFalse
'message' => '#^If condition is always false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: booleanNot.alwaysTrue
'message' => '#^Negated boolean expression is always true\\.$#',
Expand All @@ -79,12 +37,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/experimental/navigation-theme-opt-in.php',
];
$ignoreErrors[] = [
// identifier: if.alwaysFalse
'message' => '#^If condition is always false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/experimental/navigation-theme-opt-in.php',
];
$ignoreErrors[] = [
// identifier: if.alwaysTrue
'message' => '#^If condition is always true\\.$#',
Expand Down
38 changes: 1 addition & 37 deletions tools/phpstan/baseline/level-5.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$separator of function explode expects string, float given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/block-supports/layout.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$args of function register_block_type expects array\\{api_version\\?\\: string, title\\?\\: string, category\\?\\: string\\|null, parent\\?\\: array\\<string\\>\\|null, ancestor\\?\\: array\\<string\\>\\|null, allowed_blocks\\?\\: array\\<string\\>\\|null, icon\\?\\: string\\|null, description\\?\\: string, \\.\\.\\.\\}, array\\{category\\: \'widgets\', attributes\\: array\\{url\\: array\\{type\\: \'string\'\\}, service\\: array\\{type\\: \'string\', default\\: \'amazon\'\\|\'bandcamp\'\\|\'behance\'\\|\'chain\'\\|\'codepen\'\\|\'deviantart\'\\|\'dribbble\'\\|\'dropbox\'\\|\'etsy\'\\|\'facebook\'\\|\'feed\'\\|\'fivehundredpx\'\\|\'flickr\'\\|\'foursquare\'\\|\'github\'\\|\'goodreads\'\\|\'google\'\\|\'instagram\'\\|\'lastfm\'\\|\'linkedin\'\\|\'mail\'\\|\'mastodon\'\\|\'medium\'\\|\'meetup\'\\|\'pinterest\'\\|\'pocket\'\\|\'reddit\'\\|\'skype\'\\|\'snapchat\'\\|\'soundcloud\'\\|\'spotify\'\\|\'tumblr\'\\|\'twitch\'\\|\'twitter\'\\|\'vimeo\'\\|\'vk\'\\|\'wordpress\'\\|\'yelp\'\\|\'youtube\'\\}, label\\: array\\{type\\: \'string\'\\}\\}, render_callback\\: \'gutenberg_render…\'\\} given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/blocks.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$value of static method WP_Duotone_Gutenberg\\:\\:colord_parse_hue\\(\\) expects float, string given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-duotone-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$incoming of method WP_Theme_JSON\\:\\:merge\\(\\) expects WP_Theme_JSON, WP_Theme_JSON_Gutenberg given\\.$#',
Expand All @@ -33,22 +21,10 @@
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$metadata of method WP_Theme_JSON_Gutenberg\\:\\:get_feature_declarations_for_node\\(\\) expects object, array given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$function_name of function _doing_it_wrong expects string, true given\\.$#',
'message' => '#^Parameter \\#1 \\$incoming of method WP_Theme_JSON_Gutenberg\\:\\:merge\\(\\) expects WP_Theme_JSON_Gutenberg, WP_Theme_JSON given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#5 \\$media of function wp_register_style expects string, true given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/client-assets.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$value of method WP_HTTP_Response\\:\\:header\\(\\) expects string, int given\\.$#',
Expand All @@ -61,18 +37,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/class-gutenberg-rest-templates-controller-6-7.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$str of function strtoupper expects string, bool given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/class-gutenberg-token-map-6-7.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#2 \\$value of function setcookie expects string, int given\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../../lib/experimental/sync/class-gutenberg-http-signaling-server.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#5 \\$callback of function add_menu_page expects callable\\(\\)\\: mixed, \'\' given\\.$#',
Expand Down
18 changes: 0 additions & 18 deletions tools/phpstan/baseline/level-6.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/plugin/fonts.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Function gutenberg_add_can_update_block_bindings_editor_setting\\(\\) has parameter \\$editor_settings with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/block-bindings.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Function gutenberg_bootstrap_server_block_bindings_sources\\(\\) has no return type specified\\.$#',
Expand Down Expand Up @@ -397,18 +391,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/class-wp-block-templates-registry.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Function _gutenberg_add_block_template_plugin_attribute\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/compat.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Function _gutenberg_add_block_template_plugin_attribute\\(\\) has parameter \\$block_template with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/compat/wordpress-6.7/compat.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Function gutenberg_post_format_rest_posts_controller\\(\\) has no return type specified\\.$#',
Expand Down
18 changes: 12 additions & 6 deletions tools/phpstan/baseline/level-7.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset \'selectors\' on object\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: offsetAccess.nonOffsetAccessible
'message' => '#^Cannot access offset mixed on object\\.$#',
Expand All @@ -151,12 +145,24 @@
'count' => 2,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method WP_Theme_JSON_Resolver_Gutenberg\\:\\:get_theme_data\\(\\) should return WP_Theme_JSON_Gutenberg but returns WP_Theme_JSON\\|WP_Theme_JSON_Gutenberg\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: return.type
'message' => '#^Method WP_Theme_JSON_Resolver_Gutenberg\\:\\:translate\\(\\) should return array but returns array\\<array\\|string\\>\\|string\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$incoming of method WP_Theme_JSON_Gutenberg\\:\\:merge\\(\\) expects WP_Theme_JSON_Gutenberg, WP_Theme_JSON\\|WP_Theme_JSON_Gutenberg given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../../lib/class-wp-theme-json-resolver-gutenberg.php',
];
$ignoreErrors[] = [
// identifier: argument.type
'message' => '#^Parameter \\#1 \\$obj of function get_object_vars expects object, int\\|WP_Post given\\.$#',
Expand Down
Loading

0 comments on commit 3e4c557

Please sign in to comment.