@@ -14,7 +14,6 @@ |
||
| 14 | 14 | |
| 15 | 15 | use App\Lib\Model\Table\AppTable; |
| 16 | 16 | use Cake\Core\Configure; |
| 17 | -use Cake\Datasource\EntityInterface; |
|
| 18 | 17 | use Cake\Event\Event; |
| 19 | 18 | use Cake\Filesystem\File; |
| 20 | 19 | use Cake\ORM\RulesChecker; |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | ->notBlank('user_id') |
| 52 | 52 | ->requirePresence(['name', 'size', 'type', 'user_id'], 'create'); |
| 53 | 53 | |
| 54 | - $maxUploadSize = (int)Configure::read('Saito.Settings.upload_max_img_size'); |
|
| 54 | + $maxUploadSize = (int) Configure::read('Saito.Settings.upload_max_img_size'); |
|
| 55 | 55 | $validator->add( |
| 56 | 56 | 'document', |
| 57 | 57 | [ |
| 58 | 58 | 'fileSize' => [ |
| 59 | - 'rule' => ['fileSize', '<', $maxUploadSize . 'kB'], |
|
| 59 | + 'rule' => ['fileSize', '<', $maxUploadSize.'kB'], |
|
| 60 | 60 | 'message' => __d( |
| 61 | 61 | 'image_uploader', |
| 62 | 62 | 'validation.error.fileSize', |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | public function buildRules(RulesChecker $rules) |
| 84 | 84 | { |
| 85 | 85 | // check max allowed number of uploads per user |
| 86 | - $nMax = (int)Configure::read('Saito.Settings.upload_max_number_of_uploads'); |
|
| 86 | + $nMax = (int) Configure::read('Saito.Settings.upload_max_number_of_uploads'); |
|
| 87 | 87 | $rules->add( |
| 88 | - function (Upload $entity, array $options) use ($nMax) { |
|
| 88 | + function(Upload $entity, array $options) use ($nMax) { |
|
| 89 | 89 | $count = $this->findByUserId($entity->get('user_id'))->count(); |
| 90 | 90 | |
| 91 | 91 | return $count < $nMax; |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | $ratio = $size / $target; |
| 206 | 206 | $ratio = sqrt($ratio); |
| 207 | 207 | |
| 208 | - $newwidth = (int)($width / $ratio); |
|
| 209 | - $newheight = (int)($height / $ratio); |
|
| 208 | + $newwidth = (int) ($width / $ratio); |
|
| 209 | + $newheight = (int) ($height / $ratio); |
|
| 210 | 210 | $destination = imagecreatetruecolor($newwidth, $newheight); |
| 211 | 211 | |
| 212 | 212 | $source = imagecreatefromstring($raw); |
@@ -13,13 +13,11 @@ |
||
| 13 | 13 | namespace ImageUploader\Test\TestCase\Controller; |
| 14 | 14 | |
| 15 | 15 | use Api\Error\Exception\GenericApiException; |
| 16 | -use Cake\Cache\Cache; |
|
| 17 | 16 | use Cake\Core\Configure; |
| 18 | 17 | use Cake\Core\Plugin; |
| 19 | 18 | use Cake\Filesystem\File; |
| 20 | 19 | use Cake\Http\Exception\UnauthorizedException; |
| 21 | 20 | use Cake\ORM\TableRegistry; |
| 22 | -use claviska\SimpleImage; |
|
| 23 | 21 | use Saito\Exception\SaitoForbiddenException; |
| 24 | 22 | use Saito\Test\IntegrationTestCase; |
| 25 | 23 | |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | 0 => [ |
| 74 | 74 | 'file' => [ |
| 75 | 75 | 'tmp_name' => $this->file->path, |
| 76 | - 'name' => $this->file->name() . '.' . $this->file->ext(), |
|
| 76 | + 'name' => $this->file->name().'.'.$this->file->ext(), |
|
| 77 | 77 | 'size' => $this->file->size(), |
| 78 | 78 | 'type' => $this->file->mime(), |
| 79 | 79 | ] |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ]; |
| 83 | 83 | $this->post('api/v2/uploads.json', $data); |
| 84 | 84 | |
| 85 | - $response = json_decode((string)$this->_response->getBody(), true); |
|
| 85 | + $response = json_decode((string) $this->_response->getBody(), true); |
|
| 86 | 86 | |
| 87 | 87 | $this->assertResponseCode(200); |
| 88 | 88 | |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | { |
| 113 | 113 | $this->loginJwt(1); |
| 114 | 114 | unset($this->file); |
| 115 | - $this->file = new File(TMP . 'tmp_exif.jpg'); |
|
| 115 | + $this->file = new File(TMP.'tmp_exif.jpg'); |
|
| 116 | 116 | |
| 117 | - $fixture = new File($path = Plugin::path('ImageUploader') . 'tests/Fixture/exif-with-location.jpg'); |
|
| 117 | + $fixture = new File($path = Plugin::path('ImageUploader').'tests/Fixture/exif-with-location.jpg'); |
|
| 118 | 118 | $fixture->copy($this->file->path); |
| 119 | 119 | |
| 120 | - $readExif = function (File $file) { |
|
| 120 | + $readExif = function(File $file) { |
|
| 121 | 121 | //@codingStandardsIgnoreStart |
| 122 | 122 | return @exif_read_data($file->path); |
| 123 | 123 | //@codingStandardsIgnoreEnd |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 0 => [ |
| 133 | 133 | 'file' => [ |
| 134 | 134 | 'tmp_name' => $this->file->path, |
| 135 | - 'name' => $this->file->name() . '.' . $this->file->ext(), |
|
| 135 | + 'name' => $this->file->name().'.'.$this->file->ext(), |
|
| 136 | 136 | 'size' => $this->file->size(), |
| 137 | 137 | 'type' => $this->file->mime(), |
| 138 | 138 | ] |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | ]; |
| 142 | 142 | $this->post('api/v2/uploads.json', $data); |
| 143 | 143 | |
| 144 | - $response = json_decode((string)$this->_response->getBody(), true); |
|
| 144 | + $response = json_decode((string) $this->_response->getBody(), true); |
|
| 145 | 145 | |
| 146 | 146 | $this->assertResponseCode(200); |
| 147 | 147 | |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | $this->get('api/v2/uploads'); |
| 224 | 224 | |
| 225 | - $response = json_decode((string)$this->_response->getBody(), true); |
|
| 225 | + $response = json_decode((string) $this->_response->getBody(), true); |
|
| 226 | 226 | |
| 227 | 227 | $this->assertResponseCode(200); |
| 228 | 228 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $this->delete('api/v2/uploads/1'); |
| 262 | 262 | |
| 263 | - $response = json_decode((string)$this->_response->getBody(), true); |
|
| 263 | + $response = json_decode((string) $this->_response->getBody(), true); |
|
| 264 | 264 | |
| 265 | 265 | $this->assertResponseCode(204); |
| 266 | 266 | |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace Installer\Test\TestCase\Controller; |
| 14 | 14 | |
| 15 | -use App\Model\Table\SettingsTable; |
|
| 16 | 15 | use Cake\Core\Configure; |
| 17 | 16 | use Cake\Datasource\ConnectionManager; |
| 18 | 17 | use Cake\Filesystem\File; |
@@ -1,6 +1,6 @@ discard block |
||
| 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,7 +35,7 @@ discard block |
||
| 35 | 35 | public function setUp() |
| 36 | 36 | { |
| 37 | 37 | parent::setUp(); |
| 38 | - $this->token = new File(CONFIG . 'updater'); |
|
| 38 | + $this->token = new File(CONFIG.'updater'); |
|
| 39 | 39 | $this->dbVersion = (new DbVersion(TableRegistry::get('Settings'))); |
| 40 | 40 | Configure::write('Saito.updated', false); |
| 41 | 41 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $this->assertResponseOk(); |
| 56 | 56 | $this->assertEquals('failure', $this->_controller->viewBuilder()->getTemplate()); |
| 57 | - $this->assertResponseContains((string)1529737182); |
|
| 57 | + $this->assertResponseContains((string) 1529737182); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function testUpdaterShowFailureNoDbVersionString() |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $this->assertResponseOk(); |
| 66 | 66 | $this->assertEquals('failure', $this->_controller->viewBuilder()->getTemplate()); |
| 67 | - $this->assertResponseContains((string)1529737397); |
|
| 67 | + $this->assertResponseContains((string) 1529737397); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public function testUpdaterShowFailureWrongDbVersionString() |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $this->assertResponseOk(); |
| 76 | 76 | $this->assertEquals('failure', $this->_controller->viewBuilder()->getTemplate()); |
| 77 | - $this->assertResponseContains((string)1529737648); |
|
| 77 | + $this->assertResponseContains((string) 1529737648); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function testUpdaterInitMigrationsFormEmpty() |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @param string $file filename |
| 46 | - * @return mixed |
|
| 46 | + * @return false|string |
|
| 47 | 47 | */ |
| 48 | 48 | public function content($file) |
| 49 | 49 | { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | /** |
| 95 | 95 | * Creates name for sitemap-file |
| 96 | 96 | * |
| 97 | - * @param array $params additional name parameters |
|
| 97 | + * @param integer[] $params additional name parameters |
|
| 98 | 98 | * @return string |
| 99 | 99 | */ |
| 100 | 100 | protected function _filename($params = []) |
@@ -101,7 +101,7 @@ |
||
| 101 | 101 | { |
| 102 | 102 | $filename = "sitemap-{$this->_type}"; |
| 103 | 103 | if ($params) { |
| 104 | - $filename .= '-' . implode('-', $params); |
|
| 104 | + $filename .= '-'.implode('-', $params); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $filename; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | /** |
| 168 | 168 | * time to Cake start |
| 169 | 169 | * |
| 170 | - * @return mixed |
|
| 170 | + * @return double |
|
| 171 | 171 | */ |
| 172 | 172 | protected static function _timeToCake() |
| 173 | 173 | { |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | /** |
| 178 | 178 | * time from cake to stopwatch |
| 179 | 179 | * |
| 180 | - * @return int |
|
| 180 | + * @return double |
|
| 181 | 181 | */ |
| 182 | 182 | protected static function _timeFromCakeToStopwatch() |
| 183 | 183 | { |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | switch ($event) { |
| 143 | 143 | case 'start': |
| 144 | - $x = '* ' . $x; |
|
| 144 | + $x = '* '.$x; |
|
| 145 | 145 | break; |
| 146 | 146 | case 'stop': |
| 147 | - $x = '† ' . $x; |
|
| 147 | + $x = '† '.$x; |
|
| 148 | 148 | break; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | self::start('now'); |
| 209 | 209 | |
| 210 | 210 | $out = ""; |
| 211 | - $out .= 'Time to Cake: ' . sprintf('%05.3f', self::_timeToCake()) . " s\n"; |
|
| 212 | - $out .= 'Cake bootstrap: ' . sprintf('%05.3f', self::_timeFromCakeToStopwatch()) . " s\n"; |
|
| 211 | + $out .= 'Time to Cake: '.sprintf('%05.3f', self::_timeToCake())." s\n"; |
|
| 212 | + $out .= 'Cake bootstrap: '.sprintf('%05.3f', self::_timeFromCakeToStopwatch())." s\n"; |
|
| 213 | 213 | |
| 214 | 214 | $out .= "W\tU\tW_delta\tU_delta\tMem [MB]\n"; |
| 215 | 215 | $_seriesIndex = 1; |
| 216 | 216 | foreach (self::$_events as $k => $v) { |
| 217 | - $out .= '<span id="stopwatch-' . $_seriesIndex++ . '" class="stopwatch-row">'; |
|
| 217 | + $out .= '<span id="stopwatch-'.$_seriesIndex++.'" class="stopwatch-row">'; |
|
| 218 | 218 | $out .= sprintf( |
| 219 | 219 | "%05.3f\t%05.3f\t%05.3f\t%05.3f\t%5.1f\t%s\n", |
| 220 | 220 | $v['wtime'], |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - $out .= "\n\n" . self::printStatistic(); |
|
| 268 | + $out .= "\n\n".self::printStatistic(); |
|
| 269 | 269 | |
| 270 | 270 | return $out; |
| 271 | 271 | } |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public static function printStatistic() |
| 356 | 356 | { |
| 357 | - return self::$_stopwatchCalls . " calls with ca " . sprintf( |
|
| 357 | + return self::$_stopwatchCalls." calls with ca ".sprintf( |
|
| 358 | 358 | "%05.3f", |
| 359 | 359 | self::$_stopwatchTime |
| 360 | - ) . ' sec overhead.'; |
|
| 360 | + ).' sec overhead.'; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | namespace App\Auth; |
| 11 | 11 | |
| 12 | 12 | use Cake\Auth\BaseAuthenticate; |
| 13 | -use Cake\Core\Configure; |
|
| 14 | 13 | use Cake\Event\Event; |
| 15 | 14 | use Cake\Http\Response; |
| 16 | 15 | use Cake\Http\ServerRequest; |
@@ -16,7 +16,6 @@ discard block |
||
| 16 | 16 | use Cake\Core\Configure; |
| 17 | 17 | use Cake\Event\Event; |
| 18 | 18 | use Cake\ORM\TableRegistry; |
| 19 | -use Cake\Routing\Router; |
|
| 20 | 19 | use Cake\Utility\Security; |
| 21 | 20 | use Firebase\JWT\JWT; |
| 22 | 21 | use Saito\App\Registry; |
@@ -26,7 +25,6 @@ discard block |
||
| 26 | 25 | use Saito\User\CurrentUser\CurrentUserInterface; |
| 27 | 26 | use Saito\User\CurrentUser\CurrentUserTrait; |
| 28 | 27 | use Saito\User\LastRefresh; |
| 29 | -use Saito\User\ReadPostings; |
|
| 30 | 28 | use Saito\User\ReadPostings\ReadPostingsCookie; |
| 31 | 29 | use Saito\User\ReadPostings\ReadPostingsDatabase; |
| 32 | 30 | use Saito\User\ReadPostings\ReadPostingsDummy; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | //= set persistent Cookie |
| 183 | - $setCookie = (bool)$this->request->getData('remember_me'); |
|
| 183 | + $setCookie = (bool) $this->request->getData('remember_me'); |
|
| 184 | 184 | if ($setCookie) { |
| 185 | 185 | (new CurrentUserCookie($this->getController()))->write($this->getId()); |
| 186 | 186 | }; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | $auth->setConfig('loginAction', '/login'); |
| 293 | 293 | |
| 294 | 294 | $here = urlencode($this->getController()->getRequest()->getRequestTarget()); |
| 295 | - $auth->setConfig('unauthorizedRedirect', '/login?redirect=' . $here); |
|
| 295 | + $auth->setConfig('unauthorizedRedirect', '/login?redirect='.$here); |
|
| 296 | 296 | |
| 297 | 297 | if ($this->isLoggedIn()) { |
| 298 | 298 | $auth->allow(); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | private function setJwtCookie(Controller $controller): void |
| 320 | 320 | { |
| 321 | - $cookieKey = Configure::read('Session.cookie') . '-jwt'; |
|
| 321 | + $cookieKey = Configure::read('Session.cookie').'-jwt'; |
|
| 322 | 322 | $cookie = (new Storage($controller, $cookieKey, ['http' => false, 'expire' => '+1 week'])); |
| 323 | 323 | |
| 324 | 324 | $existingToken = $cookie->read(); |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace App\Controller\Component; |
| 4 | 4 | |
| 5 | 5 | use Cake\Controller\Component; |
| 6 | -use Cake\Core\Configure; |
|
| 7 | 6 | use Saito\User\ForumsUserInterface; |
| 8 | 7 | |
| 9 | 8 | class SlidetabsComponent extends Component |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $tabs = $slidetabs; |
| 50 | 50 | } |
| 51 | 51 | $tabs = array_map( |
| 52 | - function ($v) { |
|
| 52 | + function($v) { |
|
| 53 | 53 | return $this->_available[$v]; |
| 54 | 54 | }, |
| 55 | 55 | $tabs |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Cake\Core\Configure; |
| 16 | 16 | use Cake\ORM\Entity; |
| 17 | 17 | use Cake\ORM\TableRegistry; |
| 18 | -use Cake\Utility\Hash; |
|
| 19 | 18 | use Saito\App\Registry; |
| 20 | 19 | use Saito\Posting\Posting; |
| 21 | 20 | use Stopwatch\Lib\Stopwatch; |
@@ -80,14 +80,14 @@ |
||
| 80 | 80 | 'order' => $order, |
| 81 | 81 | // Performance: Custom counter from categories counter-cache; |
| 82 | 82 | // avoids a costly COUNT(*) DB call counting all pages for pagination. |
| 83 | - 'counter' => function ($query) use ($categories) { |
|
| 83 | + 'counter' => function($query) use ($categories) { |
|
| 84 | 84 | $results = $this->Entries->Categories->find('all') |
| 85 | 85 | ->select(['thread_count']) |
| 86 | 86 | ->where(['id IN' => $categories]) |
| 87 | 87 | ->all(); |
| 88 | 88 | $count = array_reduce( |
| 89 | 89 | $results->toArray(), |
| 90 | - function ($carry, Entity $entity) { |
|
| 90 | + function($carry, Entity $entity) { |
|
| 91 | 91 | return $carry + $entity->get('thread_count'); |
| 92 | 92 | }, |
| 93 | 93 | 0 |