Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 194dcf3

Browse files
Merge branch '3.1'
* 3.1: [Console] Application update PHPDoc of add and register methods [Config] Extra tests for Config component Fixed bugs in names of classes and methods. [DoctrineBridge] Fixed php doc [FrameworkBundle] Fixed parameters number mismatch declaration [BrowserKit] Added test for followRedirect method (POST method) Fix the money form type render with Bootstrap3 [BrowserKit] Uppercase the "GET" method in redirects [DomCrawler] Inherit the namespace cache in subcrawlers [WebProfilerBundle] Fixed JSDoc parameter definition [HttpFoundation] HttpCache refresh stale responses containing an ETag Conflicts: src/Symfony/Component/Console/Application.php
2 parents 695549f + 54043a0 commit 194dcf3

File tree

38 files changed

+167
-53
lines changed

38 files changed

+167
-53
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB
314314
/**
315315
* Loads a cache driver.
316316
*
317-
* @param string $cacheDriverServiceId The cache driver name
318-
* @param string $objectManagerName The object manager name
319-
* @param array $cacheDriver The cache driver mapping
320-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container The ContainerBuilder instance
317+
* @param string $cacheName The cache driver name
318+
* @param string $objectManagerName The object manager name
319+
* @param array $cacheDriver The cache driver mapping
320+
* @param ContainerBuilder $container The ContainerBuilder instance
321321
*
322322
* @return string
323323
*

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
110110
* @param string[] $managerParameters List of container parameters that could
111111
* hold the manager name.
112112
* @param string $driverPattern Pattern for the metadata driver service name
113-
* @param string $enabledParameter Service container parameter that must be
113+
* @param string|false $enabledParameter Service container parameter that must be
114114
* present to enable the mapping. Set to false
115115
* to not do any check, optional.
116116
* @param string $configurationPattern Pattern for the Configuration service name

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
{% block money_widget -%}
2323
<div class="input-group">
24-
{% set prepend = '{{' == money_pattern[0:2] %}
25-
{% if not prepend %}
24+
{% set append = money_pattern starts with '{{' %}
25+
{% if not append %}
2626
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
2727
{% endif %}
2828
{{- block('form_widget_simple') -}}
29-
{% if prepend %}
29+
{% if append %}
3030
<span class="input-group-addon">{{ money_pattern|replace({ '{{ widget }}':''}) }}</span>
3131
{% endif %}
3232
</div>

src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function listBundles($output)
4747
} else {
4848
$output->writeln($title);
4949
$table = new Table($output);
50-
$table->setHeaders($headers)->setRows($rows)->render($output);
50+
$table->setHeaders($headers)->setRows($rows)->render();
5151
}
5252
}
5353

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,10 @@ private function getValidatorMappingFiles(ContainerBuilder $container)
888888

889889
if (is_dir($dir = $dirname.'/Resources/config/validation')) {
890890
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
891-
$files[0][] = $file->getRealpath();
891+
$files[0][] = $file->getRealPath();
892892
}
893893
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
894-
$files[1][] = $file->getRealpath();
894+
$files[1][] = $file->getRealPath();
895895
}
896896

897897
$container->addResource(new DirectoryResource($dir));
@@ -1027,13 +1027,13 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
10271027

10281028
if (is_dir($dir = $dirname.'/Resources/config/serialization')) {
10291029
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
1030-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getRealpath()));
1030+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader', array($file->getRealPath()));
10311031
$definition->setPublic(false);
10321032

10331033
$serializerLoaders[] = $definition;
10341034
}
10351035
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
1036-
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getRealpath()));
1036+
$definition = new Definition('Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader', array($file->getRealPath()));
10371037
$definition->setPublic(false);
10381038

10391039
$serializerLoaders[] = $definition;

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testGetExistingEngine()
3838

3939
$delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second'));
4040

41-
$this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php', array('foo' => 'bar')));
41+
$this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php'));
4242
}
4343

4444
/**
@@ -55,7 +55,7 @@ public function testGetInvalidEngine()
5555
));
5656

5757
$delegatingEngine = new DelegatingEngine($container, array('engine.first', 'engine.second'));
58-
$delegatingEngine->getEngine('template.php', array('foo' => 'bar'));
58+
$delegatingEngine->getEngine('template.php');
5959
}
6060

6161
public function testRenderResponseWithFrameworkEngine()

src/Symfony/Bundle/FrameworkBundle/Translation/TranslationLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function loadMessages($directory, MessageCatalogue $catalogue)
5858
$extension = $catalogue->getLocale().'.'.$format;
5959
$files = $finder->files()->name('*.'.$extension)->in($directory);
6060
foreach ($files as $file) {
61-
$domain = substr($file->getFileName(), 0, -1 * strlen($extension) - 1);
61+
$domain = substr($file->getFilename(), 0, -1 * strlen($extension) - 1);
6262
$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
6363
}
6464
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
/**
161161
* Query an element with a CSS selector.
162162
*
163-
* @param string selector a CSS-selector-compatible query string
163+
* @param {string} selector - a CSS-selector-compatible query string
164164
*
165165
* @return DOMElement|null
166166
*/

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public function followRedirect()
475475
$request = $this->internalRequest;
476476

477477
if (in_array($this->internalResponse->getStatus(), array(302, 303))) {
478-
$method = 'get';
478+
$method = 'GET';
479479
$files = array();
480480
$content = null;
481481
} else {
@@ -484,7 +484,7 @@ public function followRedirect()
484484
$content = $request->getContent();
485485
}
486486

487-
if ('get' === strtolower($method)) {
487+
if ('GET' === strtoupper($method)) {
488488
// Don't forward parameters for GET request as it should reach the redirection URI
489489
$parameters = array();
490490
} else {

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public function testFollowRedirectWithMaxRedirects()
410410
$client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected')));
411411
$client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar'));
412412

413-
$this->assertEquals('get', $client->getRequest()->getMethod(), '->followRedirect() uses a get for 302');
413+
$this->assertEquals('GET', $client->getRequest()->getMethod(), '->followRedirect() uses a GET for 302');
414414
$this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method');
415415
}
416416

@@ -489,6 +489,26 @@ public function testGetMaxRedirects()
489489
$this->assertEquals(3, $client->getMaxRedirects(), '->getMaxRedirects() returns assigned value');
490490
}
491491

492+
public function testFollowRedirectWithPostMethod()
493+
{
494+
$parameters = array('foo' => 'bar');
495+
$files = array('myfile.foo' => 'baz');
496+
$server = array('X_TEST_FOO' => 'bazbar');
497+
$content = 'foobarbaz';
498+
499+
$client = new TestClient();
500+
501+
$client->setNextResponse(new Response('', 307, array('Location' => 'http://www.example.com/redirected')));
502+
$client->request('POST', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content);
503+
504+
$this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect with POST method');
505+
$this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->followRedirect() keeps parameters with POST method');
506+
$this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->followRedirect() keeps files with POST method');
507+
$this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->followRedirect() keeps $_SERVER with POST method');
508+
$this->assertEquals($content, $client->getRequest()->getContent(), '->followRedirect() keeps content with POST method');
509+
$this->assertEquals('POST', $client->getRequest()->getMethod(), '->followRedirect() keeps request method');
510+
}
511+
492512
public function testBack()
493513
{
494514
$client = new TestClient();

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,48 @@ public function testTrueEnableEnabledNode($expected, $config, $message)
185185
);
186186
}
187187

188+
public function testCanBeDisabled()
189+
{
190+
$node = new ArrayNodeDefinition('root');
191+
$node->canBeDisabled();
192+
193+
$this->assertTrue($this->getField($node, 'addDefaults'));
194+
$this->assertEquals(array('enabled' => false), $this->getField($node, 'falseEquivalent'));
195+
$this->assertEquals(array('enabled' => true), $this->getField($node, 'trueEquivalent'));
196+
$this->assertEquals(array('enabled' => true), $this->getField($node, 'nullEquivalent'));
197+
198+
$nodeChildren = $this->getField($node, 'children');
199+
$this->assertArrayHasKey('enabled', $nodeChildren);
200+
201+
$enabledNode = $nodeChildren['enabled'];
202+
$this->assertTrue($this->getField($enabledNode, 'default'));
203+
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
204+
}
205+
206+
public function testIgnoreExtraKeys()
207+
{
208+
$node = new ArrayNodeDefinition('root');
209+
210+
$this->assertFalse($this->getField($node, 'ignoreExtraKeys'));
211+
212+
$result = $node->ignoreExtraKeys();
213+
214+
$this->assertEquals($node, $result);
215+
$this->assertTrue($this->getField($node, 'ignoreExtraKeys'));
216+
}
217+
218+
public function testNormalizeKeys()
219+
{
220+
$node = new ArrayNodeDefinition('root');
221+
222+
$this->assertTrue($this->getField($node, 'normalizeKeys'));
223+
224+
$result = $node->normalizeKeys(false);
225+
226+
$this->assertEquals($node, $result);
227+
$this->assertFalse($this->getField($node, 'normalizeKeys'));
228+
}
229+
188230
public function getEnableableNodeFixtures()
189231
{
190232
return array(

src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ public function testThenUnsetExpression()
150150
$this->assertEquals(array(), $this->finalizeTestBuilder($test));
151151
}
152152

153+
/**
154+
* @expectedException \RuntimeException
155+
* @expectedExceptionMessage You must specify an if part.
156+
*/
157+
public function testEndIfPartNotSpecified()
158+
{
159+
$this->getTestBuilder()->end();
160+
}
161+
162+
/**
163+
* @expectedException \RuntimeException
164+
* @expectedExceptionMessage You must specify a then part.
165+
*/
166+
public function testEndThenPartNotSpecified()
167+
{
168+
$builder = $this->getTestBuilder();
169+
$builder->ifPart = 'test';
170+
$builder->end();
171+
}
172+
153173
/**
154174
* Create a test treebuilder with a variable node, and init the validation.
155175
*

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static function loadFile($file, $schemaOrCallable = null)
123123
*
124124
* @return array A PHP array
125125
*/
126-
public static function convertDomElementToArray(\DomElement $element, $checkPrefix = true)
126+
public static function convertDomElementToArray(\DOMElement $element, $checkPrefix = true)
127127
{
128128
$prefix = (string) $element->prefix;
129129
$empty = true;

src/Symfony/Component/Console/Application.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function getHelperSet()
211211
}
212212

213213
/**
214-
* Set an input definition set to be used with this application.
214+
* Set an input definition to be used with this application.
215215
*
216216
* @param InputDefinition $definition The input definition
217217
*/
@@ -360,6 +360,8 @@ public function register($name)
360360
/**
361361
* Adds an array of command objects.
362362
*
363+
* If a Command is not enabled it will not be added.
364+
*
363365
* @param Command[] $commands An array of commands
364366
*/
365367
public function addCommands(array $commands)
@@ -373,10 +375,11 @@ public function addCommands(array $commands)
373375
* Adds a command object.
374376
*
375377
* If a command with the same name already exists, it will be overridden.
378+
* If the command is not enabled it will not be added.
376379
*
377380
* @param Command $command A Command object
378381
*
379-
* @return Command The registered command
382+
* @return Command|null The registered command if enabled or null
380383
*/
381384
public function add(Command $command)
382385
{
@@ -445,9 +448,9 @@ public function has($name)
445448
/**
446449
* Returns an array of all unique namespaces used by currently registered commands.
447450
*
448-
* It does not returns the global namespace which always exists.
451+
* It does not return the global namespace which always exists.
449452
*
450-
* @return array An array of namespaces
453+
* @return string[] An array of namespaces
451454
*/
452455
public function getNamespaces()
453456
{
@@ -950,7 +953,7 @@ public function extractNamespace($name, $limit = null)
950953
* @param string $name The string
951954
* @param array|\Traversable $collection The collection
952955
*
953-
* @return array A sorted array of similar string
956+
* @return string[] A sorted array of similar string
954957
*/
955958
private function findAlternatives($name, $collection)
956959
{
@@ -1059,7 +1062,7 @@ private function splitStringByWidth($string, $width)
10591062
*
10601063
* @param string $name The full name of the command
10611064
*
1062-
* @return array The namespaces of the command
1065+
* @return string[] The namespaces of the command
10631066
*/
10641067
private function extractAllNamespaces($name)
10651068
{

src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function writePrompt(OutputInterface $output, Question $question)
6767

6868
break;
6969

70-
case $question instanceof ChoiceQuestion && $question->isMultiSelect():
70+
case $question instanceof ChoiceQuestion && $question->isMultiselect():
7171
$choices = $question->getChoices();
7272
$default = explode(',', $default);
7373

src/Symfony/Component/Console/Terminal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static function initDimensions()
8181
/**
8282
* Runs and parses mode CON if it's available, suppressing any error output.
8383
*
84-
* @return array|null An array composed of the width and the height or null if it could not be parsed
84+
* @return int[]|null An array composed of the width and the height or null if it could not be parsed
8585
*/
8686
private static function getConsoleMode()
8787
{
@@ -109,7 +109,7 @@ private static function getConsoleMode()
109109
/**
110110
* Runs and parses stty -a if it's available, suppressing any error output.
111111
*
112-
* @return string
112+
* @return string|null
113113
*/
114114
private static function getSttyColumns()
115115
{

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ public function testFindAlternativeNamespace()
425425
$application->add(new \FooCommand());
426426
$application->add(new \Foo1Command());
427427
$application->add(new \Foo2Command());
428-
$application->add(new \foo3Command());
428+
$application->add(new \Foo3Command());
429429

430430
try {
431431
$application->find('Unknown-namespace:Unknown-command');

src/Symfony/Component/Debug/Tests/MockExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Debug\ExceptionHandler;
1515

16-
class MockExceptionHandler extends Exceptionhandler
16+
class MockExceptionHandler extends ExceptionHandler
1717
{
1818
public $e;
1919

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ private function loadFromExtensions(\DOMDocument $xml)
585585
*
586586
* @return array A PHP array
587587
*/
588-
public static function convertDomElementToArray(\DomElement $element)
588+
public static function convertDomElementToArray(\DOMElement $element)
589589
{
590590
return XmlUtils::convertDomElementToArray($element);
591591
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function provideInvalidParameters()
100100
{
101101
return array(
102102
array(array('foo' => new Definition('stdClass'))),
103-
array(array('foo' => new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'))),
103+
array(array('foo' => new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")'))),
104104
array(array('foo' => new Reference('foo'))),
105105
array(array('foo' => new Variable('foo'))),
106106
);

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
->addMethodCall('setBar', array(new Reference('foo2', ContainerInterface::NULL_ON_INVALID_REFERENCE)))
5050
->addMethodCall('setBar', array(new Reference('foo3', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
5151
->addMethodCall('setBar', array(new Reference('foobaz', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))
52-
->addMethodCall('setBar', array(new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")')))
52+
->addMethodCall('setBar', array(new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")')))
5353
;
5454
$container
5555
->register('foo_with_inline', 'Foo')

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ protected function getMethodCall1Service()
306306
if ($this->has('foobaz')) {
307307
$instance->setBar($this->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
308308
}
309-
$instance->setBar(($this->get("foo")->foo() . (($this->hasparameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
309+
$instance->setBar(($this->get("foo")->foo() . (($this->hasParameter("foo")) ? ($this->getParameter("foo")) : ("default"))));
310310

311311
return $instance;
312312
}

0 commit comments

Comments
 (0)