Skip to content

Commit 39f7b99

Browse files
Replace more docblocks by type-hints
1 parent 31a3282 commit 39f7b99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+46
-111
lines changed

ButtonBuilder.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,11 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
5353
private $options;
5454

5555
/**
56-
* Creates a new button builder.
57-
*
58-
* @param string $name The name of the button
59-
* @param array $options The button's options
60-
*
6156
* @throws InvalidArgumentException if the name is empty
6257
*/
63-
public function __construct($name, array $options = array())
58+
public function __construct(?string $name, array $options = array())
6459
{
65-
$name = (string) $name;
66-
if ('' === $name) {
60+
if ('' === $name || null === $name) {
6761
throw new InvalidArgumentException('Buttons cannot have empty names.');
6862
}
6963

ChoiceList/ArrayChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class ArrayChoiceList implements ChoiceListInterface
6262
* incrementing integers are used as
6363
* values
6464
*/
65-
public function __construct($choices, callable $value = null)
65+
public function __construct(iterable $choices, callable $value = null)
6666
{
6767
if ($choices instanceof \Traversable) {
6868
$choices = iterator_to_array($choices);

ChoiceList/View/ChoiceView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ChoiceView
3535
* @param string $label The label displayed to humans
3636
* @param array $attr Additional attributes for the HTML tag
3737
*/
38-
public function __construct($data, $value, $label, array $attr = array())
38+
public function __construct($data, string $value, $label, array $attr = array())
3939
{
4040
$this->data = $data;
4141
$this->value = $value;

DependencyInjection/FormPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FormPass implements CompilerPassInterface
3636
private $formTypeGuesserTag;
3737
private $formDebugCommandService;
3838

39-
public function __construct($formExtensionService = 'form.extension', $formTypeTag = 'form.type', $formTypeExtensionTag = 'form.type_extension', $formTypeGuesserTag = 'form.type_guesser', $formDebugCommandService = DebugCommand::class)
39+
public function __construct(string $formExtensionService = 'form.extension', string $formTypeTag = 'form.type', string $formTypeExtensionTag = 'form.type_extension', string $formTypeGuesserTag = 'form.type_guesser', string $formDebugCommandService = DebugCommand::class)
4040
{
4141
$this->formExtensionService = $formExtensionService;
4242
$this->formTypeTag = $formTypeTag;

Exception/UnexpectedTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class UnexpectedTypeException extends InvalidArgumentException
1515
{
16-
public function __construct($value, $expectedType)
16+
public function __construct($value, string $expectedType)
1717
{
1818
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
1919
}

Extension/Core/DataTransformer/BaseDateTimeTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
3636
* @throws UnexpectedTypeException if a timezone is not a string
3737
* @throws InvalidArgumentException if a timezone is not valid
3838
*/
39-
public function __construct($inputTimezone = null, $outputTimezone = null)
39+
public function __construct(string $inputTimezone = null, string $outputTimezone = null)
4040
{
4141
if (null !== $inputTimezone && !is_string($inputTimezone)) {
4242
throw new UnexpectedTypeException($inputTimezone, 'string');

Extension/Core/DataTransformer/BooleanToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BooleanToStringTransformer implements DataTransformerInterface
2727
/**
2828
* @param string $trueValue The value emitted upon transform if the input is true
2929
*/
30-
public function __construct($trueValue)
30+
public function __construct(string $trueValue)
3131
{
3232
$this->trueValue = $trueValue;
3333
}

Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
4646
* @param string[] $fields The date fields
4747
* @param bool $pad Whether to use padding
4848
*/
49-
public function __construct(array $fields = null, $pad = false)
49+
public function __construct(array $fields = null, bool $pad = false)
5050
{
5151
if (null === $fields) {
5252
$fields = array('years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert');
5353
}
5454
$this->fields = $fields;
55-
$this->pad = (bool) $pad;
55+
$this->pad = $pad;
5656
}
5757

5858
/**

Extension/Core/DataTransformer/DateIntervalToStringTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
3333
* @param string $format The date format
3434
* @param bool $parseSigned Whether to parse as a signed interval
3535
*/
36-
public function __construct($format = 'P%yY%mM%dDT%hH%iM%sS', $parseSigned = false)
36+
public function __construct(string $format = 'P%yY%mM%dDT%hH%iM%sS', bool $parseSigned = false)
3737
{
3838
$this->format = $format;
3939
$this->parseSigned = $parseSigned;

Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
3434
*
3535
* @throws UnexpectedTypeException if a timezone is not a string
3636
*/
37-
public function __construct($inputTimezone = null, $outputTimezone = null, array $fields = null, $pad = false)
37+
public function __construct(string $inputTimezone = null, string $outputTimezone = null, array $fields = null, bool $pad = false)
3838
{
3939
parent::__construct($inputTimezone, $outputTimezone);
4040

@@ -43,7 +43,7 @@ public function __construct($inputTimezone = null, $outputTimezone = null, array
4343
}
4444

4545
$this->fields = $fields;
46-
$this->pad = (bool) $pad;
46+
$this->pad = $pad;
4747
}
4848

4949
/**

0 commit comments

Comments
 (0)