Skip to content

Commit 6336168

Browse files
Merge branch '3.4' into 4.1
* 3.4: [DI] configure inlined services before injecting them when dumping the container Consistently throw exceptions on a single line fix fopen calls Update .editorconfig
2 parents 350ca93 + 51cb3dd commit 6336168

12 files changed

+19
-93
lines changed

Extension/Core/DataTransformer/ArrayToPartsTransformer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public function reverseTransform($array)
7676
return;
7777
}
7878

79-
throw new TransformationFailedException(
80-
sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)
81-
));
79+
throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)));
8280
}
8381

8482
return $result;

Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ public function reverseTransform($value)
131131
}
132132

133133
if (\count($emptyFields) > 0) {
134-
throw new TransformationFailedException(
135-
sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)
136-
));
134+
throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)));
137135
}
138136

139137
if (isset($value['month']) && !ctype_digit((string) $value['month'])) {

Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ public function reverseTransform($rfc3339)
8080

8181
if (preg_match('/(\d{4})-(\d{2})-(\d{2})/', $rfc3339, $matches)) {
8282
if (!checkdate($matches[2], $matches[3], $matches[1])) {
83-
throw new TransformationFailedException(sprintf(
84-
'The date "%s-%s-%s" is not a valid date.',
85-
$matches[1],
86-
$matches[2],
87-
$matches[3]
88-
));
83+
throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
8984
}
9085
}
9186

Extension/Core/DataTransformer/DateTimeToStringTransformer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ public function reverseTransform($value)
122122
$lastErrors = \DateTime::getLastErrors();
123123

124124
if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) {
125-
throw new TransformationFailedException(
126-
implode(', ', array_merge(
127-
array_values($lastErrors['warnings']),
128-
array_values($lastErrors['errors'])
129-
))
130-
);
125+
throw new TransformationFailedException(implode(', ', array_merge(array_values($lastErrors['warnings']), array_values($lastErrors['errors']))));
131126
}
132127

133128
try {

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ public function reverseTransform($value)
201201
$remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0");
202202

203203
if ('' !== $remainder) {
204-
throw new TransformationFailedException(
205-
sprintf('The number contains unrecognized characters: "%s"', $remainder)
206-
);
204+
throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder));
207205
}
208206
}
209207

Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public function reverseTransform($array)
6464
foreach ($this->keys as $key) {
6565
if (isset($array[$key]) && '' !== $array[$key] && false !== $array[$key] && array() !== $array[$key]) {
6666
if ($array[$key] !== $result) {
67-
throw new TransformationFailedException(
68-
'All values in the array should be the same'
69-
);
67+
throw new TransformationFailedException('All values in the array should be the same');
7068
}
7169
} else {
7270
$emptyKeys[] = $key;
@@ -79,9 +77,7 @@ public function reverseTransform($array)
7977
return;
8078
}
8179

82-
throw new TransformationFailedException(
83-
sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)
84-
));
80+
throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys)));
8581
}
8682

8783
return $result;

Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
128128

129129
// Throw exception if unknown values were submitted
130130
if (\count($unknownValues) > 0) {
131-
throw new TransformationFailedException(sprintf(
132-
'The choices "%s" do not exist in the choice list.',
133-
implode('", "', array_keys($unknownValues))
134-
));
131+
throw new TransformationFailedException(sprintf('The choices "%s" do not exist in the choice list.', implode('", "', array_keys($unknownValues))));
135132
}
136133

137134
$event->setData($data);

Extension/DependencyInjection/DependencyInjectionExtension.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,7 @@ public function getTypeExtensions($name)
6060

6161
// validate result of getExtendedType() to ensure it is consistent with the service definition
6262
if ($extension->getExtendedType() !== $name) {
63-
throw new InvalidArgumentException(
64-
sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".',
65-
$serviceId,
66-
$name,
67-
$extension->getExtendedType()
68-
)
69-
);
63+
throw new InvalidArgumentException(sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', $serviceId, $name, $extension->getExtendedType()));
7064
}
7165
}
7266
}

Form.php

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,7 @@ public function setData($modelData)
358358
? 'an instance of class '.\get_class($viewData)
359359
: 'a(n) '.\gettype($viewData);
360360

361-
throw new LogicException(
362-
'The form\'s view data is expected to be an instance of class '.
363-
$dataClass.', but is '.$actualType.'. You can avoid this error '.
364-
'by setting the "data_class" option to null or by adding a view '.
365-
'transformer that transforms '.$actualType.' to an instance of '.
366-
$dataClass.'.'
367-
);
361+
throw new LogicException('The form\'s view data is expected to be an instance of class '.$dataClass.', but is '.$actualType.'. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms '.$actualType.' to an instance of '.$dataClass.'.');
368362
}
369363
}
370364

@@ -861,11 +855,7 @@ public function add($child, $type = null, array $options = array())
861855
$child = $this->config->getFormFactory()->createNamed($child, $type, null, $options);
862856
}
863857
} elseif ($child->getConfig()->getAutoInitialize()) {
864-
throw new RuntimeException(sprintf(
865-
'Automatic initialization is only supported on root forms. You '.
866-
'should set the "auto_initialize" option to false on the field "%s".',
867-
$child->getName()
868-
));
858+
throw new RuntimeException(sprintf('Automatic initialization is only supported on root forms. You should set the "auto_initialize" option to false on the field "%s".', $child->getName()));
869859
}
870860

871861
$this->children[$child->getName()] = $child;
@@ -1039,11 +1029,7 @@ private function modelToNorm($value)
10391029
$value = $transformer->transform($value);
10401030
}
10411031
} catch (TransformationFailedException $exception) {
1042-
throw new TransformationFailedException(
1043-
'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(),
1044-
$exception->getCode(),
1045-
$exception
1046-
);
1032+
throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception);
10471033
}
10481034

10491035
return $value;
@@ -1067,11 +1053,7 @@ private function normToModel($value)
10671053
$value = $transformers[$i]->reverseTransform($value);
10681054
}
10691055
} catch (TransformationFailedException $exception) {
1070-
throw new TransformationFailedException(
1071-
'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(),
1072-
$exception->getCode(),
1073-
$exception
1074-
);
1056+
throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception);
10751057
}
10761058

10771059
return $value;
@@ -1102,11 +1084,7 @@ private function normToView($value)
11021084
$value = $transformer->transform($value);
11031085
}
11041086
} catch (TransformationFailedException $exception) {
1105-
throw new TransformationFailedException(
1106-
'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(),
1107-
$exception->getCode(),
1108-
$exception
1109-
);
1087+
throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception);
11101088
}
11111089

11121090
return $value;
@@ -1134,11 +1112,7 @@ private function viewToNorm($value)
11341112
$value = $transformers[$i]->reverseTransform($value);
11351113
}
11361114
} catch (TransformationFailedException $exception) {
1137-
throw new TransformationFailedException(
1138-
'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(),
1139-
$exception->getCode(),
1140-
$exception
1141-
);
1115+
throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception);
11421116
}
11431117

11441118
return $value;

FormConfigBuilder.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -791,11 +791,7 @@ public function setMethod($method)
791791
$upperCaseMethod = strtoupper($method);
792792

793793
if (!\in_array($upperCaseMethod, self::$allowedMethods)) {
794-
throw new InvalidArgumentException(sprintf(
795-
'The form method is "%s", but should be one of "%s".',
796-
$method,
797-
implode('", "', self::$allowedMethods)
798-
));
794+
throw new InvalidArgumentException(sprintf('The form method is "%s", but should be one of "%s".', $method, implode('", "', self::$allowedMethods)));
799795
}
800796

801797
$this->method = $upperCaseMethod;
@@ -862,10 +858,7 @@ public static function validateName($name)
862858
}
863859

864860
if (!self::isValidName($name)) {
865-
throw new InvalidArgumentException(sprintf(
866-
'The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").',
867-
$name
868-
));
861+
throw new InvalidArgumentException(sprintf('The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").', $name));
869862
}
870863
}
871864

0 commit comments

Comments
 (0)