Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix construction of translation strings in admin/plugins.php #925

Merged
merged 4 commits into from
Jan 10, 2024

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jan 9, 2024

Summary

This fixes some things which were missed when reviewing #864. Primarily, arguments are being passed directly to wp_kses_post() when they should be passed first to sprintf(). I discovered this issue when switching to trunk and running PHPStan. In working on Image Loading Optimization, I have increased the level in the phpstan.neon from 0 to 6, and it detected these issues:

 ------ ---------------------------------------------------------------- 
  Line   admin/plugins.php                                               
 ------ ---------------------------------------------------------------- 
  290    Function wp_kses_post invoked with 3 parameters, 1 required.    
  298    Function wp_kses_post invoked with 2 parameters, 1 required.    
  304    Function wp_kses_post invoked with 2 parameters, 1 required.    
  314    Function wp_kses_post invoked with 2 parameters, 1 required.    
  323    Function wp_kses_post invoked with 2 parameters, 1 required.    
  384    Parameter #3 $number of function _nx expects int, float given.  
 ------ ---------------------------------------------------------------- 

The last one regarding _nx() is minor since _nx() doesn't have strict typing for the $number parameter passed to _nx().

Note that my local PHPStan config also has to have quite a few errors (via baseline) it has to ignore in order to pass level 6:

phpstan-baseline.neon
parameters:
	ignoreErrors:
		-
			message: "#^Parameter \\#3 \\$callback of function add_settings_section expects callable\\(\\)\\: mixed, null given\\.$#"
			count: 1
			path: admin/load.php

		-
			message: "#^Constant WP_CONTENT_DIR not found\\.$#"
			count: 1
			path: load.php

		-
			message: "#^If condition is always false\\.$#"
			count: 1
			path: load.php

		-
			message: "#^Negated boolean expression is always true\\.$#"
			count: 1
			path: load.php

		-
			message: "#^Unreachable statement \\- code above always terminates\\.$#"
			count: 1
			path: load.php

		-
			message: "#^Negated boolean expression is always false\\.$#"
			count: 2
			path: modules/images/dominant-color-images/class-dominant-color-image-editor-gd.php

		-
			message: "#^If condition is always true\\.$#"
			count: 1
			path: modules/images/dominant-color-images/class-dominant-color-image-editor-imagick.php

		-
			message: "#^Negated boolean expression is always false\\.$#"
			count: 2
			path: modules/images/dominant-color-images/class-dominant-color-image-editor-imagick.php

		-
			message: "#^Call to an undefined method WP_Image_Editor\\:\\:get_dominant_color\\(\\)\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Call to an undefined method WP_Image_Editor\\:\\:has_transparency\\(\\)\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Function dominant_color_get_dominant_color\\(\\) never returns string so it can be removed from the return type\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Function dominant_color_has_transparency\\(\\) never returns bool so it can be removed from the return type\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Offset 'dominant_color' on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) does not exist\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Offset 'has_transparency' on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) does not exist\\.$#"
			count: 1
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Unreachable statement \\- code above always terminates\\.$#"
			count: 2
			path: modules/images/dominant-color-images/helper.php

		-
			message: "#^Offset 'dominant_color' on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in empty\\(\\) does not exist\\.$#"
			count: 2
			path: modules/images/dominant-color-images/hooks.php

		-
			message: "#^Offset 'has_transparency' on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) does not exist\\.$#"
			count: 2
			path: modules/images/dominant-color-images/hooks.php

		-
			message: "#^Variable \\$data in empty\\(\\) always exists and is always falsy\\.$#"
			count: 1
			path: modules/images/dominant-color-images/hooks.php

		-
			message: "#^Variable \\$extra_class in empty\\(\\) always exists and is always falsy\\.$#"
			count: 1
			path: modules/images/dominant-color-images/hooks.php

		-
			message: "#^Call to function is_array\\(\\) with array will always evaluate to true\\.$#"
			count: 2
			path: modules/images/webp-uploads/helper.php

		-
			message: "#^Function remove_filter invoked with 4 parameters, 2\\-3 required\\.$#"
			count: 1
			path: modules/images/webp-uploads/helper.php

		-
			message: "#^Negated boolean expression is always false\\.$#"
			count: 1
			path: modules/images/webp-uploads/helper.php

		-
			message: "#^Offset 'path' on array\\{path\\: string, file\\: non\\-falsy\\-string, width\\: int, height\\: int, mime\\-type\\: string, filesize\\: int\\} in isset\\(\\) always exists and is not nullable\\.$#"
			count: 1
			path: modules/images/webp-uploads/helper.php

		-
			message: "#^Cannot assign offset string to string\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Negated boolean expression is always false\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Offset 'function' on array\\{function\\: string, line\\?\\: int, file\\?\\: string, class\\?\\: class\\-string, type\\?\\: '\\-\\>'\\|'\\:\\:', args\\?\\: array, object\\?\\: object\\} in isset\\(\\) always exists and is not nullable\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Offset 'sizes' on array\\{width\\: int, height\\: int, file\\: non\\-falsy\\-string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) always exists and is not nullable\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Offset 'sources' on array\\{width\\: int, height\\: int, file\\: non\\-falsy\\-string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) does not exist\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Parameter \\#1 \\$array \\(list\\<int\\<min, \\-1\\>\\|int\\<1, max\\>\\>\\) to function array_filter does not contain falsy values, the array will always stay the same\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Right side of && is always true\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Unreachable statement \\- code above always terminates\\.$#"
			count: 1
			path: modules/images/webp-uploads/hooks.php

		-
			message: "#^Function remove_filter invoked with 4 parameters, 2\\-3 required\\.$#"
			count: 2
			path: modules/images/webp-uploads/image-edit.php

		-
			message: "#^Offset 'function' on array\\{function\\: string, line\\?\\: int, file\\?\\: string, class\\?\\: class\\-string, type\\?\\: '\\-\\>'\\|'\\:\\:', args\\?\\: array, object\\?\\: object\\} in isset\\(\\) always exists and is not nullable\\.$#"
			count: 1
			path: modules/images/webp-uploads/image-edit.php

		-
			message: "#^Constant WP_CONTENT_DIR not found\\.$#"
			count: 1
			path: modules/js-and-css/audit-enqueued-assets/helper.php

		-
			message: "#^Call to function is_float\\(\\) with float will always evaluate to true\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing-metric.php

		-
			message: "#^Call to function is_numeric\\(\\) with float\\|int will always evaluate to true\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing-metric.php

		-
			message: "#^Result of && is always false\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing-metric.php

		-
			message: "#^Method Perflab_Server_Timing\\:\\:register_metric\\(\\) has parameter \\$args with no value type specified in iterable type array\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing.php

		-
			message: "#^Property Perflab_Server_Timing\\:\\:\\$registered_metrics type has no value type specified in iterable type array\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing.php

		-
			message: "#^Property Perflab_Server_Timing\\:\\:\\$registered_metrics_data type has no value type specified in iterable type array\\.$#"
			count: 1
			path: server-timing/class-perflab-server-timing.php

		-
			message: "#^If condition is always false\\.$#"
			count: 1
			path: server-timing/defaults.php

		-
			message: "#^Constant WP_CONTENT_DIR not found\\.$#"
			count: 3
			path: server-timing/object-cache.copy.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#"
			count: 4
			path: tests/admin/load-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false will always evaluate to false\\.$#"
			count: 2
			path: tests/admin/load-tests.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 2
			path: tests/admin/load-tests.php

		-
			message: "#^Offset 'options\\-general\\.php' on array\\{\\} in isset\\(\\) does not exist\\.$#"
			count: 3
			path: tests/admin/load-tests.php

		-
			message: "#^Offset 'perflab\\-modules' does not exist on array\\{\\}\\.$#"
			count: 4
			path: tests/admin/load-tests.php

		-
			message: "#^Offset 'perflab\\-modules' on array\\{\\} in empty\\(\\) does not exist\\.$#"
			count: 3
			path: tests/admin/load-tests.php

		-
			message: "#^Property Admin_Load_Tests\\:\\:\\$demo_focus_areas has no type specified\\.$#"
			count: 1
			path: tests/admin/load-tests.php

		-
			message: "#^Property Admin_Load_Tests\\:\\:\\$demo_modules has no type specified\\.$#"
			count: 1
			path: tests/admin/load-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'perflab\\-server…' and array\\{\\} will always evaluate to false\\.$#"
			count: 1
			path: tests/admin/server-timing-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#"
			count: 1
			path: tests/admin/server-timing-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false will always evaluate to false\\.$#"
			count: 1
			path: tests/admin/server-timing-tests.php

		-
			message: "#^Offset 'perflab\\-server…' does not exist on array\\{\\}\\.$#"
			count: 2
			path: tests/admin/server-timing-tests.php

		-
			message: "#^Offset 'tools\\.php' on array\\{\\} in isset\\(\\) does not exist\\.$#"
			count: 2
			path: tests/admin/server-timing-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFalse\\(\\) with false will always evaluate to true\\.$#"
			count: 4
			path: tests/load-tests.php

		-
			message: "#^Constant PERFLAB_PLUGIN_DIR_PATH not found\\.$#"
			count: 6
			path: tests/load-tests.php

		-
			message: "#^Constant WP_CONTENT_DIR not found\\.$#"
			count: 12
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:data_legacy_modules\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:get_expected_default_option\\(\\) is unused\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_legacy_module_for_perflab_get_module_settings\\(\\) has parameter \\$current_module_slug with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_legacy_module_for_perflab_get_module_settings\\(\\) has parameter \\$legacy_module_slug with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_perflab_can_load_module\\(\\) has parameter \\$dummy_module with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_perflab_can_load_module\\(\\) has parameter \\$expected_status with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_perflab_is_valid_module\\(\\) has parameter \\$dummy_module with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Load_Tests\\:\\:test_perflab_is_valid_module\\(\\) has parameter \\$expected_status with no type specified\\.$#"
			count: 1
			path: tests/load-tests.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_GD_Test\\:\\:test_get_dominant_color_none_images\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-gd-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color_invalid\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Method Dominant_Color_Image_Editor_Imageick_Test\\:\\:test_get_dominant_color_none_images\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-image-editor-imageick-test.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 3
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:data_dominant_color_img_tag_add_dominant_color_requires_proper_quotes\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:data_provider_dominant_color_check_inline_style\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:data_provider_dominant_color_filter_check_inline_style\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_get_dominant_color\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_get_dominant_color\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_get_dominant_color\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_has_transparency\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_has_transparency\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_has_transparency\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_metadata\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_metadata\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_metadata\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_rgb_to_hex\\(\\) has parameter \\$blue with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_rgb_to_hex\\(\\) has parameter \\$green with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_rgb_to_hex\\(\\) has parameter \\$hex with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_rgb_to_hex\\(\\) has parameter \\$red with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_set_image_editors\\(\\) has parameter \\$existing with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_dominant_color_set_image_editors\\(\\) has parameter \\$expected with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_has_transparency_metadata\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_has_transparency_metadata\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_has_transparency_metadata\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_tag_add_adjust_to_image_attributes\\(\\) has parameter \\$expected_color with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_tag_add_adjust_to_image_attributes\\(\\) has parameter \\$expected_transparency with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Method Dominant_Color_Test\\:\\:test_tag_add_adjust_to_image_attributes\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Parameter \\#3 \\$icon of function wp_get_attachment_image expects bool, string given\\.$#"
			count: 1
			path: tests/modules/images/dominant-color-images/dominant-color-test.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array\\<string, array\\<string\\>\\> will always evaluate to true\\.$#"
			count: 5
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 17
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_add_original_image_extension_to_the_webp_file_name_to_ensure_it_is_unique\\(\\) has parameter \\$jpeg_image with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_add_original_image_extension_to_the_webp_file_name_to_ensure_it_is_unique\\(\\) has parameter \\$jpg_image with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_discard_additional_image_if_larger_than_the_original_image\\(\\) has parameter \\$additional_filesize with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_discard_additional_image_if_larger_than_the_original_image\\(\\) has parameter \\$expected_status with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_discard_additional_image_if_larger_than_the_original_image\\(\\) has parameter \\$original_filesize with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_never_discard_additional_image_if_filter_is_false\\(\\) has parameter \\$additional_filesize with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_never_discard_additional_image_if_filter_is_false\\(\\) has parameter \\$original_filesize with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_prevent_processing_an_image_with_corrupted_metadata\\(\\) has parameter \\$size with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_return_an_error_when_creating_an_additional_image_source_with_invalid_parameters\\(\\) has parameter \\$attachment_id with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_return_an_error_when_creating_an_additional_image_source_with_invalid_parameters\\(\\) has parameter \\$destination_file with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_return_an_error_when_creating_an_additional_image_source_with_invalid_parameters\\(\\) has parameter \\$mime with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:it_should_return_an_error_when_creating_an_additional_image_source_with_invalid_parameters\\(\\) has parameter \\$size_data with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Method WebP_Uploads_Helper_Tests\\:\\:mock_empty_action\\(\\) has parameter \\$action with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/helper-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'full\\-orig' and array\\{\\} will always evaluate to false\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'original_image' and array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\|false will always evaluate to false\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'sizes' and \\*NEVER\\* will always evaluate to true\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'sources' and \\*NEVER\\* will always evaluate to true\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'sources' and array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\|false will always evaluate to false\\.$#"
			count: 3
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with Countable will always evaluate to false\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with 'full\\-orig' and 'full\\-orig' will always evaluate to true\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 16
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Offset 'sources' does not exist on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\|false\\.$#"
			count: 7
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Parameter \\#2 \\$hashed_size_name of method PerformanceLab\\\\Tests\\\\TestCase\\\\ImagesTestCase\\:\\:assertSizeNameIsHashed\\(\\) expects string, null given\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/image-edit-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'sources' and array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\|false will always evaluate to false\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 35
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Method WebP_Uploads_Load_Tests\\:\\:force_webp_image_quality_86\\(\\) has parameter \\$mime_type with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Method WebP_Uploads_Load_Tests\\:\\:force_webp_image_quality_86\\(\\) has parameter \\$quality with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Method WebP_Uploads_Load_Tests\\:\\:it_should_not_replace_the_references_to_a_jpg_image_when_disabled_via_filter\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Method WebP_Uploads_Load_Tests\\:\\:it_should_prevent_update_not_supported_images_with_no_available_sources\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Method WebP_Uploads_Load_Tests\\:\\:it_should_replace_references_to_a_jpg_image_to_a_webp_version\\(\\) has parameter \\$image_path with no type specified\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Offset 'sources' does not exist on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\.$#"
			count: 15
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Offset 'sources' does not exist on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\}\\|false\\.$#"
			count: 6
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Offset 'sources' does not exist on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array\\{\\}, image_meta\\: array, filesize\\: int\\}\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Property WebP_Uploads_Load_Tests\\:\\:\\$to_unlink type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/images/webp-uploads/load-tests.php

		-
			message: "#^Cannot assign offset 'id' to WP_REST_Request\\<array\\>\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/rest-api-tests.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/rest-api-tests.php

		-
			message: "#^WP_REST_Request\\<array\\> does not accept int\\|WP_Error\\.$#"
			count: 2
			path: tests/modules/images/webp-uploads/rest-api-tests.php

		-
			message: "#^Constant WP_CONTENT_DIR not found\\.$#"
			count: 1
			path: tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-helper-test.php

		-
			message: "#^Parameter \\#1 \\$resource_url of function perflab_aea_get_path_from_resource_url expects string, false given\\.$#"
			count: 1
			path: tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-helper-test.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsArray\\(\\) with array will always evaluate to true\\.$#"
			count: 1
			path: tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-test.php

		-
			message: "#^Method Audit_Enqueued_Assets_Tests\\:\\:mock_data_perflab_aea_enqueued_css_assets_test_callback\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-test.php

		-
			message: "#^Method Audit_Enqueued_Assets_Tests\\:\\:mock_data_perflab_aea_enqueued_js_assets_test_callback\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/modules/js-and-css/audit-enqueued-assets/audit-enqueued-assets-test.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false will always evaluate to false\\.$#"
			count: 1
			path: tests/server-timing/load-tests.php

		-
			message: "#^Method Server_Timing_Load_Tests\\:\\:test_perflab_sanitize_server_timing_setting\\(\\) has parameter \\$expected with no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/server-timing/load-tests.php

		-
			message: "#^Offset 'perflab\\-server…' on array\\{\\} in isset\\(\\) does not exist\\.$#"
			count: 1
			path: tests/server-timing/load-tests.php

		-
			message: "#^Property Perflab_Server_Timing_Metric_Tests\\:\\:\\$metric has no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-metric-tests.php

		-
			message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertTrue\\(\\) with false and 'Measure callback…' will always evaluate to false\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Method Perflab_Server_Timing_Tests\\:\\:test_get_header\\(\\) has parameter \\$expected with no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Method Perflab_Server_Timing_Tests\\:\\:test_get_header\\(\\) has parameter \\$metrics with no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Property Perflab_Server_Timing_Tests\\:\\:\\$admin_id has no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Property Perflab_Server_Timing_Tests\\:\\:\\$dummy_args has no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Property Perflab_Server_Timing_Tests\\:\\:\\$server_timing has no type specified\\.$#"
			count: 1
			path: tests/server-timing/perflab-server-timing-tests.php

		-
			message: "#^Constant WPINC not found\\.$#"
			count: 2
			path: tests/testdata/modules/images/webp-uploads/class-wp-image-doesnt-support-webp.php

		-
			message: "#^Property WP_Image_Edit\\:\\:\\$attachment_id has no type specified\\.$#"
			count: 1
			path: tests/testdata/modules/images/webp-uploads/class-wp-image-edit.php

		-
			message: "#^Property WP_Image_Edit\\:\\:\\$changes has no type specified\\.$#"
			count: 1
			path: tests/testdata/modules/images/webp-uploads/class-wp-image-edit.php

		-
			message: "#^Property WP_Image_Edit\\:\\:\\$result has no type specified\\.$#"
			count: 1
			path: tests/testdata/modules/images/webp-uploads/class-wp-image-edit.php

		-
			message: "#^Property WP_Image_Edit\\:\\:\\$target has no type specified\\.$#"
			count: 1
			path: tests/testdata/modules/images/webp-uploads/class-wp-image-edit.php

		-
			message: "#^Method Site_Health_Mock_Responses\\:\\:return_added_test_info_site_health\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php

		-
			message: "#^Method Site_Health_Mock_Responses\\:\\:return_aea_enqueued_css_assets_test_callback_less_than_threshold\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php

		-
			message: "#^Method Site_Health_Mock_Responses\\:\\:return_aea_enqueued_css_assets_test_callback_more_than_threshold\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php

		-
			message: "#^Method Site_Health_Mock_Responses\\:\\:return_aea_enqueued_js_assets_test_callback_less_than_threshold\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php

		-
			message: "#^Method Site_Health_Mock_Responses\\:\\:return_aea_enqueued_js_assets_test_callback_more_than_threshold\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/testdata/modules/site-health/audit-enqueued-assets/class-site-health-mock-responses.php

		-
			message: "#^Method PerformanceLab\\\\Tests\\\\Constraint\\\\ImageHasSource\\:\\:verify_sources\\(\\) has parameter \\$sources with no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/Constraint/ImageHasSource.php

		-
			message: "#^Offset 'sources' on array\\{width\\: int, height\\: int, file\\: string, sizes\\: array, image_meta\\: array, filesize\\: int\\} in isset\\(\\) does not exist\\.$#"
			count: 1
			path: tests/utils/Constraint/ImageHasSource.php

		-
			message: "#^Result of \\|\\| is always true\\.$#"
			count: 1
			path: tests/utils/Constraint/ImageHasSource.php

		-
			message: "#^Unreachable statement \\- code above always terminates\\.$#"
			count: 1
			path: tests/utils/Constraint/ImageHasSource.php

		-
			message: "#^Method WP_Filesystem_MockFilesystem\\:\\:dirlist\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/Filesystem/WP_Filesystem_MockFilesystem.php

		-
			message: "#^Method WP_Filesystem_MockFilesystem\\:\\:get_contents_array\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/Filesystem/WP_Filesystem_MockFilesystem.php

		-
			message: "#^Property WP_Filesystem_MockFilesystem\\:\\:\\$file_contents has no type specified\\.$#"
			count: 1
			path: tests/utils/Filesystem/WP_Filesystem_MockFilesystem.php

		-
			message: "#^Constant TESTS_PLUGIN_DIR not found\\.$#"
			count: 22
			path: tests/utils/TestCase/DominantColorTestCase.php

		-
			message: "#^Method PerformanceLab\\\\Tests\\\\TestCase\\\\DominantColorTestCase\\:\\:provider_get_dominant_color\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/TestCase/DominantColorTestCase.php

		-
			message: "#^Method PerformanceLab\\\\Tests\\\\TestCase\\\\DominantColorTestCase\\:\\:provider_get_dominant_color_invalid_images\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/TestCase/DominantColorTestCase.php

		-
			message: "#^Method PerformanceLab\\\\Tests\\\\TestCase\\\\DominantColorTestCase\\:\\:provider_get_dominant_color_none_images\\(\\) return type has no value type specified in iterable type array\\.$#"
			count: 1
			path: tests/utils/TestCase/DominantColorTestCase.php

Many of these should be addressed as part of #775.

Relevant technical choices

Checklist

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

@westonruter westonruter added [Type] Bug An existing feature is broken Infrastructure Issues for the overall performance plugin infrastructure Creating standalone plugins labels Jan 9, 2024
@westonruter westonruter added this to the PL Plugin 2.8.0 milestone Jan 9, 2024
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thank you, @westonruter, for the PR. The changes appear satisfactory to me. Considering that we adopted the code from the plugin API, should we also update this code within the core itself?

@westonruter
Copy link
Member Author

@mukeshpanchal27
Copy link
Member

@mukeshpanchal27 I don't think the problem exists in core. It's using sprintf(). For example: https://github.com/WordPress/wordpress-develop/blob/57597d9cccc68943fe706c8bb3148a2c71ac2105/src/wp-admin/includes/class-wp-plugins-list-table.php#L1291-L1296

@westonruter, removing wp_kses_post triggers an error in npm run lint-php stating: "All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'." Although this error isn't currently shown in core, it's possible it may appear in the future.

Similarly, the int cast, such as seen in core here, could potentially trigger similar php standard errors in the future.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Great catch!

This is actually a crucial bug fix as it prevents messages with broken links, so it should be made against the release branch :)

@felixarntz felixarntz changed the base branch from trunk to release/2.8.0 January 10, 2024 17:08
@felixarntz
Copy link
Member

After adjusting the base branch, the PR now also includes the CODEOWNERS changes from trunk, but that's perfectly fine as it doesn't affect the release anyway. I'll go ahead and merge.

@felixarntz felixarntz merged commit deb090f into release/2.8.0 Jan 10, 2024
25 checks passed
@felixarntz felixarntz deleted the fix/translation-string-construction branch January 10, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Issues for the overall performance plugin infrastructure [Type] Bug An existing feature is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants