@@ -58,7 +58,7 @@ |
||
| 58 | 58 | 'authorizeTopics' => [], |
| 59 | 59 | ]); |
| 60 | 60 | |
| 61 | - if ($env->get('RR_BROADCAST_PATH', null) !== null) { |
|
| 61 | + if ($env->get('RR_BROADCAST_PATH', null) !== null){ |
|
| 62 | 62 | $http->addMiddleware(WebsocketsMiddleware::class); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -58,7 +58,8 @@ |
||
| 58 | 58 | 'authorizeTopics' => [], |
| 59 | 59 | ]); |
| 60 | 60 | |
| 61 | - if ($env->get('RR_BROADCAST_PATH', null) !== null) { |
|
| 61 | + if ($env->get('RR_BROADCAST_PATH', null) !== null) |
|
| 62 | + { |
|
| 62 | 63 | $http->addMiddleware(WebsocketsMiddleware::class); |
| 63 | 64 | } |
| 64 | 65 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function getPermission(string $controller, string $action): Permission |
| 48 | 48 | { |
| 49 | 49 | $key = sprintf('%s:%s', $controller, $action); |
| 50 | - if (!array_key_exists($key, $this->cache)) { |
|
| 50 | + if (!array_key_exists($key, $this->cache)){ |
|
| 51 | 51 | $this->cache[$key] = $this->generatePermission($controller, $action); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -56,20 +56,20 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | private function generatePermission(string $controller, string $action): Permission |
| 58 | 58 | { |
| 59 | - try { |
|
| 59 | + try{ |
|
| 60 | 60 | $method = new \ReflectionMethod($controller, $action); |
| 61 | - } catch (\ReflectionException $e) { |
|
| 61 | + }catch (\ReflectionException $e){ |
|
| 62 | 62 | return Permission::failed(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $guarded = $this->reader->firstFunctionMetadata($method, Guarded::class); |
| 66 | - if (!$guarded instanceof Guarded) { |
|
| 66 | + if (!$guarded instanceof Guarded){ |
|
| 67 | 67 | return Permission::failed(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $namespace = $this->reader->firstClassMetadata($method->getDeclaringClass(), GuardNamespace::class); |
| 71 | 71 | |
| 72 | - if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) { |
|
| 72 | + if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)){ |
|
| 73 | 73 | return Permission::ok( |
| 74 | 74 | $this->makePermission($guarded, $method, $namespace), |
| 75 | 75 | $this->mapFailureException($guarded), |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string |
| 93 | 93 | { |
| 94 | 94 | $permission = []; |
| 95 | - if ($this->namespace) { |
|
| 95 | + if ($this->namespace){ |
|
| 96 | 96 | $permission[] = $this->namespace; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ($ns !== null && $ns->namespace) { |
|
| 99 | + if ($ns !== null && $ns->namespace){ |
|
| 100 | 100 | $permission[] = $ns->namespace; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -47,7 +47,8 @@ discard block |
||
| 47 | 47 | public function getPermission(string $controller, string $action): Permission |
| 48 | 48 | { |
| 49 | 49 | $key = sprintf('%s:%s', $controller, $action); |
| 50 | - if (!array_key_exists($key, $this->cache)) { |
|
| 50 | + if (!array_key_exists($key, $this->cache)) |
|
| 51 | + { |
|
| 51 | 52 | $this->cache[$key] = $this->generatePermission($controller, $action); |
| 52 | 53 | } |
| 53 | 54 | |
@@ -56,20 +57,25 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | private function generatePermission(string $controller, string $action): Permission |
| 58 | 59 | { |
| 59 | - try { |
|
| 60 | + try |
|
| 61 | + { |
|
| 60 | 62 | $method = new \ReflectionMethod($controller, $action); |
| 61 | - } catch (\ReflectionException $e) { |
|
| 63 | + } |
|
| 64 | + catch (\ReflectionException $e) |
|
| 65 | + { |
|
| 62 | 66 | return Permission::failed(); |
| 63 | 67 | } |
| 64 | 68 | |
| 65 | 69 | $guarded = $this->reader->firstFunctionMetadata($method, Guarded::class); |
| 66 | - if (!$guarded instanceof Guarded) { |
|
| 70 | + if (!$guarded instanceof Guarded) |
|
| 71 | + { |
|
| 67 | 72 | return Permission::failed(); |
| 68 | 73 | } |
| 69 | 74 | |
| 70 | 75 | $namespace = $this->reader->firstClassMetadata($method->getDeclaringClass(), GuardNamespace::class); |
| 71 | 76 | |
| 72 | - if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) { |
|
| 77 | + if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) |
|
| 78 | + { |
|
| 73 | 79 | return Permission::ok( |
| 74 | 80 | $this->makePermission($guarded, $method, $namespace), |
| 75 | 81 | $this->mapFailureException($guarded), |
@@ -92,11 +98,13 @@ discard block |
||
| 92 | 98 | private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string |
| 93 | 99 | { |
| 94 | 100 | $permission = []; |
| 95 | - if ($this->namespace) { |
|
| 101 | + if ($this->namespace) |
|
| 102 | + { |
|
| 96 | 103 | $permission[] = $this->namespace; |
| 97 | 104 | } |
| 98 | 105 | |
| 99 | - if ($ns !== null && $ns->namespace) { |
|
| 106 | + if ($ns !== null && $ns->namespace) |
|
| 107 | + { |
|
| 100 | 108 | $permission[] = $ns->namespace; |
| 101 | 109 | } |
| 102 | 110 | |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | string $group = self::DEFAULT_GROUP, |
| 86 | 86 | array $middleware = [], |
| 87 | 87 | int $priority = 0 |
| 88 | - ) { |
|
| 88 | + ){ |
|
| 89 | 89 | $this->route = $route; |
| 90 | 90 | $this->name = $name; |
| 91 | 91 | $this->methods = $methods; |
@@ -72,14 +72,17 @@ discard block |
||
| 72 | 72 | { |
| 73 | 73 | $result = $core->callAction($controller, $action, $parameters); |
| 74 | 74 | |
| 75 | - if (is_iterable($result)) { |
|
| 75 | + if (is_iterable($result)) |
|
| 76 | + { |
|
| 76 | 77 | $schema = $this->getSchema($controller, $action); |
| 77 | - if ($schema !== null) { |
|
| 78 | + if ($schema !== null) |
|
| 79 | + { |
|
| 78 | 80 | $grid = $this->makeFactory($schema) |
| 79 | 81 | ->withDefaults($schema['defaults']) |
| 80 | 82 | ->create($result, $schema['grid']); |
| 81 | 83 | |
| 82 | - if ($schema['view'] !== null) { |
|
| 84 | + if ($schema['view'] !== null) |
|
| 85 | + { |
|
| 83 | 86 | $grid = $grid->withView($schema['view']); |
| 84 | 87 | } |
| 85 | 88 | |
@@ -99,20 +102,25 @@ discard block |
||
| 99 | 102 | private function getSchema(string $controller, string $action): ?array |
| 100 | 103 | { |
| 101 | 104 | $key = sprintf('%s:%s', $controller, $action); |
| 102 | - if (array_key_exists($key, $this->cache)) { |
|
| 105 | + if (array_key_exists($key, $this->cache)) |
|
| 106 | + { |
|
| 103 | 107 | return $this->cache[$key]; |
| 104 | 108 | } |
| 105 | 109 | |
| 106 | 110 | $this->cache[$key] = null; |
| 107 | - try { |
|
| 111 | + try |
|
| 112 | + { |
|
| 108 | 113 | $method = new \ReflectionMethod($controller, $action); |
| 109 | - } catch (\ReflectionException $e) { |
|
| 114 | + } |
|
| 115 | + catch (\ReflectionException $e) |
|
| 116 | + { |
|
| 110 | 117 | return null; |
| 111 | 118 | } |
| 112 | 119 | |
| 113 | 120 | /** @var null|DataGrid $dataGrid */ |
| 114 | 121 | $dataGrid = $this->reader->firstFunctionMetadata($method, DataGrid::class); |
| 115 | - if ($dataGrid === null) { |
|
| 122 | + if ($dataGrid === null) |
|
| 123 | + { |
|
| 116 | 124 | return null; |
| 117 | 125 | } |
| 118 | 126 | |
@@ -133,19 +141,23 @@ discard block |
||
| 133 | 141 | 'factory' => $dataGrid->factory, |
| 134 | 142 | ]; |
| 135 | 143 | |
| 136 | - if (is_string($schema['view'])) { |
|
| 144 | + if (is_string($schema['view'])) |
|
| 145 | + { |
|
| 137 | 146 | $schema['view'] = $this->container->get($schema['view']); |
| 138 | 147 | } |
| 139 | 148 | |
| 140 | - if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) { |
|
| 149 | + if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) |
|
| 150 | + { |
|
| 141 | 151 | $schema['defaults'] = $schema['grid']->getDefaults(); |
| 142 | 152 | } |
| 143 | 153 | |
| 144 | - if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) { |
|
| 154 | + if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) |
|
| 155 | + { |
|
| 145 | 156 | $schema['options'] = $schema['grid']->getOptions(); |
| 146 | 157 | } |
| 147 | 158 | |
| 148 | - if ($schema['view'] === null && is_callable($schema['grid'])) { |
|
| 159 | + if ($schema['view'] === null && is_callable($schema['grid'])) |
|
| 160 | + { |
|
| 149 | 161 | $schema['view'] = $schema['grid']; |
| 150 | 162 | } |
| 151 | 163 | |
@@ -154,9 +166,11 @@ discard block |
||
| 154 | 166 | |
| 155 | 167 | private function makeFactory(array $schema): GridFactoryInterface |
| 156 | 168 | { |
| 157 | - if (!empty($schema['factory']) && $this->container->has($schema['factory'])) { |
|
| 169 | + if (!empty($schema['factory']) && $this->container->has($schema['factory'])) |
|
| 170 | + { |
|
| 158 | 171 | $factory = $this->container->get($schema['factory']); |
| 159 | - if ($factory instanceof GridFactoryInterface) { |
|
| 172 | + if ($factory instanceof GridFactoryInterface) |
|
| 173 | + { |
|
| 160 | 174 | return $factory; |
| 161 | 175 | } |
| 162 | 176 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | ContainerInterface $container, |
| 53 | 53 | GridFactory $gridFactory, |
| 54 | 54 | ReaderInterface $reader |
| 55 | - ) { |
|
| 55 | + ){ |
|
| 56 | 56 | $this->response = $response; |
| 57 | 57 | $this->container = $container; |
| 58 | 58 | $this->gridFactory = $gridFactory; |
@@ -71,14 +71,14 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $result = $core->callAction($controller, $action, $parameters); |
| 73 | 73 | |
| 74 | - if (is_iterable($result)) { |
|
| 74 | + if (is_iterable($result)){ |
|
| 75 | 75 | $schema = $this->getSchema($controller, $action); |
| 76 | - if ($schema !== null) { |
|
| 76 | + if ($schema !== null){ |
|
| 77 | 77 | $grid = $this->makeFactory($schema) |
| 78 | 78 | ->withDefaults($schema['defaults']) |
| 79 | 79 | ->create($result, $schema['grid']); |
| 80 | 80 | |
| 81 | - if ($schema['view'] !== null) { |
|
| 81 | + if ($schema['view'] !== null){ |
|
| 82 | 82 | $grid = $grid->withView($schema['view']); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | private function getSchema(string $controller, string $action): ?array |
| 99 | 99 | { |
| 100 | 100 | $key = sprintf('%s:%s', $controller, $action); |
| 101 | - if (array_key_exists($key, $this->cache)) { |
|
| 101 | + if (array_key_exists($key, $this->cache)){ |
|
| 102 | 102 | return $this->cache[$key]; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $this->cache[$key] = null; |
| 106 | - try { |
|
| 106 | + try{ |
|
| 107 | 107 | $method = new \ReflectionMethod($controller, $action); |
| 108 | - } catch (\ReflectionException $e) { |
|
| 108 | + }catch (\ReflectionException $e){ |
|
| 109 | 109 | return null; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** @var null|DataGrid $dataGrid */ |
| 113 | 113 | $dataGrid = $this->reader->firstFunctionMetadata($method, DataGrid::class); |
| 114 | - if ($dataGrid === null) { |
|
| 114 | + if ($dataGrid === null){ |
|
| 115 | 115 | return null; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -132,19 +132,19 @@ discard block |
||
| 132 | 132 | 'factory' => $dataGrid->factory, |
| 133 | 133 | ]; |
| 134 | 134 | |
| 135 | - if (is_string($schema['view'])) { |
|
| 135 | + if (is_string($schema['view'])){ |
|
| 136 | 136 | $schema['view'] = $this->container->get($schema['view']); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')) { |
|
| 139 | + if ($schema['defaults'] === [] && method_exists($schema['grid'], 'getDefaults')){ |
|
| 140 | 140 | $schema['defaults'] = $schema['grid']->getDefaults(); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')) { |
|
| 143 | + if ($schema['options'] === [] && method_exists($schema['grid'], 'getOptions')){ |
|
| 144 | 144 | $schema['options'] = $schema['grid']->getOptions(); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ($schema['view'] === null && is_callable($schema['grid'])) { |
|
| 147 | + if ($schema['view'] === null && is_callable($schema['grid'])){ |
|
| 148 | 148 | $schema['view'] = $schema['grid']; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | private function makeFactory(array $schema): GridFactoryInterface |
| 155 | 155 | { |
| 156 | - if (!empty($schema['factory']) && $this->container->has($schema['factory'])) { |
|
| 156 | + if (!empty($schema['factory']) && $this->container->has($schema['factory'])){ |
|
| 157 | 157 | $factory = $this->container->get($schema['factory']); |
| 158 | - if ($factory instanceof GridFactoryInterface) { |
|
| 158 | + if ($factory instanceof GridFactoryInterface){ |
|
| 159 | 159 | return $factory; |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | array $defaults = [], |
| 71 | 71 | array $options = [], |
| 72 | 72 | ?string $factory = null |
| 73 | - ) { |
|
| 73 | + ){ |
|
| 74 | 74 | $this->grid = $grid; |
| 75 | 75 | $this->view = $view; |
| 76 | 76 | $this->defaults = $defaults; |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function findClasses(string $annotation): iterable |
| 69 | 69 | { |
| 70 | - foreach ($this->getTargets() as $target) { |
|
| 70 | + foreach ($this->getTargets() as $target){ |
|
| 71 | 71 | $found = $this->reader->firstClassMetadata($target, $annotation); |
| 72 | - if ($found !== null) { |
|
| 72 | + if ($found !== null){ |
|
| 73 | 73 | yield new AnnotatedClass($target, $found); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -83,10 +83,10 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function findMethods(string $annotation): iterable |
| 85 | 85 | { |
| 86 | - foreach ($this->getTargets() as $target) { |
|
| 87 | - foreach ($target->getMethods() as $method) { |
|
| 86 | + foreach ($this->getTargets() as $target){ |
|
| 87 | + foreach ($target->getMethods() as $method){ |
|
| 88 | 88 | $found = $this->reader->firstFunctionMetadata($method, $annotation); |
| 89 | - if ($found !== null) { |
|
| 89 | + if ($found !== null){ |
|
| 90 | 90 | yield new AnnotatedMethod($method, $found); |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function findProperties(string $annotation): iterable |
| 103 | 103 | { |
| 104 | - foreach ($this->getTargets() as $target) { |
|
| 105 | - foreach ($target->getProperties() as $property) { |
|
| 104 | + foreach ($this->getTargets() as $target){ |
|
| 105 | + foreach ($target->getProperties() as $property){ |
|
| 106 | 106 | $found = $this->reader->firstPropertyMetadata($property, $annotation); |
| 107 | - if ($found !== null) { |
|
| 107 | + if ($found !== null){ |
|
| 108 | 108 | yield new AnnotatedProperty($property, $found); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function getTargets(): iterable |
| 118 | 118 | { |
| 119 | - if ($this->targets === []) { |
|
| 119 | + if ($this->targets === []){ |
|
| 120 | 120 | yield from $this->classLocator->getClasses(); |
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - foreach ($this->targets as $target) { |
|
| 124 | + foreach ($this->targets as $target){ |
|
| 125 | 125 | yield from $this->classLocator->getClasses($target); |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -67,9 +67,11 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function findClasses(string $annotation): iterable |
| 69 | 69 | { |
| 70 | - foreach ($this->getTargets() as $target) { |
|
| 70 | + foreach ($this->getTargets() as $target) |
|
| 71 | + { |
|
| 71 | 72 | $found = $this->reader->firstClassMetadata($target, $annotation); |
| 72 | - if ($found !== null) { |
|
| 73 | + if ($found !== null) |
|
| 74 | + { |
|
| 73 | 75 | yield new AnnotatedClass($target, $found); |
| 74 | 76 | } |
| 75 | 77 | } |
@@ -83,10 +85,13 @@ discard block |
||
| 83 | 85 | */ |
| 84 | 86 | public function findMethods(string $annotation): iterable |
| 85 | 87 | { |
| 86 | - foreach ($this->getTargets() as $target) { |
|
| 87 | - foreach ($target->getMethods() as $method) { |
|
| 88 | + foreach ($this->getTargets() as $target) |
|
| 89 | + { |
|
| 90 | + foreach ($target->getMethods() as $method) |
|
| 91 | + { |
|
| 88 | 92 | $found = $this->reader->firstFunctionMetadata($method, $annotation); |
| 89 | - if ($found !== null) { |
|
| 93 | + if ($found !== null) |
|
| 94 | + { |
|
| 90 | 95 | yield new AnnotatedMethod($method, $found); |
| 91 | 96 | } |
| 92 | 97 | } |
@@ -101,10 +106,13 @@ discard block |
||
| 101 | 106 | */ |
| 102 | 107 | public function findProperties(string $annotation): iterable |
| 103 | 108 | { |
| 104 | - foreach ($this->getTargets() as $target) { |
|
| 105 | - foreach ($target->getProperties() as $property) { |
|
| 109 | + foreach ($this->getTargets() as $target) |
|
| 110 | + { |
|
| 111 | + foreach ($target->getProperties() as $property) |
|
| 112 | + { |
|
| 106 | 113 | $found = $this->reader->firstPropertyMetadata($property, $annotation); |
| 107 | - if ($found !== null) { |
|
| 114 | + if ($found !== null) |
|
| 115 | + { |
|
| 108 | 116 | yield new AnnotatedProperty($property, $found); |
| 109 | 117 | } |
| 110 | 118 | } |
@@ -116,12 +124,14 @@ discard block |
||
| 116 | 124 | */ |
| 117 | 125 | private function getTargets(): iterable |
| 118 | 126 | { |
| 119 | - if ($this->targets === []) { |
|
| 127 | + if ($this->targets === []) |
|
| 128 | + { |
|
| 120 | 129 | yield from $this->classLocator->getClasses(); |
| 121 | 130 | return; |
| 122 | 131 | } |
| 123 | 132 | |
| 124 | - foreach ($this->targets as $target) { |
|
| 133 | + foreach ($this->targets as $target) |
|
| 134 | + { |
|
| 125 | 135 | yield from $this->classLocator->getClasses($target); |
| 126 | 136 | } |
| 127 | 137 | } |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | public function testLocateClasses() |
| 30 | 30 | { |
| 31 | 31 | // Annotations. |
| 32 | - $classes = $this->getAnnotationsLocator(__DIR__ . '/Fixtures')->findClasses(ClassAnnotation::class); |
|
| 32 | + $classes = $this->getAnnotationsLocator(__DIR__.'/Fixtures')->findClasses(ClassAnnotation::class); |
|
| 33 | 33 | $classes = iterator_to_array($classes); |
| 34 | 34 | |
| 35 | 35 | $this->assertCount(1, $classes); |
| 36 | 36 | |
| 37 | - foreach ($classes as $class) { |
|
| 37 | + foreach ($classes as $class){ |
|
| 38 | 38 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
| 39 | 39 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Attributes. |
| 43 | - $classes = $this->getAttributesLocator(__DIR__ . '/Fixtures')->findClasses(ClassAnnotation::class); |
|
| 43 | + $classes = $this->getAttributesLocator(__DIR__.'/Fixtures')->findClasses(ClassAnnotation::class); |
|
| 44 | 44 | $classes = iterator_to_array($classes); |
| 45 | 45 | |
| 46 | 46 | $this->assertCount(1, $classes); |
| 47 | 47 | |
| 48 | - foreach ($classes as $class) { |
|
| 48 | + foreach ($classes as $class){ |
|
| 49 | 49 | $this->assertSame(AttributeTestClass::class, $class->getClass()->getName()); |
| 50 | 50 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 51 | 51 | } |
@@ -54,24 +54,24 @@ discard block |
||
| 54 | 54 | public function testLocateProperties() |
| 55 | 55 | { |
| 56 | 56 | // Annotations. |
| 57 | - $props = $this->getAnnotationsLocator(__DIR__ . '/Fixtures')->findProperties(PropertyAnnotation::class); |
|
| 57 | + $props = $this->getAnnotationsLocator(__DIR__.'/Fixtures')->findProperties(PropertyAnnotation::class); |
|
| 58 | 58 | $props = iterator_to_array($props); |
| 59 | 59 | |
| 60 | 60 | $this->assertCount(1, $props); |
| 61 | 61 | |
| 62 | - foreach ($props as $prop) { |
|
| 62 | + foreach ($props as $prop){ |
|
| 63 | 63 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
| 64 | 64 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 65 | 65 | $this->assertSame('123', $prop->getAnnotation()->id); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Attributes. |
| 69 | - $props = $this->getAttributesLocator(__DIR__ . '/Fixtures')->findProperties(PropertyAnnotation::class); |
|
| 69 | + $props = $this->getAttributesLocator(__DIR__.'/Fixtures')->findProperties(PropertyAnnotation::class); |
|
| 70 | 70 | $props = iterator_to_array($props); |
| 71 | 71 | |
| 72 | 72 | $this->assertCount(1, $props); |
| 73 | 73 | |
| 74 | - foreach ($props as $prop) { |
|
| 74 | + foreach ($props as $prop){ |
|
| 75 | 75 | $this->assertSame(AttributeTestClass::class, $prop->getClass()->getName()); |
| 76 | 76 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 77 | 77 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -81,24 +81,24 @@ discard block |
||
| 81 | 81 | public function testLocateMethods() |
| 82 | 82 | { |
| 83 | 83 | // Annotations. |
| 84 | - $methods = $this->getAnnotationsLocator(__DIR__ . '/Fixtures')->findMethods(MethodAnnotation::class); |
|
| 84 | + $methods = $this->getAnnotationsLocator(__DIR__.'/Fixtures')->findMethods(MethodAnnotation::class); |
|
| 85 | 85 | $methods = iterator_to_array($methods); |
| 86 | 86 | |
| 87 | 87 | $this->assertCount(1, $methods); |
| 88 | 88 | |
| 89 | - foreach ($methods as $m) { |
|
| 89 | + foreach ($methods as $m){ |
|
| 90 | 90 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
| 91 | 91 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 92 | 92 | $this->assertSame('/', $m->getAnnotation()->path); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Attributes. |
| 96 | - $methods = $this->getAttributesLocator(__DIR__ . '/Fixtures')->findMethods(MethodAnnotation::class); |
|
| 96 | + $methods = $this->getAttributesLocator(__DIR__.'/Fixtures')->findMethods(MethodAnnotation::class); |
|
| 97 | 97 | $methods = iterator_to_array($methods); |
| 98 | 98 | |
| 99 | 99 | $this->assertCount(1, $methods); |
| 100 | 100 | |
| 101 | - foreach ($methods as $m) { |
|
| 101 | + foreach ($methods as $m){ |
|
| 102 | 102 | $this->assertSame(AttributeTestClass::class, $m->getClass()->getName()); |
| 103 | 103 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 104 | 104 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $this->assertCount(1, $classes); |
| 36 | 36 | |
| 37 | - foreach ($classes as $class) { |
|
| 37 | + foreach ($classes as $class) |
|
| 38 | + { |
|
| 38 | 39 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
| 39 | 40 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 40 | 41 | } |
@@ -45,7 +46,8 @@ discard block |
||
| 45 | 46 | |
| 46 | 47 | $this->assertCount(1, $classes); |
| 47 | 48 | |
| 48 | - foreach ($classes as $class) { |
|
| 49 | + foreach ($classes as $class) |
|
| 50 | + { |
|
| 49 | 51 | $this->assertSame(AttributeTestClass::class, $class->getClass()->getName()); |
| 50 | 52 | $this->assertSame('abc', $class->getAnnotation()->value); |
| 51 | 53 | } |
@@ -59,7 +61,8 @@ discard block |
||
| 59 | 61 | |
| 60 | 62 | $this->assertCount(1, $props); |
| 61 | 63 | |
| 62 | - foreach ($props as $prop) { |
|
| 64 | + foreach ($props as $prop) |
|
| 65 | + { |
|
| 63 | 66 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
| 64 | 67 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 65 | 68 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -71,7 +74,8 @@ discard block |
||
| 71 | 74 | |
| 72 | 75 | $this->assertCount(1, $props); |
| 73 | 76 | |
| 74 | - foreach ($props as $prop) { |
|
| 77 | + foreach ($props as $prop) |
|
| 78 | + { |
|
| 75 | 79 | $this->assertSame(AttributeTestClass::class, $prop->getClass()->getName()); |
| 76 | 80 | $this->assertSame('name', $prop->getProperty()->getName()); |
| 77 | 81 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -86,7 +90,8 @@ discard block |
||
| 86 | 90 | |
| 87 | 91 | $this->assertCount(1, $methods); |
| 88 | 92 | |
| 89 | - foreach ($methods as $m) { |
|
| 93 | + foreach ($methods as $m) |
|
| 94 | + { |
|
| 90 | 95 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
| 91 | 96 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 92 | 97 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -98,7 +103,8 @@ discard block |
||
| 98 | 103 | |
| 99 | 104 | $this->assertCount(1, $methods); |
| 100 | 105 | |
| 101 | - foreach ($methods as $m) { |
|
| 106 | + foreach ($methods as $m) |
|
| 107 | + { |
|
| 102 | 108 | $this->assertSame(AttributeTestClass::class, $m->getClass()->getName()); |
| 103 | 109 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
| 104 | 110 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -29,12 +29,12 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function of($value, $checker): bool |
| 31 | 31 | { |
| 32 | - if (!is_array($value) || empty($value)) { |
|
| 32 | + if (!is_array($value) || empty($value)){ |
|
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach ($value as $item) { |
|
| 37 | - if (!$this->validation->validate(compact('item'), ['item' => [$checker]])->isValid()) { |
|
| 36 | + foreach ($value as $item){ |
|
| 37 | + if (!$this->validation->validate(compact('item'), ['item' => [$checker]])->isValid()){ |
|
| 38 | 38 | return false; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function count($value, int $length): bool |
| 46 | 46 | { |
| 47 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 47 | + if (!is_array($value) && !$value instanceof \Countable){ |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | public function shorter($value, int $length): bool |
| 55 | 55 | { |
| 56 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 56 | + if (!is_array($value) && !$value instanceof \Countable){ |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public function longer($value, int $length): bool |
| 64 | 64 | { |
| 65 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 65 | + if (!is_array($value) && !$value instanceof \Countable){ |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public function range($value, int $min, int $max): bool |
| 73 | 73 | { |
| 74 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 74 | + if (!is_array($value) && !$value instanceof \Countable){ |
|
| 75 | 75 | return false; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -29,12 +29,15 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | public function of($value, $checker): bool |
| 31 | 31 | { |
| 32 | - if (!is_array($value) || empty($value)) { |
|
| 32 | + if (!is_array($value) || empty($value)) |
|
| 33 | + { |
|
| 33 | 34 | return false; |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - foreach ($value as $item) { |
|
| 37 | - if (!$this->validation->validate(compact('item'), ['item' => [$checker]])->isValid()) { |
|
| 37 | + foreach ($value as $item) |
|
| 38 | + { |
|
| 39 | + if (!$this->validation->validate(compact('item'), ['item' => [$checker]])->isValid()) |
|
| 40 | + { |
|
| 38 | 41 | return false; |
| 39 | 42 | } |
| 40 | 43 | } |
@@ -44,7 +47,8 @@ discard block |
||
| 44 | 47 | |
| 45 | 48 | public function count($value, int $length): bool |
| 46 | 49 | { |
| 47 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 50 | + if (!is_array($value) && !$value instanceof \Countable) |
|
| 51 | + { |
|
| 48 | 52 | return false; |
| 49 | 53 | } |
| 50 | 54 | |
@@ -53,7 +57,8 @@ discard block |
||
| 53 | 57 | |
| 54 | 58 | public function shorter($value, int $length): bool |
| 55 | 59 | { |
| 56 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 60 | + if (!is_array($value) && !$value instanceof \Countable) |
|
| 61 | + { |
|
| 57 | 62 | return false; |
| 58 | 63 | } |
| 59 | 64 | |
@@ -62,7 +67,8 @@ discard block |
||
| 62 | 67 | |
| 63 | 68 | public function longer($value, int $length): bool |
| 64 | 69 | { |
| 65 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 70 | + if (!is_array($value) && !$value instanceof \Countable) |
|
| 71 | + { |
|
| 66 | 72 | return false; |
| 67 | 73 | } |
| 68 | 74 | |
@@ -71,7 +77,8 @@ discard block |
||
| 71 | 77 | |
| 72 | 78 | public function range($value, int $min, int $max): bool |
| 73 | 79 | { |
| 74 | - if (!is_array($value) && !$value instanceof \Countable) { |
|
| 80 | + if (!is_array($value) && !$value instanceof \Countable) |
|
| 81 | + { |
|
| 75 | 82 | return false; |
| 76 | 83 | } |
| 77 | 84 | |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | |
| 80 | 80 | private function createCountable(int $count): \Countable |
| 81 | 81 | { |
| 82 | - return new class($count) implements \Countable { |
|
| 82 | + return new class($count) implements \Countable{ |
|
| 83 | 83 | private $count; |
| 84 | 84 | |
| 85 | 85 | public function __construct(int $count) |