@@ -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 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
32 | 32 | |
33 | - foreach ($classes as $class) { |
|
33 | + foreach ($classes as $class){ |
|
34 | 34 | $listener->shouldReceive('listen') |
35 | 35 | ->once() |
36 | 36 | ->with($class); |
@@ -30,7 +30,8 @@ |
||
30 | 30 | |
31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
32 | 32 | |
33 | - foreach ($classes as $class) { |
|
33 | + foreach ($classes as $class) |
|
34 | + { |
|
34 | 35 | $listener->shouldReceive('listen') |
35 | 36 | ->once() |
36 | 37 | ->with($class); |
@@ -32,9 +32,12 @@ discard block |
||
32 | 32 | { |
33 | 33 | $target = new \ReflectionClass($this->class); |
34 | 34 | |
35 | - foreach ($classes as $class) { |
|
36 | - if (!$target->isTrait()) { |
|
37 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
35 | + foreach ($classes as $class) |
|
36 | + { |
|
37 | + if (!$target->isTrait()) |
|
38 | + { |
|
39 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) |
|
40 | + { |
|
38 | 41 | yield $class->getName(); |
39 | 42 | } |
40 | 43 | |
@@ -42,7 +45,8 @@ discard block |
||
42 | 45 | } |
43 | 46 | |
44 | 47 | // Checking using traits |
45 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) { |
|
48 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) |
|
49 | + { |
|
46 | 50 | yield $class->getName(); |
47 | 51 | } |
48 | 52 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function __construct( |
25 | 25 | private readonly string $class, |
26 | 26 | ?string $scope = null, |
27 | - ) { |
|
27 | + ){ |
|
28 | 28 | parent::__construct($scope); |
29 | 29 | } |
30 | 30 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | $target = new \ReflectionClass($this->class); |
34 | 34 | |
35 | - foreach ($classes as $class) { |
|
36 | - if (!$target->isTrait()) { |
|
37 | - if ($class->isSubclassOf($target) || $class->getName() === $target->getName()) { |
|
35 | + foreach ($classes as $class){ |
|
36 | + if (!$target->isTrait()){ |
|
37 | + if ($class->isSubclassOf($target) || $class->getName() === $target->getName()){ |
|
38 | 38 | yield $class->getName(); |
39 | 39 | } |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | // Checking using traits |
45 | - if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)) { |
|
45 | + if (\in_array($target->getName(), $this->fetchTraits($class->getName()), true)){ |
|
46 | 46 | yield $class->getName(); |
47 | 47 | } |
48 | 48 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | public function __construct( |
26 | 26 | private readonly ConsoleBootloader $bootloader, |
27 | 27 | ContainerInterface $container |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->container = $container; |
30 | 30 | $this->target = new \ReflectionClass(SymfonyCommand::class); |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function listen(\ReflectionClass $class): void |
34 | 34 | { |
35 | - if (!$this->isTargeted($class, $this->target)) { |
|
35 | + if (!$this->isTargeted($class, $this->target)){ |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | public function finalize(): void |
43 | 43 | { |
44 | - foreach ($this->commands as $class) { |
|
45 | - if ($class->isAbstract()) { |
|
44 | + foreach ($this->commands as $class){ |
|
45 | + if ($class->isAbstract()){ |
|
46 | 46 | continue; |
47 | 47 | } |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target): bool |
57 | 57 | { |
58 | - if (!$target->isTrait()) { |
|
58 | + if (!$target->isTrait()){ |
|
59 | 59 | // Target is interface or class |
60 | 60 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
61 | 61 | } |
@@ -32,7 +32,8 @@ discard block |
||
32 | 32 | |
33 | 33 | public function listen(\ReflectionClass $class): void |
34 | 34 | { |
35 | - if (!$this->isTargeted($class, $this->target)) { |
|
35 | + if (!$this->isTargeted($class, $this->target)) |
|
36 | + { |
|
36 | 37 | return; |
37 | 38 | } |
38 | 39 | |
@@ -41,8 +42,10 @@ discard block |
||
41 | 42 | |
42 | 43 | public function finalize(): void |
43 | 44 | { |
44 | - foreach ($this->commands as $class) { |
|
45 | - if ($class->isAbstract()) { |
|
45 | + foreach ($this->commands as $class) |
|
46 | + { |
|
47 | + if ($class->isAbstract()) |
|
48 | + { |
|
46 | 49 | continue; |
47 | 50 | } |
48 | 51 | |
@@ -55,7 +58,8 @@ discard block |
||
55 | 58 | */ |
56 | 59 | protected function isTargeted(\ReflectionClass $class, \ReflectionClass $target): bool |
57 | 60 | { |
58 | - if (!$target->isTrait()) { |
|
61 | + if (!$target->isTrait()) |
|
62 | + { |
|
59 | 63 | // Target is interface or class |
60 | 64 | return $class->isSubclassOf($target) || $class->getName() === $target->getName(); |
61 | 65 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | use MockeryPHPUnitIntegration; |
19 | 19 | |
20 | 20 | private ClassLocatorByTarget $locator; |
21 | - private ClassesInterface|m\LegacyMockInterface|m\MockInterface $classes; |
|
22 | - private ScopedClassesInterface|m\LegacyMockInterface|m\MockInterface $scopedClasses; |
|
21 | + private ClassesInterface | m\LegacyMockInterface | m\MockInterface $classes; |
|
22 | + private ScopedClassesInterface | m\LegacyMockInterface | m\MockInterface $scopedClasses; |
|
23 | 23 | |
24 | 24 | protected function setUp(): void |
25 | 25 | { |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | $attr = $attr->getAttributes()[0]; |
111 | 111 | $attribute = $attr->newInstance(); |
112 | 112 | |
113 | - if ($attribute->getScope() === null) { |
|
113 | + if ($attribute->getScope() === null){ |
|
114 | 114 | $this->classes |
115 | 115 | ->shouldReceive('getClasses') |
116 | 116 | ->andReturn($classes); |
117 | - } else { |
|
117 | + }else{ |
|
118 | 118 | $this->scopedClasses |
119 | 119 | ->shouldReceive('getScopedClasses') |
120 | 120 | ->with($attribute->getScope()) |
@@ -110,11 +110,14 @@ |
||
110 | 110 | $attr = $attr->getAttributes()[0]; |
111 | 111 | $attribute = $attr->newInstance(); |
112 | 112 | |
113 | - if ($attribute->getScope() === null) { |
|
113 | + if ($attribute->getScope() === null) |
|
114 | + { |
|
114 | 115 | $this->classes |
115 | 116 | ->shouldReceive('getClasses') |
116 | 117 | ->andReturn($classes); |
117 | - } else { |
|
118 | + } |
|
119 | + else |
|
120 | + { |
|
118 | 121 | $this->scopedClasses |
119 | 122 | ->shouldReceive('getScopedClasses') |
120 | 123 | ->with($attribute->getScope()) |
@@ -12,9 +12,9 @@ |
||
12 | 12 | public function testToString(): void |
13 | 13 | { |
14 | 14 | $attribute = new TargetClass('foo'); |
15 | - $this->assertSame('3319d33aad20ad375d27dcd03c879454', (string) $attribute); |
|
15 | + $this->assertSame('3319d33aad20ad375d27dcd03c879454', (string)$attribute); |
|
16 | 16 | |
17 | 17 | $attribute = new TargetClass('foo', 'bar'); |
18 | - $this->assertSame('a95c8a2cfc901290939df93183ce98d6', (string) $attribute); |
|
18 | + $this->assertSame('a95c8a2cfc901290939df93183ce98d6', (string)$attribute); |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
19 | 19 | public function __construct( |
20 | 20 | private readonly ClassesInterface $classes, |
21 | 21 | private readonly ScopedClassesInterface $scopedClasses, |
22 | - ) { |
|
22 | + ){ |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function __construct( |
13 | 13 | public readonly ?string $scope = null, |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __toString(): string |
22 | 22 | { |
23 | - return \md5(\print_r($this, return: true)); |
|
23 | + return \md5(\print_r($this, return : true)); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |