Skip to content

Commit 29a3234

Browse files
committed
fix linting
1 parent 1770779 commit 29a3234

4 files changed

Lines changed: 28 additions & 15 deletions

File tree

plugins/dominant-color-images/helper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ function dominant_color_get_dominant_color_data( int $attachment_id ) {
140140
}
141141
$dominant_color_data['dominant_color'] = $hex;
142142

143-
144143
return $dominant_color_data;
145144
}
146145

@@ -152,7 +151,7 @@ function dominant_color_get_dominant_color_data( int $attachment_id ) {
152151
* @param int $attachment_id Attachment ID.
153152
* @return array|null Attachment metadata array or null if not an image or metadata unavailable.
154153
*/
155-
function dominant_color_get_attachment_metadata( int $attachment_id ) {
154+
function dominant_color_get_attachment_metadata( int $attachment_id ): ?array {
156155

157156
if ( ! wp_attachment_is_image( $attachment_id ) ) {
158157
return null;

plugins/dominant-color-images/tests/test-dominant-color-image-editor-gd.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,40 @@ public function test_has_transparency_no_image(): void {
7777
* @covers ::get_dominant_color
7878
*/
7979
public function test_get_dominant_color_success(): void {
80-
$im = imagecreatetruecolor( 1, 1 );
80+
$im = imagecreatetruecolor( 1, 1 );
8181
$red = imagecolorallocate( $im, 255, 0, 0 );
8282
imagefill( $im, 0, 0, $red );
8383

84-
$editor = new Dominant_Color_Image_Editor_GD( null );
84+
$editor = new Dominant_Color_Image_Editor_GD( null );
8585
$reflection = new ReflectionClass( $editor );
86-
$property = $reflection->getProperty( 'image' );
86+
$property = $reflection->getProperty( 'image' );
8787
$property->setAccessible( true );
8888
$property->setValue( $editor, $im );
8989

9090
$result = $editor->get_dominant_color();
9191

9292
$this->assertIsArray( $result );
93-
$this->assertSame( array( 'r' => 255, 'g' => 0, 'b' => 0 ), $result );
93+
$this->assertSame(
94+
array(
95+
'r' => 255,
96+
'g' => 0,
97+
'b' => 0,
98+
),
99+
$result
100+
);
94101
}
95102

96103
/**
97104
* @covers ::has_transparency
98105
*/
99106
public function test_has_no_transparency(): void {
100-
$im = imagecreatetruecolor( 1, 1 );
107+
$im = imagecreatetruecolor( 1, 1 );
101108
$red = imagecolorallocate( $im, 255, 0, 0 );
102109
imagefill( $im, 0, 0, $red );
103110

104-
$editor = new Dominant_Color_Image_Editor_GD( null );
111+
$editor = new Dominant_Color_Image_Editor_GD( null );
105112
$reflection = new ReflectionClass( $editor );
106-
$property = $reflection->getProperty( 'image' );
113+
$property = $reflection->getProperty( 'image' );
107114
$property->setAccessible( true );
108115
$property->setValue( $editor, $im );
109116

@@ -116,13 +123,13 @@ public function test_has_no_transparency(): void {
116123
* @covers ::has_transparency
117124
*/
118125
public function test_has_transparency_with_transparency(): void {
119-
$im = imagecreatetruecolor( 1, 1 );
126+
$im = imagecreatetruecolor( 1, 1 );
120127
$alpha_color = imagecolorallocatealpha( $im, 255, 0, 0, 64 );
121128
imagefill( $im, 0, 0, $alpha_color );
122129

123-
$editor = new Dominant_Color_Image_Editor_GD( null );
130+
$editor = new Dominant_Color_Image_Editor_GD( null );
124131
$reflection = new ReflectionClass( $editor );
125-
$property = $reflection->getProperty( 'image' );
132+
$property = $reflection->getProperty( 'image' );
126133
$property->setAccessible( true );
127134
$property->setValue( $editor, $im );
128135

plugins/dominant-color-images/tests/test-dominant-color-image-editor-imagick.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ public function test_get_dominant_color_success(): void {
152152

153153
$result = $editor->get_dominant_color();
154154

155-
$this->assertEquals( array( 'r' => 255, 'g' => 0, 'b' => 0 ), $result );
155+
$this->assertEquals(
156+
array(
157+
'r' => 255,
158+
'g' => 0,
159+
'b' => 0,
160+
),
161+
$result
162+
);
156163
}
157164

158165
/**

plugins/dominant-color-images/tests/test-dominant-color.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function test_dominant_color_metadata( string $image_path, array $expecte
2626
$this->assertEmpty( $dominant_color_metadata );
2727

2828
// Creating attachment.
29-
$attachment_id = self::factory()->attachment->create_upload_object( $image_path );
29+
$attachment_id = self::factory()->attachment->create_upload_object( $image_path );
3030
$dominant_color_metadata = dominant_color_metadata( array(), $attachment_id );
3131
$this->assertArrayHasKey( 'dominant_color', $dominant_color_metadata );
3232
$this->assertNotEmpty( $dominant_color_metadata['dominant_color'] );
@@ -76,7 +76,7 @@ public function test_has_transparency_metadata( string $image_path, array $expec
7676
$transparency_metadata = dominant_color_metadata( array(), 1 );
7777
$this->assertEmpty( $transparency_metadata );
7878

79-
$attachment_id = self::factory()->attachment->create_upload_object( $image_path );
79+
$attachment_id = self::factory()->attachment->create_upload_object( $image_path );
8080
$transparency_metadata = dominant_color_metadata( array(), $attachment_id );
8181
$this->assertArrayHasKey( 'has_transparency', $transparency_metadata );
8282
$this->assertSame( $expected_transparency, $transparency_metadata['has_transparency'] );

0 commit comments

Comments
 (0)