Completed
Push — develop ( fd1ec4...9ebe7a )
by Schlaefer
02:36
created
plugins/ImageUploader/tests/TestCase/Controller/UploadsControllerTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         parent::setUp();
47 47
 
48
-        $this->file = new File(TMP . 'my new-upload.png');
48
+        $this->file = new File(TMP.'my new-upload.png');
49 49
         $this->mockMediaFile($this->file);
50 50
     }
51 51
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $this->loginJwt(1);
73 73
 
74 74
         $this->upload($this->file);
75
-        $response = json_decode((string)$this->_response->getBody(), true);
75
+        $response = json_decode((string) $this->_response->getBody(), true);
76 76
 
77 77
         $this->assertResponseCode(200);
78 78
 
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
     {
115 115
         $this->loginJwt(1);
116 116
 
117
-        $this->file = new File(TMP . 'tmp_svg.svg');
117
+        $this->file = new File(TMP.'tmp_svg.svg');
118 118
         $this->file->write('<?xml version="1.0" encoding="UTF-8" ?>
119 119
             <svg width="9" height="9" style="background:red;"></svg>');
120 120
         $this->upload($this->file);
121 121
 
122
-        $response = json_decode((string)$this->_response->getBody(), true);
122
+        $response = json_decode((string) $this->_response->getBody(), true);
123 123
 
124 124
         $this->assertResponseCode(200);
125 125
 
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $this->loginJwt(1);
161 161
         unset($this->file);
162
-        $this->file = new File(TMP . 'tmp_exif.jpg');
162
+        $this->file = new File(TMP.'tmp_exif.jpg');
163 163
 
164
-        $fixture = new File($path = Plugin::path('ImageUploader') . 'tests/Fixture/exif-with-location.jpg');
164
+        $fixture = new File($path = Plugin::path('ImageUploader').'tests/Fixture/exif-with-location.jpg');
165 165
         $fixture->copy($this->file->path);
166 166
 
167
-        $readExif = function (File $file) {
167
+        $readExif = function(File $file) {
168 168
             //@codingStandardsIgnoreStart
169 169
             return @exif_read_data($file->path);
170 170
             //@codingStandardsIgnoreEnd
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         $this->upload($this->file);
178 178
 
179
-        $response = json_decode((string)$this->_response->getBody(), true);
179
+        $response = json_decode((string) $this->_response->getBody(), true);
180 180
 
181 181
         $this->assertResponseCode(200);
182 182
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         $this->get('api/v2/uploads');
238 238
 
239
-        $response = json_decode((string)$this->_response->getBody(), true);
239
+        $response = json_decode((string) $this->_response->getBody(), true);
240 240
 
241 241
         $this->assertResponseCode(200);
242 242
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
         $this->delete('api/v2/uploads/1');
285 285
 
286
-        $response = json_decode((string)$this->_response->getBody(), true);
286
+        $response = json_decode((string) $this->_response->getBody(), true);
287 287
 
288 288
         $this->assertResponseCode(204);
289 289
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                 0 => [
312 312
                     'file' => [
313 313
                         'tmp_name' => $file->path,
314
-                        'name' => $file->name() . '.' . $this->file->ext(),
314
+                        'name' => $file->name().'.'.$this->file->ext(),
315 315
                         'size' => $file->size(),
316 316
                         'type' => $file->mime(),
317 317
                     ]
Please login to merge, or discard this patch.
plugins/ImageUploader/tests/TestCase/Controller/ThumbnailControllerTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $Uploads = TableRegistry::get('ImageUploader.Uploads');
34 34
         $upload = $Uploads->get(1);
35 35
 
36
-        $file = new File(Configure::read('Saito.Settings.uploadDirectory') . $upload->get('name'));
36
+        $file = new File(Configure::read('Saito.Settings.uploadDirectory').$upload->get('name'));
37 37
         $raw = (new SimpleImage())
38 38
             ->fromNew(500, 500, 'blue')
39 39
             ->toString($upload->get('type'));
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
         $this->assertFalse(Cache::read($upload->get('id'), $cacheKey));
49 49
 
50
-        $this->get('/api/v2/uploads/thumb/1?h=' . $upload->get('hash'));
50
+        $this->get('/api/v2/uploads/thumb/1?h='.$upload->get('hash'));
51 51
 
52 52
         $cache = Cache::read($upload->get('id'), $cacheKey);
53 53
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $this->assertSame(300, imagesx($image));
56 56
         $this->assertSame(300, imagesy($image));
57 57
         $this->assertSame($upload->get('type'), $cache['type']);
58
-        $this->assertResponseEquals($cache['raw'], (string)$this->_response->getBody());
58
+        $this->assertResponseEquals($cache['raw'], (string) $this->_response->getBody());
59 59
         $this->assertHeader('content-type', 'image/png');
60 60
 
61 61
         //// cleanup
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         $Uploads = TableRegistry::get('ImageUploader.Uploads');
75 75
         $upload = $Uploads->get(1);
76 76
 
77
-        $file = new File(Configure::read('Saito.Settings.uploadDirectory') . $upload->get('name'));
77
+        $file = new File(Configure::read('Saito.Settings.uploadDirectory').$upload->get('name'));
78 78
         $raw = (new SimpleImage())
79 79
             ->fromNew(100, 100, 'blue')
80 80
             ->toString($upload->get('type'));
Please login to merge, or discard this patch.
plugins/ImageUploader/src/Model/Table/UploadsTable.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $UploaderConfig = Configure::read('Saito.Settings.uploader');
87 87
         $nMax = $UploaderConfig->getMaxNumberOfUploadsPerUser();
88 88
         $rules->add(
89
-            function (Upload $entity, array $options) use ($nMax) {
89
+            function(Upload $entity, array $options) use ($nMax) {
90 90
                 $count = $this->findByUserId($entity->get('user_id'))->count();
91 91
 
92 92
                 return $count < $nMax;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     private function convertToJpeg(File $file): File
194 194
     {
195
-        $jpeg = new File($file->folder()->path . DS . $file->name() . '.jpg');
195
+        $jpeg = new File($file->folder()->path.DS.$file->name().'.jpg');
196 196
 
197 197
         try {
198 198
             (new SimpleImage())
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
         $ratio = $size / $target;
248 248
         $ratio = sqrt($ratio);
249 249
 
250
-        $newwidth = (int)($width / $ratio);
251
-        $newheight = (int)($height / $ratio);
250
+        $newwidth = (int) ($width / $ratio);
251
+        $newheight = (int) ($height / $ratio);
252 252
         $destination = imagecreatetruecolor($newwidth, $newheight);
253 253
 
254 254
         $source = imagecreatefromstring($raw);
Please login to merge, or discard this patch.
plugins/ImageUploader/src/Controller/ThumbnailController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function thumb(): Response
37 37
     {
38
-        $id = (int)$this->request->getParam('id');
39
-        ['hash' => $fingerprint, 'type' => $type, 'raw' => $raw] = Cache::remember((string)$id, function () use ($id) {
38
+        $id = (int) $this->request->getParam('id');
39
+        ['hash' => $fingerprint, 'type' => $type, 'raw' => $raw] = Cache::remember((string) $id, function() use ($id) {
40 40
             $Uploads = $this->loadModel('ImageUploader.Uploads');
41 41
             $document = $Uploads->get($id);
42 42
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             return compact('hash', 'raw', 'type');
56 56
         }, Configure::read('Saito.Settings.uploader')->getCacheKey());
57 57
 
58
-        $hash = (string)$this->request->getQuery('h');
58
+        $hash = (string) $this->request->getQuery('h');
59 59
         if ($hash !== $fingerprint) {
60 60
             throw new SaitoForbiddenException(
61 61
                 "Attempt to access image-thumbnail $id."
Please login to merge, or discard this patch.
plugins/ImageUploader/src/Controller/UploadsController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
         }
59 59
         $parts = explode('.', $submitted['name']);
60 60
         $ext = array_pop($parts);
61
-        $name = $this->CurrentUser->getId() .
62
-                '_' .
63
-                substr(Security::hash($submitted['name'], 'sha256'), 32) .
64
-                '.' .
61
+        $name = $this->CurrentUser->getId().
62
+                '_'.
63
+                substr(Security::hash($submitted['name'], 'sha256'), 32).
64
+                '.'.
65 65
                 $ext;
66 66
         $data = [
67 67
             'document' => $submitted,
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             throw new GenericApiException($msg);
104 104
         }
105 105
 
106
-        Cache::delete((string)$imageId, 'uploadsThumbnails');
106
+        Cache::delete((string) $imageId, 'uploadsThumbnails');
107 107
 
108 108
         $this->autoRender = false;
109 109
         $this->response = $this->response->withStatus(204);
Please login to merge, or discard this patch.
plugins/ImageUploader/src/View/Helper/ImageUploaderHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                 'title' => $image->get('title') ?: $image->get('name'),
45 45
                 'size' => $image->get('size'),
46 46
                 'url' => $this->Url->assetUrl(
47
-                    'useruploads/' . $image->get('name'),
47
+                    'useruploads/'.$image->get('name'),
48 48
                     ['fullBase' => true]
49 49
                 ),
50 50
                 'thumbnail_url' => $this->Url->build(
Please login to merge, or discard this patch.
plugins/ImageUploader/src/Lib/UploaderConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types = 1);
3
+declare(strict_types=1);
4 4
 
5 5
 /**
6 6
  * Saito - The Threaded Web Forum
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function setDefaultMaxFileSize($number): self
64 64
     {
65 65
         if (is_string($number)) {
66
-            $number = (int)Text::parseFileSize($number, $this->defaultSize);
66
+            $number = (int) Text::parseFileSize($number, $this->defaultSize);
67 67
         }
68 68
         if (!is_int($number)) {
69 69
             throw new \InvalidArgumentException(
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         if ($size === null) {
90 90
             $size = $this->defaultSize;
91 91
         } elseif (is_string($size)) {
92
-            $size = (int)Text::parseFileSize($size, $this->defaultSize);
92
+            $size = (int) Text::parseFileSize($size, $this->defaultSize);
93 93
         }
94 94
         if (!is_int($size)) {
95 95
             throw new \InvalidArgumentException(
Please login to merge, or discard this patch.
plugins/BbcodeParser/tests/TestCase/Lib/BbcodeParserTest.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
     {
303 303
         $input = '@Alice @Bob @Bobby Junior @Bobby Tables @Dr. No';
304 304
         $expected =
305
-            "<a href='/at/Alice'>@Alice</a>" .
306
-            " @Bob " .
307
-            "<a href='/at/Bobby+Junior'>@Bobby Junior</a>" .
308
-            " @Bobby Tables " .
305
+            "<a href='/at/Alice'>@Alice</a>".
306
+            " @Bob ".
307
+            "<a href='/at/Bobby+Junior'>@Bobby Junior</a>".
308
+            " @Bobby Tables ".
309 309
             "<a href='/at/Dr.+No'>@Dr. No</a>";
310 310
 
311 311
         $result = $this->_Parser->parse($input);
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
     public function testIframe()
635 635
     {
636 636
         //* test allowed domain
637
-        $input = '[iframe height=349 width=560 ' .
638
-            'src=http://www.youtube.com/embed/HdoW3t_WorU ' .
637
+        $input = '[iframe height=349 width=560 '.
638
+            'src=http://www.youtube.com/embed/HdoW3t_WorU '.
639 639
             'frameborder=0][/iframe]';
640 640
         $expected = [
641 641
             [
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
         $this->assertHtml($expected, $result);
660 660
 
661 661
         //* test forbidden domains
662
-        $input = '[iframe height=349 width=560 ' .
663
-            'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
662
+        $input = '[iframe height=349 width=560 '.
663
+            'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
664 664
             'frameborder=0][/iframe]';
665 665
         $pattern = '/src/i';
666 666
         $result = $this->_Parser->parse(
@@ -672,8 +672,8 @@  discard block
 block discarded – undo
672 672
 
673 673
     public function testIframeAllDomainsAllowed()
674 674
     {
675
-        $input = '[iframe height=349 width=560 ' .
676
-            'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
675
+        $input = '[iframe height=349 width=560 '.
676
+            'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
677 677
             '][/iframe]';
678 678
         $expected = 'src="http://www.youtubescam.com/embed/HdoW3t_WorU';
679 679
         $this->MarkupSettings->setSingle('video_domains_allowed', '*');
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 
684 684
     public function testIframeNoDomainAllowed()
685 685
     {
686
-        $input = '[iframe height=349 width=560 ' .
687
-            'src=http://www.youtubescam.com/embed/HdoW3t_WorU ' .
686
+        $input = '[iframe height=349 width=560 '.
687
+            'src=http://www.youtubescam.com/embed/HdoW3t_WorU '.
688 688
             '][/iframe]';
689 689
         $expected = '/src/i';
690 690
         $result = $this->_Parser->parse(
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
     {
1030 1030
         // [code]<citation mark>[/code] should not be cited
1031 1031
         $input = h(
1032
-            "[code]\n" . $this->_Helper->getConfig('quote_symbol') . "\n[/code]"
1032
+            "[code]\n".$this->_Helper->getConfig('quote_symbol')."\n[/code]"
1033 1033
         );
1034 1034
         $expected = '`span class=.*?richtext-citation`';
1035 1035
         $result = $this->_Parser->parse($input);
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
     public function testQuote()
1047 1047
     {
1048 1048
         $_qs = $this->MarkupSettings->get('quote_symbol');
1049
-        $input = $_qs . ' fo [b]test[/b] ba';
1049
+        $input = $_qs.' fo [b]test[/b] ba';
1050 1050
         $result = $this->_Parser->parse($input);
1051 1051
         $expected = [
1052 1052
             'span' => ['class' => 'richtext-citation'],
1053
-            $_qs . ' fo ',
1053
+            $_qs.' fo ',
1054 1054
             'strong' => [],
1055 1055
             'test',
1056 1056
             '/strong',
Please login to merge, or discard this patch.
plugins/BbcodeParser/src/Lib/Helper/UrlParserTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             $validator->add('url', ['url' => ['rule' => 'url']]);
70 70
             $errors = $validator->errors(['url' => $url]);
71 71
             if (empty($errors)) {
72
-                $url = 'http://' . $url;
72
+                $url = 'http://'.$url;
73 73
             }
74 74
         }
75 75
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             if (!empty($url) && preg_match('/\<img\s*?src=/', $text) !== 1) {
86 86
                 $host = DomainParser::domainAndTld($url);
87 87
                 if ($host !== null && $host !== env('SERVER_NAME')) {
88
-                    $out .= ' <span class=\'richtext-linkInfo\'>[' . $host . ']</span>';
88
+                    $out .= ' <span class=\'richtext-linkInfo\'>['.$host.']</span>';
89 89
                 }
90 90
             }
91 91
         }
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         $_placeholder = ' … ';
121
-        $leftMargin = (int)floor($_textWordMaxLength / 2);
122
-        $rightMargin = (int)(-1 * ($_textWordMaxLength - $leftMargin - mb_strlen($_placeholder)));
121
+        $leftMargin = (int) floor($_textWordMaxLength / 2);
122
+        $rightMargin = (int) (-1 * ($_textWordMaxLength - $leftMargin - mb_strlen($_placeholder)));
123 123
 
124
-        $string = mb_substr($string, 0, $leftMargin) . $_placeholder .
124
+        $string = mb_substr($string, 0, $leftMargin).$_placeholder.
125 125
             mb_substr($string, $rightMargin);
126 126
 
127 127
         return $string;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     protected function _decorateTarget($string)
138 138
     {
139
-        $decorator = function ($matches) {
139
+        $decorator = function($matches) {
140 140
             $out = '';
141 141
             $url = $matches[1];
142 142
 
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
             $parsedUrl = parse_url($url);
148 148
 
149 149
             if (isset($parsedUrl['host'])) {
150
-                if ($parsedUrl['host'] !== env('SERVER_NAME') && $parsedUrl['host'] !== "www." . env('SERVER_NAME')) {
150
+                if ($parsedUrl['host'] !== env('SERVER_NAME') && $parsedUrl['host'] !== "www.".env('SERVER_NAME')) {
151 151
                     $out = " rel='external' target='_blank'";
152 152
                 }
153 153
             }
154 154
 
155
-            return $matches[0] . $out;
155
+            return $matches[0].$out;
156 156
         };
157 157
 
158 158
         return preg_replace_callback(
@@ -173,6 +173,6 @@  discard block
 block discarded – undo
173 173
         // @bogus, there's an user-config for that
174 174
         $root = '/useruploads/';
175 175
 
176
-        return $this->Url->build($root . $id, ['fullBase' => true]);
176
+        return $this->Url->build($root.$id, ['fullBase' => true]);
177 177
     }
178 178
 }
Please login to merge, or discard this patch.