Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,14 @@ public function inline_bootstrap_script() {
/**
* Add settings links in the plugin listing page.
*
* @param string[] $links Old plugin links.
* @param string[]|mixed $links Old plugin links.
*
* @return string[] Altered links.
* @return string[]|mixed Altered links.
*/
public function add_action_links( $links ) {
if ( ! is_array( $links ) ) {
return $links;
}
return array_merge(
$links,
[
Expand Down
10 changes: 5 additions & 5 deletions inc/app_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,10 @@ public function url_has_dam_flag( $url ) {
/**
* Get the optimized image url for the image url.
*
* @param string $url The image URL.
* @param mixed $width The image width.
* @param mixed $height The image height.
* @param array $resize The resize properties.
* @param string $url The image URL.
* @param mixed $width The image width.
* @param mixed $height The image height.
* @param array<string, mixed>|mixed $resize The resize properties.
*
* @return string
*/
Expand All @@ -668,7 +668,7 @@ protected function get_optimized_image_url( $url, $width, $height, $resize = []
->width( $width )
->height( $height );

if ( ! empty( $resize['type'] ) ) {
if ( is_array( $resize ) && ! empty( $resize['type'] ) ) {
$optimized_image->resize( $resize['type'], $resize['gravity'] ?? Position::CENTER, $resize['enlarge'] ?? false );

}
Expand Down
15 changes: 9 additions & 6 deletions inc/tag_replacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,15 +809,18 @@ public function change_url_for_size( $original_url, $width, $height, $dpr = 1 )
/**
* Replace image URLs in the srcset attributes and in case there is a resize in action, also replace the sizes.
*
* @param array<int, array{url: string, descriptor: string, value: int}> $sources Array of image sources.
* @param array{0: int, 1: int}|int[] $size_array Array of width and height values in pixels (in that order).
* @param string $image_src The 'src' of the image.
* @param array<string, mixed> $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
* @param int $attachment_id Image attachment ID or 0.
* @param array<int, array{url: string, descriptor: string, value: int}>|mixed $sources Array of image sources.
* @param array{0: int, 1: int}|int[] $size_array Array of width and height values in pixels (in that order).
* @param string $image_src The 'src' of the image.
* @param array<string, mixed> $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
* @param int $attachment_id Image attachment ID or 0.
*
* @return array
* @return array|mixed
*/
public function filter_srcset_attr( $sources = [], $size_array = [], $image_src = '', $image_meta = [], $attachment_id = 0 ) {
if ( ! is_array( $sources ) ) {
return $sources;
}
if ( Optml_Media_Offload::is_uploaded_image( $image_src ) ) {
return $sources;
}
Expand Down
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,6 @@ parameters:
count: 1
path: inc/app_replacer.php

-
message: '#^Method Optml_App_Replacer\:\:get_optimized_image_url\(\) has parameter \$resize with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: inc/app_replacer.php

-
message: '#^Method Optml_App_Replacer\:\:get_upload_resource\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down Expand Up @@ -2790,12 +2784,6 @@ parameters:
count: 1
path: inc/tag_replacer.php

-
message: '#^Method Optml_Tag_Replacer\:\:filter_srcset_attr\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: inc/tag_replacer.php

-
message: '#^Method Optml_Tag_Replacer\:\:init\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down
Loading