8000 Merge branch '2.8' into 3.1 · jeremyFreeAgent/symfony@0d5dbb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d5dbb7

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [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 156269d + be3a827 commit 0d5dbb7

File tree

11 files changed

+78
-9
lines changed

11 files changed

+78
-9
lines changed
8000

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
202202
}
203203
});
204204

205-
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
205+
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
206206

207207
return min($errors, 1);
208208
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
157157
}
158158
});
159159

160-
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
160+
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
161161

162162
return min($errors, 1);
163163
}

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 $ 628C 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
@@ -354,7 +354,7 @@ public function register($name)
354354
* Adds an array of command objects.
355355
*
356356
* If a Command is not enabled it will not be added.
357-
*
357+
*
358358
* @param Command[] $commands An array of commands
359359
*/
360360
public function addCommands(array $commands)
@@ -782,6 +782,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
782782

783783
if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) {
784784
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
785+
$input->setInteractive(false);
785786
} else {
786787
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || $input->getParameterOption('--verbose', false, true) === 3) {
787788
$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
@@ -639,9 +639,11 @@ public function testRun()
639639

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

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

646648
$tester->run(array('command' => 'list', '--verbose' => true));
647649
$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
@@ -620,8 +620,8 @@ public function testSingleChoiceAttributesWithMainAttributes()
620620
[@class="bar&baz"]
621621
[not(@required)]
622622
[
623-
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
624-
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"]
623+
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"][not(@id)][not(@name)]
624+
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"][not(@id)][not(@name)]
625625
]
626626
[count(./option)=2]
627627
'

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
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 ArgumentResolverInterface, ControllerResolve
3544
public function __construct(LoggerInterface $logger = null)
3645
{
3746
$this->logger = $logger;
47+
48+
$this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic');
3849
}
3950

4051
/**
@@ -104,6 +115,12 @@ public function getArguments(Request $request, $controller)
104115
}
105116

106117
/**
118+
* @param Request $request
119+
* @param callable $controller
120+
* @param \ReflectionParameter[] $parameters
121+
*
122+
* @return array The arguments to use when calling the action
123+
*
107124
* @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.
108125
*/
109126
protected function doGetArguments(Request $request, $controller, array $parameters)
@@ -114,7 +131,7 @@ protected function doGetArguments(Request $request, $controller, array $paramete
114131
$arguments = array();
115132
foreach ($parameters as $param) {
116133
if (array_key_exists($param->name, $attributes)) {
117-
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
134+
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
118135
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
119136
} else {
120137
$arguments[] = $attributes[$param->name];
@@ -123,6 +140,8 @@ protected function doGetArguments(Request $request, $controller, array $paramete
123140
$arguments[] = $request;
124141
} elseif ($param->isDefaultValueAvailable()) {
125142
$arguments[] = $param->getDefaultValue();
143+
} elseif ($param->allowsNull()) {
144+
$arguments[] = null;
126145
} else {
127146
if (is_array($controller)) {
128147
$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

@@ -226,6 +227,34 @@ public function testCreateControllerCanReturnAnyCallable()
226227
$mock->getController($request);
227228
}
228229

230+
/**
231+
* @requires PHP 7.1
232+
*/
233+
public function testGetNullableArguments()
234+
{
235+
$resolver = new ControllerResolver();
236+
237+
$request = Request::create('/');
238+
$request->attributes->set('foo', 'foo');
239+
$request->attributes->set('bar', new \stdClass());
240+
$request->attributes->set('mandatory', 'mandatory');
241+
$controller = array(new NullableController(), 'action');
242+
$this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller));
243+
}
244+
245+
/**
246+
* @requires PHP 7.1
247+
*/
248+
public function testGetNullableArgumentsWithDefaults()
249+
{
250+
$resolver = new ControllerResolver();
251+
252+
$request = Request::create('/');
253+
$request->attributes->set('mandatory', 'mandatory');
254+
$controller = array(new NullableController(), 'action');
255+
$this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller));
256+
}
257+
229258
protected function createControllerResolver(LoggerInterface $logger = null)
230259
{
231260
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