diff --git a/classes/Collector_Assets.php b/classes/Collector_Assets.php index 3d1039b6..a71bb742 100644 --- a/classes/Collector_Assets.php +++ b/classes/Collector_Assets.php @@ -257,8 +257,6 @@ public function process() { } /** - * Undocumented function - * * @return array|null * @phpstan-return arraygetMethod( 'get_marked_for_enqueue' ); diff --git a/collectors/environment.php b/collectors/environment.php index 8511318c..abab2900 100644 --- a/collectors/environment.php +++ b/collectors/environment.php @@ -56,7 +56,7 @@ protected static function get_error_levels( $error_reporting ) { 'E_RECOVERABLE_ERROR' => 4096, 'E_DEPRECATED' => 8192, 'E_USER_DEPRECATED' => 16384, - 'E_ALL' => 30719, + 'E_ALL' => E_ALL, ); $levels = array_fill_keys( array_keys( $constants ), false ); @@ -84,9 +84,6 @@ public function process() { 'key_buffer_size' => true, # Key cache size limit 'max_allowed_packet' => false, # Individual query size limit 'max_connections' => false, # Max number of client connections - 'query_cache_limit' => true, # Individual query cache size limit - 'query_cache_size' => true, # Total cache size limit - 'query_cache_type' => 'ON', # Query cache on or off 'innodb_buffer_pool_size' => false, # The amount of memory allocated to the InnoDB buffer pool ); @@ -94,13 +91,7 @@ public function process() { $dbq = QM_Collectors::get( 'db_queries' ); if ( $dbq ) { - if ( method_exists( $dbq->wpdb, 'db_version' ) ) { - $server = $dbq->wpdb->db_version(); - // query_cache_* deprecated since MySQL 5.7.20 - if ( version_compare( $server, '5.7.20', '>=' ) ) { - unset( $mysql_vars['query_cache_limit'], $mysql_vars['query_cache_size'], $mysql_vars['query_cache_type'] ); - } - } + $server = $dbq->wpdb->db_version(); // phpcs:disable /** @var array|null */ @@ -131,10 +122,8 @@ public function process() { $client_version = null; } - $server_version = self::get_server_version( $dbq->wpdb ); - $info = array( - 'server-version' => $server_version, + 'server-version' => $dbq->wpdb->db_server_info(), 'extension' => $extension, 'client-version' => $client_version, 'user' => $dbq->wpdb->dbuser, @@ -262,28 +251,6 @@ public function get_extension_version( $extension ) { return $version; } - /** - * @param wpdb $db - * @return string - */ - protected static function get_server_version( wpdb $db ) { - $version = null; - - if ( method_exists( $db, 'db_server_info' ) ) { - $version = $db->db_server_info(); - } - - if ( ! $version ) { - $version = $db->get_var( 'SELECT VERSION()' ); - } - - if ( ! $version ) { - $version = __( 'Unknown', 'query-monitor' ); - } - - return $version; - } - /** * @return string */ diff --git a/collectors/php_errors.php b/collectors/php_errors.php index 9dd4ae6d..d581d72b 100644 --- a/collectors/php_errors.php +++ b/collectors/php_errors.php @@ -213,11 +213,11 @@ public function error_handler( $errno, $message, $file = null, $line = null, $co $type = 'deprecated'; break; - } + // E_STRICT is deprecated in PHP 8.4 so we'll use its numeric value directly. + case 2048: // E_STRICT + $type = 'strict'; + break; - // E_STRICT is deprecated in PHP 8.4 so it needs to be behind a version check. - if ( null === $type && version_compare( PHP_VERSION, '8.4', '<' ) && E_STRICT === $errno ) { - $type = 'strict'; } if ( null === $type ) { diff --git a/composer.json b/composer.json index a23833a0..b4b0e8d8 100644 --- a/composer.json +++ b/composer.json @@ -34,16 +34,16 @@ "codeception/util-universalframework": "^1.0", "dealerdirect/phpcodesniffer-composer-installer": "0.7.2", "johnbillion/plugin-infrastructure": "dev-trunk", - "johnbillion/wp-compat": "0.3.1", + "johnbillion/wp-compat": "1.3.0", "lucatume/wp-browser": "3.2.3", "phpcompatibility/phpcompatibility-wp": "2.1.5", - "phpstan/phpstan": "1.12.11", - "phpstan/phpstan-deprecation-rules": "1.2.1", - "phpstan/phpstan-phpunit": "1.4.1", + "phpstan/phpstan": "2.1.17", + "phpstan/phpstan-deprecation-rules": "2.0.3", + "phpstan/phpstan-phpunit": "2.0.6", "roots/wordpress-core-installer": "1.100.0", "roots/wordpress-full": "*", "squizlabs/php_codesniffer": "3.11.1", - "szepeviktor/phpstan-wordpress": "1.3.5", + "szepeviktor/phpstan-wordpress": "2.0.2", "wp-coding-standards/wpcs": "2.3.0" }, "autoload": { diff --git a/output/Html.php b/output/Html.php index e7428ee8..2a552f6f 100644 --- a/output/Html.php +++ b/output/Html.php @@ -298,11 +298,11 @@ public static function output_inner( array $vars ) { * @return string Markup for the table filter controls. */ protected function build_filter( $name, $values, $label, $args = array() ) { - - if ( empty( $values ) || ! is_array( $values ) ) { + if ( empty( $values ) ) { return esc_html( $label ); // Return label text, without being marked up as a label element. } + // @phpstan-ignore function.alreadyNarrowedType (some plugins may still pass a string here for highlighting) if ( ! is_array( $args ) ) { $args = array( 'highlight' => $args, diff --git a/output/html/php_errors.php b/output/html/php_errors.php index 2a16ca1c..ab05b514 100644 --- a/output/html/php_errors.php +++ b/output/html/php_errors.php @@ -86,14 +86,10 @@ public function output() { $row_attr['data-qm-type'] = ucfirst( $type ); $row_attr['data-qm-key'] = $error_key; $row_attr['data-qm-count'] = $error['calls']; + $row_attr['data-qm-component'] = $error['component']->name; - if ( $error['component'] ) { - $component = $error['component']; - $row_attr['data-qm-component'] = $component->name; - - if ( 'core' !== $component->context ) { - $row_attr['data-qm-component'] .= ' non-core'; - } + if ( 'core' !== $error['component']->context ) { + $row_attr['data-qm-component'] .= ' non-core'; } $attr = ''; @@ -163,13 +159,7 @@ public function output() { echo ''; echo '' . esc_html( number_format_i18n( $error['calls'] ) ) . ''; - - if ( ! empty( $component ) ) { - echo '' . esc_html( $component->name ) . ''; - } else { - echo '' . esc_html__( 'Unknown', 'query-monitor' ) . ''; - } - + echo '' . esc_html( $error['component']->name ) . ''; echo ''; } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 54e338a3..071bc7ac 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -36,3 +36,10 @@ parameters: # Passing ints and floats to these functions is fine - '#^Parameter \#1 \$text of function (esc_html|esc_attr) expects string, int\|string given#' - '#^Parameter \#1 \$text of function (esc_html|esc_attr) expects string, float\|int\|string given#' + # ... + - + identifier: phpstanWP.wpConstant.fetch + # ... + - + path: collectors/languages.php + identifier: WPCompat.filterNotAvailable.loadtranslationfile diff --git a/tests/integration/Test.php b/tests/integration/Test.php index 73848d5a..a9188a3a 100644 --- a/tests/integration/Test.php +++ b/tests/integration/Test.php @@ -30,6 +30,8 @@ public function go_to_with_template( string $url ) { $this->go_to( $url ); ob_start(); + + // @phpstan-ignore require.fileNotFound require ABSPATH . WPINC . '/template-loader.php'; return (string) ob_get_clean(); }