Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,30 @@ parameters:
# https://phpstan.org/user-guide/rule-levels
level: 5
reportUnmatchedIgnoredErrors: true

# Errors that are intentionally ignored, as opposed to the baseline, which records errors still to be fixed.
ignoreErrors:
# Level 0:
# Return values from action callbacks are discarded by do_action(), but returning one is harmless and lets
# callers and tests know whether the callback did anything. Core has many such callbacks, like _wp_cron() and
# wp_set_up_cross_origin_isolation().
-
message: '#^Action callback returns .+ but should not return anything\.$#'
identifier: return.void

# Level 3:
# WP_REST_Request implements ArrayAccess, and the WordPress stubs declare its offsetSet() with a method-level
# template (`@template TOffset of key-of<T>`, `@param T[TOffset] $value`). PHPStan does not resolve that
# template for an offset write like `$request['context'] = 'edit'`, so every such write is rejected, valid
# ones included, while the equivalent `$request->set_param( 'context', 'edit' )` call is accepted.
#
# This is a false positive which should be fixed in PHPStan: https://github.com/phpstan/phpstan-src/pull/6903
# Once a PHPStan release with that fix is required, remove these entries.
-
message: '#^Cannot assign offset .+ to WP_REST_Request(?:<.+>)?\.$#'
identifier: offsetAssign.dimType
reportUnmatched: false
-
message: '#^WP_REST_Request(?:<.+>)? does not accept .+\.$#'
identifier: offsetAssign.valueType
reportUnmatched: false
7 changes: 0 additions & 7 deletions tools/phpstan/base.neon
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ parameters:
# that lib/ calls. Run `npm run build` before analyzing.
scanDirectories:
- ../../build
ignoreErrors:
# Return values from action callbacks are discarded by do_action(), but returning one is
# harmless and lets callers and tests know whether the callback did anything. Core has many
# such callbacks, like _wp_cron() and wp_set_up_cross_origin_isolation().
-
message: '#^Action callback returns .+ but should not return anything\.$#'
identifier: return.void

services:
# Renders the wp-build templates into valid PHP before they are parsed, in place of the parsers
Expand Down
37 changes: 0 additions & 37 deletions tools/phpstan/baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ parameters:
count: 1
path: ../../lib/compat/wordpress-7.1/block-bindings.php

-
message: '#^Cannot assign offset ''media_type'' to WP_REST_Request\.$#'
identifier: offsetAssign.dimType
count: 1
path: ../../lib/compat/wordpress-7.1/class-gutenberg-rest-attachments-controller-7-1.php

-
message: '#^Cannot assign offset ''mime_type'' to WP_REST_Request\.$#'
identifier: offsetAssign.dimType
count: 1
path: ../../lib/compat/wordpress-7.1/class-gutenberg-rest-attachments-controller-7-1.php

-
message: '#^WP_REST_Request does not accept array\<mixed, mixed\>\.$#'
identifier: offsetAssign.valueType
count: 2
path: ../../lib/compat/wordpress-7.1/class-gutenberg-rest-attachments-controller-7-1.php

-
message: '#^Property WP_Post\:\:\$post_date \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand Down Expand Up @@ -114,25 +96,6 @@ parameters:
count: 1
path: ../../lib/experimental/navigation-theme-opt-in.php

-
message: '#^Cannot assign offset ''_fields'' to WP_REST_Request\<array\<string, mixed\>\>\.$#'
identifier: offsetAssign.dimType
count: 1
path: ../../lib/media/class-gutenberg-rest-attachments-controller.php

-
message: '#^Cannot assign offset ''context'' to WP_REST_Request\<array\<string, mixed\>\>\.$#'
identifier: offsetAssign.dimType
count: 1
path: ../../lib/media/class-gutenberg-rest-attachments-controller.php

-
message: '#^WP_REST_Request\<array\<string, mixed\>\> does not accept string\.$#'
identifier: offsetAssign.valueType
count: 1
path: ../../lib/media/class-gutenberg-rest-attachments-controller.php


-
message: '#^Property WP_Comment\:\:\$comment_author_url \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand Down
Loading