Skip to content
Merged
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
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: 1
level: 2
paths:
- load.php
- includes/
Expand Down
15 changes: 13 additions & 2 deletions plugins/dominant-color-images/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function dominant_color_set_image_editors( $editors ) {
}

$replaces = array(
'WP_Image_Editor_GD' => 'Dominant_Color_Image_Editor_GD',
'WP_Image_Editor_Imagick' => 'Dominant_Color_Image_Editor_Imagick',
WP_Image_Editor_GD::class => Dominant_Color_Image_Editor_GD::class,
WP_Image_Editor_Imagick::class => Dominant_Color_Image_Editor_Imagick::class,
);

foreach ( $replaces as $old => $new ) {
Expand Down Expand Up @@ -58,6 +58,13 @@ function dominant_color_get_dominant_color_data( $attachment_id ) {
$file = get_attached_file( $attachment_id );
}
add_filter( 'wp_image_editors', 'dominant_color_set_image_editors' );

/**
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
/*

Seems it's local variable so do we needs to use multiline comment per https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#5-inline-comments

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's right. Without /** then the phpdoc is not parsed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The docs you link to are talking about a regular multiline comment, not one that serves as a doc block.

* Editor.
*
* @see dominant_color_set_image_editors()
* @var WP_Image_Editor|Dominant_Color_Image_Editor_GD|Dominant_Color_Image_Editor_Imagick|WP_Error $editor
*/
$editor = wp_get_image_editor(
$file,
array(
Expand All @@ -73,6 +80,10 @@ function dominant_color_get_dominant_color_data( $attachment_id ) {
return $editor;
}

if ( ! ( $editor instanceof Dominant_Color_Image_Editor_GD || $editor instanceof Dominant_Color_Image_Editor_Imagick ) ) {
return new WP_Error( 'image_no_editor', __( 'No editor could be selected.', 'default' ) );
}

$has_transparency = $editor->has_transparency();
if ( is_wp_error( $has_transparency ) ) {
return $has_transparency;
Expand Down
2 changes: 1 addition & 1 deletion plugins/dominant-color-images/phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<rule ref="../../bin/phpcs/phpcs.ruleset.xml"/>

<config name="text_domain" value="dominant-color-images"/>
<config name="text_domain" value="dominant-color-images,default"/>

<file>.</file>
</ruleset>