@@ -21,61 +21,61 @@ |
||
21 | 21 | */ |
22 | 22 | final class DisplayNormalizerTest extends TestCase |
23 | 23 | { |
24 | - /** |
|
25 | - * @dataProvider displayProvider |
|
26 | - */ |
|
27 | - public function test_it_normalizes_the_given_output(string $value, string $expected): void |
|
28 | - { |
|
29 | - $actual = DisplayNormalizer::removeTrailingSpaces($value); |
|
24 | + /** |
|
25 | + * @dataProvider displayProvider |
|
26 | + */ |
|
27 | + public function test_it_normalizes_the_given_output(string $value, string $expected): void |
|
28 | + { |
|
29 | + $actual = DisplayNormalizer::removeTrailingSpaces($value); |
|
30 | 30 | |
31 | - self::assertSame($expected, $actual); |
|
32 | - } |
|
31 | + self::assertSame($expected, $actual); |
|
32 | + } |
|
33 | 33 | |
34 | - public static function displayProvider(): iterable |
|
35 | - { |
|
36 | - yield 'empty string' => [ |
|
37 | - '', |
|
38 | - '', |
|
39 | - ]; |
|
34 | + public static function displayProvider(): iterable |
|
35 | + { |
|
36 | + yield 'empty string' => [ |
|
37 | + '', |
|
38 | + '', |
|
39 | + ]; |
|
40 | 40 | |
41 | - yield 'blank string' => [ |
|
42 | - ' ', |
|
43 | - '', |
|
44 | - ]; |
|
41 | + yield 'blank string' => [ |
|
42 | + ' ', |
|
43 | + '', |
|
44 | + ]; |
|
45 | 45 | |
46 | - yield 'string with leading and trailing spaces' => [ |
|
47 | - ' foo ', |
|
48 | - ' foo', |
|
49 | - ]; |
|
46 | + yield 'string with leading and trailing spaces' => [ |
|
47 | + ' foo ', |
|
48 | + ' foo', |
|
49 | + ]; |
|
50 | 50 | |
51 | - yield 'empty line returns' => [ |
|
52 | - <<<'EOT' |
|
51 | + yield 'empty line returns' => [ |
|
52 | + <<<'EOT' |
|
53 | 53 | |
54 | 54 | |
55 | 55 | EOT, |
56 | - <<<'EOT' |
|
56 | + <<<'EOT' |
|
57 | 57 | |
58 | 58 | |
59 | 59 | EOT, |
60 | - ]; |
|
60 | + ]; |
|
61 | 61 | |
62 | - yield 'windows line returns' => [ |
|
63 | - "\n\r", |
|
64 | - <<<'EOT' |
|
62 | + yield 'windows line returns' => [ |
|
63 | + "\n\r", |
|
64 | + <<<'EOT' |
|
65 | 65 | |
66 | 66 | |
67 | 67 | EOT, |
68 | - ]; |
|
68 | + ]; |
|
69 | 69 | |
70 | - yield 'line returns with leading and trailing spaces' => [ |
|
71 | - <<<'EOT' |
|
70 | + yield 'line returns with leading and trailing spaces' => [ |
|
71 | + <<<'EOT' |
|
72 | 72 | foo |
73 | 73 | bar |
74 | 74 | EOT, |
75 | - <<<'EOT' |
|
75 | + <<<'EOT' |
|
76 | 76 | foo |
77 | 77 | bar |
78 | 78 | EOT, |
79 | - ]; |
|
80 | - } |
|
79 | + ]; |
|
80 | + } |
|
81 | 81 | } |
@@ -19,8 +19,7 @@ |
||
19 | 19 | /** |
20 | 20 | * @covers \Fidry\Console\DisplayNormalizer |
21 | 21 | */ |
22 | -final class DisplayNormalizerTest extends TestCase |
|
23 | -{ |
|
22 | +final class DisplayNormalizerTest extends TestCase { |
|
24 | 23 | /** |
25 | 24 | * @dataProvider displayProvider |
26 | 25 | */ |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | use Symfony\Component\Console\Input\ArgvInput; |
7 | 7 | |
8 | 8 | if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { |
9 | - echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; |
|
9 | + echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | set_time_limit(0); |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | |
19 | 19 | $input = new ArgvInput(); |
20 | 20 | if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { |
21 | - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); |
|
21 | + putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if ($input->hasParameterOption('--no-debug', true)) { |
25 | - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); |
|
25 | + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | if ($_SERVER['APP_DEBUG']) { |
29 | - umask(0000); |
|
29 | + umask(0000); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
@@ -29,7 +29,7 @@ |
||
29 | 29 | umask(0000); |
30 | 30 | } |
31 | 31 | |
32 | -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); |
|
32 | +$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']); |
|
33 | 33 | |
34 | 34 | $application = new Application($kernel); |
35 | 35 | $application->run($input); |
@@ -31,188 +31,188 @@ |
||
31 | 31 | */ |
32 | 32 | final class IOTest extends TestCase |
33 | 33 | { |
34 | - public function test_it_exposes_its_input_and_output(): void |
|
35 | - { |
|
36 | - $input = new StringInput(''); |
|
37 | - $output = new NullOutput(); |
|
38 | - |
|
39 | - $io = new IO($input, $output); |
|
40 | - |
|
41 | - self::assertSame($input, $io->getInput()); |
|
42 | - self::assertSame($output, $io->getOutput()); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @dataProvider inputProvider |
|
47 | - */ |
|
48 | - public function test_it_exposes_if_its_input_is_interactive( |
|
49 | - InputInterface $input, |
|
50 | - bool $expectedInteractivity |
|
51 | - ): void { |
|
52 | - $output = new NullOutput(); |
|
53 | - |
|
54 | - $io = new IO($input, $output); |
|
55 | - |
|
56 | - self::assertSame($expectedInteractivity, $io->isInteractive()); |
|
57 | - } |
|
58 | - |
|
59 | - public static function inputProvider(): iterable |
|
60 | - { |
|
61 | - foreach ([true, false] as $interactive) { |
|
62 | - yield [ |
|
63 | - self::createInput($interactive), |
|
64 | - $interactive, |
|
65 | - ]; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - public function test_it_can_create_a_null_io(): void |
|
70 | - { |
|
71 | - $io = IO::createNull(); |
|
72 | - |
|
73 | - self::assertCount(0, $io->getInput()->getArguments()); |
|
74 | - self::assertCount(0, $io->getInput()->getOptions()); |
|
75 | - |
|
76 | - self::assertInstanceOf(NullOutput::class, $io->getOutput()); |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @dataProvider invalidScalarArgumentTypeProvider |
|
81 | - * @dataProvider invalidArrayArgumentTypeProvider |
|
82 | - * |
|
83 | - * @param mixed $default |
|
84 | - */ |
|
85 | - public function test_it_checks_against_invalid_argument_default_types( |
|
86 | - $default, |
|
87 | - string $expectedMessage |
|
88 | - ): void { |
|
89 | - $io = new IO( |
|
90 | - new ArrayInput( |
|
91 | - [], |
|
92 | - new InputDefinition( |
|
93 | - [ |
|
94 | - new InputArgument( |
|
95 | - 'arg', |
|
96 | - InputArgument::OPTIONAL, |
|
97 | - '', |
|
98 | - $default, |
|
99 | - ), |
|
100 | - ], |
|
101 | - ), |
|
102 | - ), |
|
103 | - new NullOutput(), |
|
104 | - ); |
|
105 | - |
|
106 | - $this->expectException(ConsoleInvalidArgumentException::class); |
|
107 | - $this->expectExceptionMessage($expectedMessage); |
|
108 | - |
|
109 | - $io->getStringArgument('arg'); |
|
110 | - } |
|
111 | - |
|
112 | - public static function invalidScalarArgumentTypeProvider(): iterable |
|
113 | - { |
|
114 | - yield 'boolean' => [ |
|
115 | - false, |
|
116 | - 'Expected an argument value type to be "null|string|string[]". Got "bool"', |
|
117 | - ]; |
|
118 | - |
|
119 | - yield 'int' => [ |
|
120 | - 10, |
|
121 | - 'Expected an argument value type to be "null|string|string[]". Got "int"', |
|
122 | - ]; |
|
123 | - |
|
124 | - yield 'float' => [ |
|
125 | - 10.8, |
|
126 | - 'Expected an argument value type to be "null|string|string[]". Got "float"', |
|
127 | - ]; |
|
128 | - |
|
129 | - yield 'object' => [ |
|
130 | - new stdClass(), |
|
131 | - 'Expected an argument value type to be "null|string|string[]". Got "stdClass"', |
|
132 | - ]; |
|
133 | - |
|
134 | - yield 'closure' => [ |
|
135 | - static fn () => '', |
|
136 | - 'Expected an argument value type to be "null|string|string[]". Got "Closure"', |
|
137 | - ]; |
|
138 | - } |
|
139 | - |
|
140 | - public static function invalidArrayArgumentTypeProvider(): iterable |
|
141 | - { |
|
142 | - foreach (self::invalidScalarArgumentTypeProvider() as [$item, $message]) { |
|
143 | - yield [[$item], $message]; |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * @dataProvider invalidScalarOptionTypeProvider |
|
149 | - * @dataProvider invalidArrayOptionTypeProvider |
|
150 | - * |
|
151 | - * @param mixed $default |
|
152 | - */ |
|
153 | - public function test_it_checks_against_invalid_option_default_types( |
|
154 | - $default, |
|
155 | - string $expectedMessage |
|
156 | - ): void { |
|
157 | - $io = new IO( |
|
158 | - new ArrayInput( |
|
159 | - [], |
|
160 | - new InputDefinition( |
|
161 | - [ |
|
162 | - new InputOption( |
|
163 | - 'opt', |
|
164 | - null, |
|
165 | - InputOption::VALUE_OPTIONAL, |
|
166 | - '', |
|
167 | - $default, |
|
168 | - ), |
|
169 | - ], |
|
170 | - ), |
|
171 | - ), |
|
172 | - new NullOutput(), |
|
173 | - ); |
|
174 | - |
|
175 | - $this->expectException(ConsoleInvalidArgumentException::class); |
|
176 | - $this->expectExceptionMessage($expectedMessage); |
|
177 | - |
|
178 | - $io->getStringOption('opt'); |
|
179 | - } |
|
180 | - |
|
181 | - public static function invalidScalarOptionTypeProvider(): iterable |
|
182 | - { |
|
183 | - yield 'int' => [ |
|
184 | - 10, |
|
185 | - 'Expected an option value type to be "null|bool|string|string[]". Got "int"', |
|
186 | - ]; |
|
187 | - |
|
188 | - yield 'float' => [ |
|
189 | - 10.8, |
|
190 | - 'Expected an option value type to be "null|bool|string|string[]". Got "float"', |
|
191 | - ]; |
|
192 | - |
|
193 | - yield 'object' => [ |
|
194 | - new stdClass(), |
|
195 | - 'Expected an option value type to be "null|bool|string|string[]". Got "stdClass"', |
|
196 | - ]; |
|
197 | - |
|
198 | - yield 'closure' => [ |
|
199 | - static fn () => '', |
|
200 | - 'Expected an option value type to be "null|bool|string|string[]". Got "Closure"', |
|
201 | - ]; |
|
202 | - } |
|
203 | - |
|
204 | - public static function invalidArrayOptionTypeProvider(): iterable |
|
205 | - { |
|
206 | - foreach (self::invalidScalarOptionTypeProvider() as [$item, $message]) { |
|
207 | - yield [[$item], $message]; |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - private static function createInput(bool $interactive): InputInterface |
|
212 | - { |
|
213 | - $input = new StringInput(''); |
|
214 | - $input->setInteractive($interactive); |
|
215 | - |
|
216 | - return $input; |
|
217 | - } |
|
34 | + public function test_it_exposes_its_input_and_output(): void |
|
35 | + { |
|
36 | + $input = new StringInput(''); |
|
37 | + $output = new NullOutput(); |
|
38 | + |
|
39 | + $io = new IO($input, $output); |
|
40 | + |
|
41 | + self::assertSame($input, $io->getInput()); |
|
42 | + self::assertSame($output, $io->getOutput()); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @dataProvider inputProvider |
|
47 | + */ |
|
48 | + public function test_it_exposes_if_its_input_is_interactive( |
|
49 | + InputInterface $input, |
|
50 | + bool $expectedInteractivity |
|
51 | + ): void { |
|
52 | + $output = new NullOutput(); |
|
53 | + |
|
54 | + $io = new IO($input, $output); |
|
55 | + |
|
56 | + self::assertSame($expectedInteractivity, $io->isInteractive()); |
|
57 | + } |
|
58 | + |
|
59 | + public static function inputProvider(): iterable |
|
60 | + { |
|
61 | + foreach ([true, false] as $interactive) { |
|
62 | + yield [ |
|
63 | + self::createInput($interactive), |
|
64 | + $interactive, |
|
65 | + ]; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + public function test_it_can_create_a_null_io(): void |
|
70 | + { |
|
71 | + $io = IO::createNull(); |
|
72 | + |
|
73 | + self::assertCount(0, $io->getInput()->getArguments()); |
|
74 | + self::assertCount(0, $io->getInput()->getOptions()); |
|
75 | + |
|
76 | + self::assertInstanceOf(NullOutput::class, $io->getOutput()); |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @dataProvider invalidScalarArgumentTypeProvider |
|
81 | + * @dataProvider invalidArrayArgumentTypeProvider |
|
82 | + * |
|
83 | + * @param mixed $default |
|
84 | + */ |
|
85 | + public function test_it_checks_against_invalid_argument_default_types( |
|
86 | + $default, |
|
87 | + string $expectedMessage |
|
88 | + ): void { |
|
89 | + $io = new IO( |
|
90 | + new ArrayInput( |
|
91 | + [], |
|
92 | + new InputDefinition( |
|
93 | + [ |
|
94 | + new InputArgument( |
|
95 | + 'arg', |
|
96 | + InputArgument::OPTIONAL, |
|
97 | + '', |
|
98 | + $default, |
|
99 | + ), |
|
100 | + ], |
|
101 | + ), |
|
102 | + ), |
|
103 | + new NullOutput(), |
|
104 | + ); |
|
105 | + |
|
106 | + $this->expectException(ConsoleInvalidArgumentException::class); |
|
107 | + $this->expectExceptionMessage($expectedMessage); |
|
108 | + |
|
109 | + $io->getStringArgument('arg'); |
|
110 | + } |
|
111 | + |
|
112 | + public static function invalidScalarArgumentTypeProvider(): iterable |
|
113 | + { |
|
114 | + yield 'boolean' => [ |
|
115 | + false, |
|
116 | + 'Expected an argument value type to be "null|string|string[]". Got "bool"', |
|
117 | + ]; |
|
118 | + |
|
119 | + yield 'int' => [ |
|
120 | + 10, |
|
121 | + 'Expected an argument value type to be "null|string|string[]". Got "int"', |
|
122 | + ]; |
|
123 | + |
|
124 | + yield 'float' => [ |
|
125 | + 10.8, |
|
126 | + 'Expected an argument value type to be "null|string|string[]". Got "float"', |
|
127 | + ]; |
|
128 | + |
|
129 | + yield 'object' => [ |
|
130 | + new stdClass(), |
|
131 | + 'Expected an argument value type to be "null|string|string[]". Got "stdClass"', |
|
132 | + ]; |
|
133 | + |
|
134 | + yield 'closure' => [ |
|
135 | + static fn () => '', |
|
136 | + 'Expected an argument value type to be "null|string|string[]". Got "Closure"', |
|
137 | + ]; |
|
138 | + } |
|
139 | + |
|
140 | + public static function invalidArrayArgumentTypeProvider(): iterable |
|
141 | + { |
|
142 | + foreach (self::invalidScalarArgumentTypeProvider() as [$item, $message]) { |
|
143 | + yield [[$item], $message]; |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * @dataProvider invalidScalarOptionTypeProvider |
|
149 | + * @dataProvider invalidArrayOptionTypeProvider |
|
150 | + * |
|
151 | + * @param mixed $default |
|
152 | + */ |
|
153 | + public function test_it_checks_against_invalid_option_default_types( |
|
154 | + $default, |
|
155 | + string $expectedMessage |
|
156 | + ): void { |
|
157 | + $io = new IO( |
|
158 | + new ArrayInput( |
|
159 | + [], |
|
160 | + new InputDefinition( |
|
161 | + [ |
|
162 | + new InputOption( |
|
163 | + 'opt', |
|
164 | + null, |
|
165 | + InputOption::VALUE_OPTIONAL, |
|
166 | + '', |
|
167 | + $default, |
|
168 | + ), |
|
169 | + ], |
|
170 | + ), |
|
171 | + ), |
|
172 | + new NullOutput(), |
|
173 | + ); |
|
174 | + |
|
175 | + $this->expectException(ConsoleInvalidArgumentException::class); |
|
176 | + $this->expectExceptionMessage($expectedMessage); |
|
177 | + |
|
178 | + $io->getStringOption('opt'); |
|
179 | + } |
|
180 | + |
|
181 | + public static function invalidScalarOptionTypeProvider(): iterable |
|
182 | + { |
|
183 | + yield 'int' => [ |
|
184 | + 10, |
|
185 | + 'Expected an option value type to be "null|bool|string|string[]". Got "int"', |
|
186 | + ]; |
|
187 | + |
|
188 | + yield 'float' => [ |
|
189 | + 10.8, |
|
190 | + 'Expected an option value type to be "null|bool|string|string[]". Got "float"', |
|
191 | + ]; |
|
192 | + |
|
193 | + yield 'object' => [ |
|
194 | + new stdClass(), |
|
195 | + 'Expected an option value type to be "null|bool|string|string[]". Got "stdClass"', |
|
196 | + ]; |
|
197 | + |
|
198 | + yield 'closure' => [ |
|
199 | + static fn () => '', |
|
200 | + 'Expected an option value type to be "null|bool|string|string[]". Got "Closure"', |
|
201 | + ]; |
|
202 | + } |
|
203 | + |
|
204 | + public static function invalidArrayOptionTypeProvider(): iterable |
|
205 | + { |
|
206 | + foreach (self::invalidScalarOptionTypeProvider() as [$item, $message]) { |
|
207 | + yield [[$item], $message]; |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + private static function createInput(bool $interactive): InputInterface |
|
212 | + { |
|
213 | + $input = new StringInput(''); |
|
214 | + $input->setInteractive($interactive); |
|
215 | + |
|
216 | + return $input; |
|
217 | + } |
|
218 | 218 | } |
@@ -29,8 +29,7 @@ |
||
29 | 29 | * @covers \Fidry\Console\Command\ConsoleAssert |
30 | 30 | * @covers \Fidry\Console\IO |
31 | 31 | */ |
32 | -final class IOTest extends TestCase |
|
33 | -{ |
|
32 | +final class IOTest extends TestCase { |
|
34 | 33 | public function test_it_exposes_its_input_and_output(): void |
35 | 34 | { |
36 | 35 | $input = new StringInput(''); |
@@ -21,22 +21,22 @@ |
||
21 | 21 | |
22 | 22 | final class DynamicCommandWithArguments extends Command |
23 | 23 | { |
24 | - /** |
|
25 | - * @psalm-suppress PropertyNotSetInConstructor |
|
26 | - */ |
|
27 | - public InputInterface $input; |
|
24 | + /** |
|
25 | + * @psalm-suppress PropertyNotSetInConstructor |
|
26 | + */ |
|
27 | + public InputInterface $input; |
|
28 | 28 | |
29 | - public function __construct(InputArgument $inputArgument) |
|
30 | - { |
|
31 | - parent::__construct('app:input:args'); |
|
29 | + public function __construct(InputArgument $inputArgument) |
|
30 | + { |
|
31 | + parent::__construct('app:input:args'); |
|
32 | 32 | |
33 | - $this->getDefinition()->addArgument($inputArgument); |
|
34 | - } |
|
33 | + $this->getDefinition()->addArgument($inputArgument); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
37 | - { |
|
38 | - $this->input = $input; |
|
36 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
37 | + { |
|
38 | + $this->input = $input; |
|
39 | 39 | |
40 | - return ExitCode::SUCCESS; |
|
41 | - } |
|
40 | + return ExitCode::SUCCESS; |
|
41 | + } |
|
42 | 42 | } |
@@ -19,8 +19,7 @@ |
||
19 | 19 | use Symfony\Component\Console\Input\InputInterface; |
20 | 20 | use Symfony\Component\Console\Output\OutputInterface; |
21 | 21 | |
22 | -final class DynamicCommandWithArguments extends Command |
|
23 | -{ |
|
22 | +final class DynamicCommandWithArguments extends Command { |
|
24 | 23 | /** |
25 | 24 | * @psalm-suppress PropertyNotSetInConstructor |
26 | 25 | */ |
@@ -26,483 +26,483 @@ |
||
26 | 26 | */ |
27 | 27 | final class IOOptionsTest extends TestCase |
28 | 28 | { |
29 | - private const OPTION_NAME = 'opt'; |
|
30 | - |
|
31 | - /** |
|
32 | - * @dataProvider requiredOptionProvider |
|
33 | - * @dataProvider optionalOptionProvider |
|
34 | - * @dataProvider noValueOptionProvider |
|
35 | - * @dataProvider arrayOptionProvider |
|
36 | - */ |
|
37 | - public function test_it_exposes_a_typed_api( |
|
38 | - InputOption $inputOption, |
|
39 | - string $option, |
|
40 | - TypedInput $expected |
|
41 | - ): void { |
|
42 | - $io = $this->getIO($inputOption, $option); |
|
43 | - |
|
44 | - TypeAssertions::assertExpectedOptionTypes( |
|
45 | - $expected, |
|
46 | - $io, |
|
47 | - self::OPTION_NAME, |
|
48 | - ); |
|
49 | - } |
|
50 | - |
|
51 | - public static function requiredOptionProvider(): iterable |
|
52 | - { |
|
53 | - $mode = InputOption::VALUE_REQUIRED; |
|
54 | - |
|
55 | - yield 'empty string' => [ |
|
56 | - new InputOption( |
|
57 | - self::OPTION_NAME, |
|
58 | - null, |
|
59 | - $mode, |
|
60 | - '', |
|
61 | - null, |
|
62 | - ), |
|
63 | - '--opt=""', |
|
64 | - TypedInput::createForScalar( |
|
65 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'\'"'), |
|
66 | - false, |
|
67 | - false, |
|
68 | - '', |
|
69 | - '', |
|
70 | - new TypeException('Expected an integer. Got "\'\'"'), |
|
71 | - new TypeException('Expected an integer. Got "\'\'"'), |
|
72 | - new TypeException('Expected a numeric. Got "\'\'"'), |
|
73 | - new TypeException('Expected a numeric. Got "\'\'"'), |
|
74 | - ), |
|
75 | - ]; |
|
76 | - |
|
77 | - yield 'nominal string' => [ |
|
78 | - new InputOption( |
|
79 | - self::OPTION_NAME, |
|
80 | - null, |
|
81 | - $mode, |
|
82 | - '', |
|
83 | - null, |
|
84 | - ), |
|
85 | - '--opt=foo', |
|
86 | - TypedInput::createForScalar( |
|
87 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'foo\'"'), |
|
88 | - true, |
|
89 | - true, |
|
90 | - 'foo', |
|
91 | - 'foo', |
|
92 | - new TypeException('Expected an integer. Got "\'foo\'"'), |
|
93 | - new TypeException('Expected an integer. Got "\'foo\'"'), |
|
94 | - new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
95 | - new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
96 | - ), |
|
97 | - ]; |
|
98 | - |
|
99 | - yield 'null string' => [ |
|
100 | - new InputOption( |
|
101 | - self::OPTION_NAME, |
|
102 | - null, |
|
103 | - $mode, |
|
104 | - '', |
|
105 | - null, |
|
106 | - ), |
|
107 | - '--opt=null', |
|
108 | - TypedInput::createForScalar( |
|
109 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'null\'"'), |
|
110 | - true, |
|
111 | - true, |
|
112 | - 'null', |
|
113 | - 'null', |
|
114 | - new TypeException('Expected an integer. Got "\'null\'"'), |
|
115 | - new TypeException('Expected an integer. Got "\'null\'"'), |
|
116 | - new TypeException('Expected a numeric. Got "\'null\'"'), |
|
117 | - new TypeException('Expected a numeric. Got "\'null\'"'), |
|
118 | - ), |
|
119 | - ]; |
|
120 | - |
|
121 | - yield 'integer string' => [ |
|
122 | - new InputOption( |
|
123 | - self::OPTION_NAME, |
|
124 | - null, |
|
125 | - $mode, |
|
126 | - '', |
|
127 | - null, |
|
128 | - ), |
|
129 | - '--opt=10', |
|
130 | - TypedInput::createForScalar( |
|
131 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'10\'"'), |
|
132 | - true, |
|
133 | - true, |
|
134 | - '10', |
|
135 | - '10', |
|
136 | - 10, |
|
137 | - 10, |
|
138 | - 10., |
|
139 | - 10., |
|
140 | - ), |
|
141 | - ]; |
|
142 | - |
|
143 | - // negative integer string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
144 | - |
|
145 | - yield 'zero integer string' => [ |
|
146 | - new InputOption( |
|
147 | - self::OPTION_NAME, |
|
148 | - null, |
|
149 | - $mode, |
|
150 | - '', |
|
151 | - null, |
|
152 | - ), |
|
153 | - '--opt=0', |
|
154 | - TypedInput::createForScalar( |
|
155 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'0\'"'), |
|
156 | - false, |
|
157 | - false, |
|
158 | - '0', |
|
159 | - '0', |
|
160 | - 0, |
|
161 | - 0, |
|
162 | - 0., |
|
163 | - 0., |
|
164 | - ), |
|
165 | - ]; |
|
166 | - |
|
167 | - yield 'float string' => [ |
|
168 | - new InputOption( |
|
169 | - self::OPTION_NAME, |
|
170 | - null, |
|
171 | - $mode, |
|
172 | - '', |
|
173 | - null, |
|
174 | - ), |
|
175 | - '--opt=10.8', |
|
176 | - TypedInput::createForScalar( |
|
177 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'10.8\'"'), |
|
178 | - true, |
|
179 | - true, |
|
180 | - '10.8', |
|
181 | - '10.8', |
|
182 | - new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
183 | - new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
184 | - 10.8, |
|
185 | - 10.8, |
|
186 | - ), |
|
187 | - ]; |
|
188 | - |
|
189 | - // negative float string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
190 | - |
|
191 | - yield 'zero float string' => [ |
|
192 | - new InputOption( |
|
193 | - self::OPTION_NAME, |
|
194 | - null, |
|
195 | - $mode, |
|
196 | - '', |
|
197 | - null, |
|
198 | - ), |
|
199 | - '--opt=0.', |
|
200 | - TypedInput::createForScalar( |
|
201 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'0.\'"'), |
|
202 | - true, |
|
203 | - true, |
|
204 | - '0.', |
|
205 | - '0.', |
|
206 | - new TypeException('Expected an integer. Got "\'0.\'"'), |
|
207 | - new TypeException('Expected an integer. Got "\'0.\'"'), |
|
208 | - 0., |
|
209 | - 0., |
|
210 | - ), |
|
211 | - ]; |
|
212 | - } |
|
213 | - |
|
214 | - public static function optionalOptionProvider(): iterable |
|
215 | - { |
|
216 | - yield 'empty string' => [ |
|
217 | - new InputOption( |
|
218 | - self::OPTION_NAME, |
|
219 | - null, |
|
220 | - InputOption::VALUE_OPTIONAL, |
|
221 | - '', |
|
222 | - null, |
|
223 | - ), |
|
224 | - '', |
|
225 | - TypedInput::createForScalar( |
|
226 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "NULL"'), |
|
227 | - false, |
|
228 | - null, |
|
229 | - '', |
|
230 | - null, |
|
231 | - new TypeException('Expected an integer. Got "NULL"'), |
|
232 | - null, |
|
233 | - new TypeException('Expected a numeric. Got "NULL"'), |
|
234 | - null, |
|
235 | - ), |
|
236 | - ]; |
|
237 | - } |
|
238 | - |
|
239 | - public static function noValueOptionProvider(): iterable |
|
240 | - { |
|
241 | - $mode = InputOption::VALUE_NONE; |
|
242 | - |
|
243 | - yield 'option absent' => [ |
|
244 | - new InputOption( |
|
245 | - self::OPTION_NAME, |
|
246 | - null, |
|
247 | - $mode, |
|
248 | - '', |
|
249 | - null, // is ignored for VALUE_NONE (must be NULL) |
|
250 | - ), |
|
251 | - '', |
|
252 | - TypedInput::createForScalar( |
|
253 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "false"'), |
|
254 | - false, |
|
255 | - false, |
|
256 | - '', |
|
257 | - '', |
|
258 | - new TypeException('Expected an integer. Got "false"'), |
|
259 | - new TypeException('Expected an integer. Got "false"'), |
|
260 | - new TypeException('Expected a numeric. Got "false"'), |
|
261 | - new TypeException('Expected a numeric. Got "false"'), |
|
262 | - ), |
|
263 | - ]; |
|
264 | - |
|
265 | - yield 'option present' => [ |
|
266 | - new InputOption( |
|
267 | - self::OPTION_NAME, |
|
268 | - null, |
|
269 | - $mode, |
|
270 | - '', |
|
271 | - null, |
|
272 | - ), |
|
273 | - '--opt', |
|
274 | - TypedInput::createForScalar( |
|
275 | - new TypeException('Cannot cast a non-array input argument into an array. Got the value "true"'), |
|
276 | - true, |
|
277 | - true, |
|
278 | - '1', |
|
279 | - '1', |
|
280 | - new TypeException('Expected an integer. Got "true"'), |
|
281 | - new TypeException('Expected an integer. Got "true"'), |
|
282 | - new TypeException('Expected a numeric. Got "true"'), |
|
283 | - new TypeException('Expected a numeric. Got "true"'), |
|
284 | - ), |
|
285 | - ]; |
|
286 | - } |
|
287 | - |
|
288 | - public static function arrayOptionProvider(): iterable |
|
289 | - { |
|
290 | - $mode = InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY; |
|
291 | - |
|
292 | - yield 'empty string' => [ |
|
293 | - new InputOption( |
|
294 | - self::OPTION_NAME, |
|
295 | - null, |
|
296 | - $mode, |
|
297 | - '', |
|
298 | - null, |
|
299 | - ), |
|
300 | - '--opt=""', |
|
301 | - TypedInput::createForArray( |
|
302 | - new TypeException( |
|
303 | - <<<'TXT' |
|
29 | + private const OPTION_NAME = 'opt'; |
|
30 | + |
|
31 | + /** |
|
32 | + * @dataProvider requiredOptionProvider |
|
33 | + * @dataProvider optionalOptionProvider |
|
34 | + * @dataProvider noValueOptionProvider |
|
35 | + * @dataProvider arrayOptionProvider |
|
36 | + */ |
|
37 | + public function test_it_exposes_a_typed_api( |
|
38 | + InputOption $inputOption, |
|
39 | + string $option, |
|
40 | + TypedInput $expected |
|
41 | + ): void { |
|
42 | + $io = $this->getIO($inputOption, $option); |
|
43 | + |
|
44 | + TypeAssertions::assertExpectedOptionTypes( |
|
45 | + $expected, |
|
46 | + $io, |
|
47 | + self::OPTION_NAME, |
|
48 | + ); |
|
49 | + } |
|
50 | + |
|
51 | + public static function requiredOptionProvider(): iterable |
|
52 | + { |
|
53 | + $mode = InputOption::VALUE_REQUIRED; |
|
54 | + |
|
55 | + yield 'empty string' => [ |
|
56 | + new InputOption( |
|
57 | + self::OPTION_NAME, |
|
58 | + null, |
|
59 | + $mode, |
|
60 | + '', |
|
61 | + null, |
|
62 | + ), |
|
63 | + '--opt=""', |
|
64 | + TypedInput::createForScalar( |
|
65 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'\'"'), |
|
66 | + false, |
|
67 | + false, |
|
68 | + '', |
|
69 | + '', |
|
70 | + new TypeException('Expected an integer. Got "\'\'"'), |
|
71 | + new TypeException('Expected an integer. Got "\'\'"'), |
|
72 | + new TypeException('Expected a numeric. Got "\'\'"'), |
|
73 | + new TypeException('Expected a numeric. Got "\'\'"'), |
|
74 | + ), |
|
75 | + ]; |
|
76 | + |
|
77 | + yield 'nominal string' => [ |
|
78 | + new InputOption( |
|
79 | + self::OPTION_NAME, |
|
80 | + null, |
|
81 | + $mode, |
|
82 | + '', |
|
83 | + null, |
|
84 | + ), |
|
85 | + '--opt=foo', |
|
86 | + TypedInput::createForScalar( |
|
87 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'foo\'"'), |
|
88 | + true, |
|
89 | + true, |
|
90 | + 'foo', |
|
91 | + 'foo', |
|
92 | + new TypeException('Expected an integer. Got "\'foo\'"'), |
|
93 | + new TypeException('Expected an integer. Got "\'foo\'"'), |
|
94 | + new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
95 | + new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
96 | + ), |
|
97 | + ]; |
|
98 | + |
|
99 | + yield 'null string' => [ |
|
100 | + new InputOption( |
|
101 | + self::OPTION_NAME, |
|
102 | + null, |
|
103 | + $mode, |
|
104 | + '', |
|
105 | + null, |
|
106 | + ), |
|
107 | + '--opt=null', |
|
108 | + TypedInput::createForScalar( |
|
109 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'null\'"'), |
|
110 | + true, |
|
111 | + true, |
|
112 | + 'null', |
|
113 | + 'null', |
|
114 | + new TypeException('Expected an integer. Got "\'null\'"'), |
|
115 | + new TypeException('Expected an integer. Got "\'null\'"'), |
|
116 | + new TypeException('Expected a numeric. Got "\'null\'"'), |
|
117 | + new TypeException('Expected a numeric. Got "\'null\'"'), |
|
118 | + ), |
|
119 | + ]; |
|
120 | + |
|
121 | + yield 'integer string' => [ |
|
122 | + new InputOption( |
|
123 | + self::OPTION_NAME, |
|
124 | + null, |
|
125 | + $mode, |
|
126 | + '', |
|
127 | + null, |
|
128 | + ), |
|
129 | + '--opt=10', |
|
130 | + TypedInput::createForScalar( |
|
131 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'10\'"'), |
|
132 | + true, |
|
133 | + true, |
|
134 | + '10', |
|
135 | + '10', |
|
136 | + 10, |
|
137 | + 10, |
|
138 | + 10., |
|
139 | + 10., |
|
140 | + ), |
|
141 | + ]; |
|
142 | + |
|
143 | + // negative integer string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
144 | + |
|
145 | + yield 'zero integer string' => [ |
|
146 | + new InputOption( |
|
147 | + self::OPTION_NAME, |
|
148 | + null, |
|
149 | + $mode, |
|
150 | + '', |
|
151 | + null, |
|
152 | + ), |
|
153 | + '--opt=0', |
|
154 | + TypedInput::createForScalar( |
|
155 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'0\'"'), |
|
156 | + false, |
|
157 | + false, |
|
158 | + '0', |
|
159 | + '0', |
|
160 | + 0, |
|
161 | + 0, |
|
162 | + 0., |
|
163 | + 0., |
|
164 | + ), |
|
165 | + ]; |
|
166 | + |
|
167 | + yield 'float string' => [ |
|
168 | + new InputOption( |
|
169 | + self::OPTION_NAME, |
|
170 | + null, |
|
171 | + $mode, |
|
172 | + '', |
|
173 | + null, |
|
174 | + ), |
|
175 | + '--opt=10.8', |
|
176 | + TypedInput::createForScalar( |
|
177 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'10.8\'"'), |
|
178 | + true, |
|
179 | + true, |
|
180 | + '10.8', |
|
181 | + '10.8', |
|
182 | + new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
183 | + new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
184 | + 10.8, |
|
185 | + 10.8, |
|
186 | + ), |
|
187 | + ]; |
|
188 | + |
|
189 | + // negative float string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
190 | + |
|
191 | + yield 'zero float string' => [ |
|
192 | + new InputOption( |
|
193 | + self::OPTION_NAME, |
|
194 | + null, |
|
195 | + $mode, |
|
196 | + '', |
|
197 | + null, |
|
198 | + ), |
|
199 | + '--opt=0.', |
|
200 | + TypedInput::createForScalar( |
|
201 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "\'0.\'"'), |
|
202 | + true, |
|
203 | + true, |
|
204 | + '0.', |
|
205 | + '0.', |
|
206 | + new TypeException('Expected an integer. Got "\'0.\'"'), |
|
207 | + new TypeException('Expected an integer. Got "\'0.\'"'), |
|
208 | + 0., |
|
209 | + 0., |
|
210 | + ), |
|
211 | + ]; |
|
212 | + } |
|
213 | + |
|
214 | + public static function optionalOptionProvider(): iterable |
|
215 | + { |
|
216 | + yield 'empty string' => [ |
|
217 | + new InputOption( |
|
218 | + self::OPTION_NAME, |
|
219 | + null, |
|
220 | + InputOption::VALUE_OPTIONAL, |
|
221 | + '', |
|
222 | + null, |
|
223 | + ), |
|
224 | + '', |
|
225 | + TypedInput::createForScalar( |
|
226 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "NULL"'), |
|
227 | + false, |
|
228 | + null, |
|
229 | + '', |
|
230 | + null, |
|
231 | + new TypeException('Expected an integer. Got "NULL"'), |
|
232 | + null, |
|
233 | + new TypeException('Expected a numeric. Got "NULL"'), |
|
234 | + null, |
|
235 | + ), |
|
236 | + ]; |
|
237 | + } |
|
238 | + |
|
239 | + public static function noValueOptionProvider(): iterable |
|
240 | + { |
|
241 | + $mode = InputOption::VALUE_NONE; |
|
242 | + |
|
243 | + yield 'option absent' => [ |
|
244 | + new InputOption( |
|
245 | + self::OPTION_NAME, |
|
246 | + null, |
|
247 | + $mode, |
|
248 | + '', |
|
249 | + null, // is ignored for VALUE_NONE (must be NULL) |
|
250 | + ), |
|
251 | + '', |
|
252 | + TypedInput::createForScalar( |
|
253 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "false"'), |
|
254 | + false, |
|
255 | + false, |
|
256 | + '', |
|
257 | + '', |
|
258 | + new TypeException('Expected an integer. Got "false"'), |
|
259 | + new TypeException('Expected an integer. Got "false"'), |
|
260 | + new TypeException('Expected a numeric. Got "false"'), |
|
261 | + new TypeException('Expected a numeric. Got "false"'), |
|
262 | + ), |
|
263 | + ]; |
|
264 | + |
|
265 | + yield 'option present' => [ |
|
266 | + new InputOption( |
|
267 | + self::OPTION_NAME, |
|
268 | + null, |
|
269 | + $mode, |
|
270 | + '', |
|
271 | + null, |
|
272 | + ), |
|
273 | + '--opt', |
|
274 | + TypedInput::createForScalar( |
|
275 | + new TypeException('Cannot cast a non-array input argument into an array. Got the value "true"'), |
|
276 | + true, |
|
277 | + true, |
|
278 | + '1', |
|
279 | + '1', |
|
280 | + new TypeException('Expected an integer. Got "true"'), |
|
281 | + new TypeException('Expected an integer. Got "true"'), |
|
282 | + new TypeException('Expected a numeric. Got "true"'), |
|
283 | + new TypeException('Expected a numeric. Got "true"'), |
|
284 | + ), |
|
285 | + ]; |
|
286 | + } |
|
287 | + |
|
288 | + public static function arrayOptionProvider(): iterable |
|
289 | + { |
|
290 | + $mode = InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY; |
|
291 | + |
|
292 | + yield 'empty string' => [ |
|
293 | + new InputOption( |
|
294 | + self::OPTION_NAME, |
|
295 | + null, |
|
296 | + $mode, |
|
297 | + '', |
|
298 | + null, |
|
299 | + ), |
|
300 | + '--opt=""', |
|
301 | + TypedInput::createForArray( |
|
302 | + new TypeException( |
|
303 | + <<<'TXT' |
|
304 | 304 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
305 | 305 | 0 => '', |
306 | 306 | )" |
307 | 307 | TXT, |
308 | - ), |
|
309 | - [''], |
|
310 | - new TypeException('Expected an integer. Got "\'\'"'), |
|
311 | - new TypeException('Expected a numeric. Got "\'\'"'), |
|
312 | - ), |
|
313 | - ]; |
|
314 | - |
|
315 | - yield 'single element string' => [ |
|
316 | - new InputOption( |
|
317 | - self::OPTION_NAME, |
|
318 | - null, |
|
319 | - $mode, |
|
320 | - '', |
|
321 | - null, |
|
322 | - ), |
|
323 | - '--opt=foo', |
|
324 | - TypedInput::createForArray( |
|
325 | - new TypeException( |
|
326 | - <<<'TXT' |
|
308 | + ), |
|
309 | + [''], |
|
310 | + new TypeException('Expected an integer. Got "\'\'"'), |
|
311 | + new TypeException('Expected a numeric. Got "\'\'"'), |
|
312 | + ), |
|
313 | + ]; |
|
314 | + |
|
315 | + yield 'single element string' => [ |
|
316 | + new InputOption( |
|
317 | + self::OPTION_NAME, |
|
318 | + null, |
|
319 | + $mode, |
|
320 | + '', |
|
321 | + null, |
|
322 | + ), |
|
323 | + '--opt=foo', |
|
324 | + TypedInput::createForArray( |
|
325 | + new TypeException( |
|
326 | + <<<'TXT' |
|
327 | 327 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
328 | 328 | 0 => 'foo', |
329 | 329 | )" |
330 | 330 | TXT, |
331 | - ), |
|
332 | - ['foo'], |
|
333 | - new TypeException('Expected an integer. Got "\'foo\'"'), |
|
334 | - new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
335 | - ), |
|
336 | - ]; |
|
337 | - |
|
338 | - yield 'multiple elements string' => [ |
|
339 | - new InputOption( |
|
340 | - self::OPTION_NAME, |
|
341 | - null, |
|
342 | - $mode, |
|
343 | - '', |
|
344 | - null, |
|
345 | - ), |
|
346 | - '--opt=foo --opt=bar --opt=baz', |
|
347 | - TypedInput::createForArray( |
|
348 | - new TypeException( |
|
349 | - <<<'TXT' |
|
331 | + ), |
|
332 | + ['foo'], |
|
333 | + new TypeException('Expected an integer. Got "\'foo\'"'), |
|
334 | + new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
335 | + ), |
|
336 | + ]; |
|
337 | + |
|
338 | + yield 'multiple elements string' => [ |
|
339 | + new InputOption( |
|
340 | + self::OPTION_NAME, |
|
341 | + null, |
|
342 | + $mode, |
|
343 | + '', |
|
344 | + null, |
|
345 | + ), |
|
346 | + '--opt=foo --opt=bar --opt=baz', |
|
347 | + TypedInput::createForArray( |
|
348 | + new TypeException( |
|
349 | + <<<'TXT' |
|
350 | 350 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
351 | 351 | 0 => 'foo', |
352 | 352 | 1 => 'bar', |
353 | 353 | 2 => 'baz', |
354 | 354 | )" |
355 | 355 | TXT, |
356 | - ), |
|
357 | - ['foo', 'bar', 'baz'], |
|
358 | - new TypeException('Expected an integer. Got "\'foo\'"'), |
|
359 | - new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
360 | - ), |
|
361 | - ]; |
|
362 | - |
|
363 | - yield 'null string' => [ |
|
364 | - new InputOption( |
|
365 | - self::OPTION_NAME, |
|
366 | - null, |
|
367 | - $mode, |
|
368 | - '', |
|
369 | - null, |
|
370 | - ), |
|
371 | - '--opt=null', |
|
372 | - TypedInput::createForArray( |
|
373 | - new TypeException( |
|
374 | - <<<'TXT' |
|
356 | + ), |
|
357 | + ['foo', 'bar', 'baz'], |
|
358 | + new TypeException('Expected an integer. Got "\'foo\'"'), |
|
359 | + new TypeException('Expected a numeric. Got "\'foo\'"'), |
|
360 | + ), |
|
361 | + ]; |
|
362 | + |
|
363 | + yield 'null string' => [ |
|
364 | + new InputOption( |
|
365 | + self::OPTION_NAME, |
|
366 | + null, |
|
367 | + $mode, |
|
368 | + '', |
|
369 | + null, |
|
370 | + ), |
|
371 | + '--opt=null', |
|
372 | + TypedInput::createForArray( |
|
373 | + new TypeException( |
|
374 | + <<<'TXT' |
|
375 | 375 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
376 | 376 | 0 => 'null', |
377 | 377 | )" |
378 | 378 | TXT, |
379 | - ), |
|
380 | - ['null'], |
|
381 | - new TypeException('Expected an integer. Got "\'null\'"'), |
|
382 | - new TypeException('Expected a numeric. Got "\'null\'"'), |
|
383 | - ), |
|
384 | - ]; |
|
385 | - |
|
386 | - yield 'integer string' => [ |
|
387 | - new InputOption( |
|
388 | - self::OPTION_NAME, |
|
389 | - null, |
|
390 | - $mode, |
|
391 | - '', |
|
392 | - null, |
|
393 | - ), |
|
394 | - '--opt=10', |
|
395 | - TypedInput::createForArray( |
|
396 | - new TypeException( |
|
397 | - <<<'TXT' |
|
379 | + ), |
|
380 | + ['null'], |
|
381 | + new TypeException('Expected an integer. Got "\'null\'"'), |
|
382 | + new TypeException('Expected a numeric. Got "\'null\'"'), |
|
383 | + ), |
|
384 | + ]; |
|
385 | + |
|
386 | + yield 'integer string' => [ |
|
387 | + new InputOption( |
|
388 | + self::OPTION_NAME, |
|
389 | + null, |
|
390 | + $mode, |
|
391 | + '', |
|
392 | + null, |
|
393 | + ), |
|
394 | + '--opt=10', |
|
395 | + TypedInput::createForArray( |
|
396 | + new TypeException( |
|
397 | + <<<'TXT' |
|
398 | 398 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
399 | 399 | 0 => '10', |
400 | 400 | )" |
401 | 401 | TXT, |
402 | - ), |
|
403 | - ['10'], |
|
404 | - [10], |
|
405 | - [10.], |
|
406 | - ), |
|
407 | - ]; |
|
408 | - |
|
409 | - // negative integer string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
410 | - |
|
411 | - yield 'zero integer string' => [ |
|
412 | - new InputOption( |
|
413 | - self::OPTION_NAME, |
|
414 | - null, |
|
415 | - $mode, |
|
416 | - '', |
|
417 | - null, |
|
418 | - ), |
|
419 | - '--opt=0', |
|
420 | - TypedInput::createForArray( |
|
421 | - new TypeException( |
|
422 | - <<<'TXT' |
|
402 | + ), |
|
403 | + ['10'], |
|
404 | + [10], |
|
405 | + [10.], |
|
406 | + ), |
|
407 | + ]; |
|
408 | + |
|
409 | + // negative integer string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
410 | + |
|
411 | + yield 'zero integer string' => [ |
|
412 | + new InputOption( |
|
413 | + self::OPTION_NAME, |
|
414 | + null, |
|
415 | + $mode, |
|
416 | + '', |
|
417 | + null, |
|
418 | + ), |
|
419 | + '--opt=0', |
|
420 | + TypedInput::createForArray( |
|
421 | + new TypeException( |
|
422 | + <<<'TXT' |
|
423 | 423 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
424 | 424 | 0 => '0', |
425 | 425 | )" |
426 | 426 | TXT, |
427 | - ), |
|
428 | - ['0'], |
|
429 | - [0], |
|
430 | - [0.], |
|
431 | - ), |
|
432 | - ]; |
|
433 | - |
|
434 | - yield 'float string' => [ |
|
435 | - new InputOption( |
|
436 | - self::OPTION_NAME, |
|
437 | - null, |
|
438 | - $mode, |
|
439 | - '', |
|
440 | - null, |
|
441 | - ), |
|
442 | - '--opt=10.8', |
|
443 | - TypedInput::createForArray( |
|
444 | - new TypeException( |
|
445 | - <<<'TXT' |
|
427 | + ), |
|
428 | + ['0'], |
|
429 | + [0], |
|
430 | + [0.], |
|
431 | + ), |
|
432 | + ]; |
|
433 | + |
|
434 | + yield 'float string' => [ |
|
435 | + new InputOption( |
|
436 | + self::OPTION_NAME, |
|
437 | + null, |
|
438 | + $mode, |
|
439 | + '', |
|
440 | + null, |
|
441 | + ), |
|
442 | + '--opt=10.8', |
|
443 | + TypedInput::createForArray( |
|
444 | + new TypeException( |
|
445 | + <<<'TXT' |
|
446 | 446 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
447 | 447 | 0 => '10.8', |
448 | 448 | )" |
449 | 449 | TXT, |
450 | - ), |
|
451 | - ['10.8'], |
|
452 | - new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
453 | - [10.8], |
|
454 | - ), |
|
455 | - ]; |
|
456 | - |
|
457 | - // negative float string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
458 | - |
|
459 | - yield 'zero float string' => [ |
|
460 | - new InputOption( |
|
461 | - self::OPTION_NAME, |
|
462 | - null, |
|
463 | - $mode, |
|
464 | - '', |
|
465 | - null, |
|
466 | - ), |
|
467 | - '--opt=0.', |
|
468 | - TypedInput::createForArray( |
|
469 | - new TypeException( |
|
470 | - <<<'TXT' |
|
450 | + ), |
|
451 | + ['10.8'], |
|
452 | + new TypeException('Expected an integer. Got "\'10.8\'"'), |
|
453 | + [10.8], |
|
454 | + ), |
|
455 | + ]; |
|
456 | + |
|
457 | + // negative float string case: skipped see https://github.com/symfony/symfony/issues/27333 |
|
458 | + |
|
459 | + yield 'zero float string' => [ |
|
460 | + new InputOption( |
|
461 | + self::OPTION_NAME, |
|
462 | + null, |
|
463 | + $mode, |
|
464 | + '', |
|
465 | + null, |
|
466 | + ), |
|
467 | + '--opt=0.', |
|
468 | + TypedInput::createForArray( |
|
469 | + new TypeException( |
|
470 | + <<<'TXT' |
|
471 | 471 | Cannot cast an array input argument as a scalar. Got the argument value: "array ( |
472 | 472 | 0 => '0.', |
473 | 473 | )" |
474 | 474 | TXT, |
475 | - ), |
|
476 | - ['0.'], |
|
477 | - new TypeException('Expected an integer. Got "\'0.\'"'), |
|
478 | - [0.], |
|
479 | - ), |
|
480 | - ]; |
|
481 | - } |
|
482 | - |
|
483 | - private function getIO( |
|
484 | - InputOption $inputOption, |
|
485 | - string $option |
|
486 | - ): IO { |
|
487 | - $application = new Application(); |
|
488 | - $application->add( |
|
489 | - new DynamicCommandWithOptions($inputOption), |
|
490 | - ); |
|
491 | - |
|
492 | - $input = new StringInput('app:input:opts '.$option); |
|
493 | - $input->setInteractive(false); |
|
494 | - |
|
495 | - $application->doRun( |
|
496 | - $input, |
|
497 | - new NullOutput(), |
|
498 | - ); |
|
499 | - |
|
500 | - $command = $application->find('app:input:opts'); |
|
501 | - self::assertInstanceOf(DynamicCommandWithOptions::class, $command); |
|
502 | - |
|
503 | - return new IO( |
|
504 | - $command->input, |
|
505 | - new NullOutput(), |
|
506 | - ); |
|
507 | - } |
|
475 | + ), |
|
476 | + ['0.'], |
|
477 | + new TypeException('Expected an integer. Got "\'0.\'"'), |
|
478 | + [0.], |
|
479 | + ), |
|
480 | + ]; |
|
481 | + } |
|
482 | + |
|
483 | + private function getIO( |
|
484 | + InputOption $inputOption, |
|
485 | + string $option |
|
486 | + ): IO { |
|
487 | + $application = new Application(); |
|
488 | + $application->add( |
|
489 | + new DynamicCommandWithOptions($inputOption), |
|
490 | + ); |
|
491 | + |
|
492 | + $input = new StringInput('app:input:opts '.$option); |
|
493 | + $input->setInteractive(false); |
|
494 | + |
|
495 | + $application->doRun( |
|
496 | + $input, |
|
497 | + new NullOutput(), |
|
498 | + ); |
|
499 | + |
|
500 | + $command = $application->find('app:input:opts'); |
|
501 | + self::assertInstanceOf(DynamicCommandWithOptions::class, $command); |
|
502 | + |
|
503 | + return new IO( |
|
504 | + $command->input, |
|
505 | + new NullOutput(), |
|
506 | + ); |
|
507 | + } |
|
508 | 508 | } |
@@ -246,7 +246,7 @@ |
||
246 | 246 | null, |
247 | 247 | $mode, |
248 | 248 | '', |
249 | - null, // is ignored for VALUE_NONE (must be NULL) |
|
249 | + null, // is ignored for VALUE_NONE (must be NULL) |
|
250 | 250 | ), |
251 | 251 | '', |
252 | 252 | TypedInput::createForScalar( |
@@ -24,8 +24,7 @@ |
||
24 | 24 | * @covers \Fidry\Console\Command\ConsoleAssert |
25 | 25 | * @covers \Fidry\Console\IO |
26 | 26 | */ |
27 | -final class IOOptionsTest extends TestCase |
|
28 | -{ |
|
27 | +final class IOOptionsTest extends TestCase { |
|
29 | 28 | private const OPTION_NAME = 'opt'; |
30 | 29 | |
31 | 30 | /** |
@@ -21,22 +21,22 @@ |
||
21 | 21 | |
22 | 22 | final class DynamicCommandWithOptions extends Command |
23 | 23 | { |
24 | - /** |
|
25 | - * @psalm-suppress PropertyNotSetInConstructor |
|
26 | - */ |
|
27 | - public InputInterface $input; |
|
24 | + /** |
|
25 | + * @psalm-suppress PropertyNotSetInConstructor |
|
26 | + */ |
|
27 | + public InputInterface $input; |
|
28 | 28 | |
29 | - public function __construct(InputOption $inputOption) |
|
30 | - { |
|
31 | - parent::__construct('app:input:opts'); |
|
29 | + public function __construct(InputOption $inputOption) |
|
30 | + { |
|
31 | + parent::__construct('app:input:opts'); |
|
32 | 32 | |
33 | - $this->getDefinition()->addOption($inputOption); |
|
34 | - } |
|
33 | + $this->getDefinition()->addOption($inputOption); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function execute(InputInterface $input, OutputInterface $output): int |
|
37 | - { |
|
38 | - $this->input = $input; |
|
36 | + protected function execute(InputInterface $input, OutputInterface $output): int |
|
37 | + { |
|
38 | + $this->input = $input; |
|
39 | 39 | |
40 | - return ExitCode::SUCCESS; |
|
41 | - } |
|
40 | + return ExitCode::SUCCESS; |
|
41 | + } |
|
42 | 42 | } |
@@ -19,8 +19,7 @@ |
||
19 | 19 | use Symfony\Component\Console\Input\InputOption; |
20 | 20 | use Symfony\Component\Console\Output\OutputInterface; |
21 | 21 | |
22 | -final class DynamicCommandWithOptions extends Command |
|
23 | -{ |
|
22 | +final class DynamicCommandWithOptions extends Command { |
|
24 | 23 | /** |
25 | 24 | * @psalm-suppress PropertyNotSetInConstructor |
26 | 25 | */ |
@@ -15,10 +15,10 @@ |
||
15 | 15 | |
16 | 16 | final class TypeException |
17 | 17 | { |
18 | - public string $message; |
|
18 | + public string $message; |
|
19 | 19 | |
20 | - public function __construct(string $message) |
|
21 | - { |
|
22 | - $this->message = $message; |
|
23 | - } |
|
20 | + public function __construct(string $message) |
|
21 | + { |
|
22 | + $this->message = $message; |
|
23 | + } |
|
24 | 24 | } |
@@ -13,8 +13,7 @@ |
||
13 | 13 | |
14 | 14 | namespace Fidry\Console\Tests\IO; |
15 | 15 | |
16 | -final class TypeException |
|
17 | -{ |
|
16 | +final class TypeException { |
|
18 | 17 | public string $message; |
19 | 18 | |
20 | 19 | public function __construct(string $message) |
@@ -20,142 +20,142 @@ |
||
20 | 20 | |
21 | 21 | final class TypeAssertions |
22 | 22 | { |
23 | - private function __construct() |
|
24 | - { |
|
25 | - } |
|
23 | + private function __construct() |
|
24 | + { |
|
25 | + } |
|
26 | 26 | |
27 | - public static function assertExpectedArgumentTypes( |
|
28 | - TypedInput $expected, |
|
29 | - IO $io, |
|
30 | - string $argumentName |
|
31 | - ): void { |
|
32 | - self::assertExpectedType( |
|
33 | - $expected->boolean, |
|
34 | - static fn () => $io->getBooleanArgument($argumentName), |
|
35 | - ); |
|
36 | - self::assertExpectedType( |
|
37 | - $expected->nullableBoolean, |
|
38 | - static fn () => $io->getNullableBooleanArgument($argumentName), |
|
39 | - ); |
|
40 | - self::assertExpectedType( |
|
41 | - $expected->string, |
|
42 | - static fn () => $io->getStringArgument($argumentName), |
|
43 | - ); |
|
44 | - self::assertExpectedType( |
|
45 | - $expected->nullableString, |
|
46 | - static fn () => $io->getNullableStringArgument($argumentName), |
|
47 | - ); |
|
48 | - self::assertExpectedType( |
|
49 | - $expected->stringArray, |
|
50 | - static fn () => $io->getStringArrayArgument($argumentName), |
|
51 | - ); |
|
52 | - self::assertExpectedType( |
|
53 | - $expected->integer, |
|
54 | - static fn () => $io->getIntegerArgument($argumentName), |
|
55 | - ); |
|
56 | - self::assertExpectedType( |
|
57 | - $expected->nullableInteger, |
|
58 | - static fn () => $io->getNullableIntegerArgument($argumentName), |
|
59 | - ); |
|
60 | - self::assertExpectedType( |
|
61 | - $expected->integerArray, |
|
62 | - static fn () => $io->getIntegerArrayArgument($argumentName), |
|
63 | - ); |
|
64 | - self::assertExpectedType( |
|
65 | - $expected->float, |
|
66 | - static fn () => $io->getFloatArgument($argumentName), |
|
67 | - ); |
|
68 | - self::assertExpectedType( |
|
69 | - $expected->nullableFloat, |
|
70 | - static fn () => $io->getNullableFloatArgument($argumentName), |
|
71 | - ); |
|
72 | - self::assertExpectedType( |
|
73 | - $expected->floatArray, |
|
74 | - static fn () => $io->getFloatArrayArgument($argumentName), |
|
75 | - ); |
|
76 | - } |
|
27 | + public static function assertExpectedArgumentTypes( |
|
28 | + TypedInput $expected, |
|
29 | + IO $io, |
|
30 | + string $argumentName |
|
31 | + ): void { |
|
32 | + self::assertExpectedType( |
|
33 | + $expected->boolean, |
|
34 | + static fn () => $io->getBooleanArgument($argumentName), |
|
35 | + ); |
|
36 | + self::assertExpectedType( |
|
37 | + $expected->nullableBoolean, |
|
38 | + static fn () => $io->getNullableBooleanArgument($argumentName), |
|
39 | + ); |
|
40 | + self::assertExpectedType( |
|
41 | + $expected->string, |
|
42 | + static fn () => $io->getStringArgument($argumentName), |
|
43 | + ); |
|
44 | + self::assertExpectedType( |
|
45 | + $expected->nullableString, |
|
46 | + static fn () => $io->getNullableStringArgument($argumentName), |
|
47 | + ); |
|
48 | + self::assertExpectedType( |
|
49 | + $expected->stringArray, |
|
50 | + static fn () => $io->getStringArrayArgument($argumentName), |
|
51 | + ); |
|
52 | + self::assertExpectedType( |
|
53 | + $expected->integer, |
|
54 | + static fn () => $io->getIntegerArgument($argumentName), |
|
55 | + ); |
|
56 | + self::assertExpectedType( |
|
57 | + $expected->nullableInteger, |
|
58 | + static fn () => $io->getNullableIntegerArgument($argumentName), |
|
59 | + ); |
|
60 | + self::assertExpectedType( |
|
61 | + $expected->integerArray, |
|
62 | + static fn () => $io->getIntegerArrayArgument($argumentName), |
|
63 | + ); |
|
64 | + self::assertExpectedType( |
|
65 | + $expected->float, |
|
66 | + static fn () => $io->getFloatArgument($argumentName), |
|
67 | + ); |
|
68 | + self::assertExpectedType( |
|
69 | + $expected->nullableFloat, |
|
70 | + static fn () => $io->getNullableFloatArgument($argumentName), |
|
71 | + ); |
|
72 | + self::assertExpectedType( |
|
73 | + $expected->floatArray, |
|
74 | + static fn () => $io->getFloatArrayArgument($argumentName), |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - public static function assertExpectedOptionTypes( |
|
79 | - TypedInput $expected, |
|
80 | - IO $io, |
|
81 | - string $optionName |
|
82 | - ): void { |
|
83 | - self::assertExpectedType( |
|
84 | - $expected->boolean, |
|
85 | - static fn () => $io->getBooleanOption($optionName), |
|
86 | - ); |
|
87 | - self::assertExpectedType( |
|
88 | - $expected->nullableBoolean, |
|
89 | - static fn () => $io->getNullableBooleanOption($optionName), |
|
90 | - ); |
|
91 | - self::assertExpectedType( |
|
92 | - $expected->string, |
|
93 | - static fn () => $io->getStringOption($optionName), |
|
94 | - ); |
|
95 | - self::assertExpectedType( |
|
96 | - $expected->nullableString, |
|
97 | - static fn () => $io->getNullableStringOption($optionName), |
|
98 | - ); |
|
99 | - self::assertExpectedType( |
|
100 | - $expected->stringArray, |
|
101 | - static fn () => $io->getStringArrayOption($optionName), |
|
102 | - ); |
|
103 | - self::assertExpectedType( |
|
104 | - $expected->integer, |
|
105 | - static fn () => $io->getIntegerOption($optionName), |
|
106 | - ); |
|
107 | - self::assertExpectedType( |
|
108 | - $expected->nullableInteger, |
|
109 | - static fn () => $io->getNullableIntegerOption($optionName), |
|
110 | - ); |
|
111 | - self::assertExpectedType( |
|
112 | - $expected->integerArray, |
|
113 | - static fn () => $io->getIntegerArrayOption($optionName), |
|
114 | - ); |
|
115 | - self::assertExpectedType( |
|
116 | - $expected->float, |
|
117 | - static fn () => $io->getFloatOption($optionName), |
|
118 | - ); |
|
119 | - self::assertExpectedType( |
|
120 | - $expected->nullableFloat, |
|
121 | - static fn () => $io->getNullableFloatOption($optionName), |
|
122 | - ); |
|
123 | - self::assertExpectedType( |
|
124 | - $expected->floatArray, |
|
125 | - static fn () => $io->getFloatArrayOption($optionName), |
|
126 | - ); |
|
127 | - } |
|
78 | + public static function assertExpectedOptionTypes( |
|
79 | + TypedInput $expected, |
|
80 | + IO $io, |
|
81 | + string $optionName |
|
82 | + ): void { |
|
83 | + self::assertExpectedType( |
|
84 | + $expected->boolean, |
|
85 | + static fn () => $io->getBooleanOption($optionName), |
|
86 | + ); |
|
87 | + self::assertExpectedType( |
|
88 | + $expected->nullableBoolean, |
|
89 | + static fn () => $io->getNullableBooleanOption($optionName), |
|
90 | + ); |
|
91 | + self::assertExpectedType( |
|
92 | + $expected->string, |
|
93 | + static fn () => $io->getStringOption($optionName), |
|
94 | + ); |
|
95 | + self::assertExpectedType( |
|
96 | + $expected->nullableString, |
|
97 | + static fn () => $io->getNullableStringOption($optionName), |
|
98 | + ); |
|
99 | + self::assertExpectedType( |
|
100 | + $expected->stringArray, |
|
101 | + static fn () => $io->getStringArrayOption($optionName), |
|
102 | + ); |
|
103 | + self::assertExpectedType( |
|
104 | + $expected->integer, |
|
105 | + static fn () => $io->getIntegerOption($optionName), |
|
106 | + ); |
|
107 | + self::assertExpectedType( |
|
108 | + $expected->nullableInteger, |
|
109 | + static fn () => $io->getNullableIntegerOption($optionName), |
|
110 | + ); |
|
111 | + self::assertExpectedType( |
|
112 | + $expected->integerArray, |
|
113 | + static fn () => $io->getIntegerArrayOption($optionName), |
|
114 | + ); |
|
115 | + self::assertExpectedType( |
|
116 | + $expected->float, |
|
117 | + static fn () => $io->getFloatOption($optionName), |
|
118 | + ); |
|
119 | + self::assertExpectedType( |
|
120 | + $expected->nullableFloat, |
|
121 | + static fn () => $io->getNullableFloatOption($optionName), |
|
122 | + ); |
|
123 | + self::assertExpectedType( |
|
124 | + $expected->floatArray, |
|
125 | + static fn () => $io->getFloatArrayOption($optionName), |
|
126 | + ); |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * @param mixed|TypeException $expected |
|
131 | - * @param callable():mixed $getArgument |
|
132 | - */ |
|
133 | - private static function assertExpectedType($expected, callable $getArgument): void |
|
134 | - { |
|
135 | - try { |
|
136 | - $actual = $getArgument(); |
|
129 | + /** |
|
130 | + * @param mixed|TypeException $expected |
|
131 | + * @param callable():mixed $getArgument |
|
132 | + */ |
|
133 | + private static function assertExpectedType($expected, callable $getArgument): void |
|
134 | + { |
|
135 | + try { |
|
136 | + $actual = $getArgument(); |
|
137 | 137 | |
138 | - if ($expected instanceof TypeException) { |
|
139 | - Assert::fail( |
|
140 | - sprintf( |
|
141 | - 'Expected a type exception to be thrown with the message "%s"', |
|
142 | - $expected->message, |
|
143 | - ), |
|
144 | - ); |
|
145 | - } |
|
146 | - } catch (ConsoleInvalidArgumentException $exception) { |
|
147 | - if ($expected instanceof TypeException) { |
|
148 | - Assert::assertSame( |
|
149 | - $expected->message, |
|
150 | - $exception->getMessage(), |
|
151 | - ); |
|
138 | + if ($expected instanceof TypeException) { |
|
139 | + Assert::fail( |
|
140 | + sprintf( |
|
141 | + 'Expected a type exception to be thrown with the message "%s"', |
|
142 | + $expected->message, |
|
143 | + ), |
|
144 | + ); |
|
145 | + } |
|
146 | + } catch (ConsoleInvalidArgumentException $exception) { |
|
147 | + if ($expected instanceof TypeException) { |
|
148 | + Assert::assertSame( |
|
149 | + $expected->message, |
|
150 | + $exception->getMessage(), |
|
151 | + ); |
|
152 | 152 | |
153 | - return; |
|
154 | - } |
|
153 | + return; |
|
154 | + } |
|
155 | 155 | |
156 | - throw $exception; |
|
157 | - } |
|
156 | + throw $exception; |
|
157 | + } |
|
158 | 158 | |
159 | - Assert::assertSame($expected, $actual); |
|
160 | - } |
|
159 | + Assert::assertSame($expected, $actual); |
|
160 | + } |
|
161 | 161 | } |
@@ -18,8 +18,7 @@ |
||
18 | 18 | use function Safe\sprintf; |
19 | 19 | use Symfony\Component\Console\Exception\InvalidArgumentException as ConsoleInvalidArgumentException; |
20 | 20 | |
21 | -final class TypeAssertions |
|
22 | -{ |
|
21 | +final class TypeAssertions { |
|
23 | 22 | private function __construct() |
24 | 23 | { |
25 | 24 | } |
@@ -15,159 +15,159 @@ |
||
15 | 15 | |
16 | 16 | final class TypedInput |
17 | 17 | { |
18 | - /** |
|
19 | - * @var bool|TypeException |
|
20 | - */ |
|
21 | - public $boolean; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var null|bool|TypeException |
|
25 | - */ |
|
26 | - public $nullableBoolean; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string|TypeException |
|
30 | - */ |
|
31 | - public $string; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var null|string|TypeException |
|
35 | - */ |
|
36 | - public $nullableString; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string[]|TypeException |
|
40 | - */ |
|
41 | - public $stringArray; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var int|TypeException |
|
45 | - */ |
|
46 | - public $integer; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var null|int|TypeException |
|
50 | - */ |
|
51 | - public $nullableInteger; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var int[]|TypeException |
|
55 | - */ |
|
56 | - public $integerArray; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var float|TypeException |
|
60 | - */ |
|
61 | - public $float; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var null|float|TypeException |
|
65 | - */ |
|
66 | - public $nullableFloat; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var float[]|TypeException |
|
70 | - */ |
|
71 | - public $floatArray; |
|
72 | - |
|
73 | - /** |
|
74 | - * @param bool|TypeException $boolean |
|
75 | - * @param null|bool|TypeException $nullableBoolean |
|
76 | - * @param string|TypeException $string |
|
77 | - * @param null|string|TypeException $nullableString |
|
78 | - * @param string[]|TypeException $stringArray |
|
79 | - * @param int|TypeException $integer |
|
80 | - * @param null|int|TypeException $nullableInteger |
|
81 | - * @param int[]|TypeException $integerArray |
|
82 | - * @param float|TypeException $float |
|
83 | - * @param null|float|TypeException $nullableFloat |
|
84 | - * @param float[]|TypeException $floatArray |
|
85 | - */ |
|
86 | - public function __construct( |
|
87 | - $boolean, |
|
88 | - $nullableBoolean, |
|
89 | - $string, |
|
90 | - $nullableString, |
|
91 | - $stringArray, |
|
92 | - $integer, |
|
93 | - $nullableInteger, |
|
94 | - $integerArray, |
|
95 | - $float, |
|
96 | - $nullableFloat, |
|
97 | - $floatArray |
|
98 | - ) { |
|
99 | - $this->boolean = $boolean; |
|
100 | - $this->nullableBoolean = $nullableBoolean; |
|
101 | - $this->string = $string; |
|
102 | - $this->nullableString = $nullableString; |
|
103 | - $this->stringArray = $stringArray; |
|
104 | - $this->integer = $integer; |
|
105 | - $this->nullableInteger = $nullableInteger; |
|
106 | - $this->integerArray = $integerArray; |
|
107 | - $this->float = $float; |
|
108 | - $this->nullableFloat = $nullableFloat; |
|
109 | - $this->floatArray = $floatArray; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @param bool|TypeException $boolean |
|
114 | - * @param null|bool|TypeException $nullableBoolean |
|
115 | - * @param string|TypeException $string |
|
116 | - * @param null|string|TypeException $nullableString |
|
117 | - * @param int|TypeException $integer |
|
118 | - * @param null|int|TypeException $nullableInteger |
|
119 | - * @param float|TypeException $float |
|
120 | - * @param null|float|TypeException $nullableFloat |
|
121 | - */ |
|
122 | - public static function createForScalar( |
|
123 | - TypeException $arrayToScalarTypeException, |
|
124 | - $boolean, |
|
125 | - $nullableBoolean, |
|
126 | - $string, |
|
127 | - $nullableString, |
|
128 | - $integer, |
|
129 | - $nullableInteger, |
|
130 | - $float, |
|
131 | - $nullableFloat |
|
132 | - ): self { |
|
133 | - return new self( |
|
134 | - $boolean, |
|
135 | - $nullableBoolean, |
|
136 | - $string, |
|
137 | - $nullableString, |
|
138 | - $arrayToScalarTypeException, |
|
139 | - $integer, |
|
140 | - $nullableInteger, |
|
141 | - $arrayToScalarTypeException, |
|
142 | - $float, |
|
143 | - $nullableFloat, |
|
144 | - $arrayToScalarTypeException, |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @param string[]|TypeException $stringArray |
|
150 | - * @param int[]|TypeException $integerArray |
|
151 | - * @param float[]|TypeException $floatArray |
|
152 | - */ |
|
153 | - public static function createForArray( |
|
154 | - TypeException $scalarToArrayTypeException, |
|
155 | - $stringArray, |
|
156 | - $integerArray, |
|
157 | - $floatArray |
|
158 | - ): self { |
|
159 | - return new self( |
|
160 | - $scalarToArrayTypeException, |
|
161 | - $scalarToArrayTypeException, |
|
162 | - $scalarToArrayTypeException, |
|
163 | - $scalarToArrayTypeException, |
|
164 | - $stringArray, |
|
165 | - $scalarToArrayTypeException, |
|
166 | - $scalarToArrayTypeException, |
|
167 | - $integerArray, |
|
168 | - $scalarToArrayTypeException, |
|
169 | - $scalarToArrayTypeException, |
|
170 | - $floatArray, |
|
171 | - ); |
|
172 | - } |
|
18 | + /** |
|
19 | + * @var bool|TypeException |
|
20 | + */ |
|
21 | + public $boolean; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var null|bool|TypeException |
|
25 | + */ |
|
26 | + public $nullableBoolean; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string|TypeException |
|
30 | + */ |
|
31 | + public $string; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var null|string|TypeException |
|
35 | + */ |
|
36 | + public $nullableString; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string[]|TypeException |
|
40 | + */ |
|
41 | + public $stringArray; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var int|TypeException |
|
45 | + */ |
|
46 | + public $integer; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var null|int|TypeException |
|
50 | + */ |
|
51 | + public $nullableInteger; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var int[]|TypeException |
|
55 | + */ |
|
56 | + public $integerArray; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var float|TypeException |
|
60 | + */ |
|
61 | + public $float; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var null|float|TypeException |
|
65 | + */ |
|
66 | + public $nullableFloat; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var float[]|TypeException |
|
70 | + */ |
|
71 | + public $floatArray; |
|
72 | + |
|
73 | + /** |
|
74 | + * @param bool|TypeException $boolean |
|
75 | + * @param null|bool|TypeException $nullableBoolean |
|
76 | + * @param string|TypeException $string |
|
77 | + * @param null|string|TypeException $nullableString |
|
78 | + * @param string[]|TypeException $stringArray |
|
79 | + * @param int|TypeException $integer |
|
80 | + * @param null|int|TypeException $nullableInteger |
|
81 | + * @param int[]|TypeException $integerArray |
|
82 | + * @param float|TypeException $float |
|
83 | + * @param null|float|TypeException $nullableFloat |
|
84 | + * @param float[]|TypeException $floatArray |
|
85 | + */ |
|
86 | + public function __construct( |
|
87 | + $boolean, |
|
88 | + $nullableBoolean, |
|
89 | + $string, |
|
90 | + $nullableString, |
|
91 | + $stringArray, |
|
92 | + $integer, |
|
93 | + $nullableInteger, |
|
94 | + $integerArray, |
|
95 | + $float, |
|
96 | + $nullableFloat, |
|
97 | + $floatArray |
|
98 | + ) { |
|
99 | + $this->boolean = $boolean; |
|
100 | + $this->nullableBoolean = $nullableBoolean; |
|
101 | + $this->string = $string; |
|
102 | + $this->nullableString = $nullableString; |
|
103 | + $this->stringArray = $stringArray; |
|
104 | + $this->integer = $integer; |
|
105 | + $this->nullableInteger = $nullableInteger; |
|
106 | + $this->integerArray = $integerArray; |
|
107 | + $this->float = $float; |
|
108 | + $this->nullableFloat = $nullableFloat; |
|
109 | + $this->floatArray = $floatArray; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @param bool|TypeException $boolean |
|
114 | + * @param null|bool|TypeException $nullableBoolean |
|
115 | + * @param string|TypeException $string |
|
116 | + * @param null|string|TypeException $nullableString |
|
117 | + * @param int|TypeException $integer |
|
118 | + * @param null|int|TypeException $nullableInteger |
|
119 | + * @param float|TypeException $float |
|
120 | + * @param null|float|TypeException $nullableFloat |
|
121 | + */ |
|
122 | + public static function createForScalar( |
|
123 | + TypeException $arrayToScalarTypeException, |
|
124 | + $boolean, |
|
125 | + $nullableBoolean, |
|
126 | + $string, |
|
127 | + $nullableString, |
|
128 | + $integer, |
|
129 | + $nullableInteger, |
|
130 | + $float, |
|
131 | + $nullableFloat |
|
132 | + ): self { |
|
133 | + return new self( |
|
134 | + $boolean, |
|
135 | + $nullableBoolean, |
|
136 | + $string, |
|
137 | + $nullableString, |
|
138 | + $arrayToScalarTypeException, |
|
139 | + $integer, |
|
140 | + $nullableInteger, |
|
141 | + $arrayToScalarTypeException, |
|
142 | + $float, |
|
143 | + $nullableFloat, |
|
144 | + $arrayToScalarTypeException, |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * @param string[]|TypeException $stringArray |
|
150 | + * @param int[]|TypeException $integerArray |
|
151 | + * @param float[]|TypeException $floatArray |
|
152 | + */ |
|
153 | + public static function createForArray( |
|
154 | + TypeException $scalarToArrayTypeException, |
|
155 | + $stringArray, |
|
156 | + $integerArray, |
|
157 | + $floatArray |
|
158 | + ): self { |
|
159 | + return new self( |
|
160 | + $scalarToArrayTypeException, |
|
161 | + $scalarToArrayTypeException, |
|
162 | + $scalarToArrayTypeException, |
|
163 | + $scalarToArrayTypeException, |
|
164 | + $stringArray, |
|
165 | + $scalarToArrayTypeException, |
|
166 | + $scalarToArrayTypeException, |
|
167 | + $integerArray, |
|
168 | + $scalarToArrayTypeException, |
|
169 | + $scalarToArrayTypeException, |
|
170 | + $floatArray, |
|
171 | + ); |
|
172 | + } |
|
173 | 173 | } |
@@ -13,8 +13,7 @@ |
||
13 | 13 | |
14 | 14 | namespace Fidry\Console\Tests\IO; |
15 | 15 | |
16 | -final class TypedInput |
|
17 | -{ |
|
16 | +final class TypedInput { |
|
18 | 17 | /** |
19 | 18 | * @var bool|TypeException |
20 | 19 | */ |