8000 Merge branch '5.0' · symfony/symfony@39aab26 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39aab26

Browse files
Merge branch '5.0'
* 5.0: Use PHP 7.2 minimum in tests run with github actions Fix exception messages containing exception messages
2 parents 1ae3e04 + 8cf8f5a commit 39aab26

File tree

24 files changed

+30
-30
lines changed

24 files changed

+30
-30
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
php: ['7.1', '7.4']
15+
php: ['7.2', '7.4']
1616

1717
services:
1818
redis:

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testRedisCachePools()
4545
}
4646
$this->markTestSkipped($e->getMessage());
4747
} catch (InvalidArgumentException $e) {
48-
if (0 !== strpos($e->getMessage(), 'Redis connection failed')) {
48+
if (0 !== strpos($e->getMessage(), 'Redis connection ')) {
4949
throw $e;
5050
}
5151
$this->markTestSkipped($e->getMessage());

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,6 @@ public function testNotConfusedByClassAliases()
107107

108108
$tester = new ApplicationTester($application);
109109
$tester->run(['command' => 'debug:autowiring', 'search' => 'ClassAlias']);
110-
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass (public)', $tester->getDisplay());
110+
$this->assertStringContainsString('Symfony\Bundle\FrameworkBundle\Tests\Fixtures\ClassAliasExampleClass', $tester->getDisplay());
111111
}
112112
}

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testCreateConnection(string $dsnScheme)
7171
public function testFailedCreateConnection(string $dsn)
7272
{
7373
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
74-
$this->expectExceptionMessage('Redis connection failed');
74+
$this->expectExceptionMessage('Redis connection ');
7575
RedisAdapter::createConnection($dsn);
7676
}
7777

src/Symfony/Component/Cache/Tests/Adapter/RedisClusterAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterfac
4747
public function testFailedCreateConnection(string $dsn)
4848
{
4949
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
50-
$this->expectExceptionMessage('Redis connection failed');
50+
$this->expectExceptionMessage('Redis connection ');
5151
RedisAdapter::createConnection($dsn);
5252
}
5353

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,23 @@ public static function createConnection($dsn, array $options = [])
174174
try {
175175
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
176176
} catch (\RedisException $e) {
177-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
177+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
178178
}
179179

180180
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
181181
$isConnected = $redis->isConnected();
182182
restore_error_handler();
183183
if (!$isConnected) {
184184
$error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : '';
185-
throw new InvalidArgumentException(sprintf('Redis connection failed%s: "%s".', $error, $dsn));
185+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$error.'.');
186186
}
187187

188188
if ((null !== $auth && !$redis->auth($auth))
189189
|| ($params['dbindex'] && !$redis->select($params['dbindex']))
190190
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
191191
) {
192192
$e = preg_replace('/^ERR /', '', $redis->getLastError());
193-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e, $dsn));
193+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e.'.');
194194
}
195195

196196
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@@ -215,7 +215,7 @@ public static function createConnection($dsn, array $options = [])
215215
try {
216216
$redis = new $class($hosts, $params);
217217
} catch (\RedisClusterException $e) {
218-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
218+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
219219
}
220220

221221
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@@ -230,7 +230,7 @@ public static function createConnection($dsn, array $options = [])
230230
try {
231231
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
232232
} catch (\RedisClusterException $e) {
233-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
233+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
234234
}
235235

236236
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ final public function finalize($value)
468468

469469
throw $e;
470470
} catch (\Exception $e) {
471-
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": '.$e->getMessage(), $this->getPath()), $e->getCode(), $e);
471+
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": ', $this->getPath()).$e->getMessage(), $e->getCode(), $e);
472472
}
473473
}
474474

src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ protected function getConstructor(Definition $definition, bool $required)
150150
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
151151
}
152152
} catch (\ReflectionException $e) {
153-
throw new RuntimeException(sprintf('Invalid service "%s": '.lcfirst($e->getMessage()), $this->currentId));
153+
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
154154
}
155155
if (!$r = $r->getConstructor()) {
156156
if ($required) {
157157
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
158158
}
159159
} elseif (!$r->isPublic()) {
160-
throw new RuntimeException(sprintf('Invalid service "%s": %s must be public.', $this->currentId, sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class)));
160+
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
161161
}
162162

163163
return $r;

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private function parseFileToDOM(string $file): \DOMDocument
382382
try {
383383
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
384384
} catch (\InvalidArgumentException $e) {
385-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": "%s".', $file, $e->getMessage()), $e->getCode(), $e);
385+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": ', $file).$e->getMessage(), $e->getCode(), $e);
386386
}
387387

388388
$this->validateExtensions($dom, $file);

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ protected function loadFile($file)
742742
try {
743743
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
744744
} catch (ParseException $e) {
745-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $file).': '.$e->getMessage(), 0, $e);
745+
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $file).$e->getMessage(), 0, $e);
746746
}
747747

748748
return $this->validate($configuration, $file);

src/Symfony/Component/Form/ResolvedFormType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function createBuilder(FormFactoryInterface $factory, string $name, array
9696
try {
9797
$options = $this->getOptionsResolver()->resolve($options);
9898
} catch (ExceptionInterface $e) {
99-
throw new $e(sprintf('An error has occurred resolving the options of the form "%s": '.$e->getMessage(), get_debug_type($this->getInnerType())), $e->getCode(), $e);
99+
throw new $e(sprintf('An error has occurred resolving the options of the form "%s": ', get_debug_type($this->getInnerType())).$e->getMessage(), $e->getCode(), $e);
100100
}
101101

102102
// Should be decoupled from the specific option at some point

src/Symfony/Component/HttpClient/Response/ResponseTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ public function toArray(bool $throw = true): array
153153
try {
154154
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
155155
} catch (\JsonException $e) {
156-
throw new JsonException(sprintf($e->getMessage().' for "%s".', $this->getInfo('url')), $e->getCode());
156+
throw new JsonException($e->getMessage().sprintf(' for "%s".', $this->getInfo('url')), $e->getCode());
157157
}
158158

159159
if (\PHP_VERSION_ID < 70300 && JSON_ERROR_NONE !== json_last_error()) {
160-
throw new JsonException(sprintf(json_last_error_msg().' for "%s".', $this->getInfo('url')), json_last_error());
160+
throw new JsonException(json_last_error_msg().sprintf(' for "%s".', $this->getInfo('url')), json_last_error());
161161
}
162162

163163
if (!\is_array($content)) {

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function getController(Request $request)
8585
try {
8686
$callable = $this->createController($controller);
8787
} catch (\InvalidArgumentException $e) {
88-
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: '.$e->getMessage(), $request->getPathInfo()), 0, $e);
88+
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
8989
}
9090

9191
if (!\is_callable($callable)) {

src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesApiAsyncAwsTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function getRequest(SentMessage $message): SendEmailRequest
4343
try {
4444
$email = MessageConverter::toEmail($message->getOriginalMessage());
4545
} catch (\Exception $e) {
46-
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: "%s".', __CLASS__, $e->getMessage()), 0, $e);
46+
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
4747
}
4848

4949
if ($email->getAttachments()) {

src/Symfony/Component/Mailer/Transport/AbstractApiTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
3131
try {
3232
$email = MessageConverter::toEmail($message->getOriginalMessage());
3333
} catch (\Exception $e) {
34-
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: '.$e->getMessage(), __CLASS__), 0, $e);
34+
throw new RuntimeException(sprintf('Unable to send message with the "%s" transport: ', __CLASS__).$e->getMessage(), 0, $e);
3535
}
3636

3737
return $this->doSendApi($message, $email, $message->getEnvelope());

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function testAuth()
158158
public function testFailedAuth()
159159
{
160160
$this->expectException(\InvalidArgumentException::class);
161-
$this->expectExceptionMessage('Redis connection failed');
161+
$this->expectExceptionMessage('Redis connection ');
162162
$redis = $this->getMockBuilder(\Redis::class)->disableOriginalConstructor()->getMock();
163163

164164
$redis->expects($this->exactly(1))->method('auth')

src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function load($file, string $type = null)
6767
try {
6868
$parsedConfig = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
6969
} catch (ParseException $e) {
70-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
70+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);
7171
}
7272

7373
$collection = new RouteCollection();

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public function denormalize($data, string $type, string $format = null, array $c
332332
try {
333333
$this->setAttributeValue($object, $attribute, $value, $format, $context);
334334
} catch (InvalidArgumentException $e) {
335-
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": '.$e->getMessage(), $attribute, $type), $e->getCode(), $e);
335+
throw new NotNormalizableValueException(sprintf('Failed to denormalize attribute "%s" value for class "%s": ', $attribute, $type).$e->getMessage(), $e->getCode(), $e);
336336
}
337337
}
338338

src/Symfony/Component/Translation/Loader/XliffFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private function extract($resource, MessageCatalogue $catalogue, string $domain)
5858
try {
5959
$dom = XmlUtils::loadFile($resource);
6060
} catch (\InvalidArgumentException $e) {
61-
throw new InvalidResourceException(sprintf('Unable to load "%s": '.$e->getMessage(), $resource), $e->getCode(), $e);
61+
throw new InvalidResourceException(sprintf('Unable to load "%s": ', $resource).$e->getMessage(), $e->getCode(), $e);
6262
}
6363

6464
$xliffVersion = XliffUtils::getVersionNumber($dom);

src/Symfony/Component/Translation/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function loadResource($resource)
4242
try {
4343
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT);
4444
} catch (ParseException $e) {
45-
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML', $resource).': '.$e->getMessage(), 0, $e);
45+
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML: ', $resource).$e->getMessage(), 0, $e);
4646
}
4747

4848
if (null !== $messages && !\is_array($messages)) {

src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function validate($value, Constraint $constraint)
5555
try {
5656
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
5757
} catch (NoSuchPropertyException $e) {
58-
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $path, get_debug_type($constraint)), 0, $e);
58+
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $path, get_debug_type($constraint)).$e->getMessage(), 0, $e);
5959
}
6060
} else {
6161
$comparedValue = $constraint->value;

src/Symfony/Component/Validator/Constraints/BicValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function validate($value, Constraint $constraint)
130130
try {
131131
$iban = $this->getPropertyAccessor()->getValue($object, $path);
132132
} catch (NoSuchPropertyException $e) {
133-
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $path, get_debug_type($constraint)), 0, $e);
133+
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $path, get_debug_type($constraint)).$e->getMessage(), 0, $e);
134134
}
135135
}
136136
if (!$iban) {

src/Symfony/Component/Validator/Constraints/RangeValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function getLimit($propertyPath, $default, Constraint $constraint)
157157
try {
158158
return $this->getPropertyAccessor()->getValue($object, $propertyPath);
159159
} catch (NoSuchPropertyException $e) {
160-
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: '.$e->getMessage(), $propertyPath, get_debug_type($constraint)), 0, $e);
160+
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: ', $propertyPath, get_debug_type($constraint)).$e->getMessage(), 0, $e);
161161
}
162162
}
163163

src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private function parseFile(string $path): array
114114
try {
115115
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
116116
} catch (ParseException $e) {
117-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
117+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $path).$e->getMessage(), 0, $e);
118118
}
119119

120120
// empty file

0 commit comments

Comments
 (0)
0