@@ -72,7 +72,7 @@ |
||
72 | 72 | { |
73 | 73 | $param = PromotedParameter::fromElement($this->element->addPromotedParameter($name)); |
74 | 74 | |
75 | - if (\func_num_args() > 1) { |
|
75 | + if (\func_num_args() > 1){ |
|
76 | 76 | $param->setDefaultValue($defaultValue); |
77 | 77 | } |
78 | 78 |
@@ -72,7 +72,8 @@ |
||
72 | 72 | { |
73 | 73 | $param = PromotedParameter::fromElement($this->element->addPromotedParameter($name)); |
74 | 74 | |
75 | - if (\func_num_args() > 1) { |
|
75 | + if (\func_num_args() > 1) |
|
76 | + { |
|
76 | 77 | $param->setDefaultValue($defaultValue); |
77 | 78 | } |
78 | 79 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace Spiral\Scaffolder; |
6 | 6 | |
7 | -if (!\function_exists('trimPostfix')) { |
|
7 | +if (!\function_exists('trimPostfix')){ |
|
8 | 8 | /** |
9 | 9 | * @internal |
10 | 10 | */ |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | } |
17 | 17 | } |
18 | 18 | |
19 | -if (!\function_exists('defineArrayType')) { |
|
19 | +if (!\function_exists('defineArrayType')){ |
|
20 | 20 | /** |
21 | 21 | * @internal |
22 | 22 | */ |
23 | 23 | function defineArrayType(array $array, string $failureType = null): ?string |
24 | 24 | { |
25 | - $types = \array_map(static fn ($value): string => \gettype($value), $array); |
|
25 | + $types = \array_map(static fn ($value) : string => \gettype($value), $array); |
|
26 | 26 | |
27 | 27 | $types = \array_unique($types); |
28 | 28 |
@@ -4,7 +4,8 @@ discard block |
||
4 | 4 | |
5 | 5 | namespace Spiral\Scaffolder; |
6 | 6 | |
7 | -if (!\function_exists('trimPostfix')) { |
|
7 | +if (!\function_exists('trimPostfix')) |
|
8 | +{ |
|
8 | 9 | /** |
9 | 10 | * @internal |
10 | 11 | */ |
@@ -16,7 +17,8 @@ discard block |
||
16 | 17 | } |
17 | 18 | } |
18 | 19 | |
19 | -if (!\function_exists('defineArrayType')) { |
|
20 | +if (!\function_exists('defineArrayType')) |
|
21 | +{ |
|
20 | 22 | /** |
21 | 23 | * @internal |
22 | 24 | */ |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | protected CacheInterface $storage, |
21 | 21 | protected ?EventDispatcherInterface $dispatcher = null, |
22 | 22 | protected ?string $prefix = null |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function get(string $key, mixed $default = null): mixed |
27 | 27 | { |
28 | 28 | $value = $this->storage->get($this->resolveKey($key)); |
29 | 29 | |
30 | - if ($value === null) { |
|
30 | + if ($value === null){ |
|
31 | 31 | $this->dispatcher?->dispatch(new CacheMissed($this->resolveKey($key))); |
32 | 32 | |
33 | 33 | return $default; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | return $value; |
39 | 39 | } |
40 | 40 | |
41 | - public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool |
|
41 | + public function set(string $key, mixed $value, \DateInterval | int | null $ttl = null): bool |
|
42 | 42 | { |
43 | 43 | $result = $this->storage->set($this->resolveKey($key), $value, $ttl); |
44 | 44 | |
45 | - if ($result) { |
|
45 | + if ($result){ |
|
46 | 46 | $this->dispatcher?->dispatch(new KeyWritten($this->resolveKey($key), $value)); |
47 | 47 | } |
48 | 48 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $result = $this->storage->delete($this->resolveKey($key)); |
55 | 55 | |
56 | - if ($result) { |
|
56 | + if ($result){ |
|
57 | 57 | $this->dispatcher?->dispatch(new KeyDeleted($this->resolveKey($key))); |
58 | 58 | } |
59 | 59 | |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | { |
70 | 70 | $result = []; |
71 | 71 | |
72 | - foreach ($keys as $key) { |
|
72 | + foreach ($keys as $key){ |
|
73 | 73 | $result[$key] = $this->get($key, $default); |
74 | 74 | } |
75 | 75 | |
76 | 76 | return $result; |
77 | 77 | } |
78 | 78 | |
79 | - public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool |
|
79 | + public function setMultiple(iterable $values, \DateInterval | int | null $ttl = null): bool |
|
80 | 80 | { |
81 | 81 | $state = null; |
82 | 82 | |
83 | - foreach ($values as $key => $value) { |
|
83 | + foreach ($values as $key => $value){ |
|
84 | 84 | $result = $this->set($key, $value, $ttl); |
85 | 85 | $state = \is_null($state) ? $result : $result && $state; |
86 | 86 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function deleteMultiple(iterable $keys): bool |
92 | 92 | { |
93 | 93 | $state = null; |
94 | - foreach ($keys as $key) { |
|
94 | + foreach ($keys as $key){ |
|
95 | 95 | $result = $this->delete($key); |
96 | 96 | $state = \is_null($state) ? $result : $result && $state; |
97 | 97 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | |
112 | 112 | private function resolveKey(string $key): string |
113 | 113 | { |
114 | - if (!empty($this->prefix)) { |
|
115 | - return $this->prefix . $key; |
|
114 | + if (!empty($this->prefix)){ |
|
115 | + return $this->prefix.$key; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $key; |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | { |
28 | 28 | $value = $this->storage->get($this->resolveKey($key)); |
29 | 29 | |
30 | - if ($value === null) { |
|
30 | + if ($value === null) |
|
31 | + { |
|
31 | 32 | $this->dispatcher?->dispatch(new CacheMissed($this->resolveKey($key))); |
32 | 33 | |
33 | 34 | return $default; |
@@ -42,7 +43,8 @@ discard block |
||
42 | 43 | { |
43 | 44 | $result = $this->storage->set($this->resolveKey($key), $value, $ttl); |
44 | 45 | |
45 | - if ($result) { |
|
46 | + if ($result) |
|
47 | + { |
|
46 | 48 | $this->dispatcher?->dispatch(new KeyWritten($this->resolveKey($key), $value)); |
47 | 49 | } |
48 | 50 | |
@@ -53,7 +55,8 @@ discard block |
||
53 | 55 | { |
54 | 56 | $result = $this->storage->delete($this->resolveKey($key)); |
55 | 57 | |
56 | - if ($result) { |
|
58 | + if ($result) |
|
59 | + { |
|
57 | 60 | $this->dispatcher?->dispatch(new KeyDeleted($this->resolveKey($key))); |
58 | 61 | } |
59 | 62 | |
@@ -69,7 +72,8 @@ discard block |
||
69 | 72 | { |
70 | 73 | $result = []; |
71 | 74 | |
72 | - foreach ($keys as $key) { |
|
75 | + foreach ($keys as $key) |
|
76 | + { |
|
73 | 77 | $result[$key] = $this->get($key, $default); |
74 | 78 | } |
75 | 79 | |
@@ -80,7 +84,8 @@ discard block |
||
80 | 84 | { |
81 | 85 | $state = null; |
82 | 86 | |
83 | - foreach ($values as $key => $value) { |
|
87 | + foreach ($values as $key => $value) |
|
88 | + { |
|
84 | 89 | $result = $this->set($key, $value, $ttl); |
85 | 90 | $state = \is_null($state) ? $result : $result && $state; |
86 | 91 | } |
@@ -91,7 +96,8 @@ discard block |
||
91 | 96 | public function deleteMultiple(iterable $keys): bool |
92 | 97 | { |
93 | 98 | $state = null; |
94 | - foreach ($keys as $key) { |
|
99 | + foreach ($keys as $key) |
|
100 | + { |
|
95 | 101 | $result = $this->delete($key); |
96 | 102 | $state = \is_null($state) ? $result : $result && $state; |
97 | 103 | } |
@@ -111,7 +117,8 @@ discard block |
||
111 | 117 | |
112 | 118 | private function resolveKey(string $key): string |
113 | 119 | { |
114 | - if (!empty($this->prefix)) { |
|
120 | + if (!empty($this->prefix)) |
|
121 | + { |
|
115 | 122 | return $this->prefix . $key; |
116 | 123 | } |
117 | 124 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | private readonly CacheConfig $config, |
20 | 20 | private readonly FactoryInterface $factory, |
21 | 21 | private readonly ?EventDispatcherInterface $dispatcher = null, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function storage(?string $name = null): CacheInterface |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | $storage = $this->config->getAliases()[$name] ?? $name; |
31 | 31 | |
32 | 32 | $prefix = null; |
33 | - if (\is_array($storage)) { |
|
33 | + if (\is_array($storage)){ |
|
34 | 34 | $prefix = !empty($storage['prefix']) ? $storage['prefix'] : null; |
35 | 35 | $storage = $storage['storage']; |
36 | 36 | } |
37 | 37 | |
38 | - if (!isset($this->storages[$storage])) { |
|
38 | + if (!isset($this->storages[$storage])){ |
|
39 | 39 | $this->storages[$storage] = $this->resolve($storage); |
40 | 40 | } |
41 | 41 |
@@ -30,12 +30,14 @@ |
||
30 | 30 | $storage = $this->config->getAliases()[$name] ?? $name; |
31 | 31 | |
32 | 32 | $prefix = null; |
33 | - if (\is_array($storage)) { |
|
33 | + if (\is_array($storage)) |
|
34 | + { |
|
34 | 35 | $prefix = !empty($storage['prefix']) ? $storage['prefix'] : null; |
35 | 36 | $storage = $storage['storage']; |
36 | 37 | } |
37 | 38 | |
38 | - if (!isset($this->storages[$storage])) { |
|
39 | + if (!isset($this->storages[$storage])) |
|
40 | + { |
|
39 | 41 | $this->storages[$storage] = $this->resolve($storage); |
40 | 42 | } |
41 | 43 |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | public function __construct( |
24 | 24 | public readonly ReflectionFunctionAbstract $reflection, |
25 | 25 | private array $arguments, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->modeNamed = $this->isNamedMode(); |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function addResolvedValue(mixed &$value, string $key = null): void |
31 | 31 | { |
32 | - if ($key === null) { |
|
32 | + if ($key === null){ |
|
33 | 33 | $this->resolvedValues[] = &$value; |
34 | - } else { |
|
34 | + }else{ |
|
35 | 35 | $this->resolvedValues[$key] = &$value; |
36 | 36 | } |
37 | 37 | } |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | ? $parameter->getName() |
43 | 43 | : $parameter->getPosition(); |
44 | 44 | |
45 | - if (!\array_key_exists($key, $this->arguments)) { |
|
45 | + if (!\array_key_exists($key, $this->arguments)){ |
|
46 | 46 | return []; |
47 | 47 | } |
48 | 48 | $_val = &$this->arguments[$key]; |
49 | 49 | |
50 | - if ($variadic && \is_array($_val)) { |
|
50 | + if ($variadic && \is_array($_val)){ |
|
51 | 51 | // Save keys is possible |
52 | 52 | $positional = true; |
53 | 53 | $result = []; |
54 | - foreach ($_val as $key => &$item) { |
|
55 | - if (!$positional && \is_int($key)) { |
|
54 | + foreach ($_val as $key => &$item){ |
|
55 | + if (!$positional && \is_int($key)){ |
|
56 | 56 | throw new ResolvingException( |
57 | 57 | 'Cannot use positional argument after named argument during unpacking named variadic argument.' |
58 | 58 | ); |
59 | 59 | } |
60 | 60 | $positional = $positional && \is_int($key); |
61 | - if ($positional) { |
|
61 | + if ($positional){ |
|
62 | 62 | $result[] = &$item; |
63 | - } else { |
|
63 | + }else{ |
|
64 | 64 | $result[$key] = &$item; |
65 | 65 | } |
66 | 66 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | { |
79 | 79 | $nums = 0; |
80 | 80 | $strings = 0; |
81 | - foreach ($this->arguments as $key => $_) { |
|
82 | - if (\is_int($key)) { |
|
81 | + foreach ($this->arguments as $key => $_){ |
|
82 | + if (\is_int($key)){ |
|
83 | 83 | ++$nums; |
84 | - } else { |
|
84 | + }else{ |
|
85 | 85 | ++$strings; |
86 | 86 | } |
87 | 87 | } |
@@ -29,9 +29,12 @@ discard block |
||
29 | 29 | |
30 | 30 | public function addResolvedValue(mixed &$value, string $key = null): void |
31 | 31 | { |
32 | - if ($key === null) { |
|
32 | + if ($key === null) |
|
33 | + { |
|
33 | 34 | $this->resolvedValues[] = &$value; |
34 | - } else { |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
35 | 38 | $this->resolvedValues[$key] = &$value; |
36 | 39 | } |
37 | 40 | } |
@@ -42,25 +45,32 @@ discard block |
||
42 | 45 | ? $parameter->getName() |
43 | 46 | : $parameter->getPosition(); |
44 | 47 | |
45 | - if (!\array_key_exists($key, $this->arguments)) { |
|
48 | + if (!\array_key_exists($key, $this->arguments)) |
|
49 | + { |
|
46 | 50 | return []; |
47 | 51 | } |
48 | 52 | $_val = &$this->arguments[$key]; |
49 | 53 | |
50 | - if ($variadic && \is_array($_val)) { |
|
54 | + if ($variadic && \is_array($_val)) |
|
55 | + { |
|
51 | 56 | // Save keys is possible |
52 | 57 | $positional = true; |
53 | 58 | $result = []; |
54 | - foreach ($_val as $key => &$item) { |
|
55 | - if (!$positional && \is_int($key)) { |
|
59 | + foreach ($_val as $key => &$item) |
|
60 | + { |
|
61 | + if (!$positional && \is_int($key)) |
|
62 | + { |
|
56 | 63 | throw new ResolvingException( |
57 | 64 | 'Cannot use positional argument after named argument during unpacking named variadic argument.' |
58 | 65 | ); |
59 | 66 | } |
60 | 67 | $positional = $positional && \is_int($key); |
61 | - if ($positional) { |
|
68 | + if ($positional) |
|
69 | + { |
|
62 | 70 | $result[] = &$item; |
63 | - } else { |
|
71 | + } |
|
72 | + else |
|
73 | + { |
|
64 | 74 | $result[$key] = &$item; |
65 | 75 | } |
66 | 76 | } |
@@ -78,10 +88,14 @@ discard block |
||
78 | 88 | { |
79 | 89 | $nums = 0; |
80 | 90 | $strings = 0; |
81 | - foreach ($this->arguments as $key => $_) { |
|
82 | - if (\is_int($key)) { |
|
91 | + foreach ($this->arguments as $key => $_) |
|
92 | + { |
|
93 | + if (\is_int($key)) |
|
94 | + { |
|
83 | 95 | ++$nums; |
84 | - } else { |
|
96 | + } |
|
97 | + else |
|
98 | + { |
|
85 | 99 | ++$strings; |
86 | 100 | } |
87 | 101 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | public function destruct(): void |
13 | 13 | { |
14 | 14 | $class = new \ReflectionClass($this); |
15 | - foreach ($class->getProperties() as $property) { |
|
15 | + foreach ($class->getProperties() as $property){ |
|
16 | 16 | $name = $property->getName(); |
17 | - if (!isset($this->$name)) { |
|
17 | + if (!isset($this->$name)){ |
|
18 | 18 | continue; |
19 | 19 | } |
20 | 20 | $value = $this->$name; |
21 | 21 | unset($this->$name); |
22 | - if (\is_object($value) && \method_exists($value, 'destruct')) { |
|
22 | + if (\is_object($value) && \method_exists($value, 'destruct')){ |
|
23 | 23 | $value->destruct(); |
24 | 24 | } |
25 | 25 | } |
@@ -12,14 +12,17 @@ |
||
12 | 12 | public function destruct(): void |
13 | 13 | { |
14 | 14 | $class = new \ReflectionClass($this); |
15 | - foreach ($class->getProperties() as $property) { |
|
15 | + foreach ($class->getProperties() as $property) |
|
16 | + { |
|
16 | 17 | $name = $property->getName(); |
17 | - if (!isset($this->$name)) { |
|
18 | + if (!isset($this->$name)) |
|
19 | + { |
|
18 | 20 | continue; |
19 | 21 | } |
20 | 22 | $value = $this->$name; |
21 | 23 | unset($this->$name); |
22 | - if (\is_object($value) && \method_exists($value, 'destruct')) { |
|
24 | + if (\is_object($value) && \method_exists($value, 'destruct')) |
|
25 | + { |
|
23 | 26 | $value->destruct(); |
24 | 27 | } |
25 | 28 | } |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | public function __toString(): string |
28 | 28 | { |
29 | 29 | $info = []; |
30 | - foreach ($this->info as $key => $item) { |
|
30 | + foreach ($this->info as $key => $item) |
|
31 | + { |
|
31 | 32 | $info[] = "$key: {$this->stringifyValue($item)}"; |
32 | 33 | } |
33 | 34 | return \implode("\n", $info); |
@@ -47,14 +48,17 @@ discard block |
||
47 | 48 | |
48 | 49 | private function renderArray(array $array, int $level = 0): string |
49 | 50 | { |
50 | - if ($array === []) { |
|
51 | + if ($array === []) |
|
52 | + { |
|
51 | 53 | return '[]'; |
52 | 54 | } |
53 | - if ($level >= self::ARRAY_MAX_LEVEL) { |
|
55 | + if ($level >= self::ARRAY_MAX_LEVEL) |
|
56 | + { |
|
54 | 57 | return 'array'; |
55 | 58 | } |
56 | 59 | $result = []; |
57 | - foreach ($array as $key => $value) { |
|
60 | + foreach ($array as $key => $value) |
|
61 | + { |
|
58 | 62 | $result[] = \sprintf( |
59 | 63 | '%s: %s', |
60 | 64 | $key, |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct( |
21 | 21 | public array $info = [], |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | $this->alias = $info['alias'] ?? null; |
24 | 24 | } |
25 | 25 | |
26 | 26 | public function __toString(): string |
27 | 27 | { |
28 | 28 | $info = []; |
29 | - foreach ($this->info as $key => $item) { |
|
29 | + foreach ($this->info as $key => $item){ |
|
30 | 30 | $info[] = "$key: {$this->stringifyValue($item)}"; |
31 | 31 | } |
32 | 32 | return \implode("\n", $info); |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | \is_scalar($item) => \var_export($item, true), |
40 | 40 | $item instanceof \Closure => $this->renderClosureSignature(new \ReflectionFunction($item)), |
41 | 41 | $item instanceof \ReflectionFunctionAbstract => $this->renderClosureSignature($item), |
42 | - $item instanceof \UnitEnum => $item::class . "::$item->name", |
|
43 | - \is_object($item) => $item instanceof \Stringable ? (string) $item : 'instance of ' . $item::class, |
|
42 | + $item instanceof \UnitEnum => $item::class."::$item->name", |
|
43 | + \is_object($item) => $item instanceof \Stringable ? (string)$item : 'instance of '.$item::class, |
|
44 | 44 | \is_array($item) => $this->renderArray($item), |
45 | 45 | default => \get_debug_type($item), |
46 | 46 | }; |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | |
49 | 49 | private function renderArray(array $array, int $level = 0): string |
50 | 50 | { |
51 | - if ($array === []) { |
|
51 | + if ($array === []){ |
|
52 | 52 | return '[]'; |
53 | 53 | } |
54 | - if ($level >= self::ARRAY_MAX_LEVEL) { |
|
54 | + if ($level >= self::ARRAY_MAX_LEVEL){ |
|
55 | 55 | return 'array'; |
56 | 56 | } |
57 | 57 | $result = []; |
58 | - foreach ($array as $key => $value) { |
|
58 | + foreach ($array as $key => $value){ |
|
59 | 59 | $result[] = \sprintf( |
60 | 60 | '%s: %s', |
61 | 61 | $key, |
@@ -66,6 +66,6 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | $pad = \str_repeat(' ', $level); |
69 | - return "[\n $pad" . \implode(",\n $pad", $result) . "\n$pad]"; |
|
69 | + return "[\n $pad".\implode(",\n $pad", $result)."\n$pad]"; |
|
70 | 70 | } |
71 | 71 | } |
@@ -12,6 +12,6 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | public string $method, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | } |
@@ -10,6 +10,6 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | public DateTimeInterface $logger, |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | } |