@@ -31,7 +31,8 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | protected function iterableToArray(iterable $iterable): array |
| 33 | 33 | { |
| 34 | - if ($iterable instanceof \Traversable) { |
|
| 34 | + if ($iterable instanceof \Traversable) |
|
| 35 | + { |
|
| 35 | 36 | return \iterator_to_array($iterable, false); |
| 36 | 37 | } |
| 37 | 38 | |
@@ -47,7 +48,8 @@ discard block |
||
| 47 | 48 | { |
| 48 | 49 | $instance = new $class(); |
| 49 | 50 | |
| 50 | - foreach ($fields as $field => $value) { |
|
| 51 | + foreach ($fields as $field => $value) |
|
| 52 | + { |
|
| 51 | 53 | $instance->$field = $value; |
| 52 | 54 | } |
| 53 | 55 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function iterableToArray(iterable $iterable): array |
| 26 | 26 | { |
| 27 | - if ($iterable instanceof \Traversable) { |
|
| 27 | + if ($iterable instanceof \Traversable){ |
|
| 28 | 28 | return \iterator_to_array($iterable, false); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $instance = new $class(); |
| 51 | 51 | |
| 52 | - foreach ($fields as $field => $value) { |
|
| 52 | + foreach ($fields as $field => $value){ |
|
| 53 | 53 | $instance->$field = $value; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | ->getReflectionConstants() |
| 44 | 44 | ; |
| 45 | 45 | |
| 46 | - foreach ($constants as $reflection) { |
|
| 47 | - if ($reflection->getName() === $name) { |
|
| 46 | + foreach ($constants as $reflection){ |
|
| 47 | + if ($reflection->getName() === $name){ |
|
| 48 | 48 | return $reflection; |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - throw new \ReflectionException('Constant ' . $name . ' not found'); |
|
| 52 | + throw new \ReflectionException('Constant '.$name.' not found'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | protected function getReflectionFunctionParameter(string $function, string $name): \ReflectionParameter |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | ->getParameters() |
| 59 | 59 | ; |
| 60 | 60 | |
| 61 | - foreach ($parameters as $reflection) { |
|
| 62 | - if ($reflection->getName() === $name) { |
|
| 61 | + foreach ($parameters as $reflection){ |
|
| 62 | + if ($reflection->getName() === $name){ |
|
| 63 | 63 | return $reflection; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
| 67 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | protected function getReflectionMethodParameter(string $class, string $method, string $name): \ReflectionParameter |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | ->getParameters() |
| 74 | 74 | ; |
| 75 | 75 | |
| 76 | - foreach ($parameters as $reflection) { |
|
| 77 | - if ($reflection->getName() === $name) { |
|
| 76 | + foreach ($parameters as $reflection){ |
|
| 77 | + if ($reflection->getName() === $name){ |
|
| 78 | 78 | return $reflection; |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - throw new \ReflectionException('Parameter ' . $name . ' not found'); |
|
| 82 | + throw new \ReflectionException('Parameter '.$name.' not found'); |
|
| 83 | 83 | } |
| 84 | 84 | } |
@@ -43,8 +43,10 @@ discard block |
||
| 43 | 43 | ->getReflectionConstants() |
| 44 | 44 | ; |
| 45 | 45 | |
| 46 | - foreach ($constants as $reflection) { |
|
| 47 | - if ($reflection->getName() === $name) { |
|
| 46 | + foreach ($constants as $reflection) |
|
| 47 | + { |
|
| 48 | + if ($reflection->getName() === $name) |
|
| 49 | + { |
|
| 48 | 50 | return $reflection; |
| 49 | 51 | } |
| 50 | 52 | } |
@@ -58,8 +60,10 @@ discard block |
||
| 58 | 60 | ->getParameters() |
| 59 | 61 | ; |
| 60 | 62 | |
| 61 | - foreach ($parameters as $reflection) { |
|
| 62 | - if ($reflection->getName() === $name) { |
|
| 63 | + foreach ($parameters as $reflection) |
|
| 64 | + { |
|
| 65 | + if ($reflection->getName() === $name) |
|
| 66 | + { |
|
| 63 | 67 | return $reflection; |
| 64 | 68 | } |
| 65 | 69 | } |
@@ -73,8 +77,10 @@ discard block |
||
| 73 | 77 | ->getParameters() |
| 74 | 78 | ; |
| 75 | 79 | |
| 76 | - foreach ($parameters as $reflection) { |
|
| 77 | - if ($reflection->getName() === $name) { |
|
| 80 | + foreach ($parameters as $reflection) |
|
| 81 | + { |
|
| 82 | + if ($reflection->getName() === $name) |
|
| 83 | + { |
|
| 78 | 84 | return $reflection; |
| 79 | 85 | } |
| 80 | 86 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected function each(callable $resolver): iterable |
| 20 | 20 | { |
| 21 | - foreach ($this->readers as $reader) { |
|
| 21 | + foreach ($this->readers as $reader){ |
|
| 22 | 22 | yield from $resolver($reader); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -18,7 +18,8 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected function each(callable $resolver): iterable |
| 20 | 20 | { |
| 21 | - foreach ($this->readers as $reader) { |
|
| 21 | + foreach ($this->readers as $reader) |
|
| 22 | + { |
|
| 22 | 23 | yield from $resolver($reader); |
| 23 | 24 | } |
| 24 | 25 | } |
@@ -18,10 +18,10 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected function each(callable $resolver): iterable |
| 20 | 20 | { |
| 21 | - foreach ($this->readers as $reader) { |
|
| 21 | + foreach ($this->readers as $reader){ |
|
| 22 | 22 | $result = $this->iterableToArray($resolver($reader)); |
| 23 | 23 | |
| 24 | - if (\count($result) > 0) { |
|
| 24 | + if (\count($result) > 0){ |
|
| 25 | 25 | return $result; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -18,10 +18,12 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected function each(callable $resolver): iterable |
| 20 | 20 | { |
| 21 | - foreach ($this->readers as $reader) { |
|
| 21 | + foreach ($this->readers as $reader) |
|
| 22 | + { |
|
| 22 | 23 | $result = $this->iterableToArray($resolver($reader)); |
| 23 | 24 | |
| 24 | - if (\count($result) > 0) { |
|
| 25 | + if (\count($result) > 0) |
|
| 26 | + { |
|
| 25 | 27 | return $result; |
| 26 | 28 | } |
| 27 | 29 | } |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 26 | 26 | { |
| 27 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 27 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)){ |
|
| 28 | 28 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 31 | + if ($constructor = $this->getTraitConstructors($class)){ |
|
| 32 | 32 | return $constructor; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($parent = $class->getParentClass()) { |
|
| 35 | + if ($parent = $class->getParentClass()){ |
|
| 36 | 36 | return $this->getConstructor($parent); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 47 | 47 | { |
| 48 | - foreach ($class->getTraits() as $trait) { |
|
| 49 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 48 | + foreach ($class->getTraits() as $trait){ |
|
| 49 | + if ($constructor = $this->getConstructor($trait)){ |
|
| 50 | 50 | return $constructor; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 53 | + if ($constructor = $this->getTraitConstructors($trait)){ |
|
| 54 | 54 | return $constructor; |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -24,15 +24,18 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getConstructor(\ReflectionClass $class): ?\ReflectionMethod |
| 26 | 26 | { |
| 27 | - if ($class->hasMethod(self::CONSTRUCTOR_NAME)) { |
|
| 27 | + if ($class->hasMethod(self::CONSTRUCTOR_NAME)) |
|
| 28 | + { |
|
| 28 | 29 | return $class->getMethod(self::CONSTRUCTOR_NAME); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - if ($constructor = $this->getTraitConstructors($class)) { |
|
| 32 | + if ($constructor = $this->getTraitConstructors($class)) |
|
| 33 | + { |
|
| 32 | 34 | return $constructor; |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | - if ($parent = $class->getParentClass()) { |
|
| 37 | + if ($parent = $class->getParentClass()) |
|
| 38 | + { |
|
| 36 | 39 | return $this->getConstructor($parent); |
| 37 | 40 | } |
| 38 | 41 | |
@@ -45,12 +48,15 @@ discard block |
||
| 45 | 48 | */ |
| 46 | 49 | private function getTraitConstructors(\ReflectionClass $class): ?\ReflectionMethod |
| 47 | 50 | { |
| 48 | - foreach ($class->getTraits() as $trait) { |
|
| 49 | - if ($constructor = $this->getConstructor($trait)) { |
|
| 51 | + foreach ($class->getTraits() as $trait) |
|
| 52 | + { |
|
| 53 | + if ($constructor = $this->getConstructor($trait)) |
|
| 54 | + { |
|
| 50 | 55 | return $constructor; |
| 51 | 56 | } |
| 52 | 57 | |
| 53 | - if ($constructor = $this->getTraitConstructors($trait)) { |
|
| 58 | + if ($constructor = $this->getTraitConstructors($trait)) |
|
| 59 | + { |
|
| 54 | 60 | return $constructor; |
| 55 | 61 | } |
| 56 | 62 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @var string |
| 31 | 31 | */ |
| 32 | 32 | private const ERROR_INVALID_PROPERTY = |
| 33 | - 'The attribute #[%s] declared on %s does not have a property named "%s".' . "\n" . |
|
| 33 | + 'The attribute #[%s] declared on %s does not have a property named "%s".'."\n". |
|
| 34 | 34 | 'Available properties: %s' |
| 35 | 35 | ; |
| 36 | 36 | |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | $arguments = $this->formatArguments($arguments); |
| 62 | 62 | |
| 63 | 63 | // Using constructor |
| 64 | - if ($this->getConstructor($attr)) { |
|
| 64 | + if ($this->getConstructor($attr)){ |
|
| 65 | 65 | return $attr->newInstance($arguments); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Using direct insert |
| 69 | 69 | $instance = $attr->newInstanceWithoutConstructor(); |
| 70 | 70 | |
| 71 | - foreach ($arguments as $name => $value) { |
|
| 72 | - try { |
|
| 71 | + foreach ($arguments as $name => $value){ |
|
| 72 | + try{ |
|
| 73 | 73 | $property = $attr->getProperty($name); |
| 74 | 74 | |
| 75 | - if (!$property->isPublic()) { |
|
| 75 | + if (!$property->isPublic()){ |
|
| 76 | 76 | throw $this->propertyNotFound($attr, $name, $context); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $instance->$name = $value; |
| 80 | - } catch (\Throwable $e) { |
|
| 80 | + }catch (\Throwable $e){ |
|
| 81 | 81 | throw $this->propertyNotFound($attr, $name, $context); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $result = []; |
| 95 | 95 | |
| 96 | - foreach ($arguments as $name => $value) { |
|
| 97 | - if (\is_int($name)) { |
|
| 96 | + foreach ($arguments as $name => $value){ |
|
| 97 | + if (\is_int($name)){ |
|
| 98 | 98 | $this->validateArgumentPosition($name, $value); |
| 99 | 99 | |
| 100 | 100 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | private function validateArgumentPosition(int $index, $value): void |
| 114 | 114 | { |
| 115 | - if ($index === 0) { |
|
| 115 | + if ($index === 0){ |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -61,23 +61,29 @@ discard block |
||
| 61 | 61 | $arguments = $this->formatArguments($arguments); |
| 62 | 62 | |
| 63 | 63 | // Using constructor |
| 64 | - if ($this->getConstructor($attr)) { |
|
| 64 | + if ($this->getConstructor($attr)) |
|
| 65 | + { |
|
| 65 | 66 | return $attr->newInstance($arguments); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | // Using direct insert |
| 69 | 70 | $instance = $attr->newInstanceWithoutConstructor(); |
| 70 | 71 | |
| 71 | - foreach ($arguments as $name => $value) { |
|
| 72 | - try { |
|
| 72 | + foreach ($arguments as $name => $value) |
|
| 73 | + { |
|
| 74 | + try |
|
| 75 | + { |
|
| 73 | 76 | $property = $attr->getProperty($name); |
| 74 | 77 | |
| 75 | - if (!$property->isPublic()) { |
|
| 78 | + if (!$property->isPublic()) |
|
| 79 | + { |
|
| 76 | 80 | throw $this->propertyNotFound($attr, $name, $context); |
| 77 | 81 | } |
| 78 | 82 | |
| 79 | 83 | $instance->$name = $value; |
| 80 | - } catch (\Throwable $e) { |
|
| 84 | + } |
|
| 85 | + catch (\Throwable $e) |
|
| 86 | + { |
|
| 81 | 87 | throw $this->propertyNotFound($attr, $name, $context); |
| 82 | 88 | } |
| 83 | 89 | } |
@@ -93,8 +99,10 @@ discard block |
||
| 93 | 99 | { |
| 94 | 100 | $result = []; |
| 95 | 101 | |
| 96 | - foreach ($arguments as $name => $value) { |
|
| 97 | - if (\is_int($name)) { |
|
| 102 | + foreach ($arguments as $name => $value) |
|
| 103 | + { |
|
| 104 | + if (\is_int($name)) |
|
| 105 | + { |
|
| 98 | 106 | $this->validateArgumentPosition($name, $value); |
| 99 | 107 | |
| 100 | 108 | $name = self::DEFAULT_PROPERTY_NAME; |
@@ -112,7 +120,8 @@ discard block |
||
| 112 | 120 | */ |
| 113 | 121 | private function validateArgumentPosition(int $index, $value): void |
| 114 | 122 | { |
| 115 | - if ($index === 0) { |
|
| 123 | + if ($index === 0) |
|
| 124 | + { |
|
| 116 | 125 | return; |
| 117 | 126 | } |
| 118 | 127 | |
@@ -26,14 +26,14 @@ |
||
| 26 | 26 | public function setUp(): void |
| 27 | 27 | { |
| 28 | 28 | $this->app = App::init([ |
| 29 | - 'root' => __DIR__ . '/App', |
|
| 30 | - 'app' => __DIR__ . '/App' |
|
| 29 | + 'root' => __DIR__.'/App', |
|
| 30 | + 'app' => __DIR__.'/App' |
|
| 31 | 31 | ]); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function tearDown(): void |
| 35 | 35 | { |
| 36 | - foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) { |
|
| 36 | + foreach (glob(__DIR__.'/App/runtime/cache/views/*.php') as $file){ |
|
| 37 | 37 | @unlink($file); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function tearDown(): void |
| 35 | 35 | { |
| 36 | - foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) { |
|
| 36 | + foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) |
|
| 37 | + { |
|
| 37 | 38 | @unlink($file); |
| 38 | 39 | } |
| 39 | 40 | } |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | $container->bindSingleton(ReaderInterface::class, function () use ($container) { |
| 29 | 29 | $factory = new Factory(); |
| 30 | 30 | |
| 31 | - if ($container->has(CacheInterface::class)) { |
|
| 31 | + if ($container->has(CacheInterface::class)){ |
|
| 32 | 32 | $factory = $factory->withCache( |
| 33 | 33 | $container->get(CacheInterface::class) |
| 34 | 34 | ); |
| 35 | - } elseif ($container->has(CacheItemInterface::class)) { |
|
| 35 | + } elseif ($container->has(CacheItemInterface::class)){ |
|
| 36 | 36 | $factory = $factory->withCache( |
| 37 | 37 | $container->get(CacheItemInterface::class) |
| 38 | 38 | ); |
@@ -25,14 +25,18 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function boot(Container $container): void |
| 27 | 27 | { |
| 28 | - $container->bindSingleton(ReaderInterface::class, function () use ($container) { |
|
| 28 | + $container->bindSingleton(ReaderInterface::class, function () use ($container) |
|
| 29 | + { |
|
| 29 | 30 | $factory = new Factory(); |
| 30 | 31 | |
| 31 | - if ($container->has(CacheInterface::class)) { |
|
| 32 | + if ($container->has(CacheInterface::class)) |
|
| 33 | + { |
|
| 32 | 34 | $factory = $factory->withCache( |
| 33 | 35 | $container->get(CacheInterface::class) |
| 34 | 36 | ); |
| 35 | - } elseif ($container->has(CacheItemInterface::class)) { |
|
| 37 | + } |
|
| 38 | + elseif ($container->has(CacheItemInterface::class)) |
|
| 39 | + { |
|
| 36 | 40 | $factory = $factory->withCache( |
| 37 | 41 | $container->get(CacheItemInterface::class) |
| 38 | 42 | ); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function testCache(): void |
| 26 | 26 | { |
| 27 | - $cache = __DIR__ . '/App/runtime/cache/routes.php'; |
|
| 27 | + $cache = __DIR__.'/App/runtime/cache/routes.php'; |
|
| 28 | 28 | $this->assertFileExists($cache); |
| 29 | 29 | |
| 30 | 30 | $this->assertIsIterable($this->include($cache)); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | private function include(string $file) |
| 45 | 45 | { |
| 46 | 46 | // Required when "opcache.cli_enabled=1" |
| 47 | - if (\function_exists('\\opcache_invalidate')) { |
|
| 47 | + if (\function_exists('\\opcache_invalidate')){ |
|
| 48 | 48 | \opcache_invalidate($file); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -44,7 +44,8 @@ |
||
| 44 | 44 | private function include(string $file) |
| 45 | 45 | { |
| 46 | 46 | // Required when "opcache.cli_enabled=1" |
| 47 | - if (\function_exists('\\opcache_invalidate')) { |
|
| 47 | + if (\function_exists('\\opcache_invalidate')) |
|
| 48 | + { |
|
| 48 | 49 | \opcache_invalidate($file); |
| 49 | 50 | } |
| 50 | 51 | |