@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 41 | 41 | $response = $response->withAddedHeader($header, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -37,7 +37,8 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 41 | + { |
|
| 41 | 42 | $response = $response->withAddedHeader($header, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null){ |
|
| 30 | 30 | $size = $stream->getSize(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null) |
|
| 30 | + { |
|
| 30 | 31 | $size = $stream->getSize(); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $http->setHandler( |
| 46 | 46 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 47 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 47 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
| 48 | 48 | echo 'no token'; |
| 49 | - } else { |
|
| 49 | + }else{ |
|
| 50 | 50 | echo $request->getAttribute('authContext')->getToken()->getID(); |
| 51 | 51 | echo ':'; |
| 52 | 52 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $http->setHandler( |
| 78 | 78 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 79 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 79 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
| 80 | 80 | echo 'no token'; |
| 81 | - } else { |
|
| 81 | + }else{ |
|
| 82 | 82 | echo $request->getAttribute('authContext')->getToken()->getID(); |
| 83 | 83 | echo ':'; |
| 84 | 84 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | 193 | self::assertSame( |
| 194 | - 'Expires=' . gmdate(DATE_COOKIE, time() + 3600), |
|
| 194 | + 'Expires='.gmdate(DATE_COOKIE, time() + 3600), |
|
| 195 | 195 | $cookie[1] |
| 196 | 196 | ); |
| 197 | 197 | |
@@ -43,9 +43,12 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $http->setHandler( |
| 45 | 45 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 46 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 46 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
| 47 | + { |
|
| 47 | 48 | echo 'no token'; |
| 48 | - } else { |
|
| 49 | + } |
|
| 50 | + else |
|
| 51 | + { |
|
| 49 | 52 | echo $request->getAttribute('authContext')->getToken()->getID(); |
| 50 | 53 | echo ':'; |
| 51 | 54 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -67,9 +70,12 @@ discard block |
||
| 67 | 70 | |
| 68 | 71 | $http->setHandler( |
| 69 | 72 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
| 70 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
| 73 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
| 74 | + { |
|
| 71 | 75 | echo 'no token'; |
| 72 | - } else { |
|
| 76 | + } |
|
| 77 | + else |
|
| 78 | + { |
|
| 73 | 79 | echo $request->getAttribute('authContext')->getToken()->getID(); |
| 74 | 80 | echo ':'; |
| 75 | 81 | echo json_encode($request->getAttribute('authContext')->getToken()->getPayload()); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getActor(TokenInterface $token): ?object |
| 20 | 20 | { |
| 21 | - if ($token->getPayload()['ok']) { |
|
| 21 | + if ($token->getPayload()['ok']){ |
|
| 22 | 22 | return new \stdClass(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -18,7 +18,8 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getActor(TokenInterface $token): ?object |
| 20 | 20 | { |
| 21 | - if ($token->getPayload()['ok']) { |
|
| 21 | + if ($token->getPayload()['ok']) |
|
| 22 | + { |
|
| 22 | 23 | return new \stdClass(); |
| 23 | 24 | } |
| 24 | 25 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getActor(TokenInterface $token): ?object |
| 20 | 20 | { |
| 21 | - if ($token->getID() === 'ok') { |
|
| 21 | + if ($token->getID() === 'ok'){ |
|
| 22 | 22 | return new \stdClass(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -18,7 +18,8 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getActor(TokenInterface $token): ?object |
| 20 | 20 | { |
| 21 | - if ($token->getID() === 'ok') { |
|
| 21 | + if ($token->getID() === 'ok') |
|
| 22 | + { |
|
| 22 | 23 | return new \stdClass(); |
| 23 | 24 | } |
| 24 | 25 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function load(string $id): ?TokenInterface |
| 20 | 20 | { |
| 21 | - if ($id === 'bad') { |
|
| 21 | + if ($id === 'bad'){ |
|
| 22 | 22 | return null; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -18,7 +18,8 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function load(string $id): ?TokenInterface |
| 20 | 20 | { |
| 21 | - if ($id === 'bad') { |
|
| 21 | + if ($id === 'bad') |
|
| 22 | + { |
|
| 22 | 23 | return null; |
| 23 | 24 | } |
| 24 | 25 | |
@@ -23,20 +23,20 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function getClasses($target = null): array |
| 25 | 25 | { |
| 26 | - if (!empty($target) && (is_object($target) || is_string($target))) { |
|
| 26 | + if (!empty($target) && (is_object($target) || is_string($target))){ |
|
| 27 | 27 | $target = new \ReflectionClass($target); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $result = []; |
| 31 | - foreach ($this->availableClasses() as $class) { |
|
| 32 | - try { |
|
| 31 | + foreach ($this->availableClasses() as $class){ |
|
| 32 | + try{ |
|
| 33 | 33 | $reflection = $this->classReflection($class); |
| 34 | - } catch (LocatorException $e) { |
|
| 34 | + }catch (LocatorException $e){ |
|
| 35 | 35 | //Ignoring |
| 36 | 36 | continue; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
| 39 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()){ |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $classes = []; |
| 57 | 57 | |
| 58 | - foreach ($this->availableReflections() as $reflection) { |
|
| 58 | + foreach ($this->availableReflections() as $reflection){ |
|
| 59 | 59 | $classes = array_merge($classes, $reflection->getClasses()); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool |
| 73 | 73 | { |
| 74 | - if (empty($target)) { |
|
| 74 | + if (empty($target)){ |
|
| 75 | 75 | return true; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (!$target->isTrait()) { |
|
| 78 | + if (!$target->isTrait()){ |
|
| 79 | 79 | //Target is interface or class |
| 80 | 80 | return $class->isSubclassOf($target) || $class->getName() == $target->getName(); |
| 81 | 81 | } |
@@ -23,20 +23,26 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function getClasses($target = null): array |
| 25 | 25 | { |
| 26 | - if (!empty($target) && (is_object($target) || is_string($target))) { |
|
| 26 | + if (!empty($target) && (is_object($target) || is_string($target))) |
|
| 27 | + { |
|
| 27 | 28 | $target = new \ReflectionClass($target); |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | $result = []; |
| 31 | - foreach ($this->availableClasses() as $class) { |
|
| 32 | - try { |
|
| 32 | + foreach ($this->availableClasses() as $class) |
|
| 33 | + { |
|
| 34 | + try |
|
| 35 | + { |
|
| 33 | 36 | $reflection = $this->classReflection($class); |
| 34 | - } catch (LocatorException $e) { |
|
| 37 | + } |
|
| 38 | + catch (LocatorException $e) |
|
| 39 | + { |
|
| 35 | 40 | //Ignoring |
| 36 | 41 | continue; |
| 37 | 42 | } |
| 38 | 43 | |
| 39 | - if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) { |
|
| 44 | + if (!$this->isTargeted($reflection, $target) || $reflection->isInterface()) |
|
| 45 | + { |
|
| 40 | 46 | continue; |
| 41 | 47 | } |
| 42 | 48 | |
@@ -55,7 +61,8 @@ discard block |
||
| 55 | 61 | { |
| 56 | 62 | $classes = []; |
| 57 | 63 | |
| 58 | - foreach ($this->availableReflections() as $reflection) { |
|
| 64 | + foreach ($this->availableReflections() as $reflection) |
|
| 65 | + { |
|
| 59 | 66 | $classes = array_merge($classes, $reflection->getClasses()); |
| 60 | 67 | } |
| 61 | 68 | |
@@ -71,11 +78,13 @@ discard block |
||
| 71 | 78 | */ |
| 72 | 79 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target = null): bool |
| 73 | 80 | { |
| 74 | - if (empty($target)) { |
|
| 81 | + if (empty($target)) |
|
| 82 | + { |
|
| 75 | 83 | return true; |
| 76 | 84 | } |
| 77 | 85 | |
| 78 | - if (!$target->isTrait()) { |
|
| 86 | + if (!$target->isTrait()) |
|
| 87 | + { |
|
| 79 | 88 | //Target is interface or class |
| 80 | 89 | return $class->isSubclassOf($target) || $class->getName() == $target->getName(); |
| 81 | 90 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 79 | 79 | { |
| 80 | - if ($class->isSubclassOf(ClassesInterface::class)) { |
|
| 80 | + if ($class->isSubclassOf(ClassesInterface::class)){ |
|
| 81 | 81 | return $this->classLocator(); |
| 82 | - } elseif ($class->isSubclassOf(InvocationsInterface::class)) { |
|
| 82 | + } elseif ($class->isSubclassOf(InvocationsInterface::class)){ |
|
| 83 | 83 | return $this->invocationLocator(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | $tokens = token_get_all(file_get_contents($filename)); |
| 98 | 98 | |
| 99 | 99 | $line = 0; |
| 100 | - foreach ($tokens as &$token) { |
|
| 101 | - if (isset($token[self::LINE])) { |
|
| 100 | + foreach ($tokens as &$token){ |
|
| 101 | + if (isset($token[self::LINE])){ |
|
| 102 | 102 | $line = $token[self::LINE]; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if (!is_array($token)) { |
|
| 105 | + if (!is_array($token)){ |
|
| 106 | 106 | $token = [$token, $token, $line]; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $finder = new Finder(); |
| 124 | 124 | |
| 125 | - if (empty($directories)) { |
|
| 125 | + if (empty($directories)){ |
|
| 126 | 126 | $directories = $this->config->getDirectories(); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if (empty($exclude)) { |
|
| 129 | + if (empty($exclude)){ |
|
| 130 | 130 | $exclude = $this->config->getExcludes(); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -77,9 +77,12 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function createInjection(\ReflectionClass $class, string $context = null) |
| 79 | 79 | { |
| 80 | - if ($class->isSubclassOf(ClassesInterface::class)) { |
|
| 80 | + if ($class->isSubclassOf(ClassesInterface::class)) |
|
| 81 | + { |
|
| 81 | 82 | return $this->classLocator(); |
| 82 | - } elseif ($class->isSubclassOf(InvocationsInterface::class)) { |
|
| 83 | + } |
|
| 84 | + elseif ($class->isSubclassOf(InvocationsInterface::class)) |
|
| 85 | + { |
|
| 83 | 86 | return $this->invocationLocator(); |
| 84 | 87 | } |
| 85 | 88 | |
@@ -97,12 +100,15 @@ discard block |
||
| 97 | 100 | $tokens = token_get_all(file_get_contents($filename)); |
| 98 | 101 | |
| 99 | 102 | $line = 0; |
| 100 | - foreach ($tokens as &$token) { |
|
| 101 | - if (isset($token[self::LINE])) { |
|
| 103 | + foreach ($tokens as &$token) |
|
| 104 | + { |
|
| 105 | + if (isset($token[self::LINE])) |
|
| 106 | + { |
|
| 102 | 107 | $line = $token[self::LINE]; |
| 103 | 108 | } |
| 104 | 109 | |
| 105 | - if (!is_array($token)) { |
|
| 110 | + if (!is_array($token)) |
|
| 111 | + { |
|
| 106 | 112 | $token = [$token, $token, $line]; |
| 107 | 113 | } |
| 108 | 114 | |
@@ -122,11 +128,13 @@ discard block |
||
| 122 | 128 | { |
| 123 | 129 | $finder = new Finder(); |
| 124 | 130 | |
| 125 | - if (empty($directories)) { |
|
| 131 | + if (empty($directories)) |
|
| 132 | + { |
|
| 126 | 133 | $directories = $this->config->getDirectories(); |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | - if (empty($exclude)) { |
|
| 136 | + if (empty($exclude)) |
|
| 137 | + { |
|
| 130 | 138 | $exclude = $this->config->getExcludes(); |
| 131 | 139 | } |
| 132 | 140 | |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | public function getInvocations(\ReflectionFunctionAbstract $function): array |
| 29 | 29 | { |
| 30 | 30 | $result = []; |
| 31 | - foreach ($this->availableInvocations($function->getName()) as $invocation) { |
|
| 32 | - if ($this->isTargeted($invocation, $function)) { |
|
| 31 | + foreach ($this->availableInvocations($function->getName()) as $invocation){ |
|
| 32 | + if ($this->isTargeted($invocation, $function)){ |
|
| 33 | 33 | $result[] = $invocation; |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | protected function availableInvocations(string $signature = ''): \Generator |
| 47 | 47 | { |
| 48 | 48 | $signature = strtolower(trim($signature, '\\')); |
| 49 | - foreach ($this->availableReflections() as $reflection) { |
|
| 50 | - foreach ($reflection->getInvocations() as $invocation) { |
|
| 49 | + foreach ($this->availableReflections() as $reflection){ |
|
| 50 | + foreach ($reflection->getInvocations() as $invocation){ |
|
| 51 | 51 | if ( |
| 52 | 52 | !empty($signature) |
| 53 | 53 | && strtolower(trim($invocation->getName(), '\\')) != $signature |
| 54 | - ) { |
|
| 54 | + ){ |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | protected function isTargeted(ReflectionInvocation $invocation, \ReflectionFunctionAbstract $function): bool |
| 70 | 70 | { |
| 71 | - if ($function instanceof \ReflectionFunction) { |
|
| 71 | + if ($function instanceof \ReflectionFunction){ |
|
| 72 | 72 | return !$invocation->isMethod(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - try { |
|
| 75 | + try{ |
|
| 76 | 76 | $reflection = $this->classReflection($invocation->getClass()); |
| 77 | - } catch (LocatorException $e) { |
|
| 77 | + }catch (LocatorException $e){ |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | $target = $function->getDeclaringClass(); |
| 85 | 85 | |
| 86 | - if ($target->isTrait()) { |
|
| 86 | + if ($target->isTrait()){ |
|
| 87 | 87 | //Let's compare traits |
| 88 | 88 | return in_array($target->getName(), $this->fetchTraits($invocation->getClass())); |
| 89 | 89 | } |
@@ -28,8 +28,10 @@ discard block |
||
| 28 | 28 | public function getInvocations(\ReflectionFunctionAbstract $function): array |
| 29 | 29 | { |
| 30 | 30 | $result = []; |
| 31 | - foreach ($this->availableInvocations($function->getName()) as $invocation) { |
|
| 32 | - if ($this->isTargeted($invocation, $function)) { |
|
| 31 | + foreach ($this->availableInvocations($function->getName()) as $invocation) |
|
| 32 | + { |
|
| 33 | + if ($this->isTargeted($invocation, $function)) |
|
| 34 | + { |
|
| 33 | 35 | $result[] = $invocation; |
| 34 | 36 | } |
| 35 | 37 | } |
@@ -46,8 +48,10 @@ discard block |
||
| 46 | 48 | protected function availableInvocations(string $signature = ''): \Generator |
| 47 | 49 | { |
| 48 | 50 | $signature = strtolower(trim($signature, '\\')); |
| 49 | - foreach ($this->availableReflections() as $reflection) { |
|
| 50 | - foreach ($reflection->getInvocations() as $invocation) { |
|
| 51 | + foreach ($this->availableReflections() as $reflection) |
|
| 52 | + { |
|
| 53 | + foreach ($reflection->getInvocations() as $invocation) |
|
| 54 | + { |
|
| 51 | 55 | if ( |
| 52 | 56 | !empty($signature) |
| 53 | 57 | && strtolower(trim($invocation->getName(), '\\')) != $signature |
@@ -68,13 +72,17 @@ discard block |
||
| 68 | 72 | */ |
| 69 | 73 | protected function isTargeted(ReflectionInvocation $invocation, \ReflectionFunctionAbstract $function): bool |
| 70 | 74 | { |
| 71 | - if ($function instanceof \ReflectionFunction) { |
|
| 75 | + if ($function instanceof \ReflectionFunction) |
|
| 76 | + { |
|
| 72 | 77 | return !$invocation->isMethod(); |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | - try { |
|
| 80 | + try |
|
| 81 | + { |
|
| 76 | 82 | $reflection = $this->classReflection($invocation->getClass()); |
| 77 | - } catch (LocatorException $e) { |
|
| 83 | + } |
|
| 84 | + catch (LocatorException $e) |
|
| 85 | + { |
|
| 78 | 86 | return false; |
| 79 | 87 | } |
| 80 | 88 | |
@@ -83,7 +91,8 @@ discard block |
||
| 83 | 91 | */ |
| 84 | 92 | $target = $function->getDeclaringClass(); |
| 85 | 93 | |
| 86 | - if ($target->isTrait()) { |
|
| 94 | + if ($target->isTrait()) |
|
| 95 | + { |
|
| 87 | 96 | //Let's compare traits |
| 88 | 97 | return in_array($target->getName(), $this->fetchTraits($invocation->getClass())); |
| 89 | 98 | } |