Passed
Push — master ( 7c74ee...b29661 )
by Evgenii
03:32
created
src/logic/ImagePreviewer.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
         $this->width = $width;
31 31
         $this->webp = $webp;
32 32
 
33
-        if (!$this->model->isImage() && !$this->model->isVideo())
34
-            throw new ErrorException('File is not an image or video.');
33
+        if (!$this->model->isImage() && !$this->model->isVideo()) {
34
+                    throw new ErrorException('File is not an image or video.');
35
+        }
35 36
     }
36 37
 
37 38
     /**
@@ -41,8 +42,9 @@  discard block
 block discarded – undo
41 42
      */
42 43
     public function getUrl()
43 44
     {
44
-        if ($this->model->isSvg())
45
-            return $this->model->getRootPath();
45
+        if ($this->model->isSvg()) {
46
+                    return $this->model->getRootPath();
47
+        }
46 48
 
47 49
         $cachePath = Yii::$app->getModule('files')->cacheFullPath;
48 50
         $jpegName = $this->model->makeNameWithSize($this->model->filename, $this->width);
@@ -56,21 +58,25 @@  discard block
 block discarded – undo
56 58
         $sourceImagePath = $this->model->rootPath;
57 59
         if ($this->model->isVideo()) {
58 60
             $sourceImagePath = $this->fileName . '.jpeg';
59
-            if (!is_file($sourceImagePath))
60
-                Yii::createObject(VideoFrameExtractor::class, [
61
+            if (!is_file($sourceImagePath)) {
62
+                            Yii::createObject(VideoFrameExtractor::class, [
61 63
                     $this->model->rootPath,
62 64
                     $sourceImagePath
63 65
                 ])->extract();
66
+            }
64 67
         }
65 68
 
66
-        if (!is_file($this->fileName) || filesize($this->fileName) == 0)
67
-            $this->createPreview($sourceImagePath);
69
+        if (!is_file($this->fileName) || filesize($this->fileName) == 0) {
70
+                    $this->createPreview($sourceImagePath);
71
+        }
68 72
 
69
-        if ($this->webp && !file_exists($this->fileNameWebp))
70
-            $this->createPreviewWebp();
73
+        if ($this->webp && !file_exists($this->fileNameWebp)) {
74
+                    $this->createPreviewWebp();
75
+        }
71 76
 
72
-        if ($this->webp)
73
-            return $this->fileNameWebp;
77
+        if ($this->webp) {
78
+                    return $this->fileNameWebp;
79
+        }
74 80
 
75 81
         return $this->fileName;
76 82
     }
@@ -80,19 +86,23 @@  discard block
 block discarded – undo
80 86
      */
81 87
     protected function prepareFolder()
82 88
     {
83
-        if (!file_exists(Yii::$app->getModule('files')->cacheFullPath))
84
-            mkdir(Yii::$app->getModule('files')->cacheFullPath);
89
+        if (!file_exists(Yii::$app->getModule('files')->cacheFullPath)) {
90
+                    mkdir(Yii::$app->getModule('files')->cacheFullPath);
91
+        }
85 92
         $lastFolder = '/';
86 93
         $explodes = explode('/', $this->fileName);
87 94
         array_pop($explodes);
88
-        if (empty($explodes))
89
-            return;
95
+        if (empty($explodes)) {
96
+                    return;
97
+        }
90 98
         foreach ($explodes as $folder) {
91
-            if (empty($folder))
92
-                continue;
99
+            if (empty($folder)) {
100
+                            continue;
101
+            }
93 102
             $lastFolder = $lastFolder . $folder . '/';
94
-            if (!file_exists($lastFolder))
95
-                mkdir($lastFolder);
103
+            if (!file_exists($lastFolder)) {
104
+                            mkdir($lastFolder);
105
+            }
96 106
         }
97 107
     }
98 108
 
@@ -115,8 +125,9 @@  discard block
 block discarded – undo
115 125
         }
116 126
 
117 127
         $saveType = $img->image_type;
118
-        if ($saveType == IMG_WEBP || $saveType == IMG_QUADRATIC)
119
-            $saveType = IMG_JPEG;
128
+        if ($saveType == IMG_WEBP || $saveType == IMG_QUADRATIC) {
129
+                    $saveType = IMG_JPEG;
130
+        }
120 131
         $img->save($this->fileName, $saveType);
121 132
     }
122 133
 
Please login to merge, or discard this patch.
src/logic/FileCreateFromInstance.php 1 patch
Braces   +29 added lines, -20 removed lines patch added patch discarded remove patch
@@ -35,27 +35,31 @@  discard block
 block discarded – undo
35 35
 
36 36
         $this->_onlyUploaded = $onlyUploaded;
37 37
 
38
-        if (!isset($data['attribute']) || !$data['attribute'] || !isset($data['modelClass']) || !$data['modelClass'])
39
-            throw new BadRequestHttpException("Attribute or class name not set.");
38
+        if (!isset($data['attribute']) || !$data['attribute'] || !isset($data['modelClass']) || !$data['modelClass']) {
39
+                    throw new BadRequestHttpException("Attribute or class name not set.");
40
+        }
40 41
 
41 42
         // Загружаем полученные данные
42 43
         $this->_instance = $file;
43 44
         $this->_attribute = $data['attribute'];
44 45
 
45
-        if (!file_exists($this->_instance->tempName))
46
-            throw new ErrorException("Tmp file not found on disk.");
46
+        if (!file_exists($this->_instance->tempName)) {
47
+                    throw new ErrorException("Tmp file not found on disk.");
48
+        }
47 49
 
48 50
         // Инициализируем класс владельца файла для валидаций и ставим сценарий
49 51
         $this->_owner = new $data['modelClass'];
50 52
 
51
-        if (isset($data['scenario']))
52
-            $this->_owner->setScenario($data['scenario']);
53
+        if (isset($data['scenario'])) {
54
+                    $this->_owner->setScenario($data['scenario']);
55
+        }
53 56
 
54 57
 
55 58
         if (isset($this->_owner->behaviors['files']->attributes[$this->_attribute]['validator'])) {
56 59
             foreach ($this->_owner->behaviors['files']->attributes[$this->_attribute]['validator'] as $validator) {
57
-                if (!$validator->validate($this->_instance, $error))
58
-                    throw new BadRequestHttpException($error);
60
+                if (!$validator->validate($this->_instance, $error)) {
61
+                                    throw new BadRequestHttpException($error);
62
+                }
59 63
             }
60 64
 
61 65
         }
@@ -71,10 +75,12 @@  discard block
 block discarded – undo
71 75
         $this->_model->content_type = $this->_instance->type;
72 76
         $this->_model->size = $this->_instance->size;
73 77
         $this->_model->type = $this->detectType();
74
-        if ($identity)
75
-            $this->_model->user_id = $identity->getId();
76
-        if ($this->_model->type == FileType::VIDEO)
77
-            $this->_model->video_status = 0;
78
+        if ($identity) {
79
+                    $this->_model->user_id = $identity->getId();
80
+        }
81
+        if ($this->_model->type == FileType::VIDEO) {
82
+                    $this->_model->video_status = 0;
83
+        }
78 84
 
79 85
         //Генерируем полный новый адрес сохранения файла
80 86
         $this->_fullPath = Yii::$app->getModule('files')->storageFullPath . DIRECTORY_SEPARATOR . $this->_model->filename;
@@ -86,10 +92,12 @@  discard block
 block discarded – undo
86 92
     public function detectType()
87 93
     {
88 94
         $contentTypeArray = explode('/', $this->_model->content_type);
89
-        if ($contentTypeArray[0] == 'image')
90
-            return FileType::IMAGE;
91
-        if ($contentTypeArray[0] == 'video')
92
-            return FileType::VIDEO;
95
+        if ($contentTypeArray[0] == 'image') {
96
+                    return FileType::IMAGE;
97
+        }
98
+        if ($contentTypeArray[0] == 'video') {
99
+                    return FileType::VIDEO;
100
+        }
93 101
         return FileType::FILE;
94 102
     }
95 103
 
@@ -102,10 +110,11 @@  discard block
 block discarded – undo
102 110
         $path = Yii::$app->getModule('files')->storageFullPath . $this->_model->filename;
103 111
 
104 112
         if ($this->_model->save()) {
105
-            if (!$this->_onlyUploaded)
106
-                copy($this->_instance->tempName, $this->_fullPath);
107
-            else
108
-                $this->_instance->saveAs($this->_fullPath, false);
113
+            if (!$this->_onlyUploaded) {
114
+                            copy($this->_instance->tempName, $this->_fullPath);
115
+            } else {
116
+                            $this->_instance->saveAs($this->_fullPath, false);
117
+            }
109 118
         }
110 119
 
111 120
         if ($this->_model->type == FileType::IMAGE) {
Please login to merge, or discard this patch.
src/logic/VideoFrameExtractor.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,14 +19,17 @@  discard block
 block discarded – undo
19 19
     {
20 20
         $this->ffmpegBin = Yii::$app->getModule('files')->ffmpeg;
21 21
 
22
-        if (!file_exists($this->ffmpegBin))
23
-            throw new ErrorException("ffmpeg is not found: {$this->ffmpegBin}");
22
+        if (!file_exists($this->ffmpegBin)) {
23
+                    throw new ErrorException("ffmpeg is not found: {$this->ffmpegBin}");
24
+        }
24 25
 
25
-        if (!is_executable($this->ffmpegBin))
26
-            throw new ErrorException("ffmpeg is not executable: {$this->ffmpegBin}");
26
+        if (!is_executable($this->ffmpegBin)) {
27
+                    throw new ErrorException("ffmpeg is not executable: {$this->ffmpegBin}");
28
+        }
27 29
 
28
-        if (!is_file($videoSourceFilename))
29
-            throw new ErrorException('File not found on disk.');
30
+        if (!is_file($videoSourceFilename)) {
31
+                    throw new ErrorException('File not found on disk.');
32
+        }
30 33
 
31 34
         $this->videoSourceFilename = $videoSourceFilename;
32 35
         $this->outputImageFilename = $outputImageFilename;
@@ -39,8 +42,9 @@  discard block
 block discarded – undo
39 42
     {
40 43
         $command = "{$this->ffmpegBin} -i {$this->videoSourceFilename}  -ss 00:00:03.000 -vframes 1  {$this->outputImageFilename}";
41 44
         exec($command, $out, $result);
42
-        if ($result !== 0)
43
-            throw new ErrorException('FFmpeg frame extracting fail:' . print_r($out, true));
45
+        if ($result !== 0) {
46
+                    throw new ErrorException('FFmpeg frame extracting fail:' . print_r($out, true));
47
+        }
44 48
     }
45 49
 
46 50
 }
Please login to merge, or discard this patch.
src/controllers/DefaultController.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@  discard block
 block discarded – undo
73 73
      */
74 74
     private function checkFormToken()
75 75
     {
76
-        if (in_array($this->action->id, $this->actionsToCheck) && FileInputWidget::generateToken() != Yii::$app->request->post('_fileFormToken'))
77
-            throw new BadRequestHttpException('File-form token is wrong or missing.');
76
+        if (in_array($this->action->id, $this->actionsToCheck) && FileInputWidget::generateToken() != Yii::$app->request->post('_fileFormToken')) {
77
+                    throw new BadRequestHttpException('File-form token is wrong or missing.');
78
+        }
78 79
     }
79 80
 
80 81
     /**
@@ -87,12 +88,14 @@  discard block
 block discarded – undo
87 88
 
88 89
         $zip = new  ZipArchive;
89 90
         $filename = Yii::getAlias("@webroot/assets/files.zip");
90
-        if (file_exists($filename))
91
-            @unlink($filename);
91
+        if (file_exists($filename)) {
92
+                    @unlink($filename);
93
+        }
92 94
         if (sizeof($files) && $zip->open($filename, ZipArchive::CREATE)) {
93 95
 
94
-            foreach ($files as $file)
95
-                $zip->addFile($file->rootPath, $file->title);
96
+            foreach ($files as $file) {
97
+                            $zip->addFile($file->rootPath, $file->title);
98
+            }
96 99
 
97 100
             $zip->close();
98 101
             header("Pragma: public");
@@ -165,8 +168,9 @@  discard block
 block discarded – undo
165 168
 
166 169
         $view = Yii::$app->request->post('mode') == 'single' ? "_single" : "_file";
167 170
 
168
-        if ($ratio)
169
-            $this->getView()->registerJs("initCropper({$model->id}, '{$model->href}', {$ratio}, true);");
171
+        if ($ratio) {
172
+                    $this->getView()->registerJs("initCropper({$model->id}, '{$model->href}', {$ratio}, true);");
173
+        }
170 174
 
171 175
         return $this->renderAjax($view, [
172 176
             'model' => $model,
@@ -192,8 +196,9 @@  discard block
 block discarded – undo
192 196
     {
193 197
         $model = File::findOne(['hash' => $hash]);
194 198
 
195
-        if (!$model)
196
-            throw new NotFoundHttpException("Запрашиваемый файл не найден в базе.");
199
+        if (!$model) {
200
+                    throw new NotFoundHttpException("Запрашиваемый файл не найден в базе.");
201
+        }
197 202
 
198 203
         $response = Yii::$app->response;
199 204
         $response->format = Response::FORMAT_RAW;
@@ -202,8 +207,9 @@  discard block
 block discarded – undo
202 207
         Yii::$app->response->headers->set('Last-Modified', date("c", $model->created));
203 208
         Yii::$app->response->headers->set('Cache-Control', 'public, max-age=' . (60 * 60 * 24 * 15));
204 209
 
205
-        if (!file_exists($model->getRootPreviewPath()))
206
-            throw new NotFoundHttpException('Preview not found.');
210
+        if (!file_exists($model->getRootPreviewPath())) {
211
+                    throw new NotFoundHttpException('Preview not found.');
212
+        }
207 213
 
208 214
         $response->sendFile($model->getRootPreviewPath(), 'preview.jpg');
209 215
 
Please login to merge, or discard this patch.
src/components/PictureWidget.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,11 +28,13 @@
 block discarded – undo
28 28
      */
29 29
     public function run(): ?string
30 30
     {
31
-        if (empty($this->model) || !in_array($this->model->type, [FileType::IMAGE, FileType::VIDEO]))
32
-            return null;
31
+        if (empty($this->model) || !in_array($this->model->type, [FileType::IMAGE, FileType::VIDEO])) {
32
+                    return null;
33
+        }
33 34
 
34
-        if (is_array($this->width))
35
-            $this->view = 'mediaPictureWidget';
35
+        if (is_array($this->width)) {
36
+                    $this->view = 'mediaPictureWidget';
37
+        }
36 38
 
37 39
         return $this->render($this->view, [
38 40
             'model' => $this->model,
Please login to merge, or discard this patch.
src/models/File.php 1 patch
Braces   +42 added lines, -28 removed lines patch added patch discarded remove patch
@@ -87,29 +87,37 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $icon = IconHelper::FILE;
89 89
 
90
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
91
-            $icon = IconHelper::FILE_WORD;
90
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
91
+                    $icon = IconHelper::FILE_WORD;
92
+        }
92 93
 
93
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
94
-            $icon = IconHelper::FILE_EXCEL;
94
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
95
+                    $icon = IconHelper::FILE_EXCEL;
96
+        }
95 97
 
96
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation')
97
-            $icon = IconHelper::FILE_POWERPOINT;
98
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') {
99
+                    $icon = IconHelper::FILE_POWERPOINT;
100
+        }
98 101
 
99
-        if ($this->content_type == 'application/x-zip-compressed')
100
-            $icon = IconHelper::FILE_ARCHIVE;
102
+        if ($this->content_type == 'application/x-zip-compressed') {
103
+                    $icon = IconHelper::FILE_ARCHIVE;
104
+        }
101 105
 
102
-        if ($this->content_type == 'application/octet-stream')
103
-            $icon = IconHelper::FILE_ARCHIVE;
106
+        if ($this->content_type == 'application/octet-stream') {
107
+                    $icon = IconHelper::FILE_ARCHIVE;
108
+        }
104 109
 
105
-        if (preg_match('/audio/', $this->content_type))
106
-            $icon = IconHelper::FILE_AUDIO;
110
+        if (preg_match('/audio/', $this->content_type)) {
111
+                    $icon = IconHelper::FILE_AUDIO;
112
+        }
107 113
 
108
-        if (preg_match('/pdf/', $this->content_type))
109
-            $icon = IconHelper::FILE_PDF;
114
+        if (preg_match('/pdf/', $this->content_type)) {
115
+                    $icon = IconHelper::FILE_PDF;
116
+        }
110 117
 
111
-        if ($this->type == FileType::VIDEO)
112
-            $icon = IconHelper::FILE_VIDEO;
118
+        if ($this->type == FileType::VIDEO) {
119
+                    $icon = IconHelper::FILE_VIDEO;
120
+        }
113 121
 
114 122
         return $icon;
115 123
     }
@@ -225,8 +233,9 @@  discard block
 block discarded – undo
225 233
 
226 234
     public function getRootPreviewPath()
227 235
     {
228
-        if ($this->isSvg())
229
-            return $this->getRootPath();
236
+        if ($this->isSvg()) {
237
+                    return $this->getRootPath();
238
+        }
230 239
 
231 240
         return Yii::$app->getModule('files')->storageFullPath . $this->filename . '.jpg';
232 241
     }
@@ -340,8 +349,9 @@  discard block
 block discarded – undo
340 349
             isset($this->behaviors['files']) &&
341 350
             isset($this->behaviors['files']->attributes[$this->field]) &&
342 351
             isset($this->behaviors['files']->attributes[$this->field]['watermark'])
343
-        )
344
-            return $this->behaviors['files']->attributes[$this->field]['watermark'];
352
+        ) {
353
+                    return $this->behaviors['files']->attributes[$this->field]['watermark'];
354
+        }
345 355
     }
346 356
 
347 357
     /**
@@ -361,17 +371,20 @@  discard block
 block discarded – undo
361 371
      */
362 372
     public function getPreviewWebPath(int $width = 0, bool $webp = false)
363 373
     {
364
-        if (!file_exists($this->getRootPath()))
365
-            return null;
374
+        if (!file_exists($this->getRootPath())) {
375
+                    return null;
376
+        }
366 377
 
367
-        if (!$this->isVideo() && !$this->isImage())
368
-            throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
378
+        if (!$this->isVideo() && !$this->isImage()) {
379
+                    throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
380
+        }
369 381
 
370
-        if (Yii::$app->getModule('files')->hostStatic)
371
-            return
382
+        if (Yii::$app->getModule('files')->hostStatic) {
383
+                    return
372 384
                 Yii::$app->getModule('files')->hostStatic .
373 385
                 $this->makeNameWithSize($this->filename, $width, $webp) .
374 386
                 "?hash={$this->hash}&width={$width}&webp=" . intval($webp);
387
+        }
375 388
 
376 389
         return Url::toRoute(['/files/default/image', 'hash' => $this->hash, 'width' => $width, 'webp' => $webp]);
377 390
     }
@@ -407,8 +420,9 @@  discard block
 block discarded – undo
407 420
      */
408 421
     public function getPreviewRootPath($width = 0, $webp = false)
409 422
     {
410
-        if (!$this->isVideo() && !$this->isImage())
411
-            throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
423
+        if (!$this->isVideo() && !$this->isImage()) {
424
+                    throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
425
+        }
412 426
         return $this->makeNameWithSize($this->rootPath, $width, $webp);
413 427
     }
414 428
 
Please login to merge, or discard this patch.
src/components/FileBehaviour.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@
 block discarded – undo
205 205
         if (isset($this->_values[$att_name])) {
206 206
             unset($this->_values[$att_name][0]);
207 207
             if (sizeof($this->_values[$att_name]))
208
-                return array_map(function ($fileId) {
208
+                return array_map(function($fileId) {
209 209
                     return File::findOne($fileId);
210 210
                 }, $this->_values[$att_name]);
211 211
         } else {
Please login to merge, or discard this patch.
Braces   +24 added lines, -15 removed lines patch added patch discarded remove patch
@@ -69,9 +69,11 @@  discard block
 block discarded – undo
69 69
                     ]
70 70
                 )->execute();
71 71
 
72
-                if ($ids) foreach ($ids as $id) {
72
+                if ($ids) {
73
+                    foreach ($ids as $id) {
73 74
                     if (empty($id))
74 75
                         continue;
76
+                }
75 77
                     $file = File::findOne($id);
76 78
                     if ($file) {
77 79
                         $file->object_id = $this->owner->id;
@@ -106,8 +108,9 @@  discard block
 block discarded – undo
106 108
                 in_array($this->owner->scenario, $params['requiredOn']) &&
107 109
                 !in_array($this->owner->scenario, $params['requiredExcept']) &&
108 110
                 !isset($this->_values[$attributeIds][1])
109
-            )
110
-                $this->owner->addError($attributeName, $params['requiredMessage']);
111
+            ) {
112
+                            $this->owner->addError($attributeName, $params['requiredMessage']);
113
+            }
111 114
         }
112 115
     }
113 116
 
@@ -124,8 +127,8 @@  discard block
 block discarded – undo
124 127
         $validators = $owner->validators;
125 128
 
126 129
         // Пробегаемся по валидаторам и вычисляем, какие из них касаются наших файл-полей
127
-        if ($validators)
128
-            foreach ($validators as $key => $validator) {
130
+        if ($validators) {
131
+                    foreach ($validators as $key => $validator) {
129 132
 
130 133
                 // Сначала пробегаемся по файловым валидаторам
131 134
                 if ($validator::className() == 'yii\validators\FileValidator' || $validator::className() == 'floor12\files\components\ReformatValidator') {
@@ -133,6 +136,7 @@  discard block
 block discarded – undo
133 136
 
134 137
                         if (is_string($params)) {
135 138
                             $field = $params;
139
+        }
136 140
                             $params = [];
137 141
                         }
138 142
 
@@ -168,8 +172,10 @@  discard block
 block discarded – undo
168 172
             }
169 173
 
170 174
         // Добавляем дефолтный валидатор для прилетающих айдишников
171
-        if ($this->attributes) foreach ($this->attributes as $fieldName => $fieldParams) {
175
+        if ($this->attributes) {
176
+            foreach ($this->attributes as $fieldName => $fieldParams) {
172 177
             $validator = Validator::createValidator('safe', $owner, ["{$fieldName}_ids"]);
178
+        }
173 179
             $validators->append($validator);
174 180
         }
175 181
     }
@@ -190,8 +196,9 @@  discard block
 block discarded – undo
190 196
      */
191 197
     public function canSetProperty($name, $checkVars = true)
192 198
     {
193
-        if (array_key_exists($this->getRealAttributeName($name), $this->attributes))
194
-            return true;
199
+        if (array_key_exists($this->getRealAttributeName($name), $this->attributes)) {
200
+                    return true;
201
+        }
195 202
 
196 203
         return parent::canSetProperty($name, $checkVars = true);
197 204
     }
@@ -204,9 +211,10 @@  discard block
 block discarded – undo
204 211
     {
205 212
         if (isset($this->_values[$att_name])) {
206 213
             unset($this->_values[$att_name][0]);
207
-            if (sizeof($this->_values[$att_name]))
208
-                return array_map(function ($fileId) {
214
+            if (sizeof($this->_values[$att_name])) {
215
+                            return array_map(function ($fileId) {
209 216
                     return File::findOne($fileId);
217
+            }
210 218
                 }, $this->_values[$att_name]);
211 219
         } else {
212 220
             if (!isset($this->cachedFiles[$att_name])) {
@@ -214,8 +222,8 @@  discard block
 block discarded – undo
214 222
                     isset($this->attributes[$att_name]['validator']) &&
215 223
                     isset($this->attributes[$att_name]['validator']['yii\validators\FileValidator']) &&
216 224
                     $this->attributes[$att_name]['validator']['yii\validators\FileValidator']->maxFiles > 1
217
-                )
218
-                    $this->cachedFiles[$att_name] = File::find()
225
+                ) {
226
+                                    $this->cachedFiles[$att_name] = File::find()
219 227
                         ->where(
220 228
                             [
221 229
                                 'object_id' => $this->owner->id,
@@ -224,7 +232,7 @@  discard block
 block discarded – undo
224 232
                             ])
225 233
                         ->orderBy('ordering ASC')
226 234
                         ->all();
227
-                else {
235
+                } else {
228 236
                     $this->cachedFiles[$att_name] = File::find()
229 237
                         ->where(
230 238
                             [
@@ -249,8 +257,9 @@  discard block
 block discarded – undo
249 257
     {
250 258
         $attribute = $this->getRealAttributeName($name);
251 259
 
252
-        if (array_key_exists($attribute, $this->attributes))
253
-            $this->_values[$attribute] = $value;
260
+        if (array_key_exists($attribute, $this->attributes)) {
261
+                    $this->_values[$attribute] = $value;
262
+        }
254 263
     }
255 264
 
256 265
 
Please login to merge, or discard this patch.
src/components/FileListWidget.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,9 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function init()
32 32
     {
33
-        if (empty($this->files))
34
-            return null;
33
+        if (empty($this->files)) {
34
+                    return null;
35
+        }
35 36
         Yii::$app->getModule('files')->registerTranslations();
36 37
         if (empty($this->lightboxKey)) {
37 38
             $this->lightboxKey = $this->files[0]->field . '-' . $this->files[0]->object_id;
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 
51 52
         $this->getView()->registerJs("yiiDownloadAllLink = '" . Url::toRoute('files/default/zip') . "'", View::POS_BEGIN, 'yiiDownloadAllLink');
52 53
 
53
-        if ($this->passFirst && sizeof($this->files) > 0)
54
-            $this->files = array_slice($this->files, 1);
54
+        if ($this->passFirst && sizeof($this->files) > 0) {
55
+                    $this->files = array_slice($this->files, 1);
56
+        }
55 57
 
56 58
 
57 59
         return $this->render('fileListWidget', [
Please login to merge, or discard this patch.
src/components/FileInputWidget.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@
 block discarded – undo
37 37
         $this->registerTranslations();
38 38
         $this->block_id = rand(9999999, 999999999);
39 39
 
40
-        if (!$this->uploadButtonText)
41
-            $this->uploadButtonText = Yii::t('files', 'Upload');
40
+        if (!$this->uploadButtonText) {
41
+                    $this->uploadButtonText = Yii::t('files', 'Upload');
42
+        }
42 43
 
43 44
         $this->ratio = $this->model->getBehavior('files')->attributes[$this->attribute]['ratio'] ?? null;
44 45
 
Please login to merge, or discard this patch.