10000 Merge branch '2.7' into 2.8 · symfony/symfony@be3a827 · GitHub
[go: up one dir, main page]

Skip to content

Commit be3a827

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [Form] Fix typo in doc comment [Config] Handle open_basedir restrictions in FileLocator [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level Use JSON_UNESCAPED_SLASHES for lint commands output Fixed collapsed ChoiceType options attributes Fixed the nullable support for php 7.1 and below
2 parents c555d64 + c1cc6ca commit be3a827

File tree

11 files changed

+79
-9
lines changed

11 files changed

+79
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
207207
}
208208
});
209209

210-
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
210+
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT JSON_UNESCAPED_SLASHES : 0));
211211

212212
return min($errors, 1);
213213
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
162162
}
163163
});
164164

165-
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
165+
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
166166

167167
return min($errors, 1);
168168
}

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_attributes.html.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"
21
<?php if ($disabled): ?>disabled="disabled" <?php endif ?>
32
<?php foreach ($choice_attr as $k => $v): ?>
43
<?php if ($v === true): ?>

src/Symfony/Component/Config/FileLocator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function locate($name, $currentPath = null, $first = true)
5757
$filepaths = array();
5858

5959
foreach ($paths as $path) {
60-
if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
60+
if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
6161
if (true === $first) {
6262
return $file;
6363
}

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public function register($name)
340340
* Adds an array of command objects.
341341
*
342342
* If a Command is not enabled it will not be added.
343-
*
343+
*
344344
* @param Command[] $commands An array of commands
345345
*/
346346
public function addCommands(array $commands)
@@ -811,6 +811,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
811811

812812
if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
813813
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
814+
$input->setInteractive(false);
814815
} else {
815816
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) {
816817
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,11 @@ public function testRun()
640640

641641
$tester->run(array('command' => 'list', '--quiet' => true));
642642
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
643+
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed');
643644

644645
$tester->run(array('command' => 'list', '-q' => true));
645646
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
647+
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed');
646648

647649
$tester->run(array('command' => 'list', '--verbose' => true));
648650
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');

src/Symfony/Component/Form/PreloadedExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Exception\InvalidArgumentException;
1515

1616
/**
17-
* A form extension with preloaded types, type exceptions and type guessers.
17+
* A form extension with preloaded types, type extensions and type guessers.
1818
*
1919
* @author Bernhard Schussek <bschussek@gmail.com>
2020
*/

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ public function testSingleChoiceAttributesWithMainAttributes()
657657
[@class="bar&baz"]
658658
[not(@required)]
659659
[
660-
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
661-
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"]
660+
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"][not(@id)][not(@name)]
661+
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"][not(@id)][not(@name)]
662662
]
663663
[count(./option)=2]
664664
'

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class ControllerResolver implements ControllerResolverInterface
2727
{
2828
private $logger;
2929

30+
/**
31+
* If the ...$arg functionality is available.
32+
*
33+
* Requires at least PHP 5.6.0 or HHVM 3.9.1
34+
*
35+
* @var bool
36+
*/
37+
private $supportsVariadic;
38+
3039
/**
3140
* Constructor.
3241
*
@@ -35,6 +44,8 @@ class ControllerResolver implements ControllerResolverInterface
3544
public function __construct(LoggerInterface $logger = null)
3645
{
3746
$this->logger = $logger;
47+
48+
$this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic');
3849
}
3950

4051
/**
@@ -99,13 +110,20 @@ public function getArguments(Request $request, $controller)
99110
return $this->doGetArguments($request, $controller, $r->getParameters());
100111
}
101112

113+
/**
114+
* @param Request $request
115+
* @param callable $controller
116+
* @param \ReflectionParameter[] $parameters
117+
*
118+
* @return array The arguments to use when calling the action
119+
*/
102120
protected function doGetArguments(Request $request, $controller, array $parameters)
103121
{
104122
$attributes = $request->attributes->all();
105123
$arguments = array();
106124
foreach ($parameters as $param) {
107125
if (array_key_exists($param->name, $attributes)) {
108-
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
126+
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
109127
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
110128
} else {
111129
$arguments[] = $attributes[$param->name];
@@ -114,6 +132,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete
114132
$arguments[] = $request;
115133
} elseif ($param->isDefaultValueAvailable()) {
116134
$arguments[] = $param->getDefaultValue();
135+
} elseif ($param->allowsNull()) {
136+
$arguments[] = null;
117137
} else {
118138
if (is_array($controller)) {
119139
$repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);

src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
16+
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
1617
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
1718
use Symfony\Component\HttpFoundation\Request;
1819

@@ -222,6 +223,34 @@ public function testCreateControllerCanReturnAnyCallable()
222223
$mock->getController($request);
223224
}
224225

226+
/**
227+
* @requires PHP 7.1
228+
*/
229+
public function testGetNullableArguments()
230+
{
231+
$resolver = new ControllerResolver();
232+
233+
$request = Request::create('/');
234+
$request->attributes->set('foo', 'foo');
235+
$request->attributes->set('bar', new \stdClass());
236+
$request->attributes->set('mandatory', 'mandatory');
237+
$controller = array(new NullableController(), 'action');
238+
$this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller));
239+
}
240+
241+
/**
242+
* @requires PHP 7.1
243+
*/
244+
public function testGetNullableArgumentsWithDefaults()
245+
{
246+
$resolver = new ControllerResolver();
247+
248+
$request = Request::create('/');
249+
$request->attributes->set('mandatory', 'mandatory');
250+
$contro DEBF ller = array(new NullableController(), 'action');
251+
$this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller));
252+
}
253+
225254
protected function createControllerResolver(LoggerInterface $logger = null)
226255
{
227256
return new ControllerResolver($logger);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\Component\HttpKernel\Tests\Fixtures\Controller;
13+
14+
class NullableController
15+
{
16+
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
17+
{
18+
}
19+
}

0 commit comments

Comments
 (0)
0