8000 Merge branch '3.4' into 4.0 · symfony/symfony@6b00d4b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b00d4b

Browse files
Merge branch '3.4' into 4.0
* 3.4: [Console] fix CS [OptionResolver] resolve arrays [TwigBridge] Fix missing path and separators in loader paths list on debug:twig output [PropertyInfo] Fix dock block lookup fallback loop [HttpFoundation] don't encode cookie name for BC improve deprecation messages minor #27858 [Console] changed warning verbosity; fixes typo (adrian-enspired) AppBundle->App. [DI] Fix dumping ignore-on-uninitialized references to synthetic services
2 parents 29d2101 + 08dced5 commit 6b00d4b

File tree

15 files changed

+476
-77
lines changed

15 files changed

+476
-77
lines changed

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,27 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108
}
109109

110110
$rows = array();
111+
$firstNamespace = true;
112+
$prevHasSeparator = false;
111113
foreach ($this->getLoaderPaths() as $namespace => $paths) {
112-
if (count($paths) > 1) {
114+
if (!$firstNamespace && !$prevHasSeparator && count($paths) > 1) {
113115
$rows[] = array('', '');
114116
}
117+
$firstNamespace = false;
115118
foreach ($paths as $path) {
116-
$rows[] = array($namespace, '- '.$path);
119+
$rows[] = array($namespace, $path.DIRECTORY_SEPARATOR);
117120
$namespace = '';
118121
}
119122
if (count($paths) > 1) {
120123
$rows[] = array('', '');
124+
$prevHasSeparator = true;
125+
} else {
126+
$prevHasSeparator = false;
121127
}
122128
}
123-
array_pop($rows);
129+
if ($prevHasSeparator) {
130+
array_pop($rows);
131+
}
124132
$io->section('Loader Paths');
125133
$io->table(array('Namespace', 'Paths'), $rows);
126134

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Twig\Tests\Command;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\Twig\Command\DebugCommand;
16+
use Symfony\Component\Console\Application;
17+
use Symfony\Component\Console\Tester\CommandTester;
18+
use Twig\Loader\FilesystemLoader;
19+
use Twig\Environment;
20+
21+
class DebugCommandTest extends TestCase
22+
{
23+
public function testDebugCommand()
24+
{
25+
$tester = $this->createCommandTester();
26+
$ret = $tester->execute(array(), array('decorated' => false));
27+
28+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
29+
$this->assertContains('Functions', trim($tester->getDisplay()));
30+
}
31+
32+
public function testLineSeparatorInLoaderPaths()
33+
{
34+
// these paths aren't realistic,
35+
// they're configured to force the line separator
36+
$tester = $this->createCommandTester(array(
37+
'Acme' => array('extractor', 'extractor'),
38+
'!Acme' => array('extractor', 'extractor'),
39+
FilesystemLoader::MAIN_NAMESPACE => array('extractor', 'extractor'),
40+
));
41+
$ret = $tester->execute(array(), array('decorated' => false));
42+
$ds = DIRECTORY_SEPARATOR;
43+
$loaderPaths = <<<TXT
44+
Loader Paths
45+
------------
46+
47+
----------- ------------
48+
Namespace Paths
49+
----------- ------------
50+
@Acme extractor$ds
51+
extractor$ds
52+
53+
@!Acme extractor$ds
54+
extractor$ds
55+
56+
(None) extractor$ds
57+
extractor$ds
58+
----------- ------------
59+
TXT;
60+
61+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
62+
$this->assertContains($loaderPaths, trim($tester->getDisplay(true)));
63+
}
64+
65+
private function createCommandTester(array $paths = array())
66+
{
67+
$filesystemLoader = new FilesystemLoader(array(), dirname(__DIR__).'/Fixtures');
68+
foreach ($paths as $namespace => $relDirs) {
69+
foreach ($relDirs as $relDir) {
70+
$filesystemLoader->addPath($relDir, $namespace);
71+
}
72+
}
73+
$command = new DebugCommand(new Environment($filesystemLoader));
74+
75+
$application = new Application();
76+
$application->add($command);
77+
$command = $application->find('debug:twig');
78+
79+
return new CommandTester($command);
80+
}
81+
}

src/Symfony/Bundle/SecurityBundle/Command/UserPasswordEncoderCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function configure()
7070
security:
7171
encoders:
7272
Symfony\Component\Security\Core\User\User: plaintext
73-
AppBundle\Entity\User: bcrypt
73+
App\Entity\User: bcrypt
7474
</comment>
7575
7676
If you execute the command non-interactively, the first available configured
@@ -82,16 +82,16 @@ protected function configure()
8282
Pass the full user class path as the second argument to encode passwords for
8383
your own entities:
8484
85-
<info>php %command.full_name% --no-interaction [password] AppBundle\Entity\User</info>
85+
<info>php %command.full_name% --no-interaction [password] App\Entity\User</info>
8686
8787
Executing the command interactively allows you to generate a random salt for
8888
encoding the password:
8989
90-
<info>php %command.full_name% [password] AppBundle\Entity\User</info>
90+
<info>php %command.full_name% [password] App\Entity\User</info>
9191
9292
In case your encoder doesn't require a salt, add the <comment>empty-salt</comment> option:
9393
94-
<info>php %command.full_name% --empty-salt [password] AppBundle\Entity\User</info>
94+
<info>php %command.full_name% --empty-salt [password] App\Entity\User</info>
9595
9696
EOF
9797
)

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ private function addEncodersSection(ArrayNodeDefinition $rootNode)
360360
->children()
361361
->arrayNode('encoders')
362362
->example(array(
363-
'AppBundle\Entity\User1' => 'bcrypt',
364-
'AppBundle\Entity\User2' => array(
363+
'App\Entity\User1' => 'bcrypt',
364+
'App\Entity\User2' => array(
365365
'algorithm' => 'bcrypt',
366366
'cost' => 13,
367367
),

src/Symfony/Component/Console/Command/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function run(InputInterface $input, OutputInterface $output)
220220
if (function_exists('cli_set_process_title')) {
221221
if (!@cli_set_process_title($this->processTitle)) {
222222
if ('Darwin' === PHP_OS) {
223-
$output->writeln('<comment>Running "cli_get_process_title" as an unprivileged user is not supported on MacOS.</comment>');
223+
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
224224
} else {
225225
cli_set_process_title($this->processTitle);
226226
}

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,10 @@ private function getServiceCall(string $id, Reference $reference = null): string
16401640
return '$this';
16411641
}
16421642

1643-
if ($this->container->hasDefinition($id) && ($definition = $this->container->getDefinition($id)) && !$definition->isSynthetic()) {
1644-
if (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
1643+
if ($this->container->hasDefinition($id) && $definition = $this->container->getDefinition($id)) {
1644+
if ($definition->isSynthetic()) {
1645+
$code = sprintf('$this->get(\'%s\'%s)', $id, null !== $reference ? ', '.$reference->getInvalidBehavior() : '');
1646+
} elseif (null !== $reference && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE === $reference->getInvalidBehavior()) {
16451647
$code = 'null';
16461648
if (!$definition->isShared()) {
16471649
return $code;

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,21 @@ public function testArgumentsHaveHigherPriorityThanBindings()
13991399
$this->assertSame('via-bindings', $container->get('foo')->class2->identifier);
14001400
}
14011401

1402+
public function testUninitializedSyntheticReference()
1403+
{
1404+
$container = new ContainerBuilder();
1405+
$container->register('foo', 'stdClass')->setPublic(true)->setSynthetic(true);
1406+
$container->register('bar', 'stdClass')->setPublic(true)->setShared(false)
1407+
->setProperty('foo', new Reference('foo', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE));
1408+
1409+
$container->compile();
1410+
1411+
$this->assertEquals((object) array('foo' => null), $container->get('bar'));
1412+
1413+
$container->set('foo', (object) array(123));
1414+
$this->assertEquals((object) array('foo' => (object) array(123)), $container->get('bar'));
1415+
}
1416+
14021417
public function testIdCanBeAnObjectAsLongAsItCanBeCastToString()
14031418
{
14041419
$id = new Reference('another_service');
10000

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,29 @@ public function testDumpHandlesObjectClassNames()
911911
$this->assertInstanceOf('stdClass', $container->get('bar'));
912912
}
913913

914+
public function testUninitializedSyntheticReference()
915+
{
916+
$container = new ContainerBuilder();
917+
$container->register('foo', 'stdClass')->setPublic(true)->setSynthetic(true);
918+
$container->register('bar', 'stdClass')->setPublic(true)->setShared(false)
919+
->setProperty('foo', new Reference('foo', ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE));
920+
921+
$container->compile();
922+
923+
$dumper = new PhpDumper($container);
924+
eval('?>'.$dumper->dump(array(
925+
'class' => 'Symfony_DI_PhpDumper_Test_UninitializedSyntheticReference',
926+
'inline_class_loader_parameter' => 'inline_requires',
927+
)));
928+
929+
$container = new \Symfony_DI_PhpDumper_Test_UninitializedSyntheticReference();
930+
931+
$this->assertEquals((object) array('foo' => null), $container->get('bar'));
932+
933+
$container->set('foo', (object) array(123));
934+
$this->assertEquals((object) array('foo' => (object) array(123)), $container->get('bar'));
935+
}
936+
914937
/**
915938
* This test checks the trigger of a deprecation note and should not be removed in major releases.
916939
*

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,17 @@ public function sendHeaders()
329329
}
330330

331331< D7AE code class="diff-text syntax-highlighted-line">
// headers
332-
foreach ($this->headers->allPreserveCase() as $name => $values) {
332+
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
333333
foreach ($values as $value) {
334334
header($name.': '.$value, false, $this->statusCode);
335335
}
336336
}
337337

338+
// cookies
339+
foreach ($this->headers->getCookies() as $cookie) {
340+
header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
341+
}
342+
338343
// status
339344
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
340345

src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/cookie_urlencode.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Array
44
[0] => Content-Type: text/plain; charset=utf-8
55
[1] => Cache-Control: no-cache, private
66
[2] => Date: Sat, 12 Nov 1955 20:04:00 GMT
7-
[3] => Set-Cookie: %3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
7+
[3] => Set-Cookie: ?*():@&+$/%#[]=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
88
[4] => Set-Cookie: ?*():@&+$/%#[]=%3F%2A%28%29%3A%40%26%2B%24%2F%25%23%5B%5D; path=/
99
)
1010
shutdown

0 commit comments

Comments
 (0)
0