From dd0bedc18a3a8daca6679fa9f398c7e9561e8c2d Mon Sep 17 00:00:00 2001 From: sect Date: Thu, 28 Nov 2024 09:52:12 +0900 Subject: [PATCH 1/2] chore(phpstan): upgrade PHPStan to v1.12.11 --- admin/class-recursivetable.php | 2 +- composer.json | 5 +- composer.lock | 183 +++++++++++------- functions/functions.php | 6 +- includes/admin.php | 6 +- ...ass-google-spreadsheet-to-db-activator.php | 1 + includes/delete.php | 14 +- includes/save.php | 15 +- phpstan.neon.dist | 2 + 9 files changed, 149 insertions(+), 85 deletions(-) diff --git a/admin/class-recursivetable.php b/admin/class-recursivetable.php index 1071efa..41b8d07 100644 --- a/admin/class-recursivetable.php +++ b/admin/class-recursivetable.php @@ -214,7 +214,7 @@ private static function array_to_html_table_recursive( array $arr ): string { global $wpdb; $table = GOOGLE_SS2DB_TABLE_NAME; - $paged = isset( $_GET['paged'] ) ? ( (int) $_GET['paged'] ) : 1; + $paged = filter_input( INPUT_GET, 'paged', FILTER_VALIDATE_INT ) ? filter_input( INPUT_GET, 'paged', FILTER_VALIDATE_INT ) : 1; $limit = 24; $offset = ( $paged - 1 ) * $limit; $countsql = 'SELECT * FROM ' . GOOGLE_SS2DB_TABLE_NAME . ' ORDER BY date DESC'; diff --git a/composer.json b/composer.json index de256af..842112c 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,10 @@ "yoast/phpunit-polyfills": "^2.0", "squizlabs/php_codesniffer": "^3.7", "wp-coding-standards/wpcs": "^3.0", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.12", "szepeviktor/phpstan-wordpress": "^1.3", - "phpstan/extension-installer": "^1.3" + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-deprecation-rules": "^1.2" }, "license": "GPL-3.0+", "authors": [ diff --git a/composer.lock b/composer.lock index 13951c0..61191e7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "daa501fb25f26539c5bde2e99ab4ec6d", + "content-hash": "c2bfa9fb1667f839fb2f0a4c38998eb2", "packages": [ { "name": "firebase/php-jwt", - "version": "v6.10.1", + "version": "v6.10.2", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "500501c2ce893c824c801da135d02661199f60c5" + "reference": "30c19ed0f3264cb660ea496895cfb6ef7ee3653b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/500501c2ce893c824c801da135d02661199f60c5", - "reference": "500501c2ce893c824c801da135d02661199f60c5", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/30c19ed0f3264cb660ea496895cfb6ef7ee3653b", + "reference": "30c19ed0f3264cb660ea496895cfb6ef7ee3653b", "shasum": "" }, "require": { @@ -65,22 +65,22 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.10.1" + "source": "https://github.com/firebase/php-jwt/tree/v6.10.2" }, - "time": "2024-05-18T18:05:11+00:00" + "time": "2024-11-24T11:22:49+00:00" }, { "name": "google/apiclient", - "version": "v2.18.0", + "version": "v2.18.1", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client.git", - "reference": "846f149c9f879449145326dad99ef00bf1d879f3" + "reference": "3f6cb1a970fe2d210823a79de8d5dbae405a9616" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/846f149c9f879449145326dad99ef00bf1d879f3", - "reference": "846f149c9f879449145326dad99ef00bf1d879f3", + "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/3f6cb1a970fe2d210823a79de8d5dbae405a9616", + "reference": "3f6cb1a970fe2d210823a79de8d5dbae405a9616", "shasum": "" }, "require": { @@ -134,22 +134,22 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client/issues", - "source": "https://github.com/googleapis/google-api-php-client/tree/v2.18.0" + "source": "https://github.com/googleapis/google-api-php-client/tree/v2.18.1" }, - "time": "2024-10-16T21:58:58+00:00" + "time": "2024-11-24T13:21:03+00:00" }, { "name": "google/apiclient-services", - "version": "v0.377.0", + "version": "v0.383.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "912727289dd617a97da7d2700debbe81a59cea19" + "reference": "0da092376837d363ef0cfa5ef56e43308f7c3763" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/912727289dd617a97da7d2700debbe81a59cea19", - "reference": "912727289dd617a97da7d2700debbe81a59cea19", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/0da092376837d363ef0cfa5ef56e43308f7c3763", + "reference": "0da092376837d363ef0cfa5ef56e43308f7c3763", "shasum": "" }, "require": { @@ -178,29 +178,29 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.377.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.383.0" }, - "time": "2024-10-14T00:56:24+00:00" + "time": "2024-11-20T01:10:23+00:00" }, { "name": "google/auth", - "version": "v1.42.0", + "version": "v1.43.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "0c25599a91530b5847f129b271c536f75a7563f5" + "reference": "b6a80acd906492086db59aada9196dcfb9c512fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/0c25599a91530b5847f129b271c536f75a7563f5", - "reference": "0c25599a91530b5847f129b271c536f75a7563f5", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/b6a80acd906492086db59aada9196dcfb9c512fe", + "reference": "b6a80acd906492086db59aada9196dcfb9c512fe", "shasum": "" }, "require": { "firebase/php-jwt": "^6.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", - "php": "^8.0", + "php": "^8.1", "psr/cache": "^2.0||^3.0", "psr/http-message": "^1.1||^2.0" }, @@ -238,9 +238,9 @@ "support": { "docs": "https://googleapis.github.io/google-auth-library-php/main/", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.42.0" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.43.0" }, - "time": "2024-08-26T18:33:48+00:00" + "time": "2024-11-07T19:35:20+00:00" }, { "name": "guzzlehttp/guzzle", @@ -370,16 +370,16 @@ }, { "name": "guzzlehttp/promises", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", - "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { @@ -433,7 +433,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -449,7 +449,7 @@ "type": "tidelift" } ], - "time": "2024-07-18T10:29:17+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", @@ -569,16 +569,16 @@ }, { "name": "monolog/monolog", - "version": "3.7.0", + "version": "3.8.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8" + "reference": "32e515fdc02cdafbe4593e30a9350d486b125b67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f4393b648b78a5408747de94fca38beb5f7e9ef8", - "reference": "f4393b648b78a5408747de94fca38beb5f7e9ef8", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/32e515fdc02cdafbe4593e30a9350d486b125b67", + "reference": "32e515fdc02cdafbe4593e30a9350d486b125b67", "shasum": "" }, "require": { @@ -598,12 +598,14 @@ "guzzlehttp/psr7": "^2.2", "mongodb/mongodb": "^1.8", "php-amqplib/php-amqplib": "~2.4 || ^3", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-deprecation-rules": "^1.0", - "phpstan/phpstan-strict-rules": "^1.4", - "phpunit/phpunit": "^10.5.17", + "php-console/php-console": "^3.1.8", + "phpstan/phpstan": "^2", + "phpstan/phpstan-deprecation-rules": "^2", + "phpstan/phpstan-strict-rules": "^2", + "phpunit/phpunit": "^10.5.17 || ^11.0.7", "predis/predis": "^1.1 || ^2", - "ruflin/elastica": "^7", + "rollbar/rollbar": "^4.0", + "ruflin/elastica": "^7 || ^8", "symfony/mailer": "^5.4 || ^6", "symfony/mime": "^5.4 || ^6" }, @@ -654,7 +656,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.7.0" + "source": "https://github.com/Seldaek/monolog/tree/3.8.0" }, "funding": [ { @@ -666,7 +668,7 @@ "type": "tidelift" } ], - "time": "2024-06-28T09:40:51+00:00" + "time": "2024-11-12T13:57:08+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -1417,16 +1419,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -1465,7 +1467,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -1473,7 +1475,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nikic/php-parser", @@ -1653,16 +1655,16 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.6.2", + "version": "v6.7.1", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc" + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc", - "reference": "f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/83448e918bf06d1ed3d67ceb6a985fc266a02fd1", + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1", "shasum": "" }, "require-dev": { @@ -1671,9 +1673,9 @@ "php": "^7.4 || ^8.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.4.1", - "phpstan/phpstan": "^1.10.49", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" }, "suggest": { @@ -1695,9 +1697,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.6.2" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.1" }, - "time": "2024-09-30T07:10:48+00:00" + "time": "2024-11-24T03:57:09+00:00" }, { "name": "phpcsstandards/phpcsextra", @@ -1915,16 +1917,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.6", + "version": "1.12.11", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae" + "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc4d2f145a88ea7141ae698effd64d9df46527ae", - "reference": "dc4d2f145a88ea7141ae698effd64d9df46527ae", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", + "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", "shasum": "" }, "require": { @@ -1969,7 +1971,54 @@ "type": "github" } ], - "time": "2024-10-06T15:03:59+00:00" + "time": "2024-11-17T14:08:01+00:00" + }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82", + "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.12" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.1" + }, + "time": "2024-09-11T15:52:35+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3358,16 +3407,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", "shasum": "" }, "require": { @@ -3434,7 +3483,7 @@ "type": "open_collective" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2024-11-16T12:02:36+00:00" }, { "name": "symfony/polyfill-php73", diff --git a/functions/functions.php b/functions/functions.php index 4fe4135..2049cac 100644 --- a/functions/functions.php +++ b/functions/functions.php @@ -50,7 +50,7 @@ function google_ss2db_options_pagination( int $paged = 1, int $pages = 1, int $r echo '
  • '; } for ( $i = 1; $i <= $pages; $i++ ) { - if ( 1 !== $pages && ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) ) { + if ( ! ( $i >= $paged + $range + 1 || $i <= $paged - $range - 1 ) || $pages <= $showitems ) { echo ( $paged === $i ) ? '
  • ' . $i . '
  • ' : '
  • ' . $i . '
  • '; } } @@ -196,8 +196,8 @@ function google_ss2db_get_value_google_spreadsheet( string $worksheet_id, string /** * Saves data from a Google Spreadsheet to the database. * - * @param array $post_data POST data containing spreadsheet information. - * @return array Contains details of the operation including the database row ID, date, worksheet identifiers, and operation result. + * @param array $post_data POST data containing spreadsheet information. + * @return array Contains details of the operation including the database row ID, date, worksheet identifiers, and operation result. */ function google_ss2db_save_spreadsheet( array $post_data ): array { global $wpdb; diff --git a/includes/admin.php b/includes/admin.php index cb7fb54..9f1721b 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -46,7 +46,8 @@ function google_ss2db_menu(): void { function google_ss2db_admin_styles(): void { $plugin_data = google_ss2db_get_plugin_data(); $plugin_version = $plugin_data['Version']; - wp_enqueue_style( 'admin-options', plugin_dir_url( __DIR__ ) . 'assets/css/admin-options.css?v=' . $plugin_version, array() ); + $version = is_string( $plugin_version ) ? $plugin_version : '1.0.0'; + wp_enqueue_style( 'admin-options', plugin_dir_url( __DIR__ ) . 'assets/css/admin-options.css', array(), $version ); } /** @@ -56,7 +57,8 @@ function google_ss2db_admin_styles(): void { function google_ss2db_admin_scripts(): void { $plugin_data = google_ss2db_get_plugin_data(); $plugin_version = $plugin_data['Version']; - wp_enqueue_script( 'google-ss2db-script', plugin_dir_url( __DIR__ ) . 'assets/js/admin-options.js?v=' . $plugin_version, array( 'jquery' ), null, true ); + $version = is_string( $plugin_version ) ? $plugin_version : '1.0.0'; + wp_enqueue_script( 'google-ss2db-script', plugin_dir_url( __DIR__ ) . 'assets/js/admin-options.js', array( 'jquery' ), $version, true ); wp_localize_script( 'google-ss2db-script', 'google_ss2db_data', diff --git a/includes/class-google-spreadsheet-to-db-activator.php b/includes/class-google-spreadsheet-to-db-activator.php index 4ab535c..a5f9eea 100755 --- a/includes/class-google-spreadsheet-to-db-activator.php +++ b/includes/class-google-spreadsheet-to-db-activator.php @@ -44,6 +44,7 @@ public static function activate(): void { value LONGTEXT NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; + // @phpstan-ignore-next-line require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); update_option( 'google_ss2db_version', $google_ss2db_db_version ); diff --git a/includes/delete.php b/includes/delete.php index 8b1083f..8753b12 100644 --- a/includes/delete.php +++ b/includes/delete.php @@ -29,15 +29,19 @@ * @subpackage Google_Spreadsheet_to_DB/includes */ -require '../../../../wp-load.php'; +require_once dirname( __DIR__, 4 ) . '/wp-load.php'; -if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'google_ss2db' ) || 'POST' !== $_SERVER['REQUEST_METHOD'] || ! isset( $_POST['id'] ) ) { +// Secure input handling with filter_input(). +$nonce = filter_input( INPUT_POST, 'nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); +$request_method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); +$id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); + +if ( ! $nonce || ! wp_verify_nonce( $nonce, 'google_ss2db' ) || 'POST' !== $request_method || ! $id ) { wp_die( 'Our Site is protected!!' ); } -$theid = wp_unslash( $_POST['id'] ); $array = array( - 'id' => $theid, + 'id' => $id, ); global $wpdb; @@ -45,7 +49,7 @@ $return = array( 'res' => $res, - 'id' => wp_unslash( $_POST['id'] ), + 'id' => $id, ); echo json_encode( $return ); diff --git a/includes/save.php b/includes/save.php index a34eeab..ac6ed05 100644 --- a/includes/save.php +++ b/includes/save.php @@ -26,17 +26,22 @@ * @subpackage Google_Spreadsheet_to_DB/includes */ -require '../../../../wp-load.php'; +require_once dirname( __DIR__, 4 ) . '/wp-load.php'; -if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'google_ss2db' ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { +// Sanitize and validate POST data using filter_input(). +$nonce = filter_input( INPUT_POST, 'nonce', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); +$http_referer = filter_input( INPUT_POST, '_wp_http_referer', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); + +if ( ! $nonce || ! wp_verify_nonce( $nonce, 'google_ss2db' ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { wp_die( 'Our Site is protected!!' ); } -$data = google_ss2db_save_spreadsheet( $_POST ); -$data = apply_filters( 'google_ss2db_after_save', $data ); +$sanitized_post_data = array_map( fn( $value ) => is_string( $value ) ? sanitize_text_field( $value ) : $value, $_POST ); +$data = google_ss2db_save_spreadsheet( $sanitized_post_data ); +$data = apply_filters( 'google_ss2db_after_save', $data ); $bool = (bool) $data['result']; -$referer = wp_unslash( $_POST['_wp_http_referer'] ); +$referer = wp_unslash( $http_referer ); $referer = str_replace( '&settings-updated=true', '', $referer ); $referer = $referer . '&ss2dbupdated=' . $bool; wp_redirect( $referer ); diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b6cf2ec..729b24a 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,3 +7,5 @@ parameters: - includes/ bootstrapFiles: - vendor/autoload.php +includes: + - phar://phpstan.phar/conf/bleedingEdge.neon From fc32e27d496f499a399bb7fe8a2326e9a9458434 Mon Sep 17 00:00:00 2001 From: sect Date: Thu, 28 Nov 2024 09:57:06 +0900 Subject: [PATCH 2/2] chore(phpstan): upgrade PHPStan to v2.0 --- composer.json | 12 ++-- composer.lock | 151 +++++++++++++------------------------------------- 2 files changed, 44 insertions(+), 119 deletions(-) diff --git a/composer.json b/composer.json index 842112c..0756026 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "type": "wordpress-plugin", "require": { - "php": ">=5.5", + "php": ">=8.0", "google/apiclient": "^2.16" }, "require-dev": { @@ -19,16 +19,16 @@ "yoast/phpunit-polyfills": "^2.0", "squizlabs/php_codesniffer": "^3.7", "wp-coding-standards/wpcs": "^3.0", - "phpstan/phpstan": "^1.12", - "szepeviktor/phpstan-wordpress": "^1.3", + "phpstan/phpstan": "^2.0", + "szepeviktor/phpstan-wordpress": "2.x-dev", "phpstan/extension-installer": "^1.3", - "phpstan/phpstan-deprecation-rules": "^1.2" + "phpstan/phpstan-deprecation-rules": "^2.0" }, "license": "GPL-3.0+", "authors": [ { - "name": "SECT WEB INTERACTIVE", - "homepage": "https://www.ilovesect.com/" + "name": "sect", + "homepage": "https://github.com/sectsect" } ], "config": { diff --git a/composer.lock b/composer.lock index 61191e7..480bdc6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c2bfa9fb1667f839fb2f0a4c38998eb2", + "content-hash": "d452c69b9a8d1ca486af78cd6c6107f9", "packages": [ { "name": "firebase/php-jwt", @@ -1202,16 +1202,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -1249,7 +1249,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -1265,7 +1265,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" } ], "packages-dev": [ @@ -1917,20 +1917,20 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.11", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733" + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", - "reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6c98c7600fc717b2c78c11ef60040d5b1e359c82", + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.4|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -1971,30 +1971,30 @@ "type": "github" } ], - "time": "2024-11-17T14:08:01+00:00" + "time": "2024-11-17T14:17:00+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", - "version": "1.2.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82" + "reference": "81833b5787e2e8f451b31218875e29e4ed600ab2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/f94d246cc143ec5a23da868f8f7e1393b50eaa82", - "reference": "f94d246cc143ec5a23da868f8f7e1393b50eaa82", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/81833b5787e2e8f451b31218875e29e4ed600ab2", + "reference": "81833b5787e2e8f451b31218875e29e4ed600ab2", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "php": "^7.4 || ^8.0", + "phpstan/phpstan": "^2.0" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^9.5" + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" }, "type": "phpstan-extension", "extra": { @@ -2016,9 +2016,9 @@ "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", "support": { "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", - "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.2.1" + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.0" }, - "time": "2024-09-11T15:52:35+00:00" + "time": "2024-10-26T16:04:11+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3485,108 +3485,31 @@ ], "time": "2024-11-16T12:02:36+00:00" }, - { - "name": "symfony/polyfill-php73", - "version": "v1.31.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, { "name": "szepeviktor/phpstan-wordpress", - "version": "v1.3.5", + "version": "2.x-dev", "source": { "type": "git", "url": "https://github.com/szepeviktor/phpstan-wordpress.git", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7" + "reference": "fab61ad0e3ba963877eea48d29248eb1ae2a3eda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/7f8cfe992faa96b6a33bbd75c7bace98864161e7", - "reference": "7f8cfe992faa96b6a33bbd75c7bace98864161e7", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/fab61ad0e3ba963877eea48d29248eb1ae2a3eda", + "reference": "fab61ad0e3ba963877eea48d29248eb1ae2a3eda", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "php-stubs/wordpress-stubs": "^4.7 || ^5.0 || ^6.0", - "phpstan/phpstan": "^1.10.31", - "symfony/polyfill-php73": "^1.12.0" + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": "^6.6.2", + "phpstan/phpstan": "^2.0" }, "require-dev": { "composer/composer": "^2.1.14", "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "php-parallel-lint/php-parallel-lint": "^1.1", - "phpstan/phpstan-strict-rules": "^1.2", - "phpunit/phpunit": "^8.0 || ^9.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.0", "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" }, @@ -3620,9 +3543,9 @@ ], "support": { "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", - "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v1.3.5" + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/2.x" }, - "time": "2024-06-28T22:27:19+00:00" + "time": "2024-11-17T13:12:31+00:00" }, { "name": "theseer/tokenizer", @@ -3806,11 +3729,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "szepeviktor/phpstan-wordpress": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5" + "php": ">=8.0" }, "platform-dev": {}, "plugin-api-version": "2.6.0"