@@ -12,7 +12,7 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | string $scope, |
14 | 14 | protected string $className, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | parent::__construct( |
17 | 17 | $scope, |
18 | 18 | \sprintf('Class `%s` can be resolved only in `%s` scope.', $className, $scope), |
@@ -16,7 +16,7 @@ |
||
16 | 16 | string $message = '', |
17 | 17 | int $code = 0, |
18 | 18 | ?\Throwable $previous = null, |
19 | - ) { |
|
19 | + ){ |
|
20 | 20 | parent::__construct( |
21 | 21 | $message, |
22 | 22 | $code, |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function __construct( |
16 | 16 | ?string $scope, |
17 | 17 | protected array $exceptions, |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | $count = \count($exceptions); |
20 | 20 | parent::__construct( |
21 | 21 | $scope, |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $count === 1 ? 'An exception has been' : "$count exceptions have been", |
25 | 25 | $scope === null ? 'an unnamed scope' : "the scope `$scope`", |
26 | 26 | \implode("\n\n", \array_map( |
27 | - static fn (Exception $e): string => \sprintf( |
|
27 | + static fn (Exception $e) : string => \sprintf( |
|
28 | 28 | "# %s\n%s", |
29 | 29 | $e::class, |
30 | 30 | $e->getMessage(), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public readonly string $binder = Binder::class, |
51 | 51 | public readonly string $invoker = Invoker::class, |
52 | 52 | public readonly string $tracer = Tracer::class, |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->scope = Scope::class; |
55 | 55 | $this->scopedBindings = new Internal\Config\StateStorage(); |
56 | 56 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function lockRoot(): bool |
76 | 76 | { |
77 | - try { |
|
77 | + try{ |
|
78 | 78 | return $this->rootLocked; |
79 | - } finally { |
|
79 | + }finally{ |
|
80 | 80 | $this->rootLocked = false; |
81 | 81 | } |
82 | 82 | } |
@@ -74,9 +74,12 @@ |
||
74 | 74 | */ |
75 | 75 | public function lockRoot(): bool |
76 | 76 | { |
77 | - try { |
|
77 | + try |
|
78 | + { |
|
78 | 79 | return $this->rootLocked; |
79 | - } finally { |
|
80 | + } |
|
81 | + finally |
|
82 | + { |
|
80 | 83 | $this->rootLocked = false; |
81 | 84 | } |
82 | 85 | } |
@@ -13,9 +13,9 @@ |
||
13 | 13 | public function __construct( |
14 | 14 | ?string $scope, |
15 | 15 | array $parents, |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | $scopes = \implode('->', \array_map( |
18 | - static fn (?string $scope): string => $scope === null ? 'null' : "\"$scope\"", |
|
18 | + static fn (?string $scope) : string => $scope === null ? 'null' : "\"$scope\"", |
|
19 | 19 | [...\array_reverse($parents), $scope], |
20 | 20 | )); |
21 | 21 | parent::__construct( |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | $this->logger = $logger; |
22 | 22 | $this->finalized = true; |
23 | - if ($this->throwException) { |
|
23 | + if ($this->throwException){ |
|
24 | 24 | throw new RuntimeException('Test exception from finalize method.'); |
25 | 25 | } |
26 | 26 | } |
@@ -20,7 +20,8 @@ |
||
20 | 20 | { |
21 | 21 | $this->logger = $logger; |
22 | 22 | $this->finalized = true; |
23 | - if ($this->throwException) { |
|
23 | + if ($this->throwException) |
|
24 | + { |
|
24 | 25 | throw new RuntimeException('Test exception from finalize method.'); |
25 | 26 | } |
26 | 27 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | #[ExpectedValues(values: [\E_USER_NOTICE, \E_USER_WARNING, \E_USER_ERROR])] |
69 | 69 | int $type |
70 | 70 | ): ?Throwable { |
71 | - $handler = (new class extends ExceptionHandler { |
|
71 | + $handler = (new class extends ExceptionHandler{ |
|
72 | 72 | public function handleError(int $errno, string $errstr, string $errfile = '', int $errline = 0): bool |
73 | 73 | { |
74 | 74 | return parent::handleError($errno, $errstr, $errfile, $errline); |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | { |
79 | 79 | } |
80 | 80 | }); |
81 | - try { |
|
81 | + try{ |
|
82 | 82 | $handler->handleError(...\array_values($this->generateErrorArray($type))); |
83 | - } catch (Throwable $e) { |
|
83 | + }catch (Throwable $e){ |
|
84 | 84 | return $e; |
85 | 85 | } |
86 | 86 | return null; |
@@ -68,7 +68,8 @@ discard block |
||
68 | 68 | #[ExpectedValues(values: [\E_USER_NOTICE, \E_USER_WARNING, \E_USER_ERROR])] |
69 | 69 | int $type |
70 | 70 | ): ?Throwable { |
71 | - $handler = (new class extends ExceptionHandler { |
|
71 | + $handler = (new class extends ExceptionHandler |
|
72 | + { |
|
72 | 73 | public function handleError(int $errno, string $errstr, string $errfile = '', int $errline = 0): bool |
73 | 74 | { |
74 | 75 | return parent::handleError($errno, $errstr, $errfile, $errline); |
@@ -78,9 +79,12 @@ discard block |
||
78 | 79 | { |
79 | 80 | } |
80 | 81 | }); |
81 | - try { |
|
82 | + try |
|
83 | + { |
|
82 | 84 | $handler->handleError(...\array_values($this->generateErrorArray($type))); |
83 | - } catch (Throwable $e) { |
|
85 | + } |
|
86 | + catch (Throwable $e) |
|
87 | + { |
|
84 | 88 | return $e; |
85 | 89 | } |
86 | 90 | return null; |
@@ -24,13 +24,16 @@ discard block |
||
24 | 24 | { |
25 | 25 | $io = new SymfonyStyle($input, $output); |
26 | 26 | |
27 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
27 | + foreach ($command->getDefinition()->getArguments() as $argument) |
|
28 | + { |
|
28 | 29 | // Skip default argument "the command to execute" |
29 | - if ($argument->getName() === 'command') { |
|
30 | + if ($argument->getName() === 'command') |
|
31 | + { |
|
30 | 32 | continue; |
31 | 33 | } |
32 | 34 | |
33 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
35 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) |
|
36 | + { |
|
34 | 37 | $input->setArgument( |
35 | 38 | $argument->getName(), |
36 | 39 | $io->ask($this->getQuestion($command, $argument)) |
@@ -43,25 +46,31 @@ discard block |
||
43 | 46 | { |
44 | 47 | $reflection = new \ReflectionClass($command); |
45 | 48 | |
46 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
47 | - if ($question->argument === null) { |
|
49 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) |
|
50 | + { |
|
51 | + if ($question->argument === null) |
|
52 | + { |
|
48 | 53 | throw new ConsoleException( |
49 | 54 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
50 | 55 | ); |
51 | 56 | } |
52 | 57 | |
53 | - if ($argument->getName() === $question->argument) { |
|
58 | + if ($argument->getName() === $question->argument) |
|
59 | + { |
|
54 | 60 | return $question->question; |
55 | 61 | } |
56 | 62 | } |
57 | 63 | |
58 | - foreach ($reflection->getProperties() as $property) { |
|
64 | + foreach ($reflection->getProperties() as $property) |
|
65 | + { |
|
59 | 66 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
60 | - if ($question === null) { |
|
67 | + if ($question === null) |
|
68 | + { |
|
61 | 69 | continue; |
62 | 70 | } |
63 | 71 | |
64 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
72 | + if ($argument->getName() === ($question->argument ?? $property->getName())) |
|
73 | + { |
|
65 | 74 | return $question->question; |
66 | 75 | } |
67 | 76 | } |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | { |
21 | 21 | public function __construct( |
22 | 22 | private readonly ReaderInterface $reader = new AttributeReader() |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function promptMissedArguments(Command $command, InputInterface $input, OutputInterface $output): void |
27 | 27 | { |
28 | 28 | $io = new SymfonyStyle($input, $output); |
29 | 29 | |
30 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
30 | + foreach ($command->getDefinition()->getArguments() as $argument){ |
|
31 | 31 | // Skip default argument "the command to execute" |
32 | - if ($argument->getName() === 'command') { |
|
32 | + if ($argument->getName() === 'command'){ |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
36 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null){ |
|
37 | 37 | $input->setArgument( |
38 | 38 | $argument->getName(), |
39 | 39 | $io->ask($this->getQuestion($command, $argument)) |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | { |
47 | 47 | $reflection = new \ReflectionClass($command); |
48 | 48 | |
49 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
50 | - if ($question->argument === null) { |
|
49 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question){ |
|
50 | + if ($question->argument === null){ |
|
51 | 51 | throw new ConsoleException( |
52 | 52 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - if ($argument->getName() === $question->argument) { |
|
56 | + if ($argument->getName() === $question->argument){ |
|
57 | 57 | return $question->question; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - foreach ($reflection->getProperties() as $property) { |
|
61 | + foreach ($reflection->getProperties() as $property){ |
|
62 | 62 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
63 | - if ($question === null) { |
|
63 | + if ($question === null){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
67 | + if ($argument->getName() === ($question->argument ?? $property->getName())){ |
|
68 | 68 | return $question->question; |
69 | 69 | } |
70 | 70 | } |
@@ -23,6 +23,6 @@ |
||
23 | 23 | public readonly ?string $description = null, |
24 | 24 | /** @var ?non-empty-string */ |
25 | 25 | public readonly ?string $help = null |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | } |
28 | 28 | } |