@@ -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 | |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $token = $request->getAttribute(CsrfMiddleware::ATTRIBUTE); |
| 58 | 58 | |
| 59 | - if (empty($token)) { |
|
| 59 | + if (empty($token)){ |
|
| 60 | 60 | throw new LogicException('Unable to apply CSRF firewall, attribute is missing'); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ($this->isRequired($request) && !hash_equals($token, $this->fetchToken($request))) { |
|
| 63 | + if ($this->isRequired($request) && !hash_equals($token, $this->fetchToken($request))){ |
|
| 64 | 64 | return $this->responseFactory->createResponse(412, 'Bad CSRF Token'); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function fetchToken(Request $request): string |
| 82 | 82 | { |
| 83 | - if ($request->hasHeader(self::HEADER)) { |
|
| 83 | + if ($request->hasHeader(self::HEADER)){ |
|
| 84 | 84 | return $request->getHeaderLine(self::HEADER); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $data = $request->getParsedBody(); |
| 88 | - if (is_array($data) && isset($data[self::PARAMETER]) && is_string($data[self::PARAMETER])) { |
|
| 88 | + if (is_array($data) && isset($data[self::PARAMETER]) && is_string($data[self::PARAMETER])){ |
|
| 89 | 89 | return $data[self::PARAMETER]; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -56,11 +56,13 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $token = $request->getAttribute(CsrfMiddleware::ATTRIBUTE); |
| 58 | 58 | |
| 59 | - if (empty($token)) { |
|
| 59 | + if (empty($token)) |
|
| 60 | + { |
|
| 60 | 61 | throw new LogicException('Unable to apply CSRF firewall, attribute is missing'); |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | - if ($this->isRequired($request) && !hash_equals($token, $this->fetchToken($request))) { |
|
| 64 | + if ($this->isRequired($request) && !hash_equals($token, $this->fetchToken($request))) |
|
| 65 | + { |
|
| 64 | 66 | return $this->responseFactory->createResponse(412, 'Bad CSRF Token'); |
| 65 | 67 | } |
| 66 | 68 | |
@@ -80,12 +82,14 @@ discard block |
||
| 80 | 82 | */ |
| 81 | 83 | protected function fetchToken(Request $request): string |
| 82 | 84 | { |
| 83 | - if ($request->hasHeader(self::HEADER)) { |
|
| 85 | + if ($request->hasHeader(self::HEADER)) |
|
| 86 | + { |
|
| 84 | 87 | return $request->getHeaderLine(self::HEADER); |
| 85 | 88 | } |
| 86 | 89 | |
| 87 | 90 | $data = $request->getParsedBody(); |
| 88 | - if (is_array($data) && isset($data[self::PARAMETER]) && is_string($data[self::PARAMETER])) { |
|
| 91 | + if (is_array($data) && isset($data[self::PARAMETER]) && is_string($data[self::PARAMETER])) |
|
| 92 | + { |
|
| 89 | 93 | return $data[self::PARAMETER]; |
| 90 | 94 | } |
| 91 | 95 | |
@@ -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 | |
@@ -33,9 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function loadFile(string $section, string $filename): array |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try{ |
|
| 37 | 37 | return ContainerScope::runScope($this->container, fn () => require $filename); |
| 38 | - } catch (Throwable $e) { |
|
| 38 | + }catch (Throwable $e){ |
|
| 39 | 39 | throw new LoaderException($e->getMessage(), $e->getCode(), $e); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -33,9 +33,12 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function loadFile(string $section, string $filename): array |
| 35 | 35 | { |
| 36 | - try { |
|
| 36 | + try |
|
| 37 | + { |
|
| 37 | 38 | return ContainerScope::runScope($this->container, fn () => require $filename); |
| 38 | - } catch (Throwable $e) { |
|
| 39 | + } |
|
| 40 | + catch (Throwable $e) |
|
| 41 | + { |
|
| 39 | 42 | throw new LoaderException($e->getMessage(), $e->getCode(), $e); |
| 40 | 43 | } |
| 41 | 44 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | yield from $this->filter($name, $result); |
| 54 | 54 | |
| 55 | - foreach ($class->getTraits() as $trait) { |
|
| 55 | + foreach ($class->getTraits() as $trait){ |
|
| 56 | 56 | yield from $this->getClassMetadata($trait, $name); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getFunctionMetadata(ReflectionFunctionAbstract $function, string $name = null): iterable |
| 64 | 64 | { |
| 65 | - if ($function instanceof ReflectionMethod) { |
|
| 65 | + if ($function instanceof ReflectionMethod){ |
|
| 66 | 66 | $result = $this->wrapDoctrineExceptions(fn () => $this->reader->getMethodAnnotations($function)); |
| 67 | 67 | |
| 68 | 68 | return $this->filter($name, $result); |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | private function wrapDoctrineExceptions(Closure $then): iterable |
| 106 | 106 | { |
| 107 | - try { |
|
| 107 | + try{ |
|
| 108 | 108 | return $then(); |
| 109 | - } catch (AnnotationException $e) { |
|
| 110 | - switch (true) { |
|
| 109 | + }catch (AnnotationException $e){ |
|
| 110 | + switch (true){ |
|
| 111 | 111 | case \str_starts_with($e->getMessage(), '[Syntax Error]'): |
| 112 | 112 | case \str_starts_with($e->getMessage(), '[Type Error]'): |
| 113 | 113 | $class = SyntaxAttributeException::class; |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | private function bootAnnotations(): void |
| 130 | 130 | { |
| 131 | 131 | // doctrine/annotations ^1.0 compatibility. |
| 132 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 132 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')){ |
|
| 133 | 133 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | private function checkAvailability(): void |
| 138 | 138 | { |
| 139 | - if ($this->isAvailable()) { |
|
| 139 | + if ($this->isAvailable()){ |
|
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | yield from $this->filter($name, $result); |
| 54 | 54 | |
| 55 | - foreach ($class->getTraits() as $trait) { |
|
| 55 | + foreach ($class->getTraits() as $trait) |
|
| 56 | + { |
|
| 56 | 57 | yield from $this->getClassMetadata($trait, $name); |
| 57 | 58 | } |
| 58 | 59 | } |
@@ -62,7 +63,8 @@ discard block |
||
| 62 | 63 | */ |
| 63 | 64 | public function getFunctionMetadata(ReflectionFunctionAbstract $function, string $name = null): iterable |
| 64 | 65 | { |
| 65 | - if ($function instanceof ReflectionMethod) { |
|
| 66 | + if ($function instanceof ReflectionMethod) |
|
| 67 | + { |
|
| 66 | 68 | $result = $this->wrapDoctrineExceptions(fn () => $this->reader->getMethodAnnotations($function)); |
| 67 | 69 | |
| 68 | 70 | return $this->filter($name, $result); |
@@ -104,10 +106,14 @@ discard block |
||
| 104 | 106 | |
| 105 | 107 | private function wrapDoctrineExceptions(Closure $then): iterable |
| 106 | 108 | { |
| 107 | - try { |
|
| 109 | + try |
|
| 110 | + { |
|
| 108 | 111 | return $then(); |
| 109 | - } catch (AnnotationException $e) { |
|
| 110 | - switch (true) { |
|
| 112 | + } |
|
| 113 | + catch (AnnotationException $e) |
|
| 114 | + { |
|
| 115 | + switch (true) |
|
| 116 | + { |
|
| 111 | 117 | case \str_starts_with($e->getMessage(), '[Syntax Error]'): |
| 112 | 118 | case \str_starts_with($e->getMessage(), '[Type Error]'): |
| 113 | 119 | $class = SyntaxAttributeException::class; |
@@ -129,14 +135,16 @@ discard block |
||
| 129 | 135 | private function bootAnnotations(): void |
| 130 | 136 | { |
| 131 | 137 | // doctrine/annotations ^1.0 compatibility. |
| 132 | - if (\method_exists(AnnotationRegistry::class, 'registerLoader')) { |
|
| 138 | + if (\method_exists(AnnotationRegistry::class, 'registerLoader')) |
|
| 139 | + { |
|
| 133 | 140 | AnnotationRegistry::registerLoader('\\class_exists'); |
| 134 | 141 | } |
| 135 | 142 | } |
| 136 | 143 | |
| 137 | 144 | private function checkAvailability(): void |
| 138 | 145 | { |
| 139 | - if ($this->isAvailable()) { |
|
| 146 | + if ($this->isAvailable()) |
|
| 147 | + { |
|
| 140 | 148 | return; |
| 141 | 149 | } |
| 142 | 150 | |
@@ -20,151 +20,151 @@ |
||
| 20 | 20 | interface ReaderInterface |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * Gets a list of attributes and/or annotations applied to a class. |
|
| 24 | - * |
|
| 25 | - * @template T |
|
| 26 | - * |
|
| 27 | - * @param ReflectionClass $class The reflection instance of the class from |
|
| 28 | - * which the class annotations should be read. |
|
| 29 | - * @param class-string<T>|null $name The class name of the annotation |
|
| 30 | - * and/or attribute. |
|
| 31 | - * |
|
| 32 | - * @return iterable<T> A list of class annotations and/or attributes. |
|
| 33 | - */ |
|
| 23 | + * Gets a list of attributes and/or annotations applied to a class. |
|
| 24 | + * |
|
| 25 | + * @template T |
|
| 26 | + * |
|
| 27 | + * @param ReflectionClass $class The reflection instance of the class from |
|
| 28 | + * which the class annotations should be read. |
|
| 29 | + * @param class-string<T>|null $name The class name of the annotation |
|
| 30 | + * and/or attribute. |
|
| 31 | + * |
|
| 32 | + * @return iterable<T> A list of class annotations and/or attributes. |
|
| 33 | + */ |
|
| 34 | 34 | public function getClassMetadata(ReflectionClass $class, string $name = null): iterable; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Gets the attribute or annotation applied to a class. |
|
| 38 | - * |
|
| 39 | - * @template T |
|
| 40 | - * |
|
| 41 | - * @param ReflectionClass $class The reflection instance of the class from |
|
| 42 | - * which the class annotations should be read. |
|
| 43 | - * @param class-string<T> $name The class name of the annotation |
|
| 44 | - * and/or attribute. |
|
| 45 | - * |
|
| 46 | - * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 47 | - * annotation does not exist. |
|
| 48 | - */ |
|
| 37 | + * Gets the attribute or annotation applied to a class. |
|
| 38 | + * |
|
| 39 | + * @template T |
|
| 40 | + * |
|
| 41 | + * @param ReflectionClass $class The reflection instance of the class from |
|
| 42 | + * which the class annotations should be read. |
|
| 43 | + * @param class-string<T> $name The class name of the annotation |
|
| 44 | + * and/or attribute. |
|
| 45 | + * |
|
| 46 | + * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 47 | + * annotation does not exist. |
|
| 48 | + */ |
|
| 49 | 49 | public function firstClassMetadata(ReflectionClass $class, string $name): ?object; |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * Gets a list of attributes and/or annotations applied to a function |
|
| 53 | - * or method. |
|
| 54 | - * |
|
| 55 | - * @template T |
|
| 56 | - * |
|
| 57 | - * @param ReflectionFunctionAbstract $function The reflection instance of |
|
| 58 | - * the function or method from which the function annotations should |
|
| 59 | - * be read. |
|
| 60 | - * @param class-string<T>|null $name The class name of the annotation |
|
| 61 | - * and/or attribute. |
|
| 62 | - * |
|
| 63 | - * @return iterable<T> A list of function annotations and/or attributes. |
|
| 64 | - */ |
|
| 52 | + * Gets a list of attributes and/or annotations applied to a function |
|
| 53 | + * or method. |
|
| 54 | + * |
|
| 55 | + * @template T |
|
| 56 | + * |
|
| 57 | + * @param ReflectionFunctionAbstract $function The reflection instance of |
|
| 58 | + * the function or method from which the function annotations should |
|
| 59 | + * be read. |
|
| 60 | + * @param class-string<T>|null $name The class name of the annotation |
|
| 61 | + * and/or attribute. |
|
| 62 | + * |
|
| 63 | + * @return iterable<T> A list of function annotations and/or attributes. |
|
| 64 | + */ |
|
| 65 | 65 | public function getFunctionMetadata(ReflectionFunctionAbstract $function, string $name = null): iterable; |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Gets the attribute or annotation applied to a function or method. |
|
| 69 | - * |
|
| 70 | - * @template T |
|
| 71 | - * |
|
| 72 | - * @param ReflectionFunctionAbstract $function The reflection instance of |
|
| 73 | - * the function or method from which the function annotations should |
|
| 74 | - * be read. |
|
| 75 | - * @param class-string<T> $name The class name of the annotation and/or |
|
| 76 | - * attribute. |
|
| 77 | - * |
|
| 78 | - * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 79 | - * annotation does not exist. |
|
| 80 | - */ |
|
| 68 | + * Gets the attribute or annotation applied to a function or method. |
|
| 69 | + * |
|
| 70 | + * @template T |
|
| 71 | + * |
|
| 72 | + * @param ReflectionFunctionAbstract $function The reflection instance of |
|
| 73 | + * the function or method from which the function annotations should |
|
| 74 | + * be read. |
|
| 75 | + * @param class-string<T> $name The class name of the annotation and/or |
|
| 76 | + * attribute. |
|
| 77 | + * |
|
| 78 | + * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 79 | + * annotation does not exist. |
|
| 80 | + */ |
|
| 81 | 81 | public function firstFunctionMetadata(ReflectionFunctionAbstract $function, string $name): ?object; |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | - * Gets a list of attributes and/or annotations applied to a class property. |
|
| 85 | - * |
|
| 86 | - * @template T |
|
| 87 | - * |
|
| 88 | - * @param ReflectionProperty $property The reflection instance of the |
|
| 89 | - * property from which the property annotations should be read. |
|
| 90 | - * @param class-string<T>|null $name The class name of the annotation |
|
| 91 | - * and/or attribute. |
|
| 92 | - * |
|
| 93 | - * @return iterable<T> A list of property annotations and/or attributes. |
|
| 94 | - */ |
|
| 84 | + * Gets a list of attributes and/or annotations applied to a class property. |
|
| 85 | + * |
|
| 86 | + * @template T |
|
| 87 | + * |
|
| 88 | + * @param ReflectionProperty $property The reflection instance of the |
|
| 89 | + * property from which the property annotations should be read. |
|
| 90 | + * @param class-string<T>|null $name The class name of the annotation |
|
| 91 | + * and/or attribute. |
|
| 92 | + * |
|
| 93 | + * @return iterable<T> A list of property annotations and/or attributes. |
|
| 94 | + */ |
|
| 95 | 95 | public function getPropertyMetadata(ReflectionProperty $property, string $name = null): iterable; |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * Gets the attribute or annotation applied to a property. |
|
| 99 | - * |
|
| 100 | - * @template T |
|
| 101 | - * |
|
| 102 | - * @param ReflectionProperty $property The reflection instance of the |
|
| 103 | - * property from which the property annotations should be read. |
|
| 104 | - * @param class-string<T> $name The class name of the annotation and/or |
|
| 105 | - * attribute. |
|
| 106 | - * |
|
| 107 | - * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 108 | - * annotation does not exist. |
|
| 109 | - */ |
|
| 98 | + * Gets the attribute or annotation applied to a property. |
|
| 99 | + * |
|
| 100 | + * @template T |
|
| 101 | + * |
|
| 102 | + * @param ReflectionProperty $property The reflection instance of the |
|
| 103 | + * property from which the property annotations should be read. |
|
| 104 | + * @param class-string<T> $name The class name of the annotation and/or |
|
| 105 | + * attribute. |
|
| 106 | + * |
|
| 107 | + * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 108 | + * annotation does not exist. |
|
| 109 | + */ |
|
| 110 | 110 | public function firstPropertyMetadata(ReflectionProperty $property, string $name): ?object; |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * Gets a list of attributes and/or annotations applied to a class constant. |
|
| 114 | - * |
|
| 115 | - * @template T |
|
| 116 | - * |
|
| 117 | - * @param ReflectionClassConstant $constant The reflection instance of the |
|
| 118 | - * class constant from which the constant annotations should be read. |
|
| 119 | - * @param class-string<T>|null $name The class name of the annotation |
|
| 120 | - * and/or attribute. |
|
| 121 | - * |
|
| 122 | - * @return iterable<T> A list of constant annotations and/or attributes. |
|
| 123 | - */ |
|
| 113 | + * Gets a list of attributes and/or annotations applied to a class constant. |
|
| 114 | + * |
|
| 115 | + * @template T |
|
| 116 | + * |
|
| 117 | + * @param ReflectionClassConstant $constant The reflection instance of the |
|
| 118 | + * class constant from which the constant annotations should be read. |
|
| 119 | + * @param class-string<T>|null $name The class name of the annotation |
|
| 120 | + * and/or attribute. |
|
| 121 | + * |
|
| 122 | + * @return iterable<T> A list of constant annotations and/or attributes. |
|
| 123 | + */ |
|
| 124 | 124 | public function getConstantMetadata(ReflectionClassConstant $constant, string $name = null): iterable; |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * Gets the attribute or annotation applied to a class constant. |
|
| 128 | - * |
|
| 129 | - * @template T |
|
| 130 | - * |
|
| 131 | - * @param ReflectionClassConstant $constant The reflection instance of the |
|
| 132 | - * class constant from which the constant annotations should be read. |
|
| 133 | - * @param class-string<T> $name The class name of the annotation and/or |
|
| 134 | - * attribute. |
|
| 135 | - * |
|
| 136 | - * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 137 | - * annotation does not exist. |
|
| 138 | - */ |
|
| 127 | + * Gets the attribute or annotation applied to a class constant. |
|
| 128 | + * |
|
| 129 | + * @template T |
|
| 130 | + * |
|
| 131 | + * @param ReflectionClassConstant $constant The reflection instance of the |
|
| 132 | + * class constant from which the constant annotations should be read. |
|
| 133 | + * @param class-string<T> $name The class name of the annotation and/or |
|
| 134 | + * attribute. |
|
| 135 | + * |
|
| 136 | + * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 137 | + * annotation does not exist. |
|
| 138 | + */ |
|
| 139 | 139 | public function firstConstantMetadata(ReflectionClassConstant $constant, string $name): ?object; |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | - * Gets a list of attributes and/or annotations applied to a parameter of |
|
| 143 | - * a function or method. |
|
| 144 | - * |
|
| 145 | - * @template T |
|
| 146 | - * |
|
| 147 | - * @param ReflectionParameter $parameter The reflection instance of the |
|
| 148 | - * parameter from which the parameter annotations should be read. |
|
| 149 | - * @param class-string<T>|null $name The class name of the annotation |
|
| 150 | - * and/or attribute. |
|
| 151 | - * |
|
| 152 | - * @return iterable<T> A list of parameter annotations and/or attributes. |
|
| 153 | - */ |
|
| 142 | + * Gets a list of attributes and/or annotations applied to a parameter of |
|
| 143 | + * a function or method. |
|
| 144 | + * |
|
| 145 | + * @template T |
|
| 146 | + * |
|
| 147 | + * @param ReflectionParameter $parameter The reflection instance of the |
|
| 148 | + * parameter from which the parameter annotations should be read. |
|
| 149 | + * @param class-string<T>|null $name The class name of the annotation |
|
| 150 | + * and/or attribute. |
|
| 151 | + * |
|
| 152 | + * @return iterable<T> A list of parameter annotations and/or attributes. |
|
| 153 | + */ |
|
| 154 | 154 | public function getParameterMetadata(ReflectionParameter $parameter, string $name = null): iterable; |
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | - * Gets the attribute or annotation applied to a function's parameter. |
|
| 158 | - * |
|
| 159 | - * @template T |
|
| 160 | - * |
|
| 161 | - * @param ReflectionParameter $parameter The reflection instance of the |
|
| 162 | - * parameter from which the parameter annotations should be read. |
|
| 163 | - * @param class-string<T> $name The class name of the annotation and/or |
|
| 164 | - * attribute. |
|
| 165 | - * |
|
| 166 | - * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 167 | - * annotation does not exist. |
|
| 168 | - */ |
|
| 157 | + * Gets the attribute or annotation applied to a function's parameter. |
|
| 158 | + * |
|
| 159 | + * @template T |
|
| 160 | + * |
|
| 161 | + * @param ReflectionParameter $parameter The reflection instance of the |
|
| 162 | + * parameter from which the parameter annotations should be read. |
|
| 163 | + * @param class-string<T> $name The class name of the annotation and/or |
|
| 164 | + * attribute. |
|
| 165 | + * |
|
| 166 | + * @return T|null The annotation/attribute or {@see null}, if the requested |
|
| 167 | + * annotation does not exist. |
|
| 168 | + */ |
|
| 169 | 169 | public function firstParameterMetadata(ReflectionParameter $parameter, string $name): ?object; |
| 170 | 170 | } |
@@ -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 | /** |