diff --git a/plugins/dominant-color-images/class-dominant-color-image-editor-gd.php b/plugins/dominant-color-images/class-dominant-color-image-editor-gd.php index a6106bf1f6..faf2d9850b 100644 --- a/plugins/dominant-color-images/class-dominant-color-image-editor-gd.php +++ b/plugins/dominant-color-images/class-dominant-color-image-editor-gd.php @@ -34,7 +34,7 @@ public function get_dominant_color() { $shorted_image = imagecreatetruecolor( 1, 1 ); $image_width = imagesx( $this->image ); $image_height = imagesy( $this->image ); - if ( false === $shorted_image || false === $image_width || false === $image_height ) { + if ( false === $shorted_image || false === $image_width || false === $image_height ) { // @phpstan-ignore-line return new WP_Error( 'image_editor_dominant_color_error', __( 'Dominant color detection failed.', 'dominant-color-images' ) ); } imagecopyresampled( $shorted_image, $this->image, 0, 0, 0, 0, 1, 1, $image_width, $image_height ); @@ -78,7 +78,7 @@ public function has_transparency() { return new WP_Error( 'unable_to_obtain_rgb_via_imagecolorat' ); } $rgba = imagecolorsforindex( $this->image, $rgb ); - if ( ! is_array( $rgba ) ) { + if ( ! is_array( $rgba ) ) { // @phpstan-ignore-line return new WP_Error( 'unable_to_obtain_rgba_via_imagecolorsforindex' ); } if ( $rgba['alpha'] > 0 ) { diff --git a/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php b/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php index 8d1f7a6d68..4a5fc36af9 100644 --- a/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php +++ b/plugins/image-prioritizer/class-image-prioritizer-background-image-styled-tag-visitor.php @@ -41,7 +41,7 @@ public function __invoke( OD_HTML_Tag_Walker $walker ): bool { && 0 < (int) preg_match( '/background(-image)?\s*:[^;]*?url\(\s*[\'"]?\s*(?.+?)\s*[\'"]?\s*\)/', $style, $matches ) && - '' !== $matches['background_image'] // PHPStan should ideally know that this is a non-empty string based on the `.+?` regular expression. + '' !== $matches['background_image'] // PHPStan should ideally know that this is a non-empty string based on the `.+?` regular expression. // @phpstan-ignore-line && ! $this->is_data_url( $matches['background_image'] ) ) { diff --git a/plugins/performance-lab/includes/site-health/object-cache/helper.php b/plugins/performance-lab/includes/site-health/object-cache/helper.php index c02b708bb5..8b83a71912 100644 --- a/plugins/performance-lab/includes/site-health/object-cache/helper.php +++ b/plugins/performance-lab/includes/site-health/object-cache/helper.php @@ -13,10 +13,10 @@ /** * Callback for Object Cache Info fields. * - * @return array Fields. + * @return array Fields. * @since 3.3.0 */ -function object_cache_supported_fields() { +function object_cache_supported_fields(): array { return array( 'extension' => array( 'label' => __( 'Extension', 'performance-lab' ), @@ -42,24 +42,26 @@ function object_cache_supported_fields() { } /** - * Attempts to determine which object cache is being used. + * Attempts to determine which object cache is being used as in wp-cli repository. * * Note that the guesses made by this function are based on the WP_Object_Cache classes * that define the 3rd party object cache extension. Changes to those classes could render * problems with this function's ability to determine which object cache is being used. * - * @return string + * @return string Object cache type. * @since 3.3.0 */ -function wp_get_cache_type() { +function wp_get_cache_type(): string { global $_wp_using_ext_object_cache, $wp_object_cache; + $message = ''; + if ( ! empty( $_wp_using_ext_object_cache ) ) { - // Test for Memcached PECL extension memcached object cache (https://github.com/tollmanz/wordpress-memcached-backend) + // Test for Memcached PECL extension memcached object cache (https://github.com/tollmanz/wordpress-memcached-backend). if ( isset( $wp_object_cache->m ) && $wp_object_cache->m instanceof \Memcached ) { $message = 'Memcached'; - // Test for Memcache PECL extension memcached object cache (https://wordpress.org/extend/plugins/memcached/) + // Test for Memcache PECL extension memcached object cache (https://wordpress.org/extend/plugins/memcached/). } elseif ( isset( $wp_object_cache->mc ) ) { $is_memcache = true; foreach ( $wp_object_cache->mc as $bucket ) { @@ -72,33 +74,32 @@ function wp_get_cache_type() { $message = 'Memcache'; } - // Test for Xcache object cache (https://plugins.svn.wordpress.org/xcache/trunk/object-cache.php) - } elseif ( $wp_object_cache instanceof \XCache_Object_Cache ) { + // Test for Xcache object cache (https://plugins.svn.wordpress.org/xcache/trunk/object-cache.php). + } elseif ( $wp_object_cache instanceof \XCache_Object_Cache ) { // @phpstan-ignore-line $message = 'Xcache'; - // Test for WinCache object cache (https://wordpress.org/extend/plugins/wincache-object-cache-backend/) + // Test for WinCache object cache (https://wordpress.org/extend/plugins/wincache-object-cache-backend/). } elseif ( class_exists( 'WinCache_Object_Cache' ) ) { $message = 'WinCache'; - // Test for APC object cache (https://wordpress.org/extend/plugins/apc/) + // Test for APC object cache (https://wordpress.org/extend/plugins/apc/). } elseif ( class_exists( 'APC_Object_Cache' ) ) { $message = 'APC'; - // Test for WP Redis (https://wordpress.org/plugins/wp-redis/) + // Test for WP Redis (https://wordpress.org/plugins/wp-redis/). } elseif ( isset( $wp_object_cache->redis ) && $wp_object_cache->redis instanceof \Redis ) { $message = 'Redis'; - // Test for Redis Object Cache (https://wordpress.org/plugins/redis-cache/) - } elseif ( method_exists( $wp_object_cache, 'redis_instance' ) && method_exists( $wp_object_cache, - 'redis_status' ) ) { + // Test for Redis Object Cache (https://wordpress.org/plugins/redis-cache/). + } elseif ( method_exists( $wp_object_cache, 'redis_instance' ) && method_exists( $wp_object_cache, 'redis_status' ) ) { $message = 'Redis'; - // Test for Object Cache Pro (https://objectcache.pro/) + // Test for Object Cache Pro (https://objectcache.pro/). } elseif ( method_exists( $wp_object_cache, 'config' ) && method_exists( $wp_object_cache, 'connection' ) ) { $message = 'Redis'; - // Test for WP LCache Object cache (https://github.com/lcache/wp-lcache) - } elseif ( isset( $wp_object_cache->lcache ) && $wp_object_cache->lcache instanceof \LCache\Integrated ) { + // Test for WP LCache Object cache (https://github.com/lcache/wp-lcache). + } elseif ( isset( $wp_object_cache->lcache ) && $wp_object_cache->lcache instanceof \LCache\Integrated ) { // @phpstan-ignore-line $message = 'WP LCache'; } elseif ( function_exists( 'w3_instance' ) ) { diff --git a/plugins/performance-lab/includes/site-health/object-cache/hooks.php b/plugins/performance-lab/includes/site-health/object-cache/hooks.php index 37a2f62d08..f70497ba40 100644 --- a/plugins/performance-lab/includes/site-health/object-cache/hooks.php +++ b/plugins/performance-lab/includes/site-health/object-cache/hooks.php @@ -13,17 +13,15 @@ /** * Adds Object Cache module to Site Health Info. * - * @param array $info Site Health Info. + * @param array{object_cache: array{label: string,description: string,fields: array}} $info Site Health Info. * - * @return array Amended Info. + * @return array{object_cache: array{label: string,description: string,fields: array}} Amended Info. * @since 3.3.0 * @since 3.3.0 - * */ function object_cache_supported_info( array $info ): array { $info['object_cache'] = array( 'label' => __( 'Object Caching', 'performance-lab' ), - 'description' => __( 'Shows which features object cache supports and if object caching is in use.', - 'performance-lab' ), + 'description' => __( 'Shows which features object cache supports and if object caching is in use.', 'performance-lab' ), 'fields' => object_cache_supported_fields(), ); diff --git a/plugins/webp-uploads/hooks.php b/plugins/webp-uploads/hooks.php index be993c35ac..37ff2cef3f 100644 --- a/plugins/webp-uploads/hooks.php +++ b/plugins/webp-uploads/hooks.php @@ -544,7 +544,7 @@ function webp_uploads_update_image_references( $content ): string { continue; } - if ( empty( $class_name ) ) { + if ( empty( $class_name ) ) { // @phpstan-ignore-line continue; } diff --git a/plugins/webp-uploads/tests/test-image-edit.php b/plugins/webp-uploads/tests/test-image-edit.php index 8f5fe9cc5d..db541b51f9 100644 --- a/plugins/webp-uploads/tests/test-image-edit.php +++ b/plugins/webp-uploads/tests/test-image-edit.php @@ -50,7 +50,7 @@ public function test_it_should_backup_the_sources_structure_alongside_the_full_s foreach ( $backup_sizes as $size => $properties ) { $size_name = str_replace( '-orig', '', $size ); - if ( 'full-orig' === $size ) { + if ( 'full-orig' === $size ) { // @phpstan-ignore-line continue; }