Passed
Push — develop-v4 ( 4bbc33...493817 )
by Andrew
05:12
created
src/gql/types/generators/OptimizedImagesGenerator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -279,6 +279,6 @@
 block discarded – undo
279 279
     public static function getName($context = null): string
280 280
     {
281 281
         /** @var OptimizedImages $context */
282
-        return $context->handle . '_OptimizedImages';
282
+        return $context->handle.'_OptimizedImages';
283 283
     }
284 284
 }
Please login to merge, or discard this patch.
src/jobs/ResaveOptimizedImages.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             Craft::configure($query, $this->criteria);
76 76
         }
77 77
         if (Craft::$app instanceof ConsoleApplication) {
78
-            echo $this->description . PHP_EOL;
78
+            echo $this->description.PHP_EOL;
79 79
         }
80 80
         // Use craft\db\Paginator to paginate the results so we don't exceed any memory limits
81 81
         // See batch() and each() discussion here: https://github.com/yiisoft/yii2/issues/8420
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
         while ($currentElement < $totalElements) {
90 90
             $elements = $paginator->getPageResults();
91 91
             if (Craft::$app instanceof ConsoleApplication) {
92
-                echo 'Query ' . $paginator->getCurrentPage() . '/' . $paginator->getTotalPages()
93
-                    . ' - assets: ' . $paginator->getTotalResults()
92
+                echo 'Query '.$paginator->getCurrentPage().'/'.$paginator->getTotalPages()
93
+                    . ' - assets: '.$paginator->getTotalResults()
94 94
                     . PHP_EOL;
95 95
             }
96 96
             /** @var ElementInterface $element */
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
                     /** @var Field $field */
104 104
                     foreach ($fields as $field) {
105 105
                         if ($field instanceof OptimizedImagesField && $element instanceof Asset) {
106
-                            if ($this->fieldId === null || (int)$field->id === (int)$this->fieldId) {
106
+                            if ($this->fieldId === null || (int) $field->id === (int) $this->fieldId) {
107 107
                                 if (Craft::$app instanceof ConsoleApplication) {
108
-                                    echo $currentElement . '/' . $totalElements
109
-                                        . ' - processing asset: ' . $element->title
110
-                                        . ' from field: ' . $field->name . PHP_EOL;
108
+                                    echo $currentElement.'/'.$totalElements
109
+                                        . ' - processing asset: '.$element->title
110
+                                        . ' from field: '.$field->name.PHP_EOL;
111 111
                                 }
112 112
                                 try {
113 113
                                     ImageOptimize::$plugin->optimizedImages->updateOptimizedImageFieldData($field, $element, $this->force);
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                                         echo '[error]: '
118 118
                                             . $e->getMessage()
119 119
                                             . ' while processing '
120
-                                            . $currentElement . '/' . $totalElements
121
-                                            . ' - processing asset: ' . $element->title
122
-                                            . ' from field: ' . $field->name . PHP_EOL;
120
+                                            . $currentElement.'/'.$totalElements
121
+                                            . ' - processing asset: '.$element->title
122
+                                            . ' from field: '.$field->name.PHP_EOL;
123 123
                                     }
124 124
                                 }
125 125
                             }
Please login to merge, or discard this patch.
src/services/Placeholder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             . "style='background:$color' "
71 71
             . "/>";
72 72
 
73
-        return $header . ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
73
+        return $header.ImageOptimize::$plugin->optimizedImages->encodeOptimizedSVGDataUri($content);
74 74
     }
75 75
 
76 76
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         );
92 92
         $result = '';
93 93
         $width = self::PLACEHOLDER_WIDTH;
94
-        $height = (int)($width / $aspectRatio);
94
+        $height = (int) ($width / $aspectRatio);
95 95
         $placeholderPath = $this->createImageFromPath($tempPath, $width, $height, self::PLACEHOLDER_QUALITY, $position);
96 96
         if (!empty($placeholderPath)) {
97 97
             $result = base64_encode(file_get_contents($placeholderPath));
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     {
114 114
         Craft::beginProfile('generateColorPalette', __METHOD__);
115 115
         Craft::info(
116
-            'Generating color palette for: ' . $tempPath,
116
+            'Generating color palette for: '.$tempPath,
117 117
             __METHOD__
118 118
         );
119 119
         $colorPalette = [];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      *
142 142
      * @return float|int|null
143 143
      */
144
-    public function calculateLightness(array $colors): float|int|null
144
+    public function calculateLightness(array $colors): float | int | null
145 145
     {
146 146
         $lightness = null;
147 147
         if (!empty($colors)) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             $lightness /= $colorCount;
160 160
         }
161 161
 
162
-        return $lightness === null ? $lightness : (int)$lightness;
162
+        return $lightness === null ? $lightness : (int) $lightness;
163 163
     }
164 164
 
165 165
     /**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             __METHOD__
226 226
         );
227 227
         $width = self::TEMP_PLACEHOLDER_WIDTH;
228
-        $height = (int)($width / $aspectRatio);
228
+        $height = (int) ($width / $aspectRatio);
229 229
         $tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position);
230 230
         Craft::endProfile('createTempPlaceholderImage', __METHOD__);
231 231
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             }
281 281
         } catch (Throwable $e) {
282 282
             Craft::error(
283
-                'Error creating temporary image: ' . $e->getMessage(),
283
+                'Error creating temporary image: '.$e->getMessage(),
284 284
                 __METHOD__
285 285
             );
286 286
 
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 
305 305
 
306 306
         // Save the image out to a temp file, then return its contents
307
-        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true) . '.' . 'jpg';
308
-        $tempPath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $tempFilename;
307
+        $tempFilename = uniqid(pathinfo($pathParts['filename'], PATHINFO_FILENAME), true).'.'.'jpg';
308
+        $tempPath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$tempFilename;
309 309
         clearstatcache(true, $tempPath);
310 310
         try {
311 311
             $image->saveAs($tempPath);
312 312
         } catch (Throwable $e) {
313 313
             Craft::error(
314
-                'Error saving temporary image: ' . $e->getMessage(),
314
+                'Error saving temporary image: '.$e->getMessage(),
315 315
                 __METHOD__
316 316
             );
317 317
         }
Please login to merge, or discard this patch.
src/services/OptimizedImages.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 }
114 114
                 $variant['format'] = $variantFormat;
115 115
                 // Only try the transform if it's possible
116
-                if ((int)$asset->height > 0
116
+                if ((int) $asset->height > 0
117 117
                     && Image::canManipulateAsImage($finalFormat)
118 118
                     && Image::canManipulateAsImage($asset->getExtension())
119 119
                 ) {
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
                             } catch (Throwable $exception) {
134 134
                             }
135 135
                         } catch (Throwable $e) {
136
-                            $msg = 'Failed to update transform: ' . $e->getMessage();
136
+                            $msg = 'Failed to update transform: '.$e->getMessage();
137 137
                             Craft::error($msg, __METHOD__);
138 138
                             if (Craft::$app instanceof ConsoleApplication) {
139
-                                echo $msg . PHP_EOL;
139
+                                echo $msg.PHP_EOL;
140 140
                             }
141 141
                             // Add the error message to the stickyErrors for the model
142 142
                             $model->stickyErrors[] = $msg;
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
                     }
151 151
                 } else {
152 152
                     $canManipulate = Image::canManipulateAsImage($asset->getExtension());
153
-                    $msg = 'Could not create transform for: ' . $asset->title
154
-                        . ' - Final format: ' . $finalFormat
155
-                        . ' - Element extension: ' . $asset->getExtension()
156
-                        . ' - canManipulateAsImage: ' . $canManipulate;
153
+                    $msg = 'Could not create transform for: '.$asset->title
154
+                        . ' - Final format: '.$finalFormat
155
+                        . ' - Element extension: '.$asset->getExtension()
156
+                        . ' - canManipulateAsImage: '.$canManipulate;
157 157
                     Craft::error(
158 158
                         $msg,
159 159
                         __METHOD__
160 160
                     );
161 161
                     if (Craft::$app instanceof ConsoleApplication) {
162
-                        echo $msg . PHP_EOL;
162
+                        echo $msg.PHP_EOL;
163 163
                     }
164 164
                     if ($canManipulate) {
165 165
                         // Add the error message to the stickyErrors for the model
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         // If no image variants were created, populate it with the image itself
173 173
         if (empty($model->optimizedImageUrls)) {
174 174
             $finalFormat = $asset->getExtension();
175
-            if ((int)$asset->height > 0
175
+            if ((int) $asset->height > 0
176 176
                 && Image::canManipulateAsImage($finalFormat)
177 177
             ) {
178 178
                 $variant = [
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
                 $this->addVariantImageToModel($asset, $model, $transform, $variant, $aspectRatio);
189 189
             } else {
190 190
                 $canManipulate = Image::canManipulateAsImage($asset->getExtension());
191
-                $msg = 'Could not create transform for: ' . $asset->title
192
-                    . ' - Final format: ' . $finalFormat
193
-                    . ' - Element extension: ' . $asset->getExtension()
194
-                    . ' - canManipulateAsImage: ' . $canManipulate;
191
+                $msg = 'Could not create transform for: '.$asset->title
192
+                    . ' - Final format: '.$finalFormat
193
+                    . ' - Element extension: '.$asset->getExtension()
194
+                    . ' - canManipulateAsImage: '.$canManipulate;
195 195
                 Craft::error(
196 196
                     $msg,
197 197
                     __METHOD__
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                                 $folder = $asset->getFolder();
231 231
                                 while ($folder !== null && !$createVariants) {
232 232
                                     if ($folder->uid === $subfolder || $folder->name === $subfolder) {
233
-                                        Craft::info('Matched subfolder uid: ' . print_r($subfolder, true), __METHOD__);
233
+                                        Craft::info('Matched subfolder uid: '.print_r($subfolder, true), __METHOD__);
234 234
                                         $createVariants = true;
235 235
                                     } else {
236 236
                                         $folder = $folder->getParent();
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
             } catch (SiteNotFoundException $e) {
349 349
                 $siteId = 0;
350 350
                 Craft::error(
351
-                    'Failed to get primary site: ' . $e->getMessage(),
351
+                    'Failed to get primary site: '.$e->getMessage(),
352 352
                     __METHOD__
353 353
                 );
354 354
             }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     {
453 453
         Craft::beginProfile('generatePlaceholders', __METHOD__);
454 454
         Craft::info(
455
-            'generatePlaceholders for: ' . print_r($model, true),
455
+            'generatePlaceholders for: '.print_r($model, true),
456 456
             __METHOD__
457 457
         );
458 458
         /** @var Settings $settings */
@@ -512,20 +512,20 @@  discard block
 block discarded – undo
512 512
         }
513 513
         $useAspectRatio = $variant['useAspectRatio'] ?? false;
514 514
         if ($useAspectRatio) {
515
-            $aspectRatio = (float)$variant['aspectRatioX'] / (float)$variant['aspectRatioY'];
515
+            $aspectRatio = (float) $variant['aspectRatioX'] / (float) $variant['aspectRatioY'];
516 516
         } else {
517
-            $aspectRatio = (float)$asset->width / (float)$asset->height;
517
+            $aspectRatio = (float) $asset->width / (float) $asset->height;
518 518
         }
519
-        $width = (int)$variant['width'] * (int)$retinaSize;
519
+        $width = (int) $variant['width'] * (int) $retinaSize;
520 520
         $transform->width = $width;
521
-        $transform->height = (int)($width / $aspectRatio);
521
+        $transform->height = (int) ($width / $aspectRatio);
522 522
         // Image quality
523
-        $quality = (int)($variant['quality'] ?? null);
523
+        $quality = (int) ($variant['quality'] ?? null);
524 524
         if (empty($quality)) {
525 525
             $quality = null;
526 526
         }
527 527
         if ($quality !== null && $settings->lowerQualityRetinaImageVariants && $retinaSize != '1') {
528
-            $quality = (int)($quality * (1.5 / (int)$retinaSize));
528
+            $quality = (int) ($quality * (1.5 / (int) $retinaSize));
529 529
         }
530 530
         $transform->quality = $quality;
531 531
         // Interlaced (progressive JPEGs or interlaced PNGs)
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
             $transform
553 553
         );
554 554
         Craft::info(
555
-            'URL created: ' . print_r($url, true),
555
+            'URL created: '.print_r($url, true),
556 556
             __METHOD__
557 557
         );
558 558
         // Update the model
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                 $this->generatePlaceholders($asset, $model, $aspectRatio);
581 581
             }
582 582
             Craft::info(
583
-                'Created transforms for variant: ' . print_r($variant, true),
583
+                'Created transforms for variant: '.print_r($variant, true),
584 584
                 __METHOD__
585 585
             );
586 586
         }
Please login to merge, or discard this patch.
src/imagetransforms/ImageTransform.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * @inheritdoc
66 66
      */
67
-    public function getTransformUrl(Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
67
+    public function getTransformUrl(Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
68 68
     {
69 69
         return null;
70 70
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @inheritdoc
74 74
      */
75
-    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel|string|array|null $transform): ?string
75
+    public function getWebPUrl(string $url, Asset $asset, CraftImageTransformModel | string | array | null $transform): ?string
76 76
     {
77 77
         return $url;
78 78
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if ($volume->getFs()->subfolder ?? null) {
107 107
             $subfolder = $volume->getFs()->subfolder;
108 108
             $subfolder = Craft::parseEnv($subfolder);
109
-            return rtrim($subfolder, '/') . '/' . $assetPath;
109
+            return rtrim($subfolder, '/').'/'.$assetPath;
110 110
         }
111 111
 
112 112
         return $assetPath;
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
     {
144 144
         $path = $this->decomposeUrl($pathOrUrl);
145 145
         $path_parts = pathinfo($path['path']);
146
-        $new_path = ($path_parts['filename']) . '.' . ($path_parts['extension'] ?? '') . $extension;
146
+        $new_path = ($path_parts['filename']).'.'.($path_parts['extension'] ?? '').$extension;
147 147
         if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== '.') {
148 148
             $dirname = $path_parts['dirname'];
149 149
             $dirname = $dirname === '/' ? '' : $dirname;
150
-            $new_path = $dirname . DIRECTORY_SEPARATOR . $new_path;
150
+            $new_path = $dirname.DIRECTORY_SEPARATOR.$new_path;
151 151
             $new_path = preg_replace('/([^:])(\/{2,})/', '$1/', $new_path);
152 152
         }
153 153
 
154
-        return $path['prefix'] . $new_path . $path['suffix'];
154
+        return $path['prefix'].$new_path.$path['suffix'];
155 155
     }
156 156
 
157 157
     // Protected Methods
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 
171 171
         if (filter_var($pathOrUrl, FILTER_VALIDATE_URL)) {
172 172
             $url_parts = parse_url($pathOrUrl);
173
-            $result['prefix'] = $url_parts['scheme'] . '://' . $url_parts['host'];
173
+            $result['prefix'] = $url_parts['scheme'].'://'.$url_parts['host'];
174 174
             if (!empty($url_parts['port'])) {
175
-                $result['prefix'] .= ':' . $url_parts['port'];
175
+                $result['prefix'] .= ':'.$url_parts['port'];
176 176
             }
177 177
             $result['path'] = $url_parts['path'];
178 178
             $result['suffix'] = '';
179
-            $result['suffix'] .= empty($url_parts['query']) ? '' : '?' . $url_parts['query'];
180
-            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#' . $url_parts['fragment'];
179
+            $result['suffix'] .= empty($url_parts['query']) ? '' : '?'.$url_parts['query'];
180
+            $result['suffix'] .= empty($url_parts['fragment']) ? '' : '#'.$url_parts['fragment'];
181 181
         } else {
182 182
             $result['prefix'] = '';
183 183
             $result['path'] = $pathOrUrl;
Please login to merge, or discard this patch.
src/ImageOptimize.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
     /**
140 140
      * @inheritdoc
141 141
      */
142
-    public function getSettingsResponse(): TemplateResponseBehavior|Response
142
+    public function getSettingsResponse(): TemplateResponseBehavior | Response
143 143
     {
144 144
         $view = Craft::$app->getView();
145 145
         $namespace = $view->getNamespace();
Please login to merge, or discard this patch.
src/helpers/PluginTemplate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
         array  $params = [],
62 62
         string $minifier = null,
63 63
     ): string {
64
-        $template = 'image-optimize/' . $templatePath;
64
+        $template = 'image-optimize/'.$templatePath;
65 65
         $oldMode = Craft::$app->view->getTemplateMode();
66 66
         // Look for the template on the frontend first
67 67
         try {
Please login to merge, or discard this patch.