Skip to content

Commit d8871f3

Browse files
committed
Build/Test Tools: Raise the PHPStan rule level to 2.
This rule level includes: > unknown methods checked on all expressions (not just `$this`), validating PHPDocs Baselines are regenerated for errors at this level. Developed in #12852. Follow-up to r61699, r63019. Props westonruter, apermo. See #64680. git-svn-id: https://develop.svn.wordpress.org/trunk@63020 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e9e0be1 commit d8871f3

20 files changed

Lines changed: 1740 additions & 1 deletion

‎phpstan.neon.dist‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,33 @@ includes:
2222
# Regenerate with `composer phpstan:baselines`, which rewrites both the files
2323
# and the list between the markers. Do not edit that list by hand.
2424
# phpstan:baselines start
25+
- tests/phpstan/baselines/arguments.count.neon
26+
- tests/phpstan/baselines/binaryOp.invalid.neon
27+
- tests/phpstan/baselines/class.nameCase.neon
28+
- tests/phpstan/baselines/class.notFound.neon
2529
- tests/phpstan/baselines/empty.variable.neon
30+
- tests/phpstan/baselines/encapsedStringPart.nonString.neon
31+
- tests/phpstan/baselines/greater.invalid.neon
2632
- tests/phpstan/baselines/isset.variable.neon
33+
- tests/phpstan/baselines/method.nonObject.neon
34+
- tests/phpstan/baselines/method.notFound.neon
35+
- tests/phpstan/baselines/parameter.defaultValue.neon
36+
- tests/phpstan/baselines/parameter.notFound.neon
37+
- tests/phpstan/baselines/parameter.phpDocType.neon
38+
- tests/phpstan/baselines/parameter.unresolvableType.neon
39+
- tests/phpstan/baselines/property.nonObject.neon
40+
- tests/phpstan/baselines/property.notFound.neon
41+
- tests/phpstan/baselines/property.private.neon
42+
- tests/phpstan/baselines/property.protected.neon
43+
- tests/phpstan/baselines/return.missing.neon
44+
- tests/phpstan/baselines/staticClassAccess.privateMethod.neon
45+
- tests/phpstan/baselines/varTag.noVariable.neon
2746
- tests/phpstan/baselines/variable.undefined.neon
2847
# phpstan:baselines end
2948

3049
parameters:
3150
# https://phpstan.org/user-guide/rule-levels
32-
level: 1
51+
level: 2
3352
reportUnmatchedIgnoredErrors: true
3453

3554
# The following ignored errors are not intended to be fixed, as distinct from the baselines
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# PHPStan baseline for the `arguments.count` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/arguments.count
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=arguments.count
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Method WP_List_Table\:\:display_rows\(\) invoked with 2 parameters, 0 required\.$#'
23+
identifier: arguments.count
24+
count: 1
25+
path: ../../../src/wp-admin/includes/ajax-actions.php
26+
-
27+
message: '#^Method WP_List_Table\:\:single_row\(\) invoked with 2 parameters, 1 required\.$#'
28+
identifier: arguments.count
29+
count: 2
30+
path: ../../../src/wp-admin/includes/ajax-actions.php
31+
-
32+
message: '#^Method WP_List_Table\:\:single_row\(\) invoked with 3 parameters, 1 required\.$#'
33+
identifier: arguments.count
34+
count: 1
35+
path: ../../../src/wp-admin/includes/ajax-actions.php
36+
-
37+
message: '#^Method WP_Upgrader_Skin\:\:before\(\) invoked with 1 parameter, 0 required\.$#'
38+
identifier: arguments.count
39+
count: 2
40+
path: ../../../src/wp-admin/includes/class-plugin-upgrader.php
41+
-
42+
message: '#^Method WP_Upgrader_Skin\:\:before\(\) invoked with 1 parameter, 0 required\.$#'
43+
identifier: arguments.count
44+
count: 2
45+
path: ../../../src/wp-admin/includes/class-theme-upgrader.php
46+
-
47+
message: '#^Method WP_List_Table\:\:display\(\) invoked with 1 parameter, 0 required\.$#'
48+
identifier: arguments.count
49+
count: 1
50+
path: ../../../src/wp-admin/includes/meta-boxes.php
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# PHPStan baseline for the `binaryOp.invalid` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/binaryOp.invalid
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=binaryOp.invalid
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Binary operation "/" between string and 2 results in an error\.$#'
23+
identifier: binaryOp.invalid
24+
count: 2
25+
path: ../../../src/wp-content/themes/twentytwenty/functions.php
26+
-
27+
message: '#^Binary operation "\+" between array\<int\<0, max\>\|WP_Comment\>\|int\<1, max\> and 1 results in an error\.$#'
28+
identifier: binaryOp.invalid
29+
count: 1
30+
path: ../../../src/wp-includes/comment.php
31+
-
32+
message: '#^Binary operation "\+" between string and int results in an error\.$#'
33+
identifier: binaryOp.invalid
34+
count: 1
35+
path: ../../../src/wp-includes/user.php
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PHPStan baseline for the `class.nameCase` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/class.nameCase
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=class.nameCase
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Class MO referenced with incorrect case\: Mo\.$#'
23+
identifier: class.nameCase
24+
count: 1
25+
path: ../../../src/wp-includes/class-wp-locale-switcher.php
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# PHPStan baseline for the `class.notFound` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/class.notFound
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=class.notFound
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Property WP_Filesystem_FTPext\:\:\$link has unknown class FTP\\Connection as its type\.$#'
23+
identifier: class.notFound
24+
count: 1
25+
path: ../../../src/wp-admin/includes/class-wp-filesystem-ftpext.php
26+
-
27+
message: '#^Function _crop_image_resource\(\) has invalid return type GdImage\.$#'
28+
identifier: class.notFound
29+
count: 1
30+
path: ../../../src/wp-admin/includes/image-edit.php
31+
-
32+
message: '#^Function _flip_image_resource\(\) has invalid return type GdImage\.$#'
33+
identifier: class.notFound
34+
count: 1
35+
path: ../../../src/wp-admin/includes/image-edit.php
36+
-
37+
message: '#^Function _rotate_image_resource\(\) has invalid return type GdImage\.$#'
38+
identifier: class.notFound
39+
count: 1
40+
path: ../../../src/wp-admin/includes/image-edit.php
41+
-
42+
message: '#^Parameter \$img of function _crop_image_resource\(\) has invalid type GdImage\.$#'
43+
identifier: class.notFound
44+
count: 1
45+
path: ../../../src/wp-admin/includes/image-edit.php
46+
-
47+
message: '#^Parameter \$img of function _flip_image_resource\(\) has invalid type GdImage\.$#'
48+
identifier: class.notFound
49+
count: 1
50+
path: ../../../src/wp-admin/includes/image-edit.php
51+
-
52+
message: '#^Parameter \$img of function _rotate_image_resource\(\) has invalid type GdImage\.$#'
53+
identifier: class.notFound
54+
count: 1
55+
path: ../../../src/wp-admin/includes/image-edit.php
56+
-
57+
message: '#^Function load_image_to_edit\(\) has invalid return type GdImage\.$#'
58+
identifier: class.notFound
59+
count: 1
60+
path: ../../../src/wp-admin/includes/image.php
61+
-
62+
message: '#^Call to method html\(\) on an unknown class WP_Press_This_Plugin\.$#'
63+
identifier: class.notFound
64+
count: 1
65+
path: ../../../src/wp-admin/press-this.php
66+
-
67+
message: '#^Method WP_Image_Editor_GD\:\:_resize\(\) has invalid return type GdImage\.$#'
68+
identifier: class.notFound
69+
count: 1
70+
path: ../../../src/wp-includes/class-wp-image-editor-gd.php
71+
-
72+
message: '#^Parameter \$image of method WP_Image_Editor_GD\:\:_save\(\) has invalid type GdImage\.$#'
73+
identifier: class.notFound
74+
count: 1
75+
path: ../../../src/wp-includes/class-wp-image-editor-gd.php
76+
-
77+
message: '#^Property WP_Image_Editor_GD\:\:\$image has unknown class GdImage as its type\.$#'
78+
identifier: class.notFound
79+
count: 1
80+
path: ../../../src/wp-includes/class-wp-image-editor-gd.php
81+
-
82+
message: '#^Function wp_imagecreatetruecolor\(\) has invalid return type GdImage\.$#'
83+
identifier: class.notFound
84+
count: 1
85+
path: ../../../src/wp-includes/media.php
86+
-
87+
message: '#^Parameter \$image of function is_gd_image\(\) has invalid type GdImage\.$#'
88+
identifier: class.notFound
89+
count: 1
90+
path: ../../../src/wp-includes/media.php
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PHPStan baseline for the `encapsedStringPart.nonString` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/encapsedStringPart.nonString
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=encapsedStringPart.nonString
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Part \$form_fields\[''_final''\] \(non\-empty\-array\<string, mixed\>\) of encapsed string cannot be cast to string\.$#'
23+
identifier: encapsedStringPart.nonString
24+
count: 1
25+
path: ../../../src/wp-admin/includes/media.php
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# PHPStan baseline for the `greater.invalid` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/greater.invalid
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=greater.invalid
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Comparison operation "\>" between \*NEVER\* and 0 results in an error\.$#'
23+
identifier: greater.invalid
24+
count: 1
25+
path: ../../../src/wp-admin/includes/upgrade.php
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# PHPStan baseline for the `method.nonObject` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/method.nonObject
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=method.nonObject
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Cannot call method inline_edit\(\) on WP_List_Table\|false\.$#'
23+
identifier: method.nonObject
24+
count: 1
25+
path: ../../../src/wp-admin/edit-tags.php
26+
-
27+
message: '#^Cannot call method inline_edit\(\) on WP_List_Table\|false\.$#'
28+
identifier: method.nonObject
29+
count: 1
30+
path: ../../../src/wp-admin/edit.php
31+
-
32+
message: '#^Cannot call method embed_scripts\(\) on WP_List_Table\|false\.$#'
33+
identifier: method.nonObject
34+
count: 1
35+
path: ../../../src/wp-admin/erase-personal-data.php
36+
-
37+
message: '#^Cannot call method process_bulk_action\(\) on WP_List_Table\|false\.$#'
38+
identifier: method.nonObject
39+
count: 1
40+
path: ../../../src/wp-admin/erase-personal-data.php
41+
-
42+
message: '#^Cannot call method embed_scripts\(\) on WP_List_Table\|false\.$#'
43+
identifier: method.nonObject
44+
count: 1
45+
path: ../../../src/wp-admin/export-personal-data.php
46+
-
47+
message: '#^Cannot call method process_bulk_action\(\) on WP_List_Table\|false\.$#'
48+
identifier: method.nonObject
49+
count: 1
50+
path: ../../../src/wp-admin/export-personal-data.php
51+
-
52+
message: '#^Cannot call method theme_installer_single\(\) on WP_List_Table\|false\.$#'
53+
identifier: method.nonObject
54+
count: 1
55+
path: ../../../src/wp-admin/includes/theme-install.php
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# PHPStan baseline for the `method.notFound` errors in WordPress core.
2+
#
3+
# https://phpstan.org/error-identifiers/method.notFound
4+
#
5+
# Each entry is scoped to a single file and carries an exact occurrence count,
6+
# so that a new instance is reported as a new error rather than being absorbed
7+
# silently. Fixing an occurrence therefore means decrementing or removing its
8+
# entry here as part of the same change.
9+
#
10+
# The goal is to empty this file and delete it, along with the `includes` entry
11+
# for it in phpstan.neon.dist.
12+
#
13+
# Generated by `composer phpstan:baselines`. Do not edit by hand; regenerate with
14+
#
15+
# composer phpstan:baselines -- --identifier=method.notFound
16+
#
17+
# which reruns the analysis with this file suppressed so the errors surface again.
18+
19+
parameters:
20+
ignoreErrors:
21+
-
22+
message: '#^Call to an undefined method WP_Upgrader\:\:get_name_for_update\(\)\.$#'
23+
identifier: method.notFound
24+
count: 1
25+
path: ../../../src/wp-admin/includes/class-language-pack-upgrader-skin.php
26+
-
27+
message: '#^Call to an undefined method WP_Upgrader\:\:plugin_info\(\)\.$#'
28+
identifier: method.notFound
29+
count: 1
30+
path: ../../../src/wp-admin/includes/class-plugin-installer-skin.php
31+
-
32+
message: '#^Call to an undefined method WP_Upgrader\:\:plugin_info\(\)\.$#'
33+
identifier: method.notFound
34+
count: 1
35+
path: ../../../src/wp-admin/includes/class-plugin-upgrader-skin.php
36+
-
37+
message: '#^Call to an undefined method WP_Upgrader\:\:theme_info\(\)\.$#'
38+
identifier: method.notFound
39+
count: 1
40+
path: ../../../src/wp-admin/includes/class-theme-installer-skin.php
41+
-
42+
message: '#^Call to an undefined method WP_Upgrader\:\:theme_info\(\)\.$#'
43+
identifier: method.notFound
44+
count: 1
45+
path: ../../../src/wp-admin/includes/class-theme-upgrader-skin.php

0 commit comments

Comments
 (0)