@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | public function baz(string $name, int $age): string; |
14 | 14 | |
15 | - public function qux(string|int $age = 42): string|int; |
|
15 | + public function qux(string | int $age = 42): string | int; |
|
16 | 16 | |
17 | 17 | public function space(mixed $test age = 42): mixed; |
18 | 18 |
@@ -6,5 +6,5 @@ |
||
6 | 6 | |
7 | 7 | interface ContextInterface |
8 | 8 | { |
9 | - public function getValue(): \Stringable|string|null; |
|
9 | + public function getValue(): \Stringable | string | null; |
|
10 | 10 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | trait ProxyTrait |
13 | 13 | { |
14 | 14 | private static string $__container_proxy_alias; |
15 | - private \Stringable|string|null $__container_proxy_context = null; |
|
15 | + private \Stringable | string | null $__container_proxy_context = null; |
|
16 | 16 | private ?ContainerInterface $__container_proxy_container = null; |
17 | 17 | } |
@@ -37,9 +37,11 @@ discard block |
||
37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
38 | 38 | ); |
39 | 39 | |
40 | - if (!\array_key_exists($cacheKey, self::$classes)) { |
|
40 | + if (!\array_key_exists($cacheKey, self::$classes)) |
|
41 | + { |
|
41 | 42 | $n = 0; |
42 | - do { |
|
43 | + do |
|
44 | + { |
|
43 | 45 | $className = \sprintf( |
44 | 46 | '%s\%s SCOPED PROXY%s', |
45 | 47 | $type->getNamespaceName(), |
@@ -49,7 +51,8 @@ discard block |
||
49 | 51 | } while (\class_exists($className)); |
50 | 52 | |
51 | 53 | /** @var class-string<TClass> $className */ |
52 | - try { |
|
54 | + try |
|
55 | + { |
|
53 | 56 | $classString = ProxyClassRenderer::renderClass( |
54 | 57 | $type, |
55 | 58 | $className, |
@@ -58,7 +61,9 @@ discard block |
||
58 | 61 | ); |
59 | 62 | |
60 | 63 | eval($classString); |
61 | - } catch (\Throwable $e) { |
|
64 | + } |
|
65 | + catch (\Throwable $e) |
|
66 | + { |
|
62 | 67 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
63 | 68 | } |
64 | 69 | |
@@ -67,12 +72,15 @@ discard block |
||
67 | 72 | |
68 | 73 | // Store in cache without context |
69 | 74 | self::$classes[$cacheKey] = $className; |
70 | - } else { |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
71 | 78 | /** @var TClass $instance */ |
72 | 79 | $instance = new (self::$classes[$cacheKey])(); |
73 | 80 | } |
74 | 81 | |
75 | - if ($context !== null || $attachContainer) { |
|
82 | + if ($context !== null || $attachContainer) |
|
83 | + { |
|
76 | 84 | (static function () use ($instance, $context, $attachContainer): void { |
77 | 85 | // Set the Current Context |
78 | 86 | /** @see \Spiral\Core\Internal\Proxy\ProxyTrait::$__container_proxy_context */ |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function create( |
24 | 24 | \ReflectionClass $type, |
25 | - \Stringable|string|null $context, |
|
25 | + \Stringable | string | null $context, |
|
26 | 26 | \Spiral\Core\Attribute\Proxy $attribute, |
27 | 27 | ): object { |
28 | 28 | $interface = $type->getName(); |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
38 | 38 | ); |
39 | 39 | |
40 | - if (!\array_key_exists($cacheKey, self::$classes)) { |
|
40 | + if (!\array_key_exists($cacheKey, self::$classes)){ |
|
41 | 41 | $n = 0; |
42 | - do { |
|
42 | + do{ |
|
43 | 43 | $className = \sprintf( |
44 | 44 | '%s\%s SCOPED PROXY%s', |
45 | 45 | $type->getNamespaceName(), |
46 | 46 | $type->getShortName(), |
47 | 47 | $n++ > 0 ? " {$n}" : '', |
48 | 48 | ); |
49 | - } while (\class_exists($className)); |
|
49 | + }while (\class_exists($className)); |
|
50 | 50 | |
51 | 51 | /** @var class-string<TClass> $className */ |
52 | - try { |
|
52 | + try{ |
|
53 | 53 | $classString = ProxyClassRenderer::renderClass( |
54 | 54 | $type, |
55 | 55 | $className, |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | eval($classString); |
61 | - } catch (\Throwable $e) { |
|
61 | + }catch (\Throwable $e){ |
|
62 | 62 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
63 | 63 | } |
64 | 64 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | // Store in cache without context |
69 | 69 | self::$classes[$cacheKey] = $className; |
70 | - } else { |
|
70 | + }else{ |
|
71 | 71 | /** @var TClass $instance */ |
72 | 72 | $instance = new (self::$classes[$cacheKey])(); |
73 | 73 | } |
74 | 74 | |
75 | - if ($context !== null || $attachContainer) { |
|
75 | + if ($context !== null || $attachContainer){ |
|
76 | 76 | (static function () use ($instance, $context, $attachContainer): void { |
77 | 77 | // Set the Current Context |
78 | 78 | /** @see \Spiral\Core\Internal\Proxy\ProxyTrait::$__container_proxy_context */ |
@@ -46,7 +46,9 @@ |
||
46 | 46 | $binder = $this->constructor->get('binder', BinderInterface::class); |
47 | 47 | $factory = $this->constructor->get('factory', FactoryInterface::class); |
48 | 48 | |
49 | - $this->bindSingleton('test', new #[Singleton] class {}); |
|
49 | + $this->bindSingleton('test', new #[Singleton] class |
|
50 | + { |
|
51 | +}); |
|
50 | 52 | $factory->make('test'); |
51 | 53 | |
52 | 54 | $this->assertTrue($binder->hasInstance('test')); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | #[Route('/page/<page>', name: 'page_get', methods: 'GET')] |
12 | 12 | public function get($page): string |
13 | 13 | { |
14 | - return 'page-' . $page; |
|
14 | + return 'page-'.$page; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | #[Route('/page/about', name: 'page_about', methods: 'GET', priority: -1)] |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use DestructorTrait; |
20 | 20 | |
21 | 21 | private State $state; |
22 | - private FactoryInterface|Factory $factory; |
|
22 | + private FactoryInterface | Factory $factory; |
|
23 | 23 | private Scope $scope; |
24 | 24 | |
25 | 25 | public function __construct(Registry $constructor) |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @throws ContainerException |
50 | 50 | * @throws \Throwable |
51 | 51 | */ |
52 | - public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
|
52 | + public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed |
|
53 | 53 | { |
54 | - if ($id instanceof Autowire) { |
|
54 | + if ($id instanceof Autowire){ |
|
55 | 55 | return $id->resolve($this->factory); |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function has(string $id): bool |
63 | 63 | { |
64 | - if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) { |
|
64 | + if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)){ |
|
65 | 65 | return true; |
66 | 66 | } |
67 | 67 |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
53 | 53 | { |
54 | - if ($id instanceof Autowire) { |
|
54 | + if ($id instanceof Autowire) |
|
55 | + { |
|
55 | 56 | return $id->resolve($this->factory); |
56 | 57 | } |
57 | 58 | |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | |
62 | 63 | public function has(string $id): bool |
63 | 64 | { |
64 | - if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) { |
|
65 | + if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) |
|
66 | + { |
|
65 | 67 | return true; |
66 | 68 | } |
67 | 69 |
@@ -32,35 +32,35 @@ |
||
32 | 32 | $available = $config->getDeclarations(); |
33 | 33 | |
34 | 34 | $i = 0; |
35 | - foreach ($available as $name) { |
|
36 | - $command = 'create:' . $name; |
|
35 | + foreach ($available as $name){ |
|
36 | + $command = 'create:'.$name; |
|
37 | 37 | |
38 | - if (!$console->getApplication()->has($command)) { |
|
38 | + if (!$console->getApplication()->has($command)){ |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $command = $console->getApplication()->get($command); |
43 | 43 | |
44 | - if ($i > 0) { |
|
44 | + if ($i > 0){ |
|
45 | 45 | $table->addRow(new TableSeparator()); |
46 | 46 | } |
47 | 47 | $declaration = $config->getDeclaration($name); |
48 | 48 | |
49 | 49 | $options = []; |
50 | - foreach ($declaration['options'] ?? [] as $key => $value) { |
|
51 | - $options[] = $key . ': <fg=yellow>' . \json_encode(\str_replace($rootDir, '', $value)) . '</>'; |
|
50 | + foreach ($declaration['options'] ?? [] as $key => $value){ |
|
51 | + $options[] = $key.': <fg=yellow>'.\json_encode(\str_replace($rootDir, '', $value)).'</>'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $file = \str_replace($rootDir, '', $config->classFilename($name, $this->name)); |
55 | 55 | $namespace = $config->classNamespace($name, $this->name); |
56 | 56 | $table->addRow([ |
57 | - $command->getName() . "\n<fg=gray>{$command->getDescription()}</>", |
|
57 | + $command->getName()."\n<fg=gray>{$command->getDescription()}</>", |
|
58 | 58 | <<<TARGET |
59 | 59 | path: <fg=green>/$file</> |
60 | 60 | namespace: <fg=yellow>$namespace</> |
61 | 61 | TARGET |
62 | 62 | . |
63 | - ($options !== [] ? "\n" . \implode("\n", $options) : ''), |
|
63 | + ($options !== [] ? "\n".\implode("\n", $options) : ''), |
|
64 | 64 | ]); |
65 | 65 | |
66 | 66 | $i++; |
@@ -32,22 +32,26 @@ |
||
32 | 32 | $available = $config->getDeclarations(); |
33 | 33 | |
34 | 34 | $i = 0; |
35 | - foreach ($available as $name) { |
|
35 | + foreach ($available as $name) |
|
36 | + { |
|
36 | 37 | $command = 'create:' . $name; |
37 | 38 | |
38 | - if (!$console->getApplication()->has($command)) { |
|
39 | + if (!$console->getApplication()->has($command)) |
|
40 | + { |
|
39 | 41 | continue; |
40 | 42 | } |
41 | 43 | |
42 | 44 | $command = $console->getApplication()->get($command); |
43 | 45 | |
44 | - if ($i > 0) { |
|
46 | + if ($i > 0) |
|
47 | + { |
|
45 | 48 | $table->addRow(new TableSeparator()); |
46 | 49 | } |
47 | 50 | $declaration = $config->getDeclaration($name); |
48 | 51 | |
49 | 52 | $options = []; |
50 | - foreach ($declaration['options'] ?? [] as $key => $value) { |
|
53 | + foreach ($declaration['options'] ?? [] as $key => $value) |
|
54 | + { |
|
51 | 55 | $options[] = $key . ': <fg=yellow>' . \json_encode(\str_replace($rootDir, '', $value)) . '</>'; |
52 | 56 | } |
53 | 57 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | <<<TARGET |
59 | 59 | path: <fg=green>/$file</> |
60 | 60 | namespace: <fg=yellow>$namespace</> |
61 | -TARGET |
|
61 | +target |
|
62 | 62 | . |
63 | 63 | ($options !== [] ? "\n" . \implode("\n", $options) : ''), |
64 | 64 | ]); |
@@ -12,11 +12,11 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | string $interface, |
14 | 14 | bool $singleton = false, |
15 | - private readonly string|\BackedEnum|null $scope = null, |
|
15 | + private readonly string | \BackedEnum | null $scope = null, |
|
16 | 16 | private readonly ?string $version = null, |
17 | 17 | private readonly ?string $message = null, |
18 | - ) { |
|
19 | - if (($scope === null || $version === null) && $message === null) { |
|
18 | + ){ |
|
19 | + if (($scope === null || $version === null) && $message === null){ |
|
20 | 20 | throw new \InvalidArgumentException('Scope and version or custom message must be provided.'); |
21 | 21 | } |
22 | 22 |
@@ -16,7 +16,8 @@ |
||
16 | 16 | private readonly ?string $version = null, |
17 | 17 | private readonly ?string $message = null, |
18 | 18 | ) { |
19 | - if (($scope === null || $version === null) && $message === null) { |
|
19 | + if (($scope === null || $version === null) && $message === null) |
|
20 | + { |
|
20 | 21 | throw new \InvalidArgumentException('Scope and version or custom message must be provided.'); |
21 | 22 | } |
22 | 23 |