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 57e5075

Browse filesBrowse files
committed
Merge branch '2.8' into 3.3
* 2.8: [HttpFoundation] Use the correct syntax for session gc based on Pdo driver Removed assertDateTimeEquals() methods. Revert "bug #24987 [Console] Fix global console flag when used in chain (Simperfit)" Revert "bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit)" Disable CSP header on exception pages only in debug Fixed submitting disabled buttons Fixed Button::setParent() when already submitted Improve assertions Improve assertions SCA: get rid of repetitive calls allow null values for root nodes in YAML configs [VarDumper] Fix docblock Improve phpdoc to make it more explicit
2 parents 5f537e4 + 9606f02 commit 57e5075
Copy full SHA for 57e5075

32 files changed

+145
-102
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Application.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public function __construct(KernelInterface $kernel)
3535

3636
parent::__construct('Symfony', Kernel::VERSION);
3737

38-
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name', $kernel->getEnvironment()));
39-
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode'));
38+
$inputDefinition = $this->getDefinition();
39+
$inputDefinition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
40+
$inputDefinition->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
4041
}
4142

4243
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,9 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
758758
if (1 === count($engines)) {
759759
$container->setAlias('templating', (string) reset($engines));
760760
} else {
761+
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
761762
foreach ($engines as $engine) {
762-
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
763+
$templateEngineDefinition->addMethodCall('addEngine', array($engine));
763764
}
764765
$container->setAlias('templating', 'templating.engine.delegating');
765766
}

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public function testCsrfAliases()
8484
$processor = new Processor();
8585
$configuration = new MainConfiguration(array(), array());
8686
$processedConfig = $processor->processConfiguration($configuration, array($config));
87-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_generator']));
87+
$this->assertArrayHasKey('csrf_token_generator', $processedConfig['firewalls']['stub']['logout']);
8888
$this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']);
89-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_id']));
89+
$this->assertArrayHasKey('csrf_token_id', $processedConfig['firewalls']['stub']['logout']);
9090
$this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']);
9191
}
9292

‎src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<tag name="monolog.logger" channel="request" />
126126
<argument>%twig.exception_listener.controller%</argument>
127127
<argument type="service" id="logger" on-invalid="null" />
128+
<argument>%kernel.debug%</argument>
128129
</service>
129130

130131
<service id="twig.controller.exception" class="Symfony\Bundle\TwigBundle\Controller\ExceptionController" public="true">

‎src/Symfony/Component/Console/Input/ArgvInput.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Input/ArgvInput.php
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,6 @@ public function hasParameterOption($values, $onlyParams = false)
285285
if ($token === $value || 0 === strpos($token, $value.'=')) {
286286
return true;
287287
}
288-
289-
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
290-
$noValue = explode('=', $token);
291-
$token = $noValue[0];
292-
$searchableToken = str_replace('-', '', $token);
293-
$searchableValue = str_replace('-', '', $value);
294-
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
295-
return true;
296-
}
297-
}
298288
}
299289
}
300290

‎src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ public function testHasParameterOption()
314314
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
315315
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
316316

317-
$input = new ArgvInput(array('cli.php', '-fh'));
318-
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
319-
320-
$input = new ArgvInput(array('cli.php', '-e=test'));
321-
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
322-
323317
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
324318
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
325319

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,16 @@ public function fileExists($path, $trackContents = true)
419419
* @throws BadMethodCallException When this ContainerBuilder is compiled
420420
* @throws \LogicException if the extension is not registered
421421
*/
422-
public function loadFromExtension($extension, array $values = array())
422+
public function loadFromExtension($extension, array $values = null)
423423
{
424424
if ($this->isCompiled()) {
425425
throw new BadMethodCallException('Cannot load from an extension on a compiled container.');
426426
}
427427

428+
if (func_num_args() < 2) {
429+
$values = array();
430+
}
431+
428432
$namespace = $this->getExtension($extension)->getAlias();
429433

430434
$this->extensionConfigs[$namespace][] = $values;

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ private function loadFromExtensions(array $content)
755755
continue;
756756
}
757757

758-
if (!is_array($values)) {
758+
if (!is_array($values) && null !== $values) {
759759
$values = array();
760760
}
761761

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveDefinitionTemplatesPassTest.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,23 @@ public function testDeepDefinitionsResolving()
259259
$this->process($container);
260260

261261
$configurator = $container->getDefinition('sibling')->getConfigurator();
262-
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($configurator));
262+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $configurator);
263263
$this->assertSame('parentClass', $configurator->getClass());
264264

265265
$factory = $container->getDefinition('sibling')->getFactory();
266-
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($factory[0]));
266+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $factory[0]);
267267
$this->assertSame('parentClass', $factory[0]->getClass());
268268

269269
$argument = $container->getDefinition('sibling')->getArgument(0);
270-
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($argument));
270+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $argument);
271271
$this->assertSame('parentClass', $argument->getClass());
272272

273273
$properties = $container->getDefinition('sibling')->getProperties();
274-
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($properties['prop']));
274+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $properties['prop']);
275275
$this->assertSame('parentClass', $properties['prop']->getClass());
276276

277277
$methodCalls = $container->getDefinition('sibling')->getMethodCalls();
278-
$this->assertSame('Symfony\Component\DependencyInjection\Definition', get_class($methodCalls[0][1][0]));
278+
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Definition', $methodCalls[0][1][0]);
279279
$this->assertSame('parentClass', $methodCalls[0][1][0]->getClass());
280280
}
281281

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ class ProjectExtension implements ExtensionInterface
88
{
99
public function load(array $configs, ContainerBuilder $configuration)
1010
{
11-
$config = call_user_func_array('array_merge', $configs);
11+
$configuration->setParameter('project.configs', $configs);
12+
$configs = array_filter($configs);
13+
14+
if ($configs) {
15+
$config = call_user_func_array('array_merge', $configs);
16+
} else {
17+
$config = array();
18+
}
1219

1320
$configuration->setDefinition('project.service.bar', new Definition('FooClass'));
1421
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
project: ~

‎src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ public function testExtensions()
219219
}
220220
}
221221

222+
public function testExtensionWithNullConfig()
223+
{
224+
$container = new ContainerBuilder();
225+
$container->registerExtension(new \ProjectExtension());
226+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
227+
$loader->load('null_config.yml');
228+
$container->compile();
229+
230+
$this->assertSame(array(null), $container->getParameter('project.configs'));
231+
}
232+
222233
public function testSupports()
223234
{
224235
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());

‎src/Symfony/Component/Form/Button.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Button.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function offsetUnset($offset)
106106
*/
107107
public function setParent(FormInterface $parent = null)
108108
{
109+
if ($this->submitted) {
110+
throw new AlreadySubmittedException('You cannot set the parent of a submitted button');
111+
}
112+
109113
$this->parent = $parent;
110114
}
111115

‎src/Symfony/Component/Form/SubmitButton.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/SubmitButton.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public function isClicked()
4343
*/
4444
public function submit($submittedData, $clearMissing = true)
4545
{
46+
if ($this->getConfig()->getDisabled()) {
47+
$this->clicked = false;
48+
49+
return $this;
50+
}
51+
4652
parent::submit($submittedData, $clearMissing);
4753

4854
$this->clicked = null !== $submittedData;

‎src/Symfony/Component/Form/Test/TypeTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Test/TypeTestCase.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ protected function setUp()
3434
$this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory);
3535
}
3636

37-
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
38-
{
39-
self::assertEquals($expected->format('c'), $actual->format('c'));
40-
}
41-
4237
public static function assertDateIntervalEquals(\DateInterval $expected, \DateInterval $actual)
4338
{
4439
self::assertEquals($expected->format('%RP%yY%mM%dDT%hH%iM%sS'), $actual->format('%RP%yY%mM%dDT%hH%iM%sS'));

‎src/Symfony/Component/Form/Tests/ButtonTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/ButtonTest.php
+18-2Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,34 @@ protected function setUp()
3030
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
3131
}
3232

33+
/**
34+
* @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
35+
*/
36+
public function testSetParentOnSubmittedButton()
37+
{
38+
$button = $this->getButtonBuilder('button')
39+
->getForm()
40+
;
41+
42+
$button->submit('');
43+
44+
$button->setParent($this->getFormBuilder('form')->getForm());
45+
}
46+
3347
/**
3448
* @dataProvider getDisabledStates
3549
*/
3650
public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result)
3751
{
3852
$form = $this->getFormBuilder('form')
3953
->setDisabled($parentDisabled)
40-
->getForm();
54+
->getForm()
55+
;
4156

4257
$button = $this->getButtonBuilder('button')
4358
->setDisabled($buttonDisabled)
44-
->getForm();
59+
->getForm()
60+
;
4561

4662
$button->setParent($form);
4763

‎src/Symfony/Component/Form/Tests/CompoundFormTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/CompoundFormTest.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,28 @@ public function testClickedButtonFromParentForm()
10141014
$this->assertSame($button, $this->form->getClickedButton());
10151015
}
10161016

1017+
public function testDisabledButtonIsNotSubmitted()
1018+
{
1019+
$button = new SubmitButtonBuilder('submit');
1020+
$submit = $button
1021+
->setDisabled(true)
1022+
->getForm();
1023+
1024+
$form = $this->createForm()
1025+
->add($this->getBuilder('text')->getForm())
1026+
->add($submit)
1027+
;
1028+
1029+
$form->submit(array(
1030+
'text' => '',
1031+
'submit' => '',
1032+
));
1033+
1034+
$this->assertTrue($submit->isDisabled());
1035+
$this->assertFalse($submit->isClicked());
1036+
$this->assertFalse($submit->isSubmitted());
1037+
}
1038+
10171039
protected function createForm()
10181040
{
10191041
return $this->getBuilder()

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php
-22Lines changed: 0 additions & 22 deletions
This file was deleted.

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
1313

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
1516

16-
class DateTimeToArrayTransformerTest extends DateTimeTestCase
17+
class DateTimeToArrayTransformerTest extends TestCase
1718
{
1819
public function testTransform()
1920
{
@@ -160,7 +161,7 @@ public function testReverseTransform()
160161

161162
$output = new \DateTime('2010-02-03 04:05:06 UTC');
162163

163-
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
164+
$this->assertEquals($output, $transformer->reverseTransform($input));
164165
}
165166

166167
public function testReverseTransformWithSomeZero()
@@ -178,7 +179,7 @@ public function testReverseTransformWithSomeZero()
178179

179180
$output = new \DateTime('2010-02-03 04:00:00 UTC');
180181

181-
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
182+
$this->assertEquals($output, $transformer->reverseTransform($input));
182183
}
183184

184185
public function testReverseTransformCompletelyEmpty()
@@ -323,7 +324,7 @@ public function testReverseTransformDifferentTimezones()
323324
$output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong');
324325
$output->setTimezone(new \DateTimeZone('America/New_York'));
325326

326-
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
327+
$this->assertEquals($output, $transformer->reverseTransform($input));
327328
}
328329

329330
public function testReverseTransformToDifferentTimezone()
@@ -342,7 +343,7 @@ public function testReverseTransformToDifferentTimezone()
342343
$output = new \DateTime('2010-02-03 04:05:06 UTC');
343344
$output->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
344345

345-
$this->assertDateTimeEquals($output, $transformer->reverseTransform($input));
346+
$this->assertEquals($output, $transformer->reverseTransform($input));
346347
}
347348

348349
/**

0 commit comments

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