Skip to content

Commit be727ab

Browse files
committed
Upgraded phpstan from v1 to v2
1 parent 1355ed5 commit be727ab

11 files changed

Lines changed: 20 additions & 32 deletions

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
}
2020
],
2121
"require-dev": {
22-
"szepeviktor/phpstan-wordpress": "^1",
22+
"szepeviktor/phpstan-wordpress": "^2",
2323
"phpstan/extension-installer": "^1",
24-
"phpstan/phpstan": "^1",
24+
"phpstan/phpstan": "^2",
2525
"php-stubs/wordpress-stubs": "^6",
2626
"wp-coding-standards/wpcs": "^3",
2727
"dealerdirect/phpcodesniffer-composer-installer": "^1",
@@ -59,4 +59,4 @@
5959
],
6060
"zip": "mkdir -p build && zip -X -r build/$(basename $(pwd)).zip . -x '*.git*' 'node_modules/*' '.*' '*/.git*' '*/.DS_Store' 'vendor/**/.DS_Store' 'vendor/bin/*' 'CODE_OF_CONDUCT.md' 'CONTRIBUTING.md' 'ISSUE_TEMPLATE.md' 'PULL_REQUEST_TEMPLATE.md' 'CLAUDE.md' '*.dist' '*.yml' '*.neon' 'composer.*' 'package.json' 'package-lock.json' 'dev-helpers**' 'build**' 'wporg-assets**' 'test-tools**' 'docs/*' 'phpunit**' 'phpstan-bootstrap.php' 'phpcompat-tools**'"
6161
}
62-
}
62+
}

includes/admin/class-settings-wizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function process_step() {
166166
}
167167

168168
$this->current_step = $this->get_current_step();
169-
$action = isset( $_POST['wizard_action'] ) ? sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
169+
$action = sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
170170

171171
switch ( $action ) {
172172
case 'next_step':

includes/admin/class-settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ private function validate_freemius_plugins_for_save( array $settings ): array {
832832
}
833833

834834
return array(
835-
'plugins' => array_values( $persisted_plugins ),
835+
'plugins' => $persisted_plugins,
836836
'errors' => $errors,
837837
);
838838
}

includes/admin/settings/class-settings-api.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,11 +728,7 @@ public function settings_defaults() {
728728
}
729729
}
730730

731-
$upgraded_settings = $this->upgraded_settings;
732-
733-
if ( false !== $upgraded_settings ) {
734-
$options = array_merge( $options, $upgraded_settings );
735-
}
731+
$options = array_merge( $options, $this->upgraded_settings );
736732

737733
/**
738734
* Filters the default settings array.

includes/admin/settings/class-settings-sanitize.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public function sanitize_sensitive_field( $value, $key ) {
288288
/**
289289
* Sanitize repeater field.
290290
*
291-
* @param array $value Array of repeater values.
291+
* @param mixed $value Array of repeater values (may be non-array from form data).
292292
* @param array $field Field configuration array.
293293
* @return array Sanitized array
294294
*/
@@ -418,7 +418,7 @@ public static function str_putcsv( $input_array, $delimiter = ',', $enclosure =
418418
break;
419419
// Make sure sprintf has a good datatype to work with.
420420
case 'integer':
421-
$sp_format = '%i';
421+
$sp_format = '%d';
422422
break;
423423
case 'double':
424424
$sp_format = '%0.2f';

includes/admin/settings/class-settings-wizard-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function process_step() {
341341
// Initialise the current step based on the URL or stored option before processing the action.
342342
$this->current_step = $this->get_current_step();
343343

344-
$action = isset( $_POST['wizard_action'] ) ? sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) ) : '';
344+
$action = sanitize_text_field( wp_unslash( $_POST['wizard_action'] ) );
345345

346346
switch ( $action ) {
347347
case 'next_step':

includes/admin/settings/js/settings-admin-scripts.min.js

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/kit/class-kit-credential-hooks.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ public function maybe_delete_credentials( $error, $client_id ): void {
7676
return;
7777
}
7878

79-
$code = 0;
80-
if ( $error instanceof \WP_Error ) {
81-
$code = (int) $error->get_error_data( 'convertkit_api_error' );
82-
}
79+
$code = (int) $error->get_error_data( 'convertkit_api_error' );
8380

8481
// Only count confirmed invalid token responses.
8582
if ( 401 !== $code ) {

includes/util/class-hook-registry.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,17 @@ class Hook_Registry {
3636
*
3737
* @return bool True if registered, false if duplicate or invalid hook.
3838
*/
39-
public static function register( $hook_type, $hook_name, $callback, $priority = 10, $args = 1 ) {
39+
public static function register( string $hook_type, string $hook_name, callable $callback, int $priority = 10, int $args = 1 ): bool {
4040
if ( ! in_array( $hook_type, array( 'action', 'filter' ), true ) ) {
4141
return false;
4242
}
43-
if ( ! is_string( $hook_name ) || empty( trim( $hook_name ) ) ) {
43+
if ( empty( trim( $hook_name ) ) ) {
4444
return false;
4545
}
46-
if ( ! is_callable( $callback ) ) {
46+
if ( $priority < 0 ) {
4747
return false;
4848
}
49-
if ( ! is_int( $priority ) || $priority < 0 ) {
50-
return false;
51-
}
52-
if ( ! is_int( $args ) || $args < 1 ) {
49+
if ( $args < 1 ) {
5350
return false;
5451
}
5552

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
"phpstan-baseline.neon"
2828
],
2929
"devDependencies": {
30-
"@wordpress/prettier-config": "^4.40.0",
30+
"@wordpress/prettier-config": "^4.42.0",
3131
"@wordpress/scripts": "^31",
3232
"clean-css-cli": "^5.6.3",
3333
"rtlcss": "^4.3.0",
34-
"terser": "^5.46.0"
34+
"terser": "^5.46.1"
3535
},
3636
"dependencies": {
37-
"@wordpress/icons": "^11.7.0",
37+
"@wordpress/icons": "^12.0.0",
3838
"clsx": "^2.1.1",
3939
"uuid": "^13.0.0"
4040
}

0 commit comments

Comments
 (0)