Passed
Pull Request — master (#656)
by Abdul Malik
11:30 queued 05:15
created
src/Cookies/src/Cookie.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         bool $secure = false,
117 117
         bool $httpOnly = true,
118 118
         ?string $sameSite = null
119
-    ) {
119
+    ){
120 120
         $this->name = $name;
121 121
         $this->value = $value;
122 122
         $this->lifetime = $lifetime;
@@ -221,30 +221,30 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function createHeader(): string
223 223
     {
224
-        $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
224
+        $header = [rawurlencode($this->name).'='.rawurlencode((string)$this->value)];
225 225
 
226
-        if ($this->lifetime !== null) {
227
-            $header[] = 'Expires=' . gmdate(DateTime::COOKIE, $this->getExpires());
226
+        if ($this->lifetime !== null){
227
+            $header[] = 'Expires='.gmdate(DateTime::COOKIE, $this->getExpires());
228 228
             $header[] = "Max-Age={$this->lifetime}";
229 229
         }
230 230
 
231
-        if (!empty($this->path)) {
231
+        if (!empty($this->path)){
232 232
             $header[] = "Path={$this->path}";
233 233
         }
234 234
 
235
-        if (!empty($this->domain)) {
235
+        if (!empty($this->domain)){
236 236
             $header[] = "Domain={$this->domain}";
237 237
         }
238 238
 
239
-        if ($this->secure) {
239
+        if ($this->secure){
240 240
             $header[] = 'Secure';
241 241
         }
242 242
 
243
-        if ($this->httpOnly) {
243
+        if ($this->httpOnly){
244 244
             $header[] = 'HttpOnly';
245 245
         }
246 246
 
247
-        if ($this->sameSite->get() !== null) {
247
+        if ($this->sameSite->get() !== null){
248 248
             $header[] = "SameSite={$this->sameSite->get()}";
249 249
         }
250 250
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function getExpires(): ?int
260 260
     {
261
-        if ($this->lifetime === null) {
261
+        if ($this->lifetime === null){
262 262
             return null;
263 263
         }
264 264
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -223,28 +223,34 @@  discard block
 block discarded – undo
223 223
     {
224 224
         $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)];
225 225
 
226
-        if ($this->lifetime !== null) {
226
+        if ($this->lifetime !== null)
227
+        {
227 228
             $header[] = 'Expires=' . gmdate(DateTime::COOKIE, $this->getExpires());
228 229
             $header[] = "Max-Age={$this->lifetime}";
229 230
         }
230 231
 
231
-        if (!empty($this->path)) {
232
+        if (!empty($this->path))
233
+        {
232 234
             $header[] = "Path={$this->path}";
233 235
         }
234 236
 
235
-        if (!empty($this->domain)) {
237
+        if (!empty($this->domain))
238
+        {
236 239
             $header[] = "Domain={$this->domain}";
237 240
         }
238 241
 
239
-        if ($this->secure) {
242
+        if ($this->secure)
243
+        {
240 244
             $header[] = 'Secure';
241 245
         }
242 246
 
243
-        if ($this->httpOnly) {
247
+        if ($this->httpOnly)
248
+        {
244 249
             $header[] = 'HttpOnly';
245 250
         }
246 251
 
247
-        if ($this->sameSite->get() !== null) {
252
+        if ($this->sameSite->get() !== null)
253
+        {
248 254
             $header[] = "SameSite={$this->sameSite->get()}";
249 255
         }
250 256
 
@@ -258,7 +264,8 @@  discard block
 block discarded – undo
258 264
      */
259 265
     public function getExpires(): ?int
260 266
     {
261
-        if ($this->lifetime === null) {
267
+        if ($this->lifetime === null)
268
+        {
262 269
             return null;
263 270
         }
264 271
 
Please login to merge, or discard this patch.
src/Cookies/src/Cookie/SameSite.php 1 patch
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     public const NONE   = 'None';
12 12
 
13 13
     private const VALUES  = [self::STRICT, self::LAX, self::NONE];
14
-    private const DEFAULT = self::LAX;
14
+    private const default = self::LAX;
15 15
 
16 16
     private ?string $sameSite = null;
17 17
 
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
             return null;
37 37
         }
38 38
 
39
-        return ($sameSite === self::NONE && !$secure) ? self::DEFAULT : $sameSite;
39
+        return ($sameSite === self::NONE && !$secure) ? self::default : $sameSite;
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
src/Session/src/Handler/FileHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@
 block discarded – undo
57 57
     #[ReturnTypeWillChange]
58 58
     public function gc($maxlifetime)
59 59
     {
60
-        foreach ($this->files->getFiles($this->directory) as $filename) {
61
-            if ($this->files->time($filename) < time() - $maxlifetime) {
60
+        foreach ($this->files->getFiles($this->directory) as $filename){
61
+            if ($this->files->time($filename) < time() - $maxlifetime){
62 62
                 $this->files->delete($filename);
63 63
             }
64 64
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,8 +57,10 @@
 block discarded – undo
57 57
     #[ReturnTypeWillChange]
58 58
     public function gc($maxlifetime)
59 59
     {
60
-        foreach ($this->files->getFiles($this->directory) as $filename) {
61
-            if ($this->files->time($filename) < time() - $maxlifetime) {
60
+        foreach ($this->files->getFiles($this->directory) as $filename)
61
+        {
62
+            if ($this->files->time($filename) < time() - $maxlifetime)
63
+            {
62 64
                 $this->files->delete($filename);
63 65
             }
64 66
         }
Please login to merge, or discard this patch.
src/Session/src/Session.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $this->clientSignature = $clientSignature;
62 62
         $this->lifetime = $lifetime;
63 63
 
64
-        if (!empty($id) && $this->validID($id)) {
64
+        if (!empty($id) && $this->validID($id)){
65 65
             $this->id = $id;
66 66
         }
67 67
     }
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function resume(): void
94 94
     {
95
-        if ($this->isStarted()) {
95
+        if ($this->isStarted()){
96 96
             return;
97 97
         }
98 98
 
99
-        if (!empty($this->id)) {
99
+        if (!empty($this->id)){
100 100
             session_id($this->id);
101
-        } else {
101
+        }else{
102 102
             // always new id
103 103
             session_id(session_create_id());
104 104
         }
105 105
 
106
-        try {
106
+        try{
107 107
             session_start(['use_cookies' => false]);
108
-        } catch (Throwable $e) {
108
+        }catch (Throwable $e){
109 109
             throw new SessionException('Unable to start session', $e->getCode(), $e);
110 110
         }
111 111
 
112
-        if (empty($this->id)) {
112
+        if (empty($this->id)){
113 113
             //Sign newly created session
114 114
             $_SESSION[self::CLIENT_SIGNATURE] = $this->clientSignature;
115 115
             $_SESSION[self::SESSION_CREATED] = time();
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $this->started = true;
121 121
 
122 122
         //Ensure that session is valid
123
-        if (!$this->validSession()) {
123
+        if (!$this->validSession()){
124 124
             $this->invalidateSession();
125 125
         }
126 126
     }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function commit(): bool
161 161
     {
162
-        if (!$this->isStarted()) {
162
+        if (!$this->isStarted()){
163 163
             return false;
164 164
         }
165 165
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function abort(): bool
176 176
     {
177
-        if (!$this->isStarted()) {
177
+        if (!$this->isStarted()){
178 178
             return false;
179 179
         }
180 180
 
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
         if (
216 216
             !array_key_exists(self::CLIENT_SIGNATURE, $_SESSION)
217 217
             || !array_key_exists(self::SESSION_CREATED, $_SESSION)
218
-        ) {
218
+        ){
219 219
             //Missing session signature or timestamp!
220 220
             return false;
221 221
         }
222 222
 
223
-        if ($_SESSION[self::SESSION_CREATED] < time() - $this->lifetime) {
223
+        if ($_SESSION[self::SESSION_CREATED] < time() - $this->lifetime){
224 224
             //Session expired
225 225
             return false;
226 226
         }
227 227
 
228
-        if (!hash_equals($_SESSION[self::CLIENT_SIGNATURE], $this->clientSignature)) {
228
+        if (!hash_equals($_SESSION[self::CLIENT_SIGNATURE], $this->clientSignature)){
229 229
             //Signatures do not match
230 230
             return false;
231 231
         }
Please login to merge, or discard this patch.
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,7 +61,8 @@  discard block
 block discarded – undo
61 61
         $this->clientSignature = $clientSignature;
62 62
         $this->lifetime = $lifetime;
63 63
 
64
-        if (!empty($id) && $this->validID($id)) {
64
+        if (!empty($id) && $this->validID($id))
65
+        {
65 66
             $this->id = $id;
66 67
         }
67 68
     }
@@ -92,24 +93,32 @@  discard block
 block discarded – undo
92 93
      */
93 94
     public function resume(): void
94 95
     {
95
-        if ($this->isStarted()) {
96
+        if ($this->isStarted())
97
+        {
96 98
             return;
97 99
         }
98 100
 
99
-        if (!empty($this->id)) {
101
+        if (!empty($this->id))
102
+        {
100 103
             session_id($this->id);
101
-        } else {
104
+        }
105
+        else
106
+        {
102 107
             // always new id
103 108
             session_id(session_create_id());
104 109
         }
105 110
 
106
-        try {
111
+        try
112
+        {
107 113
             session_start(['use_cookies' => false]);
108
-        } catch (Throwable $e) {
114
+        }
115
+        catch (Throwable $e)
116
+        {
109 117
             throw new SessionException('Unable to start session', $e->getCode(), $e);
110 118
         }
111 119
 
112
-        if (empty($this->id)) {
120
+        if (empty($this->id))
121
+        {
113 122
             //Sign newly created session
114 123
             $_SESSION[self::CLIENT_SIGNATURE] = $this->clientSignature;
115 124
             $_SESSION[self::SESSION_CREATED] = time();
@@ -120,7 +129,8 @@  discard block
 block discarded – undo
120 129
         $this->started = true;
121 130
 
122 131
         //Ensure that session is valid
123
-        if (!$this->validSession()) {
132
+        if (!$this->validSession())
133
+        {
124 134
             $this->invalidateSession();
125 135
         }
126 136
     }
@@ -159,7 +169,8 @@  discard block
 block discarded – undo
159 169
      */
160 170
     public function commit(): bool
161 171
     {
162
-        if (!$this->isStarted()) {
172
+        if (!$this->isStarted())
173
+        {
163 174
             return false;
164 175
         }
165 176
 
@@ -174,7 +185,8 @@  discard block
 block discarded – undo
174 185
      */
175 186
     public function abort(): bool
176 187
     {
177
-        if (!$this->isStarted()) {
188
+        if (!$this->isStarted())
189
+        {
178 190
             return false;
179 191
         }
180 192
 
@@ -220,12 +232,14 @@  discard block
 block discarded – undo
220 232
             return false;
221 233
         }
222 234
 
223
-        if ($_SESSION[self::SESSION_CREATED] < time() - $this->lifetime) {
235
+        if ($_SESSION[self::SESSION_CREATED] < time() - $this->lifetime)
236
+        {
224 237
             //Session expired
225 238
             return false;
226 239
         }
227 240
 
228
-        if (!hash_equals($_SESSION[self::CLIENT_SIGNATURE], $this->clientSignature)) {
241
+        if (!hash_equals($_SESSION[self::CLIENT_SIGNATURE], $this->clientSignature))
242
+        {
229 243
             //Signatures do not match
230 244
             return false;
231 245
         }
Please login to merge, or discard this patch.
src/Session/src/SessionFactory.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,15 +36,15 @@
 block discarded – undo
36 36
 
37 37
     public function initSession(string $clientSignature, string $id = null): SessionInterface
38 38
     {
39
-        if (session_status() === PHP_SESSION_ACTIVE) {
39
+        if (session_status() === PHP_SESSION_ACTIVE){
40 40
             throw new MultipleSessionException('Unable to initiate session, session already started');
41 41
         }
42 42
 
43 43
         // Initiating proper session handler
44
-        if ($this->config->getHandler() !== null) {
45
-            try {
44
+        if ($this->config->getHandler() !== null){
45
+            try{
46 46
                 $handler = $this->config->getHandler()->resolve($this->factory);
47
-            } catch (Throwable | ContainerExceptionInterface $e) {
47
+            }catch (Throwable | ContainerExceptionInterface $e){
48 48
                 throw new SessionException($e->getMessage(), $e->getCode(), $e);
49 49
             }
50 50
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,15 +36,20 @@
 block discarded – undo
36 36
 
37 37
     public function initSession(string $clientSignature, string $id = null): SessionInterface
38 38
     {
39
-        if (session_status() === PHP_SESSION_ACTIVE) {
39
+        if (session_status() === PHP_SESSION_ACTIVE)
40
+        {
40 41
             throw new MultipleSessionException('Unable to initiate session, session already started');
41 42
         }
42 43
 
43 44
         // Initiating proper session handler
44
-        if ($this->config->getHandler() !== null) {
45
-            try {
45
+        if ($this->config->getHandler() !== null)
46
+        {
47
+            try
48
+            {
46 49
                 $handler = $this->config->getHandler()->resolve($this->factory);
47
-            } catch (Throwable | ContainerExceptionInterface $e) {
50
+            }
51
+            catch (Throwable | ContainerExceptionInterface $e)
52
+            {
48 53
                 throw new SessionException($e->getMessage(), $e->getCode(), $e);
49 54
             }
50 55
 
Please login to merge, or discard this patch.
src/Dumper/src/System.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public static function isCLI(): bool
27 27
     {
28
-        if (!empty(getenv('RR'))) {
28
+        if (!empty(getenv('RR'))){
29 29
             // Do not treat RoadRunner as CLI.
30 30
             return false;
31 31
         }
32 32
 
33
-        if (php_sapi_name() === 'cli') {
33
+        if (php_sapi_name() === 'cli'){
34 34
             return true;
35 35
         }
36 36
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public static function isColorsSupported($stream = STDOUT): bool
48 48
     {
49
-        if ('Hyper' === getenv('TERM_PROGRAM')) {
49
+        if ('Hyper' === getenv('TERM_PROGRAM')){
50 50
             return true;
51 51
         }
52 52
 
53
-        try {
54
-            if (\DIRECTORY_SEPARATOR === '\\') {
53
+        try{
54
+            if (\DIRECTORY_SEPARATOR === '\\'){
55 55
                 return (
56 56
                         function_exists('sapi_windows_vt100_support')
57 57
                         && @sapi_windows_vt100_support($stream)
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             }
62 62
 
63 63
             return @stream_isatty($stream);
64
-        } catch (Throwable $e) {
64
+        }catch (Throwable $e){
65 65
             return false;
66 66
         }
67 67
     }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,12 +25,14 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public static function isCLI(): bool
27 27
     {
28
-        if (!empty(getenv('RR'))) {
28
+        if (!empty(getenv('RR')))
29
+        {
29 30
             // Do not treat RoadRunner as CLI.
30 31
             return false;
31 32
         }
32 33
 
33
-        if (php_sapi_name() === 'cli') {
34
+        if (php_sapi_name() === 'cli')
35
+        {
34 36
             return true;
35 37
         }
36 38
 
@@ -46,12 +48,15 @@  discard block
 block discarded – undo
46 48
      */
47 49
     public static function isColorsSupported($stream = STDOUT): bool
48 50
     {
49
-        if ('Hyper' === getenv('TERM_PROGRAM')) {
51
+        if ('Hyper' === getenv('TERM_PROGRAM'))
52
+        {
50 53
             return true;
51 54
         }
52 55
 
53
-        try {
54
-            if (\DIRECTORY_SEPARATOR === '\\') {
56
+        try
57
+        {
58
+            if (\DIRECTORY_SEPARATOR === '\\')
59
+            {
55 60
                 return (
56 61
                         function_exists('sapi_windows_vt100_support')
57 62
                         && @sapi_windows_vt100_support($stream)
@@ -61,7 +66,9 @@  discard block
 block discarded – undo
61 66
             }
62 67
 
63 68
             return @stream_isatty($stream);
64
-        } catch (Throwable $e) {
69
+        }
70
+        catch (Throwable $e)
71
+        {
65 72
             return false;
66 73
         }
67 74
     }
Please login to merge, or discard this patch.
src/Dumper/src/Dumper.php 2 patches
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function __construct(LoggerInterface $logger = null)
64 64
     {
65
-        if ($logger !== null) {
65
+        if ($logger !== null){
66 66
             $this->setLogger($logger);
67 67
         }
68 68
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         $r = $this->getRenderer($target);
89 89
         $dump = $r->wrapContent($this->renderValue($r, $value));
90 90
 
91
-        switch ($target) {
91
+        switch ($target){
92 92
             case self::OUTPUT:
93 93
                 echo $dump;
94 94
                 break;
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
                 return $dump;
99 99
 
100 100
             case self::LOGGER:
101
-                if ($this->logger === null) {
101
+                if ($this->logger === null){
102 102
                     throw new DumperException('Unable to dump value to log, no associated LoggerInterface.');
103 103
                 }
104
-                $this->logger->debug((string) $dump);
104
+                $this->logger->debug((string)$dump);
105 105
                 break;
106 106
 
107 107
             case self::ERROR_LOG:
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function setRenderer(int $target, RendererInterface $renderer): Dumper
121 121
     {
122
-        if (!isset($this->targets[$target])) {
122
+        if (!isset($this->targets[$target])){
123 123
             throw new DumperException(sprintf('Undefined dump target %d', $target));
124 124
         }
125 125
 
@@ -136,19 +136,19 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function getRenderer(int $target): RendererInterface
138 138
     {
139
-        if ($target == self::OUTPUT && System::isCLI()) {
140
-            if (System::isColorsSupported(STDOUT)) {
139
+        if ($target == self::OUTPUT && System::isCLI()){
140
+            if (System::isColorsSupported(STDOUT)){
141 141
                 $target = self::OUTPUT_CLI_COLORS;
142
-            } else {
142
+            }else{
143 143
                 $target = self::OUTPUT_CLI;
144 144
             }
145 145
         }
146 146
 
147
-        if (!isset($this->targets[$target])) {
147
+        if (!isset($this->targets[$target])){
148 148
             throw new DumperException(sprintf('Undefined dump target %d', $target));
149 149
         }
150 150
 
151
-        if (is_string($this->targets[$target])) {
151
+        if (is_string($this->targets[$target])){
152 152
             $this->targets[$target] = new $this->targets[$target]();
153 153
         }
154 154
 
@@ -171,32 +171,32 @@  discard block
 block discarded – undo
171 171
         int $level = 0,
172 172
         bool $hideHeader = false
173 173
     ): string {
174
-        if (!$hideHeader && !empty($name)) {
175
-            $header = $r->indent($level) . $r->apply($name, 'name') . $r->apply(' = ', 'syntax', '=');
176
-        } else {
174
+        if (!$hideHeader && !empty($name)){
175
+            $header = $r->indent($level).$r->apply($name, 'name').$r->apply(' = ', 'syntax', '=');
176
+        }else{
177 177
             $header = $r->indent($level);
178 178
         }
179 179
 
180
-        if ($level > $this->maxLevel) {
180
+        if ($level > $this->maxLevel){
181 181
             //Renderer is not reference based, we can't dump too deep values
182
-            return $r->indent($level) . $r->apply('-too deep-', 'maxLevel') . "\n";
182
+            return $r->indent($level).$r->apply('-too deep-', 'maxLevel')."\n";
183 183
         }
184 184
 
185 185
         $type = strtolower(gettype($value));
186 186
 
187
-        if ($type === 'array') {
188
-            return $header . $this->renderArray($r, $value, $level, $hideHeader);
187
+        if ($type === 'array'){
188
+            return $header.$this->renderArray($r, $value, $level, $hideHeader);
189 189
         }
190 190
 
191
-        if ($type === 'object') {
192
-            return $header . $this->renderObject($r, $value, $level, $hideHeader);
191
+        if ($type === 'object'){
192
+            return $header.$this->renderObject($r, $value, $level, $hideHeader);
193 193
         }
194 194
 
195
-        if ($type === 'resource') {
195
+        if ($type === 'resource'){
196 196
             //No need to dump resource value
197
-            $element = get_resource_type($value) . ' resource ';
197
+            $element = get_resource_type($value).' resource ';
198 198
 
199
-            return $header . $r->apply($element, 'type', 'resource') . "\n";
199
+            return $header.$r->apply($element, 'type', 'resource')."\n";
200 200
         }
201 201
 
202 202
         //Value length
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $header .= $r->apply("{$type}({$length})", 'type', $type);
207 207
 
208 208
         $element = null;
209
-        switch ($type) {
209
+        switch ($type){
210 210
             case 'string':
211 211
                 $element = $r->escapeStrings() ? htmlspecialchars($value) : $value;
212 212
                 break;
@@ -216,31 +216,31 @@  discard block
 block discarded – undo
216 216
                 break;
217 217
 
218 218
             default:
219
-                if ($value !== null) {
219
+                if ($value !== null){
220 220
                     //Not showing null value, type is enough
221 221
                     $element = var_export($value, true);
222 222
                 }
223 223
         }
224 224
 
225 225
         //Including value
226
-        return $header . ' ' . $r->apply($element, 'value', $type) . "\n";
226
+        return $header.' '.$r->apply($element, 'value', $type)."\n";
227 227
     }
228 228
 
229 229
     private function renderArray(RendererInterface $r, array $array, int $level, bool $hideHeader = false): string
230 230
     {
231
-        if (!$hideHeader) {
231
+        if (!$hideHeader){
232 232
             $count = count($array);
233 233
 
234 234
             //Array size and scope
235
-            $output = $r->apply("array({$count})", 'type', 'array') . "\n";
236
-            $output .= $r->indent($level) . $r->apply('[', 'syntax', '[') . "\n";
237
-        } else {
235
+            $output = $r->apply("array({$count})", 'type', 'array')."\n";
236
+            $output .= $r->indent($level).$r->apply('[', 'syntax', '[')."\n";
237
+        }else{
238 238
             $output = '';
239 239
         }
240 240
 
241
-        foreach ($array as $key => $value) {
242
-            if (!is_numeric($key)) {
243
-                if (is_string($key) && $r->escapeStrings()) {
241
+        foreach ($array as $key => $value){
242
+            if (!is_numeric($key)){
243
+                if (is_string($key) && $r->escapeStrings()){
244 244
                     $key = htmlspecialchars($key);
245 245
                 }
246 246
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
             $output .= $this->renderValue($r, $value, "[{$key}]", $level + 1);
251 251
         }
252 252
 
253
-        if (!$hideHeader) {
253
+        if (!$hideHeader){
254 254
             //Closing array scope
255
-            $output .= $r->indent($level) . $r->apply(']', 'syntax', ']') . "\n";
255
+            $output .= $r->indent($level).$r->apply(']', 'syntax', ']')."\n";
256 256
         }
257 257
 
258 258
         return $output;
@@ -269,47 +269,47 @@  discard block
 block discarded – undo
269 269
         bool $hideHeader = false,
270 270
         string $class = ''
271 271
     ): string {
272
-        if (!$hideHeader) {
273
-            $type = ($class ?: get_class($value)) . ' object ';
272
+        if (!$hideHeader){
273
+            $type = ($class ?: get_class($value)).' object ';
274 274
 
275
-            $header = $r->apply($type, 'type', 'object') . "\n";
276
-            $header .= $r->indent($level) . $r->apply('(', 'syntax', '(') . "\n";
277
-        } else {
275
+            $header = $r->apply($type, 'type', 'object')."\n";
276
+            $header .= $r->indent($level).$r->apply('(', 'syntax', '(')."\n";
277
+        }else{
278 278
             $header = '';
279 279
         }
280 280
 
281 281
         //Let's use method specifically created for dumping
282
-        if (method_exists($value, '__debugInfo') || $value instanceof Closure) {
283
-            if ($value instanceof Closure) {
282
+        if (method_exists($value, '__debugInfo') || $value instanceof Closure){
283
+            if ($value instanceof Closure){
284 284
                 $debugInfo = $this->describeClosure($value);
285
-            } else {
285
+            }else{
286 286
                 $debugInfo = $value->__debugInfo();
287 287
             }
288 288
 
289
-            if (is_array($debugInfo)) {
289
+            if (is_array($debugInfo)){
290 290
                 //Pretty view
291 291
                 $debugInfo = (object)$debugInfo;
292 292
             }
293 293
 
294
-            if (is_object($debugInfo)) {
294
+            if (is_object($debugInfo)){
295 295
                 //We are not including syntax elements here
296 296
                 return $this->renderObject($r, $debugInfo, $level, false, get_class($value));
297 297
             }
298 298
 
299 299
             return $header
300 300
                 . $this->renderValue($r, $debugInfo, '', $level + (is_scalar($value)), true)
301
-                . $r->indent($level) . $r->apply(')', 'syntax', ')') . "\n";
301
+                . $r->indent($level).$r->apply(')', 'syntax', ')')."\n";
302 302
         }
303 303
 
304 304
         $refection = new ReflectionObject($value);
305 305
 
306 306
         $output = '';
307
-        foreach ($refection->getProperties() as $property) {
307
+        foreach ($refection->getProperties() as $property){
308 308
             $output .= $this->renderProperty($r, $value, $property, $level);
309 309
         }
310 310
 
311 311
         //Header, content, footer
312
-        return $header . $output . $r->indent($level) . $r->apply(')', 'syntax', ')') . "\n";
312
+        return $header.$output.$r->indent($level).$r->apply(')', 'syntax', ')')."\n";
313 313
     }
314 314
 
315 315
     /**
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     private function renderProperty(RendererInterface $r, $value, ReflectionProperty $p, int $level): string
320 320
     {
321
-        if ($p->isStatic()) {
321
+        if ($p->isStatic()){
322 322
             return '';
323 323
         }
324 324
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
             !($value instanceof stdClass)
327 327
             && is_string($p->getDocComment())
328 328
             && strpos($p->getDocComment(), '@internal') !== false
329
-        ) {
329
+        ){
330 330
             // Memory loop while reading doc comment for stdClass variables?
331 331
             // Report a PHP bug about treating comment INSIDE property declaration as doc comment.
332 332
             return '';
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
         //To read private and protected properties
339 339
         $p->setAccessible(true);
340 340
 
341
-        if ($value instanceof stdClass) {
341
+        if ($value instanceof stdClass){
342 342
             $name = $r->apply($p->getName(), 'dynamic');
343
-        } else {
343
+        }else{
344 344
             //Property name includes access level
345
-            $name = $p->getName() . $r->apply(':' . $access, 'access', $access);
345
+            $name = $p->getName().$r->apply(':'.$access, 'access', $access);
346 346
         }
347 347
 
348 348
         return $this->renderValue($r, $p->getValue($value), $name, $level + 1);
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
      */
354 354
     private function describeClosure(Closure $closure): array
355 355
     {
356
-        try {
356
+        try{
357 357
             $r = new ReflectionFunction($closure);
358
-        } catch (ReflectionException $e) {
358
+        }catch (ReflectionException $e){
359 359
             return ['closure' => 'unable to resolve'];
360 360
         }
361 361
 
362 362
         return [
363
-            'name' => $r->getName() . " (lines {$r->getStartLine()}:{$r->getEndLine()})",
363
+            'name' => $r->getName()." (lines {$r->getStartLine()}:{$r->getEndLine()})",
364 364
             'file' => $r->getFileName(),
365 365
             'this' => $r->getClosureThis(),
366 366
         ];
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
      */
374 374
     private function getAccess(ReflectionProperty $p): string
375 375
     {
376
-        if ($p->isPrivate()) {
376
+        if ($p->isPrivate()){
377 377
             return 'private';
378
-        } elseif ($p->isProtected()) {
378
+        } elseif ($p->isProtected()){
379 379
             return 'protected';
380 380
         }
381 381
 
Please login to merge, or discard this patch.
Braces   +84 added lines, -38 removed lines patch added patch discarded remove patch
@@ -62,7 +62,8 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function __construct(LoggerInterface $logger = null)
64 64
     {
65
-        if ($logger !== null) {
65
+        if ($logger !== null)
66
+        {
66 67
             $this->setLogger($logger);
67 68
         }
68 69
     }
@@ -88,7 +89,8 @@  discard block
 block discarded – undo
88 89
         $r = $this->getRenderer($target);
89 90
         $dump = $r->wrapContent($this->renderValue($r, $value));
90 91
 
91
-        switch ($target) {
92
+        switch ($target)
93
+        {
92 94
             case self::OUTPUT:
93 95
                 echo $dump;
94 96
                 break;
@@ -98,7 +100,8 @@  discard block
 block discarded – undo
98 100
                 return $dump;
99 101
 
100 102
             case self::LOGGER:
101
-                if ($this->logger === null) {
103
+                if ($this->logger === null)
104
+                {
102 105
                     throw new DumperException('Unable to dump value to log, no associated LoggerInterface.');
103 106
                 }
104 107
                 $this->logger->debug((string) $dump);
@@ -119,7 +122,8 @@  discard block
 block discarded – undo
119 122
      */
120 123
     public function setRenderer(int $target, RendererInterface $renderer): Dumper
121 124
     {
122
-        if (!isset($this->targets[$target])) {
125
+        if (!isset($this->targets[$target]))
126
+        {
123 127
             throw new DumperException(sprintf('Undefined dump target %d', $target));
124 128
         }
125 129
 
@@ -136,19 +140,25 @@  discard block
 block discarded – undo
136 140
      */
137 141
     private function getRenderer(int $target): RendererInterface
138 142
     {
139
-        if ($target == self::OUTPUT && System::isCLI()) {
140
-            if (System::isColorsSupported(STDOUT)) {
143
+        if ($target == self::OUTPUT && System::isCLI())
144
+        {
145
+            if (System::isColorsSupported(STDOUT))
146
+            {
141 147
                 $target = self::OUTPUT_CLI_COLORS;
142
-            } else {
148
+            }
149
+            else
150
+            {
143 151
                 $target = self::OUTPUT_CLI;
144 152
             }
145 153
         }
146 154
 
147
-        if (!isset($this->targets[$target])) {
155
+        if (!isset($this->targets[$target]))
156
+        {
148 157
             throw new DumperException(sprintf('Undefined dump target %d', $target));
149 158
         }
150 159
 
151
-        if (is_string($this->targets[$target])) {
160
+        if (is_string($this->targets[$target]))
161
+        {
152 162
             $this->targets[$target] = new $this->targets[$target]();
153 163
         }
154 164
 
@@ -171,28 +181,35 @@  discard block
 block discarded – undo
171 181
         int $level = 0,
172 182
         bool $hideHeader = false
173 183
     ): string {
174
-        if (!$hideHeader && !empty($name)) {
184
+        if (!$hideHeader && !empty($name))
185
+        {
175 186
             $header = $r->indent($level) . $r->apply($name, 'name') . $r->apply(' = ', 'syntax', '=');
176
-        } else {
187
+        }
188
+        else
189
+        {
177 190
             $header = $r->indent($level);
178 191
         }
179 192
 
180
-        if ($level > $this->maxLevel) {
193
+        if ($level > $this->maxLevel)
194
+        {
181 195
             //Renderer is not reference based, we can't dump too deep values
182 196
             return $r->indent($level) . $r->apply('-too deep-', 'maxLevel') . "\n";
183 197
         }
184 198
 
185 199
         $type = strtolower(gettype($value));
186 200
 
187
-        if ($type === 'array') {
201
+        if ($type === 'array')
202
+        {
188 203
             return $header . $this->renderArray($r, $value, $level, $hideHeader);
189 204
         }
190 205
 
191
-        if ($type === 'object') {
206
+        if ($type === 'object')
207
+        {
192 208
             return $header . $this->renderObject($r, $value, $level, $hideHeader);
193 209
         }
194 210
 
195
-        if ($type === 'resource') {
211
+        if ($type === 'resource')
212
+        {
196 213
             //No need to dump resource value
197 214
             $element = get_resource_type($value) . ' resource ';
198 215
 
@@ -206,7 +223,8 @@  discard block
 block discarded – undo
206 223
         $header .= $r->apply("{$type}({$length})", 'type', $type);
207 224
 
208 225
         $element = null;
209
-        switch ($type) {
226
+        switch ($type)
227
+        {
210 228
             case 'string':
211 229
                 $element = $r->escapeStrings() ? htmlspecialchars($value) : $value;
212 230
                 break;
@@ -216,7 +234,8 @@  discard block
 block discarded – undo
216 234
                 break;
217 235
 
218 236
             default:
219
-                if ($value !== null) {
237
+                if ($value !== null)
238
+                {
220 239
                     //Not showing null value, type is enough
221 240
                     $element = var_export($value, true);
222 241
                 }
@@ -228,19 +247,25 @@  discard block
 block discarded – undo
228 247
 
229 248
     private function renderArray(RendererInterface $r, array $array, int $level, bool $hideHeader = false): string
230 249
     {
231
-        if (!$hideHeader) {
250
+        if (!$hideHeader)
251
+        {
232 252
             $count = count($array);
233 253
 
234 254
             //Array size and scope
235 255
             $output = $r->apply("array({$count})", 'type', 'array') . "\n";
236 256
             $output .= $r->indent($level) . $r->apply('[', 'syntax', '[') . "\n";
237
-        } else {
257
+        }
258
+        else
259
+        {
238 260
             $output = '';
239 261
         }
240 262
 
241
-        foreach ($array as $key => $value) {
242
-            if (!is_numeric($key)) {
243
-                if (is_string($key) && $r->escapeStrings()) {
263
+        foreach ($array as $key => $value)
264
+        {
265
+            if (!is_numeric($key))
266
+            {
267
+                if (is_string($key) && $r->escapeStrings())
268
+                {
244 269
                     $key = htmlspecialchars($key);
245 270
                 }
246 271
 
@@ -250,7 +275,8 @@  discard block
 block discarded – undo
250 275
             $output .= $this->renderValue($r, $value, "[{$key}]", $level + 1);
251 276
         }
252 277
 
253
-        if (!$hideHeader) {
278
+        if (!$hideHeader)
279
+        {
254 280
             //Closing array scope
255 281
             $output .= $r->indent($level) . $r->apply(']', 'syntax', ']') . "\n";
256 282
         }
@@ -269,29 +295,38 @@  discard block
 block discarded – undo
269 295
         bool $hideHeader = false,
270 296
         string $class = ''
271 297
     ): string {
272
-        if (!$hideHeader) {
298
+        if (!$hideHeader)
299
+        {
273 300
             $type = ($class ?: get_class($value)) . ' object ';
274 301
 
275 302
             $header = $r->apply($type, 'type', 'object') . "\n";
276 303
             $header .= $r->indent($level) . $r->apply('(', 'syntax', '(') . "\n";
277
-        } else {
304
+        }
305
+        else
306
+        {
278 307
             $header = '';
279 308
         }
280 309
 
281 310
         //Let's use method specifically created for dumping
282
-        if (method_exists($value, '__debugInfo') || $value instanceof Closure) {
283
-            if ($value instanceof Closure) {
311
+        if (method_exists($value, '__debugInfo') || $value instanceof Closure)
312
+        {
313
+            if ($value instanceof Closure)
314
+            {
284 315
                 $debugInfo = $this->describeClosure($value);
285
-            } else {
316
+            }
317
+            else
318
+            {
286 319
                 $debugInfo = $value->__debugInfo();
287 320
             }
288 321
 
289
-            if (is_array($debugInfo)) {
322
+            if (is_array($debugInfo))
323
+            {
290 324
                 //Pretty view
291 325
                 $debugInfo = (object)$debugInfo;
292 326
             }
293 327
 
294
-            if (is_object($debugInfo)) {
328
+            if (is_object($debugInfo))
329
+            {
295 330
                 //We are not including syntax elements here
296 331
                 return $this->renderObject($r, $debugInfo, $level, false, get_class($value));
297 332
             }
@@ -304,7 +339,8 @@  discard block
 block discarded – undo
304 339
         $refection = new ReflectionObject($value);
305 340
 
306 341
         $output = '';
307
-        foreach ($refection->getProperties() as $property) {
342
+        foreach ($refection->getProperties() as $property)
343
+        {
308 344
             $output .= $this->renderProperty($r, $value, $property, $level);
309 345
         }
310 346
 
@@ -318,7 +354,8 @@  discard block
 block discarded – undo
318 354
      */
319 355
     private function renderProperty(RendererInterface $r, $value, ReflectionProperty $p, int $level): string
320 356
     {
321
-        if ($p->isStatic()) {
357
+        if ($p->isStatic())
358
+        {
322 359
             return '';
323 360
         }
324 361
 
@@ -338,9 +375,12 @@  discard block
 block discarded – undo
338 375
         //To read private and protected properties
339 376
         $p->setAccessible(true);
340 377
 
341
-        if ($value instanceof stdClass) {
378
+        if ($value instanceof stdClass)
379
+        {
342 380
             $name = $r->apply($p->getName(), 'dynamic');
343
-        } else {
381
+        }
382
+        else
383
+        {
344 384
             //Property name includes access level
345 385
             $name = $p->getName() . $r->apply(':' . $access, 'access', $access);
346 386
         }
@@ -353,9 +393,12 @@  discard block
 block discarded – undo
353 393
      */
354 394
     private function describeClosure(Closure $closure): array
355 395
     {
356
-        try {
396
+        try
397
+        {
357 398
             $r = new ReflectionFunction($closure);
358
-        } catch (ReflectionException $e) {
399
+        }
400
+        catch (ReflectionException $e)
401
+        {
359 402
             return ['closure' => 'unable to resolve'];
360 403
         }
361 404
 
@@ -373,9 +416,12 @@  discard block
 block discarded – undo
373 416
      */
374 417
     private function getAccess(ReflectionProperty $p): string
375 418
     {
376
-        if ($p->isPrivate()) {
419
+        if ($p->isPrivate())
420
+        {
377 421
             return 'private';
378
-        } elseif ($p->isProtected()) {
422
+        }
423
+        elseif ($p->isProtected())
424
+        {
379 425
             return 'protected';
380 426
         }
381 427
 
Please login to merge, or discard this patch.
src/Dumper/src/helpers.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use Spiral\Core\ContainerScope;
13 13
 use Spiral\Debug\Dumper;
14 14
 
15
-if (!function_exists('dump')) {
15
+if (!function_exists('dump')){
16 16
     /**
17 17
      * Dump value.
18 18
      *
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
      */
24 24
     function dump($value, int $output = Dumper::OUTPUT): ?string
25 25
     {
26
-        if (!class_exists(ContainerScope::class)) {
26
+        if (!class_exists(ContainerScope::class)){
27 27
             return (new Dumper())->dump($value, $output);
28 28
         }
29 29
 
30 30
         $container = ContainerScope::getContainer();
31
-        if (is_null($container) || !$container->has(Dumper::class)) {
31
+        if (is_null($container) || !$container->has(Dumper::class)){
32 32
             $dumper = new Dumper();
33 33
 
34 34
             return $dumper->dump($value, $output);
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
 use Spiral\Core\ContainerScope;
13 13
 use Spiral\Debug\Dumper;
14 14
 
15
-if (!function_exists('dump')) {
15
+if (!function_exists('dump'))
16
+{
16 17
     /**
17 18
      * Dump value.
18 19
      *
@@ -23,12 +24,14 @@  discard block
 block discarded – undo
23 24
      */
24 25
     function dump($value, int $output = Dumper::OUTPUT): ?string
25 26
     {
26
-        if (!class_exists(ContainerScope::class)) {
27
+        if (!class_exists(ContainerScope::class))
28
+        {
27 29
             return (new Dumper())->dump($value, $output);
28 30
         }
29 31
 
30 32
         $container = ContainerScope::getContainer();
31
-        if (is_null($container) || !$container->has(Dumper::class)) {
33
+        if (is_null($container) || !$container->has(Dumper::class))
34
+        {
32 35
             $dumper = new Dumper();
33 36
 
34 37
             return $dumper->dump($value, $output);
Please login to merge, or discard this patch.
src/Dumper/src/Renderer/HtmlRenderer.php 1 patch
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * Default coloring schema.
23 23
      */
24
-    public const DEFAULT = [
24
+    public const default = [
25 25
         'body'     => '<pre style="background-color: white; font-family: monospace;">%s</pre>',
26 26
         'element'  => '<span style="%s;">%s</span>',
27 27
         'indent'   => '&middot;    ',
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * Set of styles associated with different dumping properties.
101 101
      */
102
-    protected array $style = self::DEFAULT;
102
+    protected array $style = self::default;
103 103
 
104
-    public function __construct(array $style = self::DEFAULT)
104
+    public function __construct(array $style = self::default)
105 105
     {
106 106
         $this->style = $style;
107 107
     }
Please login to merge, or discard this patch.