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
This commit is contained in:
commit
0d5dbb75ee
@ -202,7 +202,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
|
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ EOF
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
|
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||||
|
|
||||||
return min($errors, 1);
|
return min($errors, 1);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
id="<?php echo $view->escape($id) ?>" name="<?php echo $view->escape($full_name) ?>"
|
|
||||||
<?php if ($disabled): ?>disabled="disabled" <?php endif ?>
|
<?php if ($disabled): ?>disabled="disabled" <?php endif ?>
|
||||||
<?php foreach ($choice_attr as $k => $v): ?>
|
<?php foreach ($choice_attr as $k => $v): ?>
|
||||||
<?php if ($v === true): ?>
|
<?php if ($v === true): ?>
|
||||||
|
@ -57,7 +57,7 @@ class FileLocator implements FileLocatorInterface
|
|||||||
$filepaths = array();
|
$filepaths = array();
|
||||||
|
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
|
if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
|
||||||
if (true === $first) {
|
if (true === $first) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
@ -782,6 +782,7 @@ class Application
|
|||||||
|
|
||||||
if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) {
|
if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) {
|
||||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||||
|
$input->setInteractive(false);
|
||||||
} else {
|
} else {
|
||||||
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || $input->getParameterOption('--verbose', false, true) === 3) {
|
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || $input->getParameterOption('--verbose', false, true) === 3) {
|
||||||
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||||
|
@ -639,9 +639,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$tester->run(array('command' => 'list', '--quiet' => true));
|
$tester->run(array('command' => 'list', '--quiet' => true));
|
||||||
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
|
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
|
||||||
|
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed');
|
||||||
|
|
||||||
$tester->run(array('command' => 'list', '-q' => true));
|
$tester->run(array('command' => 'list', '-q' => true));
|
||||||
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
|
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
|
||||||
|
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed');
|
||||||
|
|
||||||
$tester->run(array('command' => 'list', '--verbose' => true));
|
$tester->run(array('command' => 'list', '--verbose' => true));
|
||||||
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
|
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Form;
|
|||||||
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
use Symfony\Component\Form\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A form extension with preloaded types, type exceptions and type guessers.
|
* A form extension with preloaded types, type extensions and type guessers.
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
@ -620,8 +620,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
|||||||
[@class="bar&baz"]
|
[@class="bar&baz"]
|
||||||
[not(@required)]
|
[not(@required)]
|
||||||
[
|
[
|
||||||
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"][not(@id)][not(@name)]
|
||||||
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"]
|
/following-sibling::option[@value="&b"][not(@class)][not(@selected)][.="[trans]Choice&B[/trans]"][not(@id)][not(@name)]
|
||||||
]
|
]
|
||||||
[count(./option)=2]
|
[count(./option)=2]
|
||||||
'
|
'
|
||||||
|
@ -27,6 +27,15 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
{
|
{
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the ...$arg functionality is available.
|
||||||
|
*
|
||||||
|
* Requires at least PHP 5.6.0 or HHVM 3.9.1
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $supportsVariadic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -35,6 +44,8 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
public function __construct(LoggerInterface $logger = null)
|
public function __construct(LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
||||||
|
$this->supportsVariadic = method_exists('ReflectionParameter', 'isVariadic');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,6 +115,12 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param callable $controller
|
||||||
|
* @param \ReflectionParameter[] $parameters
|
||||||
|
*
|
||||||
|
* @return array The arguments to use when calling the action
|
||||||
|
*
|
||||||
* @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.
|
* @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.
|
||||||
*/
|
*/
|
||||||
protected function doGetArguments(Request $request, $controller, array $parameters)
|
protected function doGetArguments(Request $request, $controller, array $parameters)
|
||||||
@ -114,7 +131,7 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
$arguments = array();
|
$arguments = array();
|
||||||
foreach ($parameters as $param) {
|
foreach ($parameters as $param) {
|
||||||
if (array_key_exists($param->name, $attributes)) {
|
if (array_key_exists($param->name, $attributes)) {
|
||||||
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
|
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
|
||||||
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
|
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
|
||||||
} else {
|
} else {
|
||||||
$arguments[] = $attributes[$param->name];
|
$arguments[] = $attributes[$param->name];
|
||||||
@ -123,6 +140,8 @@ class ControllerResolver implements ArgumentResolverInterface, ControllerResolve
|
|||||||
$arguments[] = $request;
|
$arguments[] = $request;
|
||||||
} elseif ($param->isDefaultValueAvailable()) {
|
} elseif ($param->isDefaultValueAvailable()) {
|
||||||
$arguments[] = $param->getDefaultValue();
|
$arguments[] = $param->getDefaultValue();
|
||||||
|
} elseif ($param->allowsNull()) {
|
||||||
|
$arguments[] = null;
|
||||||
} else {
|
} else {
|
||||||
if (is_array($controller)) {
|
if (is_array($controller)) {
|
||||||
$repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
|
$repr = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
|||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
||||||
|
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\NullableController;
|
||||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
|
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -226,6 +227,34 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
|||||||
$mock->getController($request);
|
$mock->getController($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires PHP 7.1
|
||||||
|
*/
|
||||||
|
public function testGetNullableArguments()
|
||||||
|
{
|
||||||
|
$resolver = new ControllerResolver();
|
||||||
|
|
||||||
|
$request = Request::create('/');
|
||||||
|
$request->attributes->set('foo', 'foo');
|
||||||
|
$request->attributes->set('bar', new \stdClass());
|
||||||
|
$request->attributes->set('mandatory', 'mandatory');
|
||||||
|
$controller = array(new NullableController(), 'action');
|
||||||
|
$this->assertEquals(array('foo', new \stdClass(), 'value', 'mandatory'), $resolver->getArguments($request, $controller));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires PHP 7.1
|
||||||
|
*/
|
||||||
|
public function testGetNullableArgumentsWithDefaults()
|
||||||
|
{
|
||||||
|
$resolver = new ControllerResolver();
|
||||||
|
|
||||||
|
$request = Request::create('/');
|
||||||
|
$request->attributes->set('mandatory', 'mandatory');
|
||||||
|
$controller = array(new NullableController(), 'action');
|
||||||
|
$this->assertEquals(array(null, null, 'value', 'mandatory'), $resolver->getArguments($request, $controller));
|
||||||
|
}
|
||||||
|
|
||||||
protected function createControllerResolver(LoggerInterface $logger = null)
|
protected function createControllerResolver(LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
return new ControllerResolver($logger);
|
return new ControllerResolver($logger);
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
|
||||||
|
|
||||||
|
class NullableController
|
||||||
|
{
|
||||||
|
public function action(?string $foo, ?\stdClass $bar, ?string $baz = 'value', $mandatory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user