Skip to content

Commit c45546b

Browse files
[DependencyInjection][Console] tighten types
1 parent 44f08fa commit c45546b

File tree

10 files changed

+31
-63
lines changed

10 files changed

+31
-63
lines changed

src/Symfony/Component/Console/Input/InputArgument.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class InputArgument
3131
private $description;
3232

3333
/**
34-
* @param string $name The argument name
35-
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
36-
* @param string $description A description text
37-
* @param mixed $default The default value (for self::OPTIONAL mode only)
34+
* @param string $name The argument name
35+
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
36+
* @param string $description A description text
37+
* @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only)
3838
*
3939
* @throws InvalidArgumentException When argument mode is not valid
4040
*/
@@ -86,7 +86,7 @@ public function isArray()
8686
/**
8787
* Sets the default value.
8888
*
89-
* @param mixed $default The default value
89+
* @param string|bool|int|float|array|null $default
9090
*
9191
* @throws LogicException When incorrect default value is given
9292
*/
@@ -110,7 +110,7 @@ public function setDefault($default = null)
110110
/**
111111
* Returns the default value.
112112
*
113-
* @return mixed
113+
* @return string|bool|int|float|array|null
114114
*/
115115
public function getDefault()
116116
{

src/Symfony/Component/Console/Input/InputDefinition.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ public function getArgumentRequiredCount()
185185
}
186186

187187
/**
188-
* Gets the default values.
189-
*
190-
* @return array An array of default values
188+
* @return array<string|bool|int|float|null|array>
191189
*/
192190
public function getArgumentDefaults()
193191
{
@@ -316,9 +314,7 @@ public function getOptionForShortcut($shortcut)
316314
}
317315

318316
/**
319-
* Gets an array of default values.
320-
*
321-
* @return array An array of all default values
317+
* @return array<string|bool|int|float|null|array>
322318
*/
323319
public function getOptionDefaults()
324320
{

src/Symfony/Component/Console/Input/InputInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function hasParameterOption($values, $onlyParams = false);
5151
* Does not necessarily return the correct result for short options
5252
* when multiple flags are combined in the same option.
5353
*
54-
* @param string|array $values The value(s) to look for in the raw parameters (can be an array)
55-
* @param mixed $default The default value to return if no result is found
56-
* @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
54+
* @param string|array $values The value(s) to look for in the raw parameters (can be an array)
55+
* @param string|bool|int|float|array|null $default The default value to return if no result is found
56+
* @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
5757
*
5858
* @return mixed The option value
5959
*/
@@ -76,7 +76,7 @@ public function validate();
7676
/**
7777
* Returns all the given arguments merged with the default values.
7878
*
79-
* @return array
79+
* @return array<string|bool|int|float|null|array>
8080
*/
8181
public function getArguments();
8282

@@ -113,7 +113,7 @@ public function hasArgument($name);
113113
/**
114114
* Returns all the given options merged with the default values.
115115
*
116-
* @return array
116+
* @return array<string|bool|int|float|null|array>
117117
*/
118118
public function getOptions();
119119

src/Symfony/Component/Console/Input/InputOption.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ class InputOption
4848
private $description;
4949

5050
/**
51-
* @param string $name The option name
52-
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
53-
* @param int|null $mode The option mode: One of the VALUE_* constants
54-
* @param string $description A description text
55-
* @param mixed $default The default value (must be null for self::VALUE_NONE)
51+
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
52+
* @param int|null $mode The option mode: One of the VALUE_* constants
53+
* @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
5654
*
5755
* @throws InvalidArgumentException If option mode is invalid or incompatible
5856
*/
@@ -162,11 +160,7 @@ public function isArray()
162160
}
163161

164162
/**
165-
* Sets the default value.
166-
*
167-
* @param mixed $default The default value
168-
*
169-
* @throws LogicException When incorrect default value is given
163+
* @param string|bool|int|float|array|null $default
170164
*/
171165
public function setDefault($default = null)
172166
{
@@ -188,7 +182,7 @@ public function setDefault($default = null)
188182
/**
189183
* Returns the default value.
190184
*
191-
* @return mixed
185+
* @return string|bool|int|float|array|null
192186
*/
193187
public function getDefault()
194188
{

src/Symfony/Component/Console/Question/Question.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Question
3232
private $trimmable = true;
3333

3434
/**
35-
* @param string $question The question to ask to the user
36-
* @param mixed $default The default answer to return if the user enters nothing
35+
* @param string $question The question to ask to the user
36+
* @param string|bool|int|float|null $default The default answer to return if the user enters nothing
3737
*/
3838
public function __construct(string $question, $default = null)
3939
{
@@ -54,7 +54,7 @@ public function getQuestion()
5454
/**
5555
* Returns the default answer.
5656
*
57-
* @return mixed
57+
* @return string|bool|int|float|null
5858
*/
5959
public function getDefault()
6060
{

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getParameterBag()
109109
*
110110
* @param string $name The parameter name
111111
*
112-
* @return mixed
112+
* @return array|bool|string|int|float|null
113113
*
114114
* @throws InvalidArgumentException if the parameter is not defined
115115
*/
@@ -133,8 +133,8 @@ public function hasParameter($name)
133133
/**
134134
* Sets a parameter.
135135
*
136-
* @param string $name The parameter name
137-
* @param mixed $value The parameter value
136+
* @param string $name The parameter name
137+
* @param array|bool|string|int|float|null $value The parameter value
138138
*/
139139
public function setParameter($name, $value)
140140
{

src/Symfony/Component/DependencyInjection/ContainerInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function initialized($id);
7474
*
7575
* @param string $name The parameter name
7676
*
77-
* @return mixed The parameter value
77+
* @return array|bool|string|int|float|null
7878
*
7979
* @throws InvalidArgumentException if the parameter is not defined
8080
*/
@@ -92,8 +92,8 @@ public function hasParameter($name);
9292
/**
9393
* Sets a parameter.
9494
*
95-
* @param string $name The parameter name
96-
* @param mixed $value The parameter value
95+
* @param string $name The parameter name
96+
* @param array|bool|string|int|float|null $value The parameter value
9797
*/
9898
public function setParameter($name, $value);
9999
}

src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function all()
3636
/**
3737
* {@inheritdoc}
3838
*
39-
* @return mixed
39+
* @return array|bool|string|int|float|null
4040
*/
4141
public function get($name)
4242
{

src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBagInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function all();
4747
*
4848
* @param string $name The parameter name
4949
*
50-
* @return mixed The parameter value
50+
* @return array|bool|string|int|float|null
5151
*
5252
* @throws ParameterNotFoundException if the parameter is not defined
5353
*/
@@ -63,8 +63,8 @@ public function remove($name);
6363
/**
6464
* Sets a service container parameter.
6565
*
66-
* @param string $name The parameter name
67-
* @param mixed $value The parameter value
66+
* @param string $name The parameter name
67+
* @param array|bool|string|int|float|null $value The parameter value
6868
*
6969
* @throws LogicException if the parameter can not be set
7070
*/

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -164,28 +164,6 @@ public function testDumpCustomContainerClassWithMandatoryArgumentLessConstructor
164164
$this->assertStringEqualsFile(self::$fixturesPath.'/php/custom_container_class_with_mandatory_constructor_arguments.php', $dumper->dump(['base_class' => 'ConstructorWithMandatoryArgumentsContainer', 'namespace' => 'Symfony\Component\DependencyInjection\Tests\Fixtures\Container']));
165165
}
166166

167-
/**
168-
* @dataProvider provideInvalidParameters
169-
*/
170-
public function testExportParameters($parameters)
171-
{
172-
$this->expectException(\InvalidArgumentException::class);
173-
$container = new ContainerBuilder(new ParameterBag($parameters));
174-
$container->compile();
175-
$dumper = new PhpDumper($container);
176-
$dumper->dump();
177-
}
178-
179-
public function provideInvalidParameters()
180-
{
181-
return [
182-
[['foo' => new Definition('stdClass')]],
183-
[['foo' => new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')]],
184-
[['foo' => new Reference('foo')]],
185-
[['foo' => new Variable('foo')]],
186-
];
187-
}
188-
189167
public function testAddParameters()
190168
{
191169
$container = include self::$fixturesPath.'/containers/container8.php';

0 commit comments

Comments
 (0)