@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | $buffer = null; |
| 28 | 28 | $bufferOffset = 0; |
| 29 | 29 | |
| 30 | - foreach ($inner as $n) { |
|
| 30 | + foreach ($inner as $n){ |
|
| 31 | 31 | $token->offset ??= $n->offset; |
| 32 | 32 | |
| 33 | - if ($n instanceof Byte) { |
|
| 34 | - if ($buffer === null) { |
|
| 33 | + if ($n instanceof Byte){ |
|
| 34 | + if ($buffer === null){ |
|
| 35 | 35 | $buffer = ''; |
| 36 | 36 | $bufferOffset = $n->offset; |
| 37 | 37 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ($buffer !== null) { |
|
| 45 | + if ($buffer !== null){ |
|
| 46 | 46 | $token->tokens[] = new Token( |
| 47 | 47 | Token::TYPE_RAW, |
| 48 | 48 | $bufferOffset, |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $token->tokens[] = $n; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ($buffer !== null) { |
|
| 59 | + if ($buffer !== null){ |
|
| 60 | 60 | $token->tokens[] = new Token( |
| 61 | 61 | Token::TYPE_RAW, |
| 62 | 62 | $bufferOffset, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
| 68 | + if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW){ |
|
| 69 | 69 | $token->tokens = []; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -27,11 +27,14 @@ discard block |
||
| 27 | 27 | $buffer = null; |
| 28 | 28 | $bufferOffset = 0; |
| 29 | 29 | |
| 30 | - foreach ($inner as $n) { |
|
| 30 | + foreach ($inner as $n) |
|
| 31 | + { |
|
| 31 | 32 | $token->offset ??= $n->offset; |
| 32 | 33 | |
| 33 | - if ($n instanceof Byte) { |
|
| 34 | - if ($buffer === null) { |
|
| 34 | + if ($n instanceof Byte) |
|
| 35 | + { |
|
| 36 | + if ($buffer === null) |
|
| 37 | + { |
|
| 35 | 38 | $buffer = ''; |
| 36 | 39 | $bufferOffset = $n->offset; |
| 37 | 40 | } |
@@ -42,7 +45,8 @@ discard block |
||
| 42 | 45 | continue; |
| 43 | 46 | } |
| 44 | 47 | |
| 45 | - if ($buffer !== null) { |
|
| 48 | + if ($buffer !== null) |
|
| 49 | + { |
|
| 46 | 50 | $token->tokens[] = new Token( |
| 47 | 51 | Token::TYPE_RAW, |
| 48 | 52 | $bufferOffset, |
@@ -56,7 +60,8 @@ discard block |
||
| 56 | 60 | $token->tokens[] = $n; |
| 57 | 61 | } |
| 58 | 62 | |
| 59 | - if ($buffer !== null) { |
|
| 63 | + if ($buffer !== null) |
|
| 64 | + { |
|
| 60 | 65 | $token->tokens[] = new Token( |
| 61 | 66 | Token::TYPE_RAW, |
| 62 | 67 | $bufferOffset, |
@@ -65,7 +70,8 @@ discard block |
||
| 65 | 70 | ); |
| 66 | 71 | } |
| 67 | 72 | |
| 68 | - if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) { |
|
| 73 | + if (count($token->tokens) === 1 && $token->tokens[0]->type === Token::TYPE_RAW) |
|
| 74 | + { |
|
| 69 | 75 | $token->tokens = []; |
| 70 | 76 | } |
| 71 | 77 | |
@@ -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); |
@@ -42,33 +42,33 @@ |
||
| 42 | 42 | public function wrap(array $args): array |
| 43 | 43 | { |
| 44 | 44 | $result = []; |
| 45 | - foreach ($args as $arg) { |
|
| 45 | + foreach ($args as $arg){ |
|
| 46 | 46 | $display = $type = strtolower(gettype($arg)); |
| 47 | 47 | |
| 48 | - if (is_numeric($arg)) { |
|
| 48 | + if (is_numeric($arg)){ |
|
| 49 | 49 | $result[] = $this->r->apply($arg, 'value', $type); |
| 50 | 50 | continue; |
| 51 | - } elseif (is_bool($arg)) { |
|
| 51 | + } elseif (is_bool($arg)){ |
|
| 52 | 52 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
| 53 | 53 | continue; |
| 54 | - } elseif (is_null($arg)) { |
|
| 54 | + } elseif (is_null($arg)){ |
|
| 55 | 55 | $result[] = $this->r->apply('null', 'value', $type); |
| 56 | 56 | continue; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if (is_object($arg)) { |
|
| 59 | + if (is_object($arg)){ |
|
| 60 | 60 | $reflection = new \ReflectionClass($arg); |
| 61 | 61 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $type = $this->r->apply($display, 'value', $type); |
| 65 | 65 | |
| 66 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
| 66 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG){ |
|
| 67 | 67 | $result[] = sprintf('<span>%s</span>', $type); |
| 68 | - } else { |
|
| 68 | + }else{ |
|
| 69 | 69 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR)); |
| 70 | 70 | |
| 71 | - if (!isset($this->values[$hash])) { |
|
| 71 | + if (!isset($this->values[$hash])){ |
|
| 72 | 72 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -42,33 +42,44 @@ |
||
| 42 | 42 | public function wrap(array $args): array |
| 43 | 43 | { |
| 44 | 44 | $result = []; |
| 45 | - foreach ($args as $arg) { |
|
| 45 | + foreach ($args as $arg) |
|
| 46 | + { |
|
| 46 | 47 | $display = $type = strtolower(gettype($arg)); |
| 47 | 48 | |
| 48 | - if (is_numeric($arg)) { |
|
| 49 | + if (is_numeric($arg)) |
|
| 50 | + { |
|
| 49 | 51 | $result[] = $this->r->apply($arg, 'value', $type); |
| 50 | 52 | continue; |
| 51 | - } elseif (is_bool($arg)) { |
|
| 53 | + } |
|
| 54 | + elseif (is_bool($arg)) |
|
| 55 | + { |
|
| 52 | 56 | $result[] = $this->r->apply($arg ? 'true' : 'false', 'value', $type); |
| 53 | 57 | continue; |
| 54 | - } elseif (is_null($arg)) { |
|
| 58 | + } |
|
| 59 | + elseif (is_null($arg)) |
|
| 60 | + { |
|
| 55 | 61 | $result[] = $this->r->apply('null', 'value', $type); |
| 56 | 62 | continue; |
| 57 | 63 | } |
| 58 | 64 | |
| 59 | - if (is_object($arg)) { |
|
| 65 | + if (is_object($arg)) |
|
| 66 | + { |
|
| 60 | 67 | $reflection = new \ReflectionClass($arg); |
| 61 | 68 | $display = sprintf('<span title="%s">%s</span>', $reflection->getName(), $reflection->getShortName()); |
| 62 | 69 | } |
| 63 | 70 | |
| 64 | 71 | $type = $this->r->apply($display, 'value', $type); |
| 65 | 72 | |
| 66 | - if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) { |
|
| 73 | + if ($this->verbosity < HandlerInterface::VERBOSITY_DEBUG) |
|
| 74 | + { |
|
| 67 | 75 | $result[] = sprintf('<span>%s</span>', $type); |
| 68 | - } else { |
|
| 76 | + } |
|
| 77 | + else |
|
| 78 | + { |
|
| 69 | 79 | $hash = is_object($arg) ? spl_object_hash($arg) : md5(json_encode($arg, JSON_THROW_ON_ERROR)); |
| 70 | 80 | |
| 71 | - if (!isset($this->values[$hash])) { |
|
| 81 | + if (!isset($this->values[$hash])) |
|
| 82 | + { |
|
| 72 | 83 | $this->values[$hash] = $this->dumper->dump($arg, Dumper::RETURN); |
| 73 | 84 | } |
| 74 | 85 | |
@@ -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 | |
@@ -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( |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace Spiral\Scaffolder; |
| 13 | 13 | |
| 14 | -if (!function_exists('trimPostfix')) { |
|
| 14 | +if (!function_exists('trimPostfix')){ |
|
| 15 | 15 | /** |
| 16 | 16 | * @param string $name |
| 17 | 17 | * @param string $postfix |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if (!function_exists('isAssociativeArray')) { |
|
| 29 | +if (!function_exists('isAssociativeArray')){ |
|
| 30 | 30 | /** |
| 31 | 31 | * @param array $array |
| 32 | 32 | * @return bool |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | function isAssociativeArray(array $array): bool |
| 36 | 36 | { |
| 37 | 37 | $keys = []; |
| 38 | - foreach ($array as $key => $_) { |
|
| 39 | - if (!is_int($key)) { |
|
| 38 | + foreach ($array as $key => $_){ |
|
| 39 | + if (!is_int($key)){ |
|
| 40 | 40 | return true; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ($key !== count($keys)) { |
|
| 43 | + if ($key !== count($keys)){ |
|
| 44 | 44 | return true; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -if (!function_exists('defineArrayType')) { |
|
| 54 | +if (!function_exists('defineArrayType')){ |
|
| 55 | 55 | /** |
| 56 | 56 | * @param array $array |
| 57 | 57 | * @param string|null $failureType |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function defineArrayType(array $array, string $failureType = null): ?string |
| 62 | 62 | { |
| 63 | - $types = array_map(static fn ($value): string => gettype($value), $array); |
|
| 63 | + $types = array_map(static fn ($value) : string => gettype($value), $array); |
|
| 64 | 64 | |
| 65 | 65 | $types = array_unique($types); |
| 66 | 66 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $manager = new CacheManager($config, $container); |
| 56 | 56 | |
| 57 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
| 57 | + foreach ($config->getAliases() as $alias => $storageName){ |
|
| 58 | 58 | $container->bind($alias, static fn (CacheManager $manager) => $manager->storage($storageName)); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ], |
| 75 | 75 | 'file' => [ |
| 76 | 76 | 'type' => 'file', |
| 77 | - 'path' => $dirs->get('runtime') . 'cache', |
|
| 77 | + 'path' => $dirs->get('runtime').'cache', |
|
| 78 | 78 | ], |
| 79 | 79 | ], |
| 80 | 80 | 'typeAliases' => [ |
@@ -54,7 +54,8 @@ |
||
| 54 | 54 | { |
| 55 | 55 | $manager = new CacheManager($config, $container); |
| 56 | 56 | |
| 57 | - foreach ($config->getAliases() as $alias => $storageName) { |
|
| 57 | + foreach ($config->getAliases() as $alias => $storageName) |
|
| 58 | + { |
|
| 58 | 59 | $container->bind($alias, static fn (CacheManager $manager) => $manager->storage($storageName)); |
| 59 | 60 | } |
| 60 | 61 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function addElement(DeclarationInterface $element): FileDeclaration |
| 81 | 81 | { |
| 82 | 82 | $this->elements->add($element); |
| 83 | - if ($element instanceof DependedInterface) { |
|
| 83 | + if ($element instanceof DependedInterface){ |
|
| 84 | 84 | $this->addUses($element->getDependencies()); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -105,28 +105,28 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $result = "<?php\n"; |
| 107 | 107 | |
| 108 | - if (!$this->docComment->isEmpty()) { |
|
| 109 | - $result .= $this->docComment->render($indentLevel) . "\n"; |
|
| 108 | + if (!$this->docComment->isEmpty()){ |
|
| 109 | + $result .= $this->docComment->render($indentLevel)."\n"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ($this->directives !== null && !empty($this->directives->render())) { |
|
| 113 | - $result .= $this->directives->render() . "\n\n"; |
|
| 112 | + if ($this->directives !== null && !empty($this->directives->render())){ |
|
| 113 | + $result .= $this->directives->render()."\n\n"; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if (!empty($this->namespace)) { |
|
| 117 | - if ($this->docComment->isEmpty()) { |
|
| 116 | + if (!empty($this->namespace)){ |
|
| 117 | + if ($this->docComment->isEmpty()){ |
|
| 118 | 118 | $result .= "\n"; |
| 119 | 119 | } |
| 120 | 120 | $result .= "namespace {$this->namespace};\n\n"; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (!empty($this->uses)) { |
|
| 124 | - $result .= $this->renderUses($indentLevel) . "\n\n"; |
|
| 123 | + if (!empty($this->uses)){ |
|
| 124 | + $result .= $this->renderUses($indentLevel)."\n\n"; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $result .= $this->elements->render($indentLevel); |
| 128 | 128 | |
| 129 | - return $result . "\n"; |
|
| 129 | + return $result."\n"; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * Every dumped element is wrapped using this pattern. |
| 25 | 25 | */ |
| 26 | - protected string $element = '%s%s' . Color::RESET; |
|
| 26 | + protected string $element = '%s%s'.Color::RESET; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Set of styles associated with different dumping properties. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function apply($element, string $type, string $context = ''): string |
| 62 | 62 | { |
| 63 | - if (!empty($style = $this->getStyle($type, $context))) { |
|
| 63 | + if (!empty($style = $this->getStyle($type, $context))){ |
|
| 64 | 64 | return sprintf($this->element, $style, $element); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function getStyle(string $type, string $context): string |
| 84 | 84 | { |
| 85 | - if (isset($this->styles[$type][$context])) { |
|
| 85 | + if (isset($this->styles[$type][$context])){ |
|
| 86 | 86 | return $this->styles[$type][$context]; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (isset($this->styles[$type]['common'])) { |
|
| 89 | + if (isset($this->styles[$type]['common'])){ |
|
| 90 | 90 | return $this->styles[$type]['common']; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - if (isset($this->styles[$type]) && is_string($this->styles[$type])) { |
|
| 93 | + if (isset($this->styles[$type]) && is_string($this->styles[$type])){ |
|
| 94 | 94 | return $this->styles[$type]; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | protected function toArray($entries): array |
| 30 | 30 | { |
| 31 | - switch (true) { |
|
| 31 | + switch (true){ |
|
| 32 | 32 | case \is_array($entries): |
| 33 | 33 | return $entries; |
| 34 | 34 | |
@@ -28,7 +28,8 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | protected function toArray($entries): array |
| 30 | 30 | { |
| 31 | - switch (true) { |
|
| 31 | + switch (true) |
|
| 32 | + { |
|
| 32 | 33 | case \is_array($entries): |
| 33 | 34 | return $entries; |
| 34 | 35 | |