Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
f7902b2
tests: configure PHPStan
justlevine Oct 22, 2024
805199c
chore: update config
justlevine Oct 27, 2024
5aad07a
tests: exclude `wp-include/blocks` from PHPStan analysis
justlevine Oct 30, 2024
cc24e27
chore: remove `-v` flag from `analyse` composer command
justlevine Nov 4, 2024
c2da5b6
tests: regenerate PHPStan baselines after rebase
justlevine Nov 4, 2024
8fd0517
tests: exclude additional external libraries to match phpcs.xml.dist
justlevine Nov 4, 2024
cdc3c6d
tmp: bump PHPStan to 2.x
justlevine Feb 1, 2025
9bb36a4
chore: regenerate PHPStan Baselines after rebase
justlevine Feb 21, 2025
6744b39
tests: suppress errors when string is used as `callable`
justlevine Feb 21, 2025
64d5311
chore: regenerate PHPStan Baselines after rebase
justlevine Apr 12, 2025
3746454
chore: regenerate PHPStan baselines after rebase
justlevine May 9, 2025
da39d35
dev: revert PHPStan to v1.x
justlevine May 23, 2025
52375af
ci: add GH workflow for PHPStan
justlevine May 23, 2025
004f70a
chore: regenerate PHPStan baselines after rebase
justlevine May 23, 2025
44c3beb
ci: use verbose PHPStan debugging
justlevine May 23, 2025
8a3775f
chore: regenerate PHPStan baselines after rebase
justlevine May 31, 2025
6589ce9
tests: define PHPStan `dynamicConstantNames`
justlevine May 31, 2025
c2acb6e
tests: Ignore `missingType.return` PHPStan error until `: void` types…
justlevine May 31, 2025
44a62c0
chore: regenerate PHPStan baselines
justlevine May 31, 2025
0e2d031
tests: set PHPStan `treatPhpDocTypesAsCertain` to false
justlevine May 31, 2025
d949a94
chore: regenerate PHPStan baselines
justlevine May 31, 2025
c92201e
chore: regenerate PHPStan baselines
justlevine Jun 1, 2025
d6d59a0
tests: Don't stan deprecated `wp-tinymce.php`
justlevine Jun 10, 2025
3a7f4d4
chore: regenerate PHPStan baselines
justlevine Jun 10, 2025
06f7f92
PHPStan: define additional dynamic constants
justlevine Jun 11, 2025
9ca376e
PHPStan: additional dynamicConstantNames
justlevine Jun 18, 2025
50169b6
chore: regenerate PHPStan baselines
justlevine Jun 18, 2025
fb61258
chore: regenerate PHPStan baselines
justlevine Jun 23, 2025
174afe0
PHPStan: limit memory usage when running `composer analyse`
justlevine Jun 28, 2025
c8645e8
chore: regenerate PHPStan baselines
justlevine Jun 28, 2025
fe5882a
tests: bump PHPStan to v2.x
justlevine Jul 8, 2025
5f43db2
chore: regenerate PHPStan baselines
justlevine Jul 8, 2025
0840486
chore: regenerate baselines
justlevine Jul 11, 2025
8a152d3
Remove some testing on < 7.4.
johnbillion Jul 12, 2025
9125d57
chore: use tabs for `.neon` and update annotation tenses
justlevine Jul 14, 2025
94fca70
PHPStan: restore and baseline inner function smells.
justlevine Jul 14, 2025
87e966a
ci: rename job + fix version targeting
justlevine Jul 14, 2025
1c9cfb9
PHPStan: clarify `dynamicConstantNames`
justlevine Jul 14, 2025
c43413f
chore: regenerate baselines
justlevine Jul 19, 2025
7e71c2f
chore: fix mixed tabs/spaces
justlevine Jul 19, 2025
0069fc5
chore: fix typo in phpstan.neon
justlevine Jul 25, 2025
d5a10d2
chore: regenerate baselines
justlevine Jul 25, 2025
f6af340
chore: bump phpstan to minimum 2.1.19 (bugfix)
justlevine Jul 26, 2025
46d4e72
phpstan: regenerate baselines
justlevine Jul 26, 2025
760d701
phpstan: regenerate baselines after rebase
justlevine Aug 16, 2025
9680162
phpstan: regenerate baselines after rebase
justlevine Oct 24, 2025
2839f28
phpstan: bump max PHP version to check to 80500
justlevine Oct 24, 2025
a4ee081
phpstan: remove unnecessary `WP_CONTENT_DIR` from bootstrap
justlevine Oct 24, 2025
6e2aa00
phpstan: ignore `wp-includes.user`
justlevine Oct 24, 2025
020f347
phpstan: update excludePaths
justlevine Oct 24, 2025
9f09845
phpstan: regenerate baselines
justlevine Oct 24, 2025
86c9442
tests: phpstan level 0
justlevine Oct 25, 2025
e50b2dc
Merge branch 'tests/phpstan/level-0' into feat/phpstan
justlevine Oct 25, 2025
8ea09de
chore: post-merge cleanup
justlevine Oct 25, 2025
0308f9e
tests: phpstan level 0
justlevine Nov 7, 2025
5ccfa1c
Merge branch 'tests/phpstan/level-0' into feat/phpstan
justlevine Nov 7, 2025
79b737b
chore: regenerate baselines
justlevine Nov 7, 2025
e169af4
Merge branch 'trunk' into feat/phpstan
justlevine Jan 16, 2026
b427ca6
Merge branch 'trunk' into tests/phpstan/level-0
justlevine Jan 16, 2026
a741131
chore: phpstan v2 and post merge cleanup
justlevine Jan 16, 2026
88c5426
chore: cleanup readme
justlevine Jan 16, 2026
03b4080
tests: remove unnecessary @phpstan-ignore
justlevine Jan 16, 2026
cd1149a
docs: add `never|void` return type to `wp_die()`
justlevine Jan 16, 2026
aec7e74
ci: run `build:dev`
justlevine Jan 16, 2026
acfeb8d
Merge branch 'trunk' into tests/phpstan/level-0
westonruter Feb 12, 2026
d429181
Update src/wp-includes/functions.php
justlevine Feb 12, 2026
de6d304
Update tests/phpstan/bootstrap.php
justlevine Feb 12, 2026
d43edb1
Update tests/phpstan/README.md
justlevine Feb 12, 2026
8e5e8b0
Update .github/workflows/php-static-analysis.yml
justlevine Feb 12, 2026
75c8c54
Merge branch 'trunk' into tests/phpstan/level-0
justlevine Feb 12, 2026
4c255e5
PHPStan: Use explicit paths to avoid hanging on wp-content traversal
westonruter Feb 16, 2026
522147a
Remove excludePaths for non-PHP directories since files already excluded
westonruter Feb 16, 2026
f77df14
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Feb 16, 2026
baf4516
Address issues with class-wp-html-processor.php which required it to …
westonruter Feb 16, 2026
1603823
Fix return types for core themes
westonruter Feb 16, 2026
367af1c
Add variable return type for WP_Theme::get()
westonruter Feb 16, 2026
ae6c4b6
Ensure Customizer setting exists before setting transport to postMessage
westonruter Feb 16, 2026
9d178c6
Pass empty strings instead of null in twenty_twenty_one_generate_css()
westonruter Feb 16, 2026
b1005dc
Ensure Twenty_Twenty_One_SVG_Icons::get_svg() always returns string v…
westonruter Feb 16, 2026
f95668e
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Feb 16, 2026
2f72407
Fix return types for Customize setting update methods
westonruter Feb 16, 2026
22370b6
Update return value for WP_Customize_Background_Image_Setting::update()
westonruter Feb 16, 2026
199f15f
Use phpstan as composer script name
westonruter Feb 16, 2026
ec446a1
Update phpstan as script name in docs
westonruter Feb 16, 2026
420731d
Rename test:php:stan to typecheck:php
westonruter Feb 16, 2026
e0398cd
Declare 7.0.0 as the verison which introduced PHPStan
westonruter Feb 16, 2026
8132f48
Fix paths in readme
westonruter Feb 16, 2026
9ebcf81
Use US spelling of 'analyze' for consistency with the rest of the cod…
westonruter Feb 16, 2026
c87e560
Add baseline.php to list of files which triggers the workflow
westonruter Feb 16, 2026
ee31281
Fix grammar typo in readme
westonruter Feb 16, 2026
1c1cb16
Use same version of actions/cache as rest of codebase
westonruter Feb 16, 2026
cc01268
CI: Optimize PHP Static Analysis by caching Gutenberg build
westonruter Feb 16, 2026
77d9403
Improve placement and formatting of phpstan-return
westonruter Feb 17, 2026
61f8a11
Fix wp_insert_user() so PHPStan won't hang
westonruter Feb 17, 2026
fd8f672
Fix handling of ArrayAccess since PHPStan still would hang
westonruter Feb 17, 2026
512e368
Revert now-unnecessary change since $userdata is always an array
westonruter Feb 17, 2026
dd0727f
Update tests/phpunit/tests/user.php
justlevine Feb 17, 2026
dada996
Add assertion for warning
westonruter Feb 17, 2026
b883096
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Feb 17, 2026
646edd0
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Feb 18, 2026
03b9766
Update package.json
justlevine Feb 18, 2026
7b9c9b1
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Feb 18, 2026
935e7e2
Replace phpstan-ignore-next-line comment with returning false
westonruter Feb 18, 2026
34d5a05
Add isset.variable error suppression for extracted var
westonruter Feb 18, 2026
4513d92
CI: Report PHPStan errors as warnings in reusable workflow
westonruter Feb 18, 2026
6a46b90
Build: Add phpstan task and include it in precommit:php
westonruter Feb 18, 2026
18ecd38
Disable reportUnmatchedIgnoredErrors to allow ignoring errors for str…
westonruter Feb 18, 2026
6d7f578
Revert reportUnmatchedIgnoredErrors and ignoring isset.variable in fa…
westonruter Feb 18, 2026
05a968f
Invoke PHPStan via composer and remove phpstan-ignore comment to test
westonruter Feb 18, 2026
f3990da
Restore phpstan-ignore comment
westonruter Feb 18, 2026
57d6d90
Remove Gutenberg cache for initial commit
westonruter Feb 18, 2026
4486d82
Rename workflows to be specific for PHPStan
westonruter Feb 18, 2026
88d619b
Pin phpstan at latest version
westonruter Feb 19, 2026
2a1c830
Merge branch 'trunk' into tests/phpstan/level-0
westonruter Feb 19, 2026
12dc127
Remove redundant paths in scanDirectories
westonruter Feb 19, 2026
83246de
Fix return description for wp_die()
westonruter Feb 19, 2026
5cb43a0
Merge branch 'tests/phpstan/level-0' of https://github.com/justlevine…
westonruter Feb 20, 2026
05da415
Merge branch 'trunk' into feat/phpstan
westonruter Feb 20, 2026
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
24 changes: 22 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ includes:

# The baseline file includes preexisting errors in the codebase that should be ignored.
# https://phpstan.org/user-guide/baseline
- tests/phpstan/baseline.php
- tests/phpstan/baseline.php # level 0.
- tests/phpstan/baseline/level-1.php
- tests/phpstan/baseline/level-2.php
- tests/phpstan/baseline/level-3.php
- tests/phpstan/baseline/level-4.php
- tests/phpstan/baseline/level-5.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justlevine How were these generated? It seems level-2.php omits the errors from level 1? And level-3.php omits the errors from level 2, and so on? When I run composer phpstan -- --level=3 --generate-baseline=tests/phpstan/baseline/level-3.php it includes errors from levels 1-3.

- tests/phpstan/baseline/level-6.php

parameters:
# https://phpstan.org/user-guide/rule-levels
level: 0
level: 6
reportUnmatchedIgnoredErrors: true

ignoreErrors:
Expand All @@ -34,3 +40,17 @@ parameters:
identifier: function.inner
path: src/wp-includes/canonical.php
count: 1

# Level 1:
- # These are too noisy at the moment.
message: '#Variable \$[a-zA-Z0-9_]+ might not be defined\.#'

# Level 2:
- # Callable-strings are used as callables in WordPress.
message: '#Default value of the parameter .* is incompatible with type callable.*#'

# Level 6:
- # WPCS syntax for iterable types is not supported.
identifier: missingType.iterableValue
- # Too noisy until `void` return types are allowed.
identifier: missingType.return
Comment on lines +55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now allowed!

125 changes: 125 additions & 0 deletions tests/phpstan/baseline/level-1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^Call to function compact\\(\\) contains possibly undefined variable \\$comment_author\\.$#',
'identifier' => 'variable.undefined',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/ajax-actions.php',
];
$ignoreErrors[] = [
'message' => '#^Call to function compact\\(\\) contains possibly undefined variable \\$comment_author_email\\.$#',
'identifier' => 'variable.undefined',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/ajax-actions.php',
];
$ignoreErrors[] = [
'message' => '#^Call to function compact\\(\\) contains possibly undefined variable \\$comment_author_url\\.$#',
'identifier' => 'variable.undefined',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/ajax-actions.php',
];
$ignoreErrors[] = [
'message' => '#^Call to function compact\\(\\) contains possibly undefined variable \\$user_id\\.$#',
'identifier' => 'variable.undefined',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/ajax-actions.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$_POST in isset\\(\\) always exists and is not nullable\\.$#',
'identifier' => 'isset.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/class-custom-image-header.php',
];
$ignoreErrors[] = [
'message' => '#^Constructor of class WP_Filesystem_Direct has an unused parameter \\$arg\\.$#',
'identifier' => 'constructor.unusedParameter',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/class-wp-filesystem-direct.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$class in empty\\(\\) always exists and is always falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/class-wp-posts-list-table.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$_POST in isset\\(\\) always exists and is not nullable\\.$#',
'identifier' => 'isset.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/includes/media.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$parent_file in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-admin/themes.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$addl_path in empty\\(\\) always exists and is always falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/canonical.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$namespace in isset\\(\\) always exists and is not nullable\\.$#',
'identifier' => 'isset.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wp-block-parser.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$block_type in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wp-block-supports.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$loader in isset\\(\\) always exists and is not nullable\\.$#',
'identifier' => 'isset.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wp-oembed.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$search in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wp-query.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$status_type_clauses in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wp-query.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$modes_str in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/class-wpdb.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$deprecated in empty\\(\\) always exists and is always falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/pluggable.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$schema in empty\\(\\) is never defined\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$the_parent in empty\\(\\) always exists and is not falsy\\.$#',
'identifier' => 'empty.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/taxonomy.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$s in isset\\(\\) is never defined\\.$#',
'identifier' => 'isset.variable',
'count' => 1,
'path' => __DIR__ . '/../../../src/wp-includes/template.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
Loading
Loading