@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function handle(string $name, string $id, $payload): void |
| 47 | 47 | { |
| 48 | - if (\is_string($payload)) { |
|
| 48 | + if (\is_string($payload)){ |
|
| 49 | 49 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if (!\is_array($payload)) { |
|
| 52 | + if (!\is_array($payload)){ |
|
| 53 | 53 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $email = $this->renderer->render($message); |
| 59 | 59 | |
| 60 | - if ($email->getFrom() === []) { |
|
| 60 | + if ($email->getFrom() === []){ |
|
| 61 | 61 | $email->from(Address::create($this->config->getFromAddress())); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $recipients = $this->getRecipients($email); |
| 65 | 65 | |
| 66 | - try { |
|
| 66 | + try{ |
|
| 67 | 67 | $this->mailer->send($email); |
| 68 | - } catch (TransportExceptionInterface $e) { |
|
| 68 | + }catch (TransportExceptionInterface $e){ |
|
| 69 | 69 | $this->getLogger()->error( |
| 70 | 70 | sprintf( |
| 71 | 71 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 97 | 97 | |
| 98 | - foreach ($addresses as $address) { |
|
| 98 | + foreach ($addresses as $address){ |
|
| 99 | 99 | $emails[] = $address->toString(); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -45,11 +45,13 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function handle(string $name, string $id, $payload): void |
| 47 | 47 | { |
| 48 | - if (\is_string($payload)) { |
|
| 48 | + if (\is_string($payload)) |
|
| 49 | + { |
|
| 49 | 50 | $payload = json_decode($payload, true, 512, JSON_THROW_ON_ERROR); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | - if (!\is_array($payload)) { |
|
| 53 | + if (!\is_array($payload)) |
|
| 54 | + { |
|
| 53 | 55 | throw new InvalidArgumentException('Mail job payload should be an array.'); |
| 54 | 56 | } |
| 55 | 57 | |
@@ -57,15 +59,19 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | $email = $this->renderer->render($message); |
| 59 | 61 | |
| 60 | - if ($email->getFrom() === []) { |
|
| 62 | + if ($email->getFrom() === []) |
|
| 63 | + { |
|
| 61 | 64 | $email->from(Address::create($this->config->getFromAddress())); |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | $recipients = $this->getRecipients($email); |
| 65 | 68 | |
| 66 | - try { |
|
| 69 | + try |
|
| 70 | + { |
|
| 67 | 71 | $this->mailer->send($email); |
| 68 | - } catch (TransportExceptionInterface $e) { |
|
| 72 | + } |
|
| 73 | + catch (TransportExceptionInterface $e) |
|
| 74 | + { |
|
| 69 | 75 | $this->getLogger()->error( |
| 70 | 76 | sprintf( |
| 71 | 77 | 'Failed to send `%s` to "%s": %s', |
@@ -95,7 +101,8 @@ discard block |
||
| 95 | 101 | |
| 96 | 102 | $addresses = array_merge($message->getTo(), $message->getCc(), $message->getBcc()); |
| 97 | 103 | |
| 98 | - foreach ($addresses as $address) { |
|
| 104 | + foreach ($addresses as $address) |
|
| 105 | + { |
|
| 99 | 106 | $emails[] = $address->toString(); |
| 100 | 107 | } |
| 101 | 108 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | public function findDeclarations(): array |
| 46 | 46 | { |
| 47 | 47 | $result = []; |
| 48 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
| 49 | - foreach ($class->getMethods() as $method) { |
|
| 48 | + foreach ($this->locator->getScopedClasses('routes') as $class){ |
|
| 49 | + foreach ($class->getMethods() as $method){ |
|
| 50 | 50 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
| 51 | 51 | |
| 52 | - if ($route === null) { |
|
| 52 | + if ($route === null){ |
|
| 53 | 53 | continue; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | 'controller' => $class->getName(), |
| 60 | 60 | 'action' => $method->getName(), |
| 61 | 61 | 'group' => $route->group, |
| 62 | - 'verbs' => (array) $route->methods, |
|
| 62 | + 'verbs' => (array)$route->methods, |
|
| 63 | 63 | 'defaults' => $route->defaults, |
| 64 | - 'middleware' => (array) $route->middleware, |
|
| 64 | + 'middleware' => (array)$route->middleware, |
|
| 65 | 65 | 'priority' => $route->priority, |
| 66 | 66 | ]; |
| 67 | 67 | } |
@@ -45,11 +45,14 @@ |
||
| 45 | 45 | public function findDeclarations(): array |
| 46 | 46 | { |
| 47 | 47 | $result = []; |
| 48 | - foreach ($this->locator->getScopedClasses('routes') as $class) { |
|
| 49 | - foreach ($class->getMethods() as $method) { |
|
| 48 | + foreach ($this->locator->getScopedClasses('routes') as $class) |
|
| 49 | + { |
|
| 50 | + foreach ($class->getMethods() as $method) |
|
| 51 | + { |
|
| 50 | 52 | $route = $this->reader->firstFunctionMetadata($method, Route::class); |
| 51 | 53 | |
| 52 | - if ($route === null) { |
|
| 54 | + if ($route === null) |
|
| 55 | + { |
|
| 53 | 56 | continue; |
| 54 | 57 | } |
| 55 | 58 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | $registry = $container->get(HandlerRegistryInterface::class); |
| 58 | 58 | $config = $container->get(QueueConfig::class); |
| 59 | 59 | |
| 60 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 60 | + foreach ($config->getRegistryHandlers() as $jobType => $handler){ |
|
| 61 | 61 | $registry->setHandler($jobType, $handler); |
| 62 | 62 | } |
| 63 | 63 | }); |
@@ -57,7 +57,8 @@ |
||
| 57 | 57 | $registry = $container->get(HandlerRegistryInterface::class); |
| 58 | 58 | $config = $container->get(QueueConfig::class); |
| 59 | 59 | |
| 60 | - foreach ($config->getRegistryHandlers() as $jobType => $handler) { |
|
| 60 | + foreach ($config->getRegistryHandlers() as $jobType => $handler) |
|
| 61 | + { |
|
| 61 | 62 | $registry->setHandler($jobType, $handler); |
| 62 | 63 | } |
| 63 | 64 | }); |
@@ -23,13 +23,13 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function getHandler(string $jobType): HandlerInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 26 | + try{ |
|
| 27 | 27 | $handler = $this->container->get($this->className($jobType)); |
| 28 | - } catch (ContainerException $e) { |
|
| 28 | + }catch (ContainerException $e){ |
|
| 29 | 29 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if (!$handler instanceof HandlerInterface) { |
|
| 32 | + if (!$handler instanceof HandlerInterface){ |
|
| 33 | 33 | throw new JobException("Unable to resolve job handler for `{$jobType}`"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -23,13 +23,17 @@ |
||
| 23 | 23 | |
| 24 | 24 | public function getHandler(string $jobType): HandlerInterface |
| 25 | 25 | { |
| 26 | - try { |
|
| 26 | + try |
|
| 27 | + { |
|
| 27 | 28 | $handler = $this->container->get($this->className($jobType)); |
| 28 | - } catch (ContainerException $e) { |
|
| 29 | + } |
|
| 30 | + catch (ContainerException $e) |
|
| 31 | + { |
|
| 29 | 32 | throw new JobException($e->getMessage(), $e->getCode(), $e); |
| 30 | 33 | } |
| 31 | 34 | |
| 32 | - if (!$handler instanceof HandlerInterface) { |
|
| 35 | + if (!$handler instanceof HandlerInterface) |
|
| 36 | + { |
|
| 33 | 37 | throw new JobException("Unable to resolve job handler for `{$jobType}`"); |
| 34 | 38 | } |
| 35 | 39 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | // Replaces alias with real pipeline name |
| 29 | 29 | $name = $this->config->getAliases()[$name] ?? $name; |
| 30 | 30 | |
| 31 | - if (!isset($this->pipelines[$name])) { |
|
| 31 | + if (!isset($this->pipelines[$name])){ |
|
| 32 | 32 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $config = $this->config->getConnection($name); |
| 45 | 45 | |
| 46 | - try { |
|
| 46 | + try{ |
|
| 47 | 47 | return $this->factory->make($config['driver'], $config); |
| 48 | - } catch (ContainerException $e) { |
|
| 48 | + }catch (ContainerException $e){ |
|
| 49 | 49 | throw new NotSupportedDriverException( |
| 50 | 50 | \sprintf( |
| 51 | 51 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | // Replaces alias with real pipeline name |
| 29 | 29 | $name = $this->config->getAliases()[$name] ?? $name; |
| 30 | 30 | |
| 31 | - if (!isset($this->pipelines[$name])) { |
|
| 31 | + if (!isset($this->pipelines[$name])) |
|
| 32 | + { |
|
| 32 | 33 | $this->pipelines[$name] = $this->resolveConnection($name); |
| 33 | 34 | } |
| 34 | 35 | |
@@ -43,9 +44,12 @@ discard block |
||
| 43 | 44 | { |
| 44 | 45 | $config = $this->config->getConnection($name); |
| 45 | 46 | |
| 46 | - try { |
|
| 47 | + try |
|
| 48 | + { |
|
| 47 | 49 | return $this->factory->make($config['driver'], $config); |
| 48 | - } catch (ContainerException $e) { |
|
| 50 | + } |
|
| 51 | + catch (ContainerException $e) |
|
| 52 | + { |
|
| 49 | 53 | throw new NotSupportedDriverException( |
| 50 | 54 | \sprintf( |
| 51 | 55 | 'Driver `%s` is not supported. Connection `%s` cannot be created. Reason: `%s`', |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Argument types. |
| 23 | 23 | */ |
| 24 | - public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
| 25 | - public const VARIABLE = 'variable'; //PHP variable |
|
| 24 | + public const CONSTANT = 'constant'; //Scalar constant and not variable. |
|
| 25 | + public const VARIABLE = 'variable'; //PHP variable |
|
| 26 | 26 | public const EXPRESSION = 'expression'; //PHP code (expression). |
| 27 | 27 | public const STRING = 'string'; |
| 28 | 28 | private string $type; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function stringValue(): string |
| 61 | 61 | { |
| 62 | - if ($this->type != self::STRING) { |
|
| 62 | + if ($this->type != self::STRING){ |
|
| 63 | 63 | throw new ReflectionException( |
| 64 | 64 | "Unable to represent value as string, value type is '{$this->type}'" |
| 65 | 65 | ); |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | $level = 0; |
| 81 | 81 | |
| 82 | 82 | $result = []; |
| 83 | - foreach ($tokens as $token) { |
|
| 84 | - if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE) { |
|
| 83 | + foreach ($tokens as $token){ |
|
| 84 | + if ($token[ReflectionFile::TOKEN_TYPE] == T_WHITESPACE){ |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if (empty($definition)) { |
|
| 88 | + if (empty($definition)){ |
|
| 89 | 89 | $definition = ['type' => self::EXPRESSION, 'value' => '', 'tokens' => []]; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | if ( |
| 93 | 93 | $token[ReflectionFile::TOKEN_TYPE] == '(' |
| 94 | 94 | || $token[ReflectionFile::TOKEN_TYPE] == '[' |
| 95 | - ) { |
|
| 95 | + ){ |
|
| 96 | 96 | ++$level; |
| 97 | 97 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 98 | 98 | continue; |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | if ( |
| 102 | 102 | $token[ReflectionFile::TOKEN_TYPE] == ')' |
| 103 | 103 | || $token[ReflectionFile::TOKEN_TYPE] == ']' |
| 104 | - ) { |
|
| 104 | + ){ |
|
| 105 | 105 | --$level; |
| 106 | 106 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 107 | 107 | continue; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($level) { |
|
| 110 | + if ($level){ |
|
| 111 | 111 | $definition['value'] .= $token[ReflectionFile::TOKEN_CODE]; |
| 112 | 112 | continue; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if ($token[ReflectionFile::TOKEN_TYPE] == ',') { |
|
| 115 | + if ($token[ReflectionFile::TOKEN_TYPE] == ','){ |
|
| 116 | 116 | $result[] = self::createArgument($definition); |
| 117 | 117 | $definition = null; |
| 118 | 118 | continue; |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | //Last argument |
| 126 | - if (is_array($definition)) { |
|
| 126 | + if (is_array($definition)){ |
|
| 127 | 127 | $definition = self::createArgument($definition); |
| 128 | - if (!empty($definition->getType())) { |
|
| 128 | + if (!empty($definition->getType())){ |
|
| 129 | 129 | $result[] = $definition; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $result = new static(self::EXPRESSION, $definition['value']); |
| 144 | 144 | |
| 145 | - if (count($definition['tokens']) == 1) { |
|
| 145 | + if (count($definition['tokens']) == 1){ |
|
| 146 | 146 | //If argument represent by one token we can try to resolve it's type more precisely |
| 147 | - switch ($definition['tokens'][0][0]) { |
|
| 147 | + switch ($definition['tokens'][0][0]){ |
|
| 148 | 148 | case T_VARIABLE: |
| 149 | 149 | $result->type = self::VARIABLE; |
| 150 | 150 | break; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public function getGuard(): GuardInterface |
| 28 | 28 | { |
| 29 | 29 | $container = ContainerScope::getContainer(); |
| 30 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
| 30 | + if (empty($container) || !$container->has(GuardInterface::class)){ |
|
| 31 | 31 | throw new ScopeException( |
| 32 | 32 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
| 33 | 33 | ); |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | protected function resolvePermission(string $permission): string |
| 53 | 53 | { |
| 54 | - if (defined('static::GUARD_NAMESPACE')) { |
|
| 54 | + if (defined('static::GUARD_NAMESPACE')){ |
|
| 55 | 55 | // Yay! Isolation |
| 56 | - $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
|
| 56 | + $permission = constant(static::class.'::'.'GUARD_NAMESPACE').'.'.$permission; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $permission; |
@@ -27,7 +27,8 @@ discard block |
||
| 27 | 27 | public function getGuard(): GuardInterface |
| 28 | 28 | { |
| 29 | 29 | $container = ContainerScope::getContainer(); |
| 30 | - if (empty($container) || !$container->has(GuardInterface::class)) { |
|
| 30 | + if (empty($container) || !$container->has(GuardInterface::class)) |
|
| 31 | + { |
|
| 31 | 32 | throw new ScopeException( |
| 32 | 33 | 'Unable to get `GuardInterface`, binding is missing or container scope is not set' |
| 33 | 34 | ); |
@@ -51,7 +52,8 @@ discard block |
||
| 51 | 52 | */ |
| 52 | 53 | protected function resolvePermission(string $permission): string |
| 53 | 54 | { |
| 54 | - if (defined('static::GUARD_NAMESPACE')) { |
|
| 55 | + if (defined('static::GUARD_NAMESPACE')) |
|
| 56 | + { |
|
| 55 | 57 | // Yay! Isolation |
| 56 | 58 | $permission = constant(static::class . '::' . 'GUARD_NAMESPACE') . '.' . $permission; |
| 57 | 59 | } |
@@ -140,23 +140,23 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $this->updateContext($node); |
| 142 | 142 | |
| 143 | - if ($node instanceof ClassLike) { |
|
| 144 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 143 | + if ($node instanceof ClassLike){ |
|
| 144 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 145 | 145 | $this->classes[$node->namespacedName->toString()][] = $prototype; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | return null; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ($node instanceof FunctionLike) { |
|
| 151 | + if ($node instanceof FunctionLike){ |
|
| 152 | 152 | $line = $node->getEndLine(); |
| 153 | 153 | |
| 154 | - foreach ($this->parse($node->getAttrGroups()) as $prototype) { |
|
| 154 | + foreach ($this->parse($node->getAttrGroups()) as $prototype){ |
|
| 155 | 155 | $this->functions[$line][] = $prototype; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - foreach ($node->getParams() as $param) { |
|
| 159 | - foreach ($this->parse($param->attrGroups) as $prototype) { |
|
| 158 | + foreach ($node->getParams() as $param){ |
|
| 159 | + foreach ($this->parse($param->attrGroups) as $prototype){ |
|
| 160 | 160 | assert(\is_string($param->var->name), 'Function parameter name should be an identifier'); |
| 161 | 161 | |
| 162 | 162 | $this->parameters[$line][$param->var->name][] = $prototype; |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ($node instanceof ClassConst) { |
|
| 169 | + if ($node instanceof ClassConst){ |
|
| 170 | 170 | $class = $this->fqn(); |
| 171 | 171 | |
| 172 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 173 | - foreach ($node->consts as $const) { |
|
| 172 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 173 | + foreach ($node->consts as $const){ |
|
| 174 | 174 | $this->constants[$class][$this->name($const->name)][] = $prototype; |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ($node instanceof Property) { |
|
| 181 | + if ($node instanceof Property){ |
|
| 182 | 182 | $class = $this->fqn(); |
| 183 | 183 | |
| 184 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 185 | - foreach ($node->props as $property) { |
|
| 184 | + foreach ($this->parse($node->attrGroups) as $prototype){ |
|
| 185 | + foreach ($node->props as $property){ |
|
| 186 | 186 | $this->properties[$class][$this->name($property->name)][] = $prototype; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -195,27 +195,27 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public function leaveNode(Node $node): void |
| 197 | 197 | { |
| 198 | - if ($node instanceof Namespace_) { |
|
| 198 | + if ($node instanceof Namespace_){ |
|
| 199 | 199 | $this->context[AttributeParser::CTX_NAMESPACE] = ''; |
| 200 | 200 | |
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ($node instanceof ClassLike) { |
|
| 204 | + if ($node instanceof ClassLike){ |
|
| 205 | 205 | $this->context[AttributeParser::CTX_CLASS] = ''; |
| 206 | 206 | $this->context[AttributeParser::CTX_TRAIT] = ''; |
| 207 | 207 | |
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if ($node instanceof FunctionLike) { |
|
| 211 | + if ($node instanceof FunctionLike){ |
|
| 212 | 212 | $this->context[AttributeParser::CTX_FUNCTION] = ''; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | private function updateContext(Node $node): void |
| 217 | 217 | { |
| 218 | - switch (true) { |
|
| 218 | + switch (true){ |
|
| 219 | 219 | case $node instanceof Namespace_: |
| 220 | 220 | $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name); |
| 221 | 221 | break; |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | private function name($name): string |
| 242 | 242 | { |
| 243 | - if ($name === null) { |
|
| 243 | + if ($name === null){ |
|
| 244 | 244 | return ''; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -262,6 +262,6 @@ discard block |
||
| 262 | 262 | $namespace = $this->context[AttributeParser::CTX_NAMESPACE] ?? ''; |
| 263 | 263 | $class = $this->context[AttributeParser::CTX_CLASS] ?? ''; |
| 264 | 264 | |
| 265 | - return \trim($namespace . '\\' . $class, '\\'); |
|
| 265 | + return \trim($namespace.'\\'.$class, '\\'); |
|
| 266 | 266 | } |
| 267 | 267 | } |
@@ -140,23 +140,29 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $this->updateContext($node); |
| 142 | 142 | |
| 143 | - if ($node instanceof ClassLike) { |
|
| 144 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 143 | + if ($node instanceof ClassLike) |
|
| 144 | + { |
|
| 145 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 146 | + { |
|
| 145 | 147 | $this->classes[$node->namespacedName->toString()][] = $prototype; |
| 146 | 148 | } |
| 147 | 149 | |
| 148 | 150 | return null; |
| 149 | 151 | } |
| 150 | 152 | |
| 151 | - if ($node instanceof FunctionLike) { |
|
| 153 | + if ($node instanceof FunctionLike) |
|
| 154 | + { |
|
| 152 | 155 | $line = $node->getEndLine(); |
| 153 | 156 | |
| 154 | - foreach ($this->parse($node->getAttrGroups()) as $prototype) { |
|
| 157 | + foreach ($this->parse($node->getAttrGroups()) as $prototype) |
|
| 158 | + { |
|
| 155 | 159 | $this->functions[$line][] = $prototype; |
| 156 | 160 | } |
| 157 | 161 | |
| 158 | - foreach ($node->getParams() as $param) { |
|
| 159 | - foreach ($this->parse($param->attrGroups) as $prototype) { |
|
| 162 | + foreach ($node->getParams() as $param) |
|
| 163 | + { |
|
| 164 | + foreach ($this->parse($param->attrGroups) as $prototype) |
|
| 165 | + { |
|
| 160 | 166 | assert(\is_string($param->var->name), 'Function parameter name should be an identifier'); |
| 161 | 167 | |
| 162 | 168 | $this->parameters[$line][$param->var->name][] = $prototype; |
@@ -166,11 +172,14 @@ discard block |
||
| 166 | 172 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 167 | 173 | } |
| 168 | 174 | |
| 169 | - if ($node instanceof ClassConst) { |
|
| 175 | + if ($node instanceof ClassConst) |
|
| 176 | + { |
|
| 170 | 177 | $class = $this->fqn(); |
| 171 | 178 | |
| 172 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 173 | - foreach ($node->consts as $const) { |
|
| 179 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 180 | + { |
|
| 181 | + foreach ($node->consts as $const) |
|
| 182 | + { |
|
| 174 | 183 | $this->constants[$class][$this->name($const->name)][] = $prototype; |
| 175 | 184 | } |
| 176 | 185 | } |
@@ -178,11 +187,14 @@ discard block |
||
| 178 | 187 | return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; |
| 179 | 188 | } |
| 180 | 189 | |
| 181 | - if ($node instanceof Property) { |
|
| 190 | + if ($node instanceof Property) |
|
| 191 | + { |
|
| 182 | 192 | $class = $this->fqn(); |
| 183 | 193 | |
| 184 | - foreach ($this->parse($node->attrGroups) as $prototype) { |
|
| 185 | - foreach ($node->props as $property) { |
|
| 194 | + foreach ($this->parse($node->attrGroups) as $prototype) |
|
| 195 | + { |
|
| 196 | + foreach ($node->props as $property) |
|
| 197 | + { |
|
| 186 | 198 | $this->properties[$class][$this->name($property->name)][] = $prototype; |
| 187 | 199 | } |
| 188 | 200 | } |
@@ -195,27 +207,31 @@ discard block |
||
| 195 | 207 | |
| 196 | 208 | public function leaveNode(Node $node): void |
| 197 | 209 | { |
| 198 | - if ($node instanceof Namespace_) { |
|
| 210 | + if ($node instanceof Namespace_) |
|
| 211 | + { |
|
| 199 | 212 | $this->context[AttributeParser::CTX_NAMESPACE] = ''; |
| 200 | 213 | |
| 201 | 214 | return; |
| 202 | 215 | } |
| 203 | 216 | |
| 204 | - if ($node instanceof ClassLike) { |
|
| 217 | + if ($node instanceof ClassLike) |
|
| 218 | + { |
|
| 205 | 219 | $this->context[AttributeParser::CTX_CLASS] = ''; |
| 206 | 220 | $this->context[AttributeParser::CTX_TRAIT] = ''; |
| 207 | 221 | |
| 208 | 222 | return; |
| 209 | 223 | } |
| 210 | 224 | |
| 211 | - if ($node instanceof FunctionLike) { |
|
| 225 | + if ($node instanceof FunctionLike) |
|
| 226 | + { |
|
| 212 | 227 | $this->context[AttributeParser::CTX_FUNCTION] = ''; |
| 213 | 228 | } |
| 214 | 229 | } |
| 215 | 230 | |
| 216 | 231 | private function updateContext(Node $node): void |
| 217 | 232 | { |
| 218 | - switch (true) { |
|
| 233 | + switch (true) |
|
| 234 | + { |
|
| 219 | 235 | case $node instanceof Namespace_: |
| 220 | 236 | $this->context[AttributeParser::CTX_NAMESPACE] = $this->name($node->name); |
| 221 | 237 | break; |
@@ -240,7 +256,8 @@ discard block |
||
| 240 | 256 | */ |
| 241 | 257 | private function name($name): string |
| 242 | 258 | { |
| 243 | - if ($name === null) { |
|
| 259 | + if ($name === null) |
|
| 260 | + { |
|
| 244 | 261 | return ''; |
| 245 | 262 | } |
| 246 | 263 | |
@@ -12,7 +12,7 @@ discard block |
||
| 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 |
||
| 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); |
@@ -12,7 +12,8 @@ discard block |
||
| 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 |
||
| 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); |