Passed
Pull Request — master (#293)
by Kirill
03:57
created
src/Tokenizer/src/AbstractLocator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
         /**
51 51
          * @var SplFileInfo
52 52
          */
53
-        foreach ($this->finder->getIterator() as $file) {
53
+        foreach ($this->finder->getIterator() as $file){
54 54
             $reflection = new ReflectionFile((string)$file);
55 55
 
56
-            if ($reflection->hasIncludes()) {
56
+            if ($reflection->hasIncludes()){
57 57
                 //We are not analyzing files which has includes, it's not safe to require such reflections
58 58
                 $this->getLogger()->warning(
59 59
                     sprintf('File `%s` has includes and excluded from analysis', $file),
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function classReflection(string $class): \ReflectionClass
82 82
     {
83
-        $loader = function ($class) {
84
-            if ($class == LocatorException::class) {
83
+        $loader = function ($class){
84
+            if ($class == LocatorException::class){
85 85
                 return;
86 86
             }
87 87
 
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
         //To suspend class dependency exception
92 92
         spl_autoload_register($loader);
93 93
 
94
-        try {
94
+        try{
95 95
             //In some cases reflection can thrown an exception if class invalid or can not be loaded,
96 96
             //we are going to handle such exception and convert it soft exception
97 97
             return new \ReflectionClass($class);
98
-        } catch (\Throwable $e) {
99
-            if ($e instanceof LocatorException && $e->getPrevious() != null) {
98
+        }catch (\Throwable $e){
99
+            if ($e instanceof LocatorException && $e->getPrevious() != null){
100 100
                 $e = $e->getPrevious();
101 101
             }
102 102
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             );
113 113
 
114 114
             throw new LocatorException($e->getMessage(), $e->getCode(), $e);
115
-        } finally {
115
+        }finally{
116 116
             spl_autoload_unregister($loader);
117 117
         }
118 118
     }
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $traits = [];
130 130
 
131
-        while ($class) {
131
+        while ($class){
132 132
             $traits = array_merge(class_uses($class), $traits);
133 133
             $class = get_parent_class($class);
134 134
         }
135 135
 
136 136
         //Traits from traits
137
-        foreach (array_flip($traits) as $trait) {
137
+        foreach (array_flip($traits) as $trait){
138 138
             $traits = array_merge(class_uses($trait), $traits);
139 139
         }
140 140
 
Please login to merge, or discard this patch.
src/Views/src/ViewManager.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
             'namespaces' => $config->getNamespaces(),
45 45
         ]);
46 46
 
47
-        foreach ($this->config->getDependencies() as $dependency) {
47
+        foreach ($this->config->getDependencies() as $dependency){
48 48
             $this->addDependency($dependency->resolve($factory));
49 49
         }
50 50
 
51
-        foreach ($this->config->getEngines() as $engine) {
51
+        foreach ($this->config->getEngines() as $engine){
52 52
             $this->addEngine($engine->resolve($factory));
53 53
         }
54 54
 
55
-        if ($this->config->isCacheEnabled()) {
55
+        if ($this->config->isCacheEnabled()){
56 56
             $this->cache = new ViewCache();
57 57
         }
58 58
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $this->engines[] = $engine->withLoader($this->loader);
86 86
 
87
-        uasort($this->engines, function (EngineInterface $a, EngineInterface $b) {
87
+        uasort($this->engines, function (EngineInterface $a, EngineInterface $b){
88 88
             return strcmp($a->getLoader()->getExtension(), $b->getLoader()->getExtension());
89 89
         });
90 90
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function compile(string $path): void
112 112
     {
113
-        if ($this->cache !== null) {
113
+        if ($this->cache !== null){
114 114
             $this->cache->resetPath($path);
115 115
         }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
         // Rotate all possible context variants and warm up cache
120 120
         $generator = new ContextGenerator($this->context);
121
-        foreach ($generator->generate() as $context) {
121
+        foreach ($generator->generate() as $context){
122 122
             $engine->reset($path, $context);
123 123
             $engine->compile($path, $context);
124 124
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function reset(string $path): void
133 133
     {
134
-        if ($this->cache !== null) {
134
+        if ($this->cache !== null){
135 135
             $this->cache->resetPath($path);
136 136
         }
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
         // Rotate all possible context variants and warm up cache
141 141
         $generator = new ContextGenerator($this->context);
142
-        foreach ($generator->generate() as $context) {
142
+        foreach ($generator->generate() as $context){
143 143
             $engine->reset($path, $context);
144 144
         }
145 145
     }
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function get(string $path): ViewInterface
156 156
     {
157
-        if ($this->cache !== null && $this->cache->has($this->context, $path)) {
157
+        if ($this->cache !== null && $this->cache->has($this->context, $path)){
158 158
             return $this->cache->get($this->context, $path);
159 159
         }
160 160
 
161 161
         $view = $this->findEngine($path)->get($path, $this->context);
162 162
 
163
-        if ($this->cache !== null) {
163
+        if ($this->cache !== null){
164 164
             $this->cache->set($this->context, $path, $view);
165 165
         }
166 166
 
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
      */
188 188
     protected function findEngine(string $path): EngineInterface
189 189
     {
190
-        foreach ($this->engines as $engine) {
191
-            if ($engine->getLoader()->exists($path)) {
190
+        foreach ($this->engines as $engine){
191
+            if ($engine->getLoader()->exists($path)){
192 192
                 return $engine;
193 193
             }
194 194
         }
Please login to merge, or discard this patch.
src/Framework/Bootloader/Views/ViewsBootloader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function boot(EnvironmentInterface $env, DirectoriesInterface $dirs): void
46 46
     {
47
-        if (!$dirs->has('views')) {
48
-            $dirs->set('views', $dirs->get('app') . 'views');
47
+        if (!$dirs->has('views')){
48
+            $dirs->set('views', $dirs->get('app').'views');
49 49
         }
50 50
 
51 51
         // default view config
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             [
55 55
                 'cache'        => [
56 56
                     'enabled'   => $env->get('VIEW_CACHE', !$env->get('DEBUG', false)),
57
-                    'directory' => $dirs->get('cache') . 'views',
57
+                    'directory' => $dirs->get('cache').'views',
58 58
                 ],
59 59
                 'namespaces'   => [
60 60
                     'default' => [$dirs->get('views')],
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function addDirectory(string $namespace, string $directory): void
73 73
     {
74
-        if (!isset($this->config->getConfig('views')['namespaces'][$namespace])) {
74
+        if (!isset($this->config->getConfig('views')['namespaces'][$namespace])){
75 75
             $this->config->modify('views', new Append('namespaces', $namespace, []));
76 76
         }
77 77
 
78
-        $this->config->modify('views', new Append('namespaces.' . $namespace, null, $directory));
78
+        $this->config->modify('views', new Append('namespaces.'.$namespace, null, $directory));
79 79
     }
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
src/Framework/Bootloader/Http/SessionBootloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
                 'handler'  => new Autowire(
64 64
                     FileHandler::class,
65 65
                     [
66
-                        'directory' => $directories->get('runtime') . 'session',
66
+                        'directory' => $directories->get('runtime').'session',
67 67
                         'lifetime'  => 86400,
68 68
                     ]
69 69
                 ),
Please login to merge, or discard this patch.
src/Framework/Command/Migrate/StatusCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function perform(FilesInterface $files): void
30 30
     {
31
-        if (!$this->verifyConfigured()) {
31
+        if (!$this->verifyConfigured()){
32 32
             return;
33 33
         }
34 34
 
35
-        if (empty($this->migrator->getMigrations())) {
35
+        if (empty($this->migrator->getMigrations())){
36 36
             $this->writeln('<comment>No migrations were found.</comment>');
37 37
 
38 38
             return;
39 39
         }
40 40
 
41 41
         $table = $this->table(['Migration', 'Created at', 'Executed at']);
42
-        foreach ($this->migrator->getMigrations() as $migration) {
42
+        foreach ($this->migrator->getMigrations() as $migration){
43 43
             $state = $migration->getState();
44 44
 
45 45
             $table->addRow(
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                     $state->getTimeCreated()->format('Y-m-d H:i:s'),
49 49
                     $state->getStatus() == State::STATUS_PENDING
50 50
                         ? self::PENDING
51
-                        : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>',
51
+                        : '<info>'.$state->getTimeExecuted()->format('Y-m-d H:i:s').'</info>',
52 52
                 ]
53 53
             );
54 54
         }
Please login to merge, or discard this patch.
src/Framework/Command/Translator/ExportCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         ['locale', InputArgument::REQUIRED, 'Locale to be dumped'],
29 29
         ['path', InputArgument::REQUIRED, 'Export path'],
30 30
     ];
31
-    protected const OPTIONS     = [
31
+    protected const OPTIONS = [
32 32
         ['dumper', 'd', InputOption::VALUE_OPTIONAL, 'Dumper name', 'php'],
33 33
         ['fallback', 'f', InputOption::VALUE_NONE, 'Merge messages from fallback catalogue'],
34 34
     ];
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function perform(TranslatorConfig $config, CatalogueManager $manager): void
41 41
     {
42
-        if (!$config->hasDumper($this->option('dumper'))) {
42
+        if (!$config->hasDumper($this->option('dumper'))){
43 43
             $this->writeln("<fg=red>Undefined dumper '{$this->option('dumper')}'.</fg=red>");
44 44
 
45 45
             return;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $manager->get($this->argument('locale'))
52 52
         );
53 53
 
54
-        if ($this->isVerbose() && !empty($mc->getDomains())) {
54
+        if ($this->isVerbose() && !empty($mc->getDomains())){
55 55
             $this->sprintf(
56 56
                 "<info>Exporting domain(s):</info> %s\n",
57 57
                 implode(',', $mc->getDomains())
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
             ]
70 70
         );
71 71
 
72
-        $this->writeln('Export successfully completed using <info>' . get_class($dumper) . '</info>');
73
-        $this->writeln('Output: <comment>' . realpath($this->argument('path')) . '</comment>');
72
+        $this->writeln('Export successfully completed using <info>'.get_class($dumper).'</info>');
73
+        $this->writeln('Output: <comment>'.realpath($this->argument('path')).'</comment>');
74 74
     }
75 75
 
76 76
     /**
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
             $catalogue->getData()
90 90
         );
91 91
 
92
-        if ($this->option('fallback')) {
93
-            foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages) {
94
-                foreach ($messages as $id => $message) {
95
-                    if (!$messageCatalogue->defines($id, $domain)) {
92
+        if ($this->option('fallback')){
93
+            foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages){
94
+                foreach ($messages as $id => $message){
95
+                    if (!$messageCatalogue->defines($id, $domain)){
96 96
                         $messageCatalogue->set($id, $message, $domain);
97 97
                     }
98 98
                 }
Please login to merge, or discard this patch.
src/Framework/Command/Database/ListCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function perform(DatabaseConfig $config, DatabaseManager $dbal): void
36 36
     {
37
-        if ($this->argument('db')) {
37
+        if ($this->argument('db')){
38 38
             $databases = [$this->argument('db')];
39
-        } else {
39
+        }else{
40 40
             $databases = array_keys($config->getDatabases());
41 41
         }
42 42
 
43
-        if (empty($databases)) {
43
+        if (empty($databases)){
44 44
             $this->writeln('<fg=red>No databases found.</fg=red>');
45 45
 
46 46
             return;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             ]
59 59
         );
60 60
 
61
-        foreach ($databases as $database) {
61
+        foreach ($databases as $database){
62 62
             $database = $dbal->database($database);
63 63
 
64 64
             /** @var Driver $driver */
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
                 $database->getPrefix() ?: '<comment>---</comment>',
72 72
             ];
73 73
 
74
-            try {
74
+            try{
75 75
                 $driver->connect();
76
-            } catch (\Exception $exception) {
76
+            }catch (\Exception $exception){
77 77
                 $this->renderException($grid, $header, $exception);
78 78
 
79
-                if ($database->getName() != end($databases)) {
79
+                if ($database->getName() != end($databases)){
80 80
                     $grid->addRow(new TableSeparator());
81 81
                 }
82 82
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
             $header[] = '<info>connected</info>';
87 87
             $this->renderTables($grid, $header, $database);
88
-            if ($database->getName() != end($databases)) {
88
+            if ($database->getName() != end($databases)){
89 89
                 $grid->addRow(new TableSeparator());
90 90
             }
91 91
         }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     private function renderTables(Table $grid, array $header, Database $database): void
121 121
     {
122
-        foreach ($database->getTables() as $table) {
122
+        foreach ($database->getTables() as $table){
123 123
             $grid->addRow(
124 124
                 array_merge(
125 125
                     $header,
Please login to merge, or discard this patch.
src/Framework/Domain/GuardInterceptor.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $permission = $this->getPermissions($controller, $action);
54 54
 
55
-        if ($permission !== null && !$this->guard->allows($permission[0], $parameters)) {
55
+        if ($permission !== null && !$this->guard->allows($permission[0], $parameters)){
56 56
             throw new ControllerException($permission[2], $permission[1]);
57 57
         }
58 58
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
     private function getPermissions(string $controller, string $action): ?array
71 71
     {
72 72
         $key = sprintf('%s:%s', $controller, $action);
73
-        if (array_key_exists($key, $this->cache)) {
73
+        if (array_key_exists($key, $this->cache)){
74 74
             return $this->cache[$key];
75 75
         }
76 76
 
77 77
         $this->cache[$key] = null;
78
-        try {
78
+        try{
79 79
             $method = new \ReflectionMethod($controller, $action);
80
-        } catch (\ReflectionException $e) {
80
+        }catch (\ReflectionException $e){
81 81
             return null;
82 82
         }
83 83
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             Guarded::class
96 96
         );
97 97
 
98
-        if ($action === null) {
98
+        if ($action === null){
99 99
             return null;
100 100
         }
101 101
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             $guarded->errorMessage ?? sprintf('Unauthorized access `%s`', $guarded->permission ?? $method->getName()),
119 119
         ];
120 120
 
121
-        if ($guarded->permission === null && $ns === null) {
121
+        if ($guarded->permission === null && $ns === null){
122 122
             throw new InterceptorException(
123 123
                 sprintf(
124 124
                     'Unable to apply @Guarded without name or @GuardNamespace on `%s`->`%s`',
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
             );
129 129
         }
130 130
 
131
-        if ($ns !== null) {
131
+        if ($ns !== null){
132 132
             $permission[0] = sprintf('%s.%s', $ns->namespace, $permission[0]);
133 133
         }
134 134
 
135
-        if ($this->namespace !== null) {
135
+        if ($this->namespace !== null){
136 136
             // global namespace
137 137
             $permission[0] = sprintf('%s.%s', $this->namespace, $permission[0]);
138 138
         }
139 139
 
140
-        switch ($guarded->else) {
140
+        switch ($guarded->else){
141 141
             case 'unauthorized':
142 142
                 $permission[1] = ControllerException::UNAUTHORIZED;
143 143
                 break;
Please login to merge, or discard this patch.
src/Streams/src/StreamWrapper.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function stream_open($path, $mode, $options, &$opened_path)
74 74
     {
75
-        if (!isset(self::$uris[$path])) {
75
+        if (!isset(self::$uris[$path])){
76 76
             return false;
77 77
         }
78 78
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function url_stat($path, $flags)
158 158
     {
159
-        if (!isset(self::$uris[$path])) {
159
+        if (!isset(self::$uris[$path])){
160 160
             return null;
161 161
         }
162 162
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public static function register()
170 170
     {
171
-        if (self::$registered) {
171
+        if (self::$registered){
172 172
             return;
173 173
         }
174 174
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public static function has($file)
186 186
     {
187
-        if ($file instanceof StreamInterface) {
188
-            $file = 'spiral://' . spl_object_hash($file);
187
+        if ($file instanceof StreamInterface){
188
+            $file = 'spiral://'.spl_object_hash($file);
189 189
         }
190 190
 
191 191
         return isset(self::$uris[$file]);
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
     public static function getResource(StreamInterface $stream)
203 203
     {
204 204
         $mode = null;
205
-        if ($stream->isReadable()) {
205
+        if ($stream->isReadable()){
206 206
             $mode = 'r';
207 207
         }
208 208
 
209
-        if ($stream->isWritable()) {
209
+        if ($stream->isWritable()){
210 210
             $mode = !empty($mode) ? 'r+' : 'w';
211 211
         }
212 212
 
213
-        if (empty($mode)) {
213
+        if (empty($mode)){
214 214
             throw new WrapperException('Stream is not available in read or write modes');
215 215
         }
216 216
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     {
228 228
         self::register();
229 229
 
230
-        $uri = 'spiral://' . spl_object_hash($stream);
230
+        $uri = 'spiral://'.spl_object_hash($stream);
231 231
         self::$uris[$uri] = $stream;
232 232
 
233 233
         return $uri;
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public static function release($file)
243 243
     {
244
-        if ($file instanceof StreamInterface) {
245
-            $file = 'spiral://' . spl_object_hash($file);
244
+        if ($file instanceof StreamInterface){
245
+            $file = 'spiral://'.spl_object_hash($file);
246 246
         }
247 247
 
248 248
         unset(self::$uris[$file]);
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
     private function getStreamStats(StreamInterface $stream)
258 258
     {
259 259
         $mode = $this->mode;
260
-        if (empty($mode)) {
261
-            if ($stream->isReadable()) {
260
+        if (empty($mode)){
261
+            if ($stream->isReadable()){
262 262
                 $mode = 'r';
263 263
             }
264 264
 
265
-            if ($stream->isWritable()) {
265
+            if ($stream->isWritable()){
266 266
                 $mode = !empty($mode) ? 'r+' : 'w';
267 267
             }
268 268
         }
Please login to merge, or discard this patch.