@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | { |
27 | 27 | $result = ''; |
28 | 28 | |
29 | - $result .= '[' . get_class($e) . "]\n" . $e->getMessage(); |
|
29 | + $result .= '['.get_class($e)."]\n".$e->getMessage(); |
|
30 | 30 | |
31 | 31 | $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine()); |
32 | 32 | |
33 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
33 | + if ($verbosity >= self::VERBOSITY_DEBUG){ |
|
34 | 34 | $result .= $this->renderTrace($e, new Highlighter(new PlainStyle())); |
35 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
35 | + } elseif ($verbosity >= self::VERBOSITY_VERBOSE){ |
|
36 | 36 | $result .= $this->renderTrace($e); |
37 | 37 | } |
38 | 38 | |
@@ -47,38 +47,38 @@ discard block |
||
47 | 47 | private function renderTrace(Throwable $e, Highlighter $h = null): string |
48 | 48 | { |
49 | 49 | $stacktrace = $this->getStacktrace($e); |
50 | - if (empty($stacktrace)) { |
|
50 | + if (empty($stacktrace)){ |
|
51 | 51 | return ''; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $result = "\nException Trace:\n"; |
55 | 55 | |
56 | - foreach ($stacktrace as $trace) { |
|
57 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
56 | + foreach ($stacktrace as $trace){ |
|
57 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
58 | 58 | $line = sprintf( |
59 | 59 | ' %s%s%s()', |
60 | 60 | $trace['class'], |
61 | 61 | $trace['type'], |
62 | 62 | $trace['function'] |
63 | 63 | ); |
64 | - } else { |
|
64 | + }else{ |
|
65 | 65 | $line = $trace['function']; |
66 | 66 | } |
67 | 67 | |
68 | - if (isset($trace['file'])) { |
|
68 | + if (isset($trace['file'])){ |
|
69 | 69 | $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']); |
70 | - } else { |
|
70 | + }else{ |
|
71 | 71 | $line .= sprintf(' at %s:%s', 'n/a', 'n/a'); |
72 | 72 | } |
73 | 73 | |
74 | - $result .= $line . "\n"; |
|
74 | + $result .= $line."\n"; |
|
75 | 75 | |
76 | - if (!empty($h) && !empty($trace['file'])) { |
|
76 | + if (!empty($h) && !empty($trace['file'])){ |
|
77 | 77 | $result .= $h->highlightLines( |
78 | 78 | file_get_contents($trace['file']), |
79 | 79 | $trace['line'], |
80 | 80 | static::SHOW_LINES |
81 | - ) . "\n"; |
|
81 | + )."\n"; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 |
@@ -30,9 +30,12 @@ discard block |
||
30 | 30 | |
31 | 31 | $result .= sprintf(" in %s:%s\n", $e->getFile(), $e->getLine()); |
32 | 32 | |
33 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
33 | + if ($verbosity >= self::VERBOSITY_DEBUG) |
|
34 | + { |
|
34 | 35 | $result .= $this->renderTrace($e, new Highlighter(new PlainStyle())); |
35 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
36 | + } |
|
37 | + elseif ($verbosity >= self::VERBOSITY_VERBOSE) |
|
38 | + { |
|
36 | 39 | $result .= $this->renderTrace($e); |
37 | 40 | } |
38 | 41 | |
@@ -47,33 +50,42 @@ discard block |
||
47 | 50 | private function renderTrace(Throwable $e, Highlighter $h = null): string |
48 | 51 | { |
49 | 52 | $stacktrace = $this->getStacktrace($e); |
50 | - if (empty($stacktrace)) { |
|
53 | + if (empty($stacktrace)) |
|
54 | + { |
|
51 | 55 | return ''; |
52 | 56 | } |
53 | 57 | |
54 | 58 | $result = "\nException Trace:\n"; |
55 | 59 | |
56 | - foreach ($stacktrace as $trace) { |
|
57 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
60 | + foreach ($stacktrace as $trace) |
|
61 | + { |
|
62 | + if (isset($trace['type']) && isset($trace['class'])) |
|
63 | + { |
|
58 | 64 | $line = sprintf( |
59 | 65 | ' %s%s%s()', |
60 | 66 | $trace['class'], |
61 | 67 | $trace['type'], |
62 | 68 | $trace['function'] |
63 | 69 | ); |
64 | - } else { |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
65 | 73 | $line = $trace['function']; |
66 | 74 | } |
67 | 75 | |
68 | - if (isset($trace['file'])) { |
|
76 | + if (isset($trace['file'])) |
|
77 | + { |
|
69 | 78 | $line .= sprintf(' at %s:%s', $trace['file'], $trace['line']); |
70 | - } else { |
|
79 | + } |
|
80 | + else |
|
81 | + { |
|
71 | 82 | $line .= sprintf(' at %s:%s', 'n/a', 'n/a'); |
72 | 83 | } |
73 | 84 | |
74 | 85 | $result .= $line . "\n"; |
75 | 86 | |
76 | - if (!empty($h) && !empty($trace['file'])) { |
|
87 | + if (!empty($h) && !empty($trace['file'])) |
|
88 | + { |
|
77 | 89 | $result .= $h->highlightLines( |
78 | 90 | file_get_contents($trace['file']), |
79 | 91 | $trace['line'], |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | protected function getStacktrace(Throwable $e): array |
33 | 33 | { |
34 | 34 | $stacktrace = $e->getTrace(); |
35 | - if (empty($stacktrace)) { |
|
35 | + if (empty($stacktrace)){ |
|
36 | 36 | return []; |
37 | 37 | } |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'line' => $e->getLine(), |
43 | 43 | ] + $stacktrace[0]; |
44 | 44 | |
45 | - if ($stacktrace[0] != $header) { |
|
45 | + if ($stacktrace[0] != $header){ |
|
46 | 46 | array_unshift($stacktrace, $header); |
47 | 47 | } |
48 | 48 |
@@ -32,7 +32,8 @@ discard block |
||
32 | 32 | protected function getStacktrace(Throwable $e): array |
33 | 33 | { |
34 | 34 | $stacktrace = $e->getTrace(); |
35 | - if (empty($stacktrace)) { |
|
35 | + if (empty($stacktrace)) |
|
36 | + { |
|
36 | 37 | return []; |
37 | 38 | } |
38 | 39 | |
@@ -42,7 +43,8 @@ discard block |
||
42 | 43 | 'line' => $e->getLine(), |
43 | 44 | ] + $stacktrace[0]; |
44 | 45 | |
45 | - if ($stacktrace[0] != $header) { |
|
46 | + if ($stacktrace[0] != $header) |
|
47 | + { |
|
46 | 48 | array_unshift($stacktrace, $header); |
47 | 49 | } |
48 | 50 |
@@ -43,33 +43,33 @@ |
||
43 | 43 | public function wrap(array $args): array |
44 | 44 | { |
45 | 45 | $result = []; |
46 | - foreach ($args as $arg) { |
|
46 | + foreach ($args as $arg){ |
|
47 | 47 | $display = $type = strtolower(gettype($arg)); |
48 | 48 | |
49 | - if (is_numeric($arg)) { |
|
49 | + if (is_numeric($arg)){ |
|
50 | 50 | $result[] = $this->r->apply($arg, 'value', $type); |
51 | 51 | continue; |
52 | - } elseif (is_bool($arg)) { |
|
52 | + } elseif (is_bool($arg)){ |
|
53 | 53 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
54 | 54 | continue; |
55 | - } elseif (is_null($arg)) { |
|
55 | + } elseif (is_null($arg)){ |
|
56 | 56 | $result[] = $this->r->apply('null', 'value', $type); |
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | |
60 | - if (is_object($arg)) { |
|
60 | + if (is_object($arg)){ |
|
61 | 61 | $reflection = new ReflectionClass($arg); |
62 | 62 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
63 | 63 | } |
64 | 64 | |
65 | 65 | $type = $this->r->apply($display, 'value', $type); |
66 | 66 | |
67 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
67 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG){ |
|
68 | 68 | $result[] = sprintf('<span>%s</span>', $type); |
69 | - } else { |
|
69 | + }else{ |
|
70 | 70 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR)); |
71 | 71 | |
72 | - if (!isset($this->values[$hash])) { |
|
72 | + if (!isset($this->values[$hash])){ |
|
73 | 73 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
74 | 74 | } |
75 | 75 |
@@ -43,33 +43,44 @@ |
||
43 | 43 | public function wrap(array $args): array |
44 | 44 | { |
45 | 45 | $result = []; |
46 | - foreach ($args as $arg) { |
|
46 | + foreach ($args as $arg) |
|
47 | + { |
|
47 | 48 | $display = $type = strtolower(gettype($arg)); |
48 | 49 | |
49 | - if (is_numeric($arg)) { |
|
50 | + if (is_numeric($arg)) |
|
51 | + { |
|
50 | 52 | $result[] = $this->r->apply($arg, 'value', $type); |
51 | 53 | continue; |
52 | - } elseif (is_bool($arg)) { |
|
54 | + } |
|
55 | + elseif (is_bool($arg)) |
|
56 | + { |
|
53 | 57 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
54 | 58 | continue; |
55 | - } elseif (is_null($arg)) { |
|
59 | + } |
|
60 | + elseif (is_null($arg)) |
|
61 | + { |
|
56 | 62 | $result[] = $this->r->apply('null', 'value', $type); |
57 | 63 | continue; |
58 | 64 | } |
59 | 65 | |
60 | - if (is_object($arg)) { |
|
66 | + if (is_object($arg)) |
|
67 | + { |
|
61 | 68 | $reflection = new ReflectionClass($arg); |
62 | 69 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
63 | 70 | } |
64 | 71 | |
65 | 72 | $type = $this->r->apply($display, 'value', $type); |
66 | 73 | |
67 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
74 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) |
|
75 | + { |
|
68 | 76 | $result[] = sprintf('<span>%s</span>', $type); |
69 | - } else { |
|
77 | + } |
|
78 | + else |
|
79 | + { |
|
70 | 80 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR)); |
71 | 81 | |
72 | - if (!isset($this->values[$hash])) { |
|
82 | + if (!isset($this->values[$hash])) |
|
83 | + { |
|
73 | 84 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
74 | 85 | } |
75 | 86 |
@@ -70,7 +70,7 @@ |
||
70 | 70 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR)); |
71 | 71 | |
72 | 72 | if (!isset($this->values[$hash])) { |
73 | - $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
|
73 | + $this->values[$hash] = $this->dumper->dump($arg, Dumper::return); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $result[] = sprintf('<span onclick="_da(\'%s\')">%s</span>', $hash, $type); |
@@ -32,24 +32,24 @@ |
||
32 | 32 | |
33 | 33 | private function renderTrace(array $trace, int $verbosity): Generator |
34 | 34 | { |
35 | - foreach ($trace as $item) { |
|
35 | + foreach ($trace as $item){ |
|
36 | 36 | $result = []; |
37 | 37 | |
38 | - if (isset($item['class'])) { |
|
38 | + if (isset($item['class'])){ |
|
39 | 39 | $result['function'] = sprintf( |
40 | 40 | '%s%s%s()', |
41 | 41 | $item['class'], |
42 | 42 | $item['type'], |
43 | 43 | $item['function'] |
44 | 44 | ); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | $result['function'] = sprintf( |
47 | 47 | '%s()', |
48 | 48 | $item['function'] |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) { |
|
52 | + if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])){ |
|
53 | 53 | $result['at'] = [ |
54 | 54 | 'file' => $item['file'] ?? null, |
55 | 55 | 'line' => $item['line'] ?? null, |
@@ -32,24 +32,29 @@ |
||
32 | 32 | |
33 | 33 | private function renderTrace(array $trace, int $verbosity): Generator |
34 | 34 | { |
35 | - foreach ($trace as $item) { |
|
35 | + foreach ($trace as $item) |
|
36 | + { |
|
36 | 37 | $result = []; |
37 | 38 | |
38 | - if (isset($item['class'])) { |
|
39 | + if (isset($item['class'])) |
|
40 | + { |
|
39 | 41 | $result['function'] = sprintf( |
40 | 42 | '%s%s%s()', |
41 | 43 | $item['class'], |
42 | 44 | $item['type'], |
43 | 45 | $item['function'] |
44 | 46 | ); |
45 | - } else { |
|
47 | + } |
|
48 | + else |
|
49 | + { |
|
46 | 50 | $result['function'] = sprintf( |
47 | 51 | '%s()', |
48 | 52 | $item['function'] |
49 | 53 | ); |
50 | 54 | } |
51 | 55 | |
52 | - if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) { |
|
56 | + if ($verbosity >= self::VERBOSITY_VERBOSE && isset($item['file'])) |
|
57 | + { |
|
53 | 58 | $result['at'] = [ |
54 | 59 | 'file' => $item['file'] ?? null, |
55 | 60 | 'line' => $item['line'] ?? null, |
@@ -40,7 +40,7 @@ |
||
40 | 40 | { |
41 | 41 | $name ??= $this->default; |
42 | 42 | |
43 | - if (!isset($this->transports[$name])) { |
|
43 | + if (!isset($this->transports[$name])){ |
|
44 | 44 | throw new TransportException("Undefined auth transport {$name}"); |
45 | 45 | } |
46 | 46 |
@@ -40,7 +40,8 @@ |
||
40 | 40 | { |
41 | 41 | $name ??= $this->default; |
42 | 42 | |
43 | - if (!isset($this->transports[$name])) { |
|
43 | + if (!isset($this->transports[$name])) |
|
44 | + { |
|
44 | 45 | throw new TransportException("Undefined auth transport {$name}"); |
45 | 46 | } |
46 | 47 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | bool $secure = false, |
44 | 44 | bool $httpOnly = true, |
45 | 45 | ?string $sameSite = null |
46 | - ) { |
|
46 | + ){ |
|
47 | 47 | $this->cookie = $cookie; |
48 | 48 | $this->basePath = $basePath; |
49 | 49 | $this->domain = $domain; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ): Response { |
73 | 73 | /** @var CookieQueue $cookieQueue */ |
74 | 74 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
75 | - if ($cookieQueue === null) { |
|
75 | + if ($cookieQueue === null){ |
|
76 | 76 | return $response->withAddedHeader( |
77 | 77 | 'Set-Cookie', |
78 | 78 | Cookie::create( |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | ); |
89 | 89 | } |
90 | 90 | |
91 | - if ($tokenID === null) { |
|
91 | + if ($tokenID === null){ |
|
92 | 92 | $cookieQueue->delete($this->cookie); |
93 | - } else { |
|
93 | + }else{ |
|
94 | 94 | $cookieQueue->set( |
95 | 95 | $this->cookie, |
96 | 96 | $tokenID, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | private function getLifetime(DateTimeInterface $expiresAt = null): ?int |
122 | 122 | { |
123 | - if ($expiresAt === null) { |
|
123 | + if ($expiresAt === null){ |
|
124 | 124 | return null; |
125 | 125 | } |
126 | 126 |
@@ -72,7 +72,8 @@ discard block |
||
72 | 72 | ): Response { |
73 | 73 | /** @var CookieQueue $cookieQueue */ |
74 | 74 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
75 | - if ($cookieQueue === null) { |
|
75 | + if ($cookieQueue === null) |
|
76 | + { |
|
76 | 77 | return $response->withAddedHeader( |
77 | 78 | 'Set-Cookie', |
78 | 79 | Cookie::create( |
@@ -88,9 +89,12 @@ discard block |
||
88 | 89 | ); |
89 | 90 | } |
90 | 91 | |
91 | - if ($tokenID === null) { |
|
92 | + if ($tokenID === null) |
|
93 | + { |
|
92 | 94 | $cookieQueue->delete($this->cookie); |
93 | - } else { |
|
95 | + } |
|
96 | + else |
|
97 | + { |
|
94 | 98 | $cookieQueue->set( |
95 | 99 | $this->cookie, |
96 | 100 | $tokenID, |
@@ -120,7 +124,8 @@ discard block |
||
120 | 124 | */ |
121 | 125 | private function getLifetime(DateTimeInterface $expiresAt = null): ?int |
122 | 126 | { |
123 | - if ($expiresAt === null) { |
|
127 | + if ($expiresAt === null) |
|
128 | + { |
|
124 | 129 | return null; |
125 | 130 | } |
126 | 131 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function fetchToken(Request $request): ?string |
38 | 38 | { |
39 | - if ($request->hasHeader($this->header)) { |
|
39 | + if ($request->hasHeader($this->header)){ |
|
40 | 40 | return $this->extractToken($request); |
41 | 41 | } |
42 | 42 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | string $tokenID, |
53 | 53 | DateTimeInterface $expiresAt = null |
54 | 54 | ): Response { |
55 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
55 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID){ |
|
56 | 56 | return $response; |
57 | 57 | } |
58 | 58 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | { |
72 | 72 | $headerLine = $request->getHeaderLine($this->header); |
73 | 73 | |
74 | - if ($this->valueFormat !== '%s') { |
|
74 | + if ($this->valueFormat !== '%s'){ |
|
75 | 75 | [$token] = sscanf($headerLine, $this->valueFormat); |
76 | 76 | |
77 | - return $token !== null ? (string) $token : null; |
|
77 | + return $token !== null ? (string)$token : null; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | return $headerLine; |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function fetchToken(Request $request): ?string |
38 | 38 | { |
39 | - if ($request->hasHeader($this->header)) { |
|
39 | + if ($request->hasHeader($this->header)) |
|
40 | + { |
|
40 | 41 | return $this->extractToken($request); |
41 | 42 | } |
42 | 43 | |
@@ -52,7 +53,8 @@ discard block |
||
52 | 53 | string $tokenID, |
53 | 54 | DateTimeInterface $expiresAt = null |
54 | 55 | ): Response { |
55 | - if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) { |
|
56 | + if ($request->hasHeader($this->header) && $this->extractToken($request) === $tokenID) |
|
57 | + { |
|
56 | 58 | return $response; |
57 | 59 | } |
58 | 60 | |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | { |
72 | 74 | $headerLine = $request->getHeaderLine($this->header); |
73 | 75 | |
74 | - if ($this->valueFormat !== '%s') { |
|
76 | + if ($this->valueFormat !== '%s') |
|
77 | + { |
|
75 | 78 | [$token] = sscanf($headerLine, $this->valueFormat); |
76 | 79 | |
77 | 80 | return $token !== null ? (string) $token : null; |
@@ -70,14 +70,17 @@ discard block |
||
70 | 70 | |
71 | 71 | private function initContext(Request $request, AuthContextInterface $authContext): AuthContextInterface |
72 | 72 | { |
73 | - foreach ($this->transportRegistry->getTransports() as $name => $transport) { |
|
73 | + foreach ($this->transportRegistry->getTransports() as $name => $transport) |
|
74 | + { |
|
74 | 75 | $tokenID = $transport->fetchToken($request); |
75 | - if ($tokenID === null) { |
|
76 | + if ($tokenID === null) |
|
77 | + { |
|
76 | 78 | continue; |
77 | 79 | } |
78 | 80 | |
79 | 81 | $token = $this->tokenStorage->load($tokenID); |
80 | - if ($token === null) { |
|
82 | + if ($token === null) |
|
83 | + { |
|
81 | 84 | continue; |
82 | 85 | } |
83 | 86 | |
@@ -91,13 +94,15 @@ discard block |
||
91 | 94 | |
92 | 95 | private function closeContext(Request $request, Response $response, AuthContextInterface $authContext): Response |
93 | 96 | { |
94 | - if ($authContext->getToken() === null) { |
|
97 | + if ($authContext->getToken() === null) |
|
98 | + { |
|
95 | 99 | return $response; |
96 | 100 | } |
97 | 101 | |
98 | 102 | $transport = $this->transportRegistry->getTransport($authContext->getTransport()); |
99 | 103 | |
100 | - if ($authContext->isClosed()) { |
|
104 | + if ($authContext->isClosed()) |
|
105 | + { |
|
101 | 106 | $this->tokenStorage->delete($authContext->getToken()); |
102 | 107 | |
103 | 108 | return $transport->removeToken( |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public function process(Request $request, RequestHandlerInterface $handler): Response |
46 | 46 | { |
47 | 47 | $cookie = null; |
48 | - if (isset($request->getCookieParams()[$this->config->getCookie()])) { |
|
48 | + if (isset($request->getCookieParams()[$this->config->getCookie()])){ |
|
49 | 49 | $token = $request->getCookieParams()[$this->config->getCookie()]; |
50 | - } else { |
|
50 | + }else{ |
|
51 | 51 | //Making new token |
52 | 52 | $token = $this->random($this->config->getTokenLength()); |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | //CSRF issues must be handled by Firewall middleware |
59 | 59 | $response = $handler->handle($request->withAttribute(static::ATTRIBUTE, $token)); |
60 | 60 | |
61 | - if (!empty($cookie)) { |
|
61 | + if (!empty($cookie)){ |
|
62 | 62 | return $response->withAddedHeader('Set-Cookie', $cookie); |
63 | 63 | } |
64 | 64 | |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private function random(int $length = 32): string |
91 | 91 | { |
92 | - try { |
|
93 | - if (empty($string = random_bytes($length))) { |
|
92 | + try{ |
|
93 | + if (empty($string = random_bytes($length))){ |
|
94 | 94 | throw new RuntimeException('Unable to generate random string'); |
95 | 95 | } |
96 | - } catch (Throwable $e) { |
|
96 | + }catch (Throwable $e){ |
|
97 | 97 | throw new RuntimeException('Unable to generate random string', $e->getCode(), $e); |
98 | 98 | } |
99 | 99 |
@@ -45,9 +45,12 @@ discard block |
||
45 | 45 | public function process(Request $request, RequestHandlerInterface $handler): Response |
46 | 46 | { |
47 | 47 | $cookie = null; |
48 | - if (isset($request->getCookieParams()[$this->config->getCookie()])) { |
|
48 | + if (isset($request->getCookieParams()[$this->config->getCookie()])) |
|
49 | + { |
|
49 | 50 | $token = $request->getCookieParams()[$this->config->getCookie()]; |
50 | - } else { |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
51 | 54 | //Making new token |
52 | 55 | $token = $this->random($this->config->getTokenLength()); |
53 | 56 | |
@@ -58,7 +61,8 @@ discard block |
||
58 | 61 | //CSRF issues must be handled by Firewall middleware |
59 | 62 | $response = $handler->handle($request->withAttribute(static::ATTRIBUTE, $token)); |
60 | 63 | |
61 | - if (!empty($cookie)) { |
|
64 | + if (!empty($cookie)) |
|
65 | + { |
|
62 | 66 | return $response->withAddedHeader('Set-Cookie', $cookie); |
63 | 67 | } |
64 | 68 | |
@@ -89,11 +93,15 @@ discard block |
||
89 | 93 | */ |
90 | 94 | private function random(int $length = 32): string |
91 | 95 | { |
92 | - try { |
|
93 | - if (empty($string = random_bytes($length))) { |
|
96 | + try |
|
97 | + { |
|
98 | + if (empty($string = random_bytes($length))) |
|
99 | + { |
|
94 | 100 | throw new RuntimeException('Unable to generate random string'); |
95 | 101 | } |
96 | - } catch (Throwable $e) { |
|
102 | + } |
|
103 | + catch (Throwable $e) |
|
104 | + { |
|
97 | 105 | throw new RuntimeException('Unable to generate random string', $e->getCode(), $e); |
98 | 106 | } |
99 | 107 |