Skip to content

Commit e50b2dc

Browse files
committed
Merge branch 'tests/phpstan/level-0' into feat/phpstan
2 parents 9f09845 + 86c9442 commit e50b2dc

13 files changed

+110
-86
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
"env:logs": "node ./tools/local-env/scripts/docker.js logs",
193193
"env:pull": "node ./tools/local-env/scripts/docker.js pull",
194194
"test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.js",
195+
"test:php:stan": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpstan analyse --memory-limit=2G",
195196
"test:php": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit",
196197
"test:coverage": "npm run test:php -- --coverage-html ./coverage/html/ --coverage-php ./coverage/php/report.php --coverage-text=./coverage/text/report.txt",
197198
"test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js",

phpstan.neon.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ parameters:
2626
- # Inner functions arent supported by PHPstan.
2727
message: '#Function wxr_[a-z_]+ not found#'
2828
path: src/wp-admin/includes/export.php
29+
-
30+
identifier: function.inner
31+
path: src/wp-admin/includes/export.php
32+
count: 13
33+
-
34+
identifier: function.inner
35+
path: src/wp-admin/includes/file.php
36+
count: 1
37+
-
38+
identifier: function.inner
39+
path: src/wp-includes/canonical.php
40+
count: 1
2941

3042
# Level 1:
3143
- # These are too noisy at the moment.

src/wp-admin/includes/class-wp-filesystem-ssh2.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ public function size( $file ) {
672672
* Default 0.
673673
*/
674674
public function touch( $file, $time = 0, $atime = 0 ) {
675+
// @phpstan-ignore-next-line
675676
// Not implemented.
676677
}
677678

src/wp-admin/press-this.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function wp_load_press_this() {
2222
403
2323
);
2424
} elseif ( is_plugin_active( $plugin_file ) ) {
25-
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
26-
$wp_press_this = new WP_Press_This_Plugin();
25+
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; // @phpstan-ignore include.fileNotFound
26+
$wp_press_this = new WP_Press_This_Plugin(); // @phpstan-ignore class.notFound
2727
$wp_press_this->html();
2828
} elseif ( current_user_can( 'activate_plugins' ) ) {
2929
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {

src/wp-includes/class-wp-theme-json.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3365,7 +3365,7 @@ public function get_svg_filters( $origins ) {
33653365
* @param array $theme_json The theme.json like structure to inspect.
33663366
* @param array $path Path to inspect.
33673367
* @param bool|array $override Data to compute whether to override the preset.
3368-
* @return bool
3368+
* @return bool|null True if the preset should override the defaults, false if not. Null if the override parameter is invalid.
33693369
*/
33703370
protected static function should_override_preset( $theme_json, $path, $override ) {
33713371
_deprecated_function( __METHOD__, '6.0.0', 'get_metadata_boolean' );
@@ -3400,6 +3400,8 @@ protected static function should_override_preset( $theme_json, $path, $override
34003400

34013401
return true;
34023402
}
3403+
3404+
return null;
34033405
}
34043406

34053407
/**

src/wp-includes/customize/class-wp-customize-background-image-setting.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class WP_Customize_Background_Image_Setting extends WP_Customize_Setting {
2828
* @since 3.4.0
2929
*
3030
* @param mixed $value The value to update. Not used.
31+
* @return bool|void Nothing is returned.
3132
*/
3233
public function update( $value ) {
3334
remove_theme_mod( 'background_image_thumb' );

src/wp-includes/customize/class-wp-customize-filter-setting.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class WP_Customize_Filter_Setting extends WP_Customize_Setting {
2424
* @since 3.4.0
2525
*
2626
* @param mixed $value The value to update.
27+
* @return bool|void Nothing is returned.
2728
*/
2829
public function update( $value ) {}
2930
}

src/wp-includes/customize/class-wp-customize-header-image-setting.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
3232
* @global Custom_Image_Header $custom_image_header
3333
*
3434
* @param mixed $value The value to update.
35+
* @return bool|void Nothing is returned.
3536
*/
3637
public function update( $value ) {
3738
global $custom_image_header;

src/wp-includes/media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4118,7 +4118,7 @@ function get_taxonomies_for_attachments( $output = 'names' ) {
41184118
* false otherwise.
41194119
*/
41204120
function is_gd_image( $image ) {
4121-
if ( $image instanceof GdImage
4121+
if ( $image instanceof GdImage // @phpstan-ignore class.notFound (Only available with PHP8+.)
41224122
|| is_resource( $image ) && 'gd' === get_resource_type( $image )
41234123
) {
41244124
return true;

src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static function get_store( $store_name = 'default' ) {
5656
return;
5757
}
5858
if ( ! isset( static::$stores[ $store_name ] ) ) {
59+
// @phpstan-ignore new.static (In PHPStan 2.x we can enforce with `@phpstan-consistent-constructor`)
5960
static::$stores[ $store_name ] = new static();
6061
// Set the store name.
6162
static::$stores[ $store_name ]->set_name( $store_name );

0 commit comments

Comments
 (0)