Skip to content
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"squizlabs/php_codesniffer": "3.13.5",
"wp-coding-standards/wpcs": "~3.4.1",
"phpcompatibility/phpcompatibility-wp": "~2.1.3",
"phpstan/phpstan": "2.2.5",
"phpstan/phpstan": "2.2.13",
"phpstan/phpstan-phpunit": "2.0.18",
"yoast/phpunit-polyfills": "^1.1.0"
},
Expand Down
4 changes: 0 additions & 4 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -4848,10 +4848,6 @@ function esc_xml( $text ) {
$safe_text = (string) preg_replace_callback(
$regex,
static function ( $matches ) {
if ( ! isset( $matches[0] ) ) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixes

  4851   Call to function array_key_exists() with 0 and array{0: string, non_cdata_followed_by_cdata: '', 1: '', 2: '', cdata: '', 3: '', 4: '', non_cdata: string, ...}|array{0:  
         string, non_cdata_followed_by_cdata: string, 1: string, 2: string, cdata: non-falsy-string, 3: non-falsy-string, 4: non-falsy-string} will always evaluate to true.       
         🪪  function.alreadyNarrowedType                                                                                                                                          
         at src/wp-includes/formatting.php:4851                                                                                                                                    

return '';
}

if ( isset( $matches['non_cdata'] ) ) {
// escape HTML entities in the non-CDATA Section.
return _wp_specialchars( $matches['non_cdata'], ENT_XML1 );
Expand Down
10 changes: 10 additions & 0 deletions tests/phpstan/baselines/argument.type.neon
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ parameters:
identifier: argument.type
count: 2
path: ../../../src/wp-includes/class-wp-embed.php
-
message: '#^Parameter \#1 \$handle of function curl_getinfo expects resource, \(resource\|false\) given\.$#'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will be fixed upstream with phpstan/phpstan#15185

identifier: argument.type
count: 2
path: ../../../src/wp-includes/class-wp-http-curl.php
-
message: '#^Parameter \#3 \$value of function curl_setopt expects int, string given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -928,6 +933,11 @@ parameters:
identifier: argument.type
count: 1
path: ../../../src/wp-includes/formatting.php
-
message: '#^Parameter \#1 \$finfo of function finfo_file expects resource, resource\|false given\.$#'
identifier: argument.type
count: 2
path: ../../../src/wp-includes/functions.php
-
message: '#^Parameter \#1 \$prefix of function uniqid expects string, int\<0, max\> given\.$#'
identifier: argument.type
Expand Down
5 changes: 0 additions & 5 deletions tests/phpstan/baselines/empty.variable.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ parameters:
identifier: empty.variable
count: 1
path: ../../../src/wp-admin/includes/class-wp-posts-list-table.php
-
message: '#^Variable \$title in empty\(\) always exists and is always falsy\.$#'
identifier: empty.variable
count: 1
path: ../../../src/wp-admin/includes/plugin.php
-
message: '#^Variable \$parent_file in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
Expand Down
20 changes: 10 additions & 10 deletions tests/phpstan/baselines/function.alreadyNarrowedType.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ parameters:
identifier: function.alreadyNarrowedType
count: 2
path: ../../../src/wp-admin/includes/ajax-actions.php
-
message: '#^Call to function is_wp_error\(\) with WP_Error will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../../src/wp-admin/includes/ajax-actions.php
-
message: '#^Call to function method_exists\(\) with ''ParagonIE_Sodium…'' and ''runtime_speed_test'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand All @@ -48,11 +43,6 @@ parameters:
identifier: function.alreadyNarrowedType
count: 1
path: ../../../src/wp-admin/includes/plugin.php
-
message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../../src/wp-includes/block-editor.php
-
message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand All @@ -78,6 +68,16 @@ parameters:
identifier: function.alreadyNarrowedType
count: 1
path: ../../../src/wp-includes/functions.php
-
message: '#^Call to function is_scalar\(\) with string will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 3
path: ../../../src/wp-includes/functions.php
-
message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: ../../../src/wp-includes/functions.php
-
message: '#^Call to function is_array\(\) with array will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand Down
5 changes: 0 additions & 5 deletions tests/phpstan/baselines/if.alwaysFalse.neon
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ parameters:
identifier: if.alwaysFalse
count: 2
path: ../../../src/wp-includes/class-wp-block-processor.php
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
count: 1
path: ../../../src/wp-includes/load.php
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
Expand Down
2 changes: 1 addition & 1 deletion tests/phpstan/baselines/property.notFound.neon
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ parameters:
-
message: '#^Access to an undefined property WP_Theme\:\:\$version\.$#'
identifier: property.notFound
count: 5
count: 6
path: ../../../src/wp-admin/includes/class-wp-debug-data.php
-
message: '#^Access to an undefined property WP_Theme\:\:\$auto_update_forced\.$#'
Expand Down
Loading