Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c3ad3ee

Browse filesBrowse files
Merge branch '5.0'
* 5.0: [Validator] fix access to uninitialized property when getting value [HttpClient] Fix regex bearer [Translator] Default value for 'sort' option in translation:update should be 'asc' [HttpKernel] Fix stale-if-error behavior, add tests [Intl] Provide more locale translations [Mailer] Fix STARTTLS support for Postmark and Mandrill [Messenger] Check for all serialization exceptions during message dec… [Messenger] Fix bug when using single route with XML config Fix exception message in Doctrine Messenger [DI] CheckTypeDeclarationsPass now checks if value is type of parameter type [SecurityBundle] fix security.authentication.provider.ldap_bind arguments Improved error message when no supported user provider is found Mysqli doesn't support the named parameters used by PdoAdapter Added debug argument to decide if debug page should be shown or not Mysqli doesn't support the named parameters used by PdoStore Properly handle phpunit arguments for configuration file [Mailer] add tests for http transports
2 parents 09bdaf5 + b0fc564 commit c3ad3ee
Copy full SHA for c3ad3ee

File tree

Expand file treeCollapse file tree

157 files changed

+1668
-59
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

157 files changed

+1668
-59
lines changed

‎src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
+39-7Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,47 @@
2424

2525
static $phpunitConfig = null;
2626
if (null === $phpunitConfig) {
27-
$opt = min(array_search('-c', $opts = array_reverse($argv), true) ?: INF, array_search('--configuration', $opts, true) ?: INF);
2827
$phpunitConfigFilename = null;
29-
if (INF !== $opt && isset($opts[$opt - 1])) {
30-
$phpunitConfigFilename = $opts[$opt - 1];
31-
} elseif (file_exists('phpunit.xml')) {
32-
$phpunitConfigFilename = 'phpunit.xml';
33-
} elseif (file_exists('phpunit.xml.dist')) {
34-
$phpunitConfigFilename = 'phpunit.xml.dist';
28+
$getPhpUnitConfig = function ($probableConfig) use (&$getPhpUnitConfig) {
29+
if (!$probableConfig) {
30+
return null;
31+
}
32+
if (is_dir($probableConfig)) {
33+
return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml');
34+
}
35+
36+
if (file_exists($probableConfig)) {
37+
return $probableConfig;
38+
}
39+
if (file_exists($probableConfig.'.dist')) {
40+
return $probableConfig.'.dist';
41+
}
42+
43+
return null;
44+
};
45+
46+
foreach ($argv as $cliArgumentIndex => $cliArgument) {
47+
if ('--' === $cliArgument) {
48+
break;
49+
}
50+
// long option
51+
if ('--configuration' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
52+
$phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
53+
break;
54+
}
55+
// short option
56+
if (0 === strpos($cliArgument, '-c')) {
57+
if ('-c' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
58+
$phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
59+
} else {
60+
$phpunitConfigFilename = $getPhpUnitConfig(substr($cliArgument, 2));
61+
}
62+
break;
63+
}
3564
}
65+
66+
$phpunitConfigFilename = $phpunitConfigFilename ?: $getPhpUnitConfig('phpunit.xml');
67+
3668
if ($phpunitConfigFilename) {
3769
$phpunitConfig = new DomDocument();
3870
$phpunitConfig->load($phpunitConfigFilename);

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function configure()
8383
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
8484
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
8585
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
86-
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically'),
86+
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
8787
])
8888
->setDescription('Updates the translation file')
8989
->setHelp(<<<'EOF'

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,10 @@ private function addMessengerSection(ArrayNodeDefinition $rootNode)
10651065
if (!\is_array($config)) {
10661066
return [];
10671067
}
1068+
// If XML config with only one routing attribute
1069+
if (2 === \count($config) && isset($config['message-class']) && isset($config['sender'])) {
1070+
$config = [0 => $config];
1071+
}
10681072

10691073
$newConfig = [];
10701074
foreach ($config as $k => $v) {

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ public function testDumpReverseSortedMessagesAndClean()
4848
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
4949
}
5050

51+
public function testDumpSortWithoutValueAndClean()
52+
{
53+
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
54+
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort']);
55+
$this->assertRegExp("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
56+
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
57+
}
58+
5159
public function testDumpWrongSortAndClean()
5260
{
5361
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'messenger' => [
5+
'routing' => [
6+
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage' => ['amqp'],
7+
],
8+
'transports' => [
9+
'amqp' => 'amqp://localhost/%2f/messages',
10+
],
11+
],
12+
]);
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:messenger>
10+
<framework:routing message-class="Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage">
11+
<framework:sender service="amqp" />
12+
</framework:routing>
13+
<framework:transport name="amqp" dsn="amqp://localhost/%2f/messages" />
14+
</framework:messenger>
15+
</framework:config>
16+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework:
2+
messenger:
3+
routing:
4+
'Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyMessage': [amqp]
5+
6+
transports:
7+
amqp: 'amqp://localhost/%2f/messages'

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,15 @@ public function testMessengerRouting()
642642
$this->assertEquals(new Reference('messenger.transport.audit'), $sendersLocator->getArgument(0)['messenger.transport.audit']->getValues()[0]);
643643
}
644644

645+
public function testMessengerRoutingSingle()
646+
{
647+
$container = $this->createContainerFromFile('messenger_routing_single');
648+
$senderLocatorDefinition = $container->getDefinition('messenger.senders_locator');
649+
650+
$sendersMapping = $senderLocatorDefinition->getArgument(0);
651+
$this->assertEquals(['amqp'], $sendersMapping[DummyMessage::class]);
652+
}
653+
645654
public function testMessengerTransportConfiguration()
646655
{
647656
$container = $this->createContainerFromFile('messenger_transport');

‎src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@
166166
<argument /> <!-- UserChecker -->
167167
<argument /> <!-- Provider-shared Key -->
168168
<argument /> <!-- LDAP -->
169-
<argument /> <!-- search dn -->
170-
<argument /> <!-- search password -->
171169
<argument /> <!-- Base DN -->
172170
<argument>%security.authentication.hide_user_not_found%</argument>
171+
<argument /> <!-- search dn -->
172+
<argument /> <!-- search password -->
173173
</service>
174174

175175
<service id="security.authentication.provider.pre_authenticated" class="Symfony\Component\Security\Core\Authentication\Provider\PreAuthenticatedAuthenticationProvider" abstract="true">

‎src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/PdoAdapter.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ private function getConnection(): object
427427
} else {
428428
switch ($this->driver = $this->conn->getDriver()->getName()) {
429429
case 'mysqli':
430+
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', \get_class($this)));
430431
case 'pdo_mysql':
431432
case 'drizzle_pdo_mysql':
432433
$this->driver = 'mysql';

‎src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php
+54-29Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
15+
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
1516
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
17+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1618
use Symfony\Component\DependencyInjection\Container;
1719
use Symfony\Component\DependencyInjection\Definition;
1820
use Symfony\Component\DependencyInjection\Exception\EnvNotFoundException;
@@ -40,7 +42,23 @@
4042
*/
4143
final class CheckTypeDeclarationsPass extends AbstractRecursivePass
4244
{
43-
private const SCALAR_TYPES = ['int', 'float', 'bool', 'string'];
45+
private const SCALAR_TYPES = [
46+
'int' => true,
47+
'float' => true,
48+
'bool' => true,
49+
'string' => true,
50+
];
51+
52+
private const BUILTIN_TYPES = [
53+
'array' => true,
54+
'bool' => true,
55+
'callable' => true,
56+
'float' => true,
57+
'int' => true,
58+
'iterable' => true,
59+
'object' => true,
60+
'string' => true,
61+
];
4462

4563
private $autoload;
4664
private $skippedIds;
@@ -160,33 +178,17 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
160178
$type = $checkedDefinition->getClass();
161179
}
162180

181+
$class = null;
182+
163183
if ($value instanceof Definition) {
164184
$class = $value->getClass();
165185

166-
if (!$class || (!$this->autoload && !class_exists($class, false) && !interface_exists($class, false))) {
167-
return;
168-
}
169-
170-
if ('callable' === $type && (\Closure::class === $class || method_exists($class, '__invoke'))) {
171-
return;
172-
}
173-
174-
if ('iterable' === $type && is_subclass_of($class, 'Traversable')) {
175-
return;
176-
}
177-
178-
if ('object' === $type) {
179-
return;
180-
}
181-
182-
if (is_a($class, $type, true)) {
186+
if (isset(self::BUILTIN_TYPES[strtolower($class)])) {
187+
$class = strtolower($class);
188+
} elseif (!$class || (!$this->autoload && !class_exists($class, false) && !interface_exists($class, false))) {
183189
return;
184190
}
185-
186-
throw new InvalidParameterTypeException($this->currentId, $class, $parameter);
187-
}
188-
189-
if ($value instanceof Parameter) {
191+
} elseif ($value instanceof Parameter) {
190192
$value = $this->container->getParameter($value);
191193
} elseif ($value instanceof Expression) {
192194
$value = $this->getExpressionLanguage()->evaluate($value, ['container' => $this->container]);
@@ -212,30 +214,53 @@ private function checkType(Definition $checkedDefinition, $value, \ReflectionPar
212214
return;
213215
}
214216

215-
if (\in_array($type, self::SCALAR_TYPES, true) && is_scalar($value)) {
217+
if (null === $class) {
218+
if ($value instanceof IteratorArgument) {
219+
$class = RewindableGenerator::class;
220+
} elseif ($value instanceof ServiceClosureArgument) {
221+
$class = \Closure::class;
222+
} elseif ($value instanceof ServiceLocatorArgument) {
223+
$class = ServiceLocator::class;
224+
} elseif (\is_object($value)) {
225+
$class = \get_class($value);
226+
} else {
227+
$class = \gettype($value);
228+
$class = ['integer' => 'int', 'double' => 'float', 'boolean' => 'bool'][$class] ?? $class;
229+
}
230+
}
231+
232+
if (isset(self::SCALAR_TYPES[$type]) && isset(self::SCALAR_TYPES[$class])) {
233+
return;
234+
}
235+
236+
if ('string' === $type && \is_callable([$class, '__toString'])) {
237+
return;
238+
}
239+
240+
if ('callable' === $type && (\Closure::class === $class || \is_callable([$class, '__invoke']))) {
216241
return;
217242
}
218243

219-
if ('callable' === $type && \is_array($value) && isset($value[0]) && ($value[0] instanceof Reference || $value[0] instanceof Definition)) {
244+
if ('callable' === $type && \is_array($value) && isset($value[0]) && ($value[0] instanceof Reference || $value[0] instanceof Definition || \is_string($value[0]))) {
220245
return;
221246
}
222247

223-
if (\in_array($type, ['callable', 'Closure'], true) && $value instanceof ServiceClosureArgument) {
248+
if ('iterable' === $type && (\is_array($value) || is_subclass_of($class, \Traversable::class))) {
224249
return;
225250
}
226251

227-
if ('iterable' === $type && (\is_array($value) || $value instanceof \Traversable || $value instanceof IteratorArgument)) {
252+
if ('object' === $type && !isset(self::BUILTIN_TYPES[$class])) {
228253
return;
229254
}
230255

231-
if ('Traversable' === $type && ($value instanceof \Traversable || $value instanceof IteratorArgument)) {
256+
if (is_a($class, $type, true)) {
232257
return;
233258
}
234259

235260
$checkFunction = sprintf('is_%s', $parameter->getType()->getName());
236261

237262
if (!$parameter->getType()->isBuiltin() || !$checkFunction($value)) {
238-
throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? \get_class($value) : \gettype($value), $parameter);
263+
throw new InvalidParameterTypeException($this->currentId, \is_object($value) ? $class : \gettype($value), $parameter);
239264
}
240265
}
241266

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
2727
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
2828
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
29+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Waldo;
30+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Wobble;
2931
use Symfony\Component\ExpressionLanguage\Expression;
3032

3133
/**
@@ -602,6 +604,21 @@ public function testProcessResolveExpressions()
602604
$this->addToAssertionCount(1);
603605
}
604606

607+
public function testProcessSuccessWhenExpressionReturnsObject()
608+
{
609+
$container = new ContainerBuilder();
610+
611+
$container->register('waldo', Waldo::class);
612+
613+
$container
614+
->register('wobble', Wobble::class)
615+
->setArguments([new Expression("service('waldo')")]);
616+
617+
(new CheckTypeDeclarationsPass(true))->process($container);
618+
619+
$this->addToAssertionCount(1);
620+
}
621+
605622
public function testProcessHandleMixedEnvPlaceholder()
606623
{
607624
$this->expectException(\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException::class);
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
class Waldo implements WaldoInterface
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
interface WaldoInterface
6+
{
7+
}
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
class Wobble
6+
{
7+
private $waldo;
8+
9+
public function __construct(WaldoInterface $waldo)
10+
{
11+
$this->waldo = $waldo;
12+
}
13+
}

‎src/Symfony/Component/ErrorHandler/Debug.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/Debug.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static function enable(): ErrorHandler
3131

3232
DebugClassLoader::enable();
3333

34-
return ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
34+
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
3535
}
3636
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.