Skip to content

Commit f0bb3ac

Browse files
authored
Simplify PHPStan settings to eliminate environment-specific errors (#222)
* Remove PHPStan errors * Add generic error about `wp-admin/includes`
1 parent fb52a98 commit f0bb3ac

File tree

5 files changed

+8
-34
lines changed

5 files changed

+8
-34
lines changed

acf.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
}
1414

1515
if ( is_admin() ) {
16-
/** @phpstan-ignore-next-line */ // phpcs:ignore
1716
include_once ABSPATH . 'wp-admin/includes/plugin.php';
1817

1918
// Network activations first since is_plugin_active will return true for network activated plugins, whereas this won't for single.

bin/baseline.neon

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,41 +90,13 @@ parameters:
9090
count: 1
9191
path: ../includes/admin/views/upgrade/notice.php
9292

93-
-
94-
message: '#^Path in include_once\(\) "\./wp\-admin/includes/plugin\.php" is not a file or it does not exist\.$#'
95-
identifier: includeOnce.fileNotFound
96-
count: 1
97-
path: ../includes/api/api-helpers.php
98-
99-
-
100-
message: '#^Path in require_once\(\) "\.//wp\-admin/includes/file\.php" is not a file or it does not exist\.$#'
101-
identifier: requireOnce.fileNotFound
102-
count: 1
103-
path: ../includes/api/api-helpers.php
104-
105-
-
106-
message: '#^Path in require_once\(\) "\.//wp\-admin/includes/image\.php" is not a file or it does not exist\.$#'
107-
identifier: requireOnce.fileNotFound
108-
count: 1
109-
path: ../includes/api/api-helpers.php
110-
111-
-
112-
message: '#^Path in require_once\(\) "\.//wp\-admin/includes/media\.php" is not a file or it does not exist\.$#'
113-
identifier: requireOnce.fileNotFound
114-
count: 1
115-
path: ../includes/api/api-helpers.php
11693

11794
-
11895
message: '#^Offset ''thumb'' on array\{alt\: string, author\: string, authorName\: string, caption\: string, compat\: array, context\: string, date\: int, dateFormatted\: string, \.\.\.\}\|null in isset\(\) does not exist\.$#'
11996
identifier: isset.offset
12097
count: 1
12198
path: ../includes/fields/class-acf-field-gallery.php
12299

123-
-
124-
message: '#^Path in require\(\) "\./wp\-admin/includes/media\.php" is not a file or it does not exist\.$#'
125-
identifier: require.fileNotFound
126-
count: 1
127-
path: ../includes/fields/class-acf-field-wysiwyg.php
128100

129101
-
130102
message: '#^Undefined variable\: \$method$#'

includes/api/api-helpers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,9 +2879,9 @@ function acf_get_valid_terms( $terms = false, $taxonomy = 'category' ) {
28792879
*
28802880
* @since ACF 5.2.3
28812881
*
2882-
* @param $attachment (array) attachment data. Changes based on context
2883-
* @param $field (array) field settings containing restrictions
2884-
* @param context (string) $file is different when uploading / preparing
2882+
* @param array $attachment attachment data. Changes based on context.
2883+
* @param array $field field settings containing restrictions.
2884+
* @param string $context context is different when uploading / preparing.
28852885
* @return $errors (array)
28862886
*/
28872887
function acf_validate_attachment( $attachment, $field, $context = 'prepare' ) {
@@ -3277,7 +3277,7 @@ function acf_is_ajax( $action = '' ) {
32773277
$is_ajax = false;
32783278

32793279
// check if is doing ajax
3280-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
3280+
if ( wp_doing_ajax() ) {
32813281
$is_ajax = true;
32823282
}
32833283

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ includes:
22
- bin/baseline.neon
33
parameters:
44
level: 1
5+
reportUnmatchedIgnoredErrors: false
6+
ignoreErrors:
7+
- '#^Path in (include_once|require_once|require)\(\) ".*wp-admin/includes/.*" is not a file#'
58
paths:
69
- .
710
excludePaths:
@@ -13,5 +16,6 @@ parameters:
1316
- wordpress (?)
1417
- includes/forms/WC_Order.php
1518
bootstrapFiles:
19+
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
1620
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
1721
- bin/phpstan-bootstrap.php

secure-custom-fields.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ function scf_deactivate_other_instances() {
853853
} elseif ( is_plugin_active( 'advanced-custom-fields/acf.php' ) ) {
854854
// Check if the plugin to deactivate is 'advanced-custom-fields/acf.php' but the title is 'Secure Custom Fields'.
855855
if ( ! function_exists( 'get_plugin_data' ) ) {
856-
/** @phpstan-ignore-next-line */ // phpcs:ignore
857856
require_once ABSPATH . 'wp-admin/includes/plugin.php';
858857
}
859858
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_to_deactivate );

0 commit comments

Comments
 (0)