Merge branch '2.7' into 2.8

* 2.7:
  [HttpFoundation] Fix FileBag issue with associative arrays
  fix the phpdoc that is not really inherited from response
  Minor docblock cleanup
  Remove redundant sprintf arguments.
This commit is contained in:
Nicolas Grekas 2017-10-28 18:44:51 +02:00
commit 865622e630
15 changed files with 46 additions and 36 deletions

View File

@ -37,12 +37,6 @@ use Doctrine\DBAL\Types\Type as DoctrineType;
*/
class DoctrineTokenProvider implements TokenProviderInterface
{
/**
* Doctrine DBAL database connection
* F.ex. service id: doctrine.dbal.default_connection.
*
* @var Connection
*/
private $conn;
public function __construct(Connection $conn)

View File

@ -68,9 +68,9 @@ class CodeExtension extends AbstractExtension
list($class, $method) = explode('::', $method, 2);
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
} elseif ('Closure' === $method) {
$result = sprintf('<abbr title="%s">%s</abbr>', $method, $method);
$result = sprintf('<abbr title="%s">%1$s</abbr>', $method);
} else {
$result = sprintf('<abbr title="%s">%s</abbr>()', $method, $method);
$result = sprintf('<abbr title="%s">%1$s</abbr>()', $method);
}
return $result;

View File

@ -74,11 +74,11 @@ class FormThemeTest extends TestCase
protected function getVariableGetter($name)
{
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
return sprintf('($context["%s"] ?? null)', $name);
}
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
}
return sprintf('$this->getContext($context, "%s")', $name);

View File

@ -272,11 +272,11 @@ class SearchAndRenderBlockNodeTest extends TestCase
protected function getVariableGetter($name)
{
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
return sprintf('($context["%s"] ?? null)', $name);
}
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
}
return sprintf('$this->getContext($context, "%s")', $name);

View File

@ -45,11 +45,11 @@ class TransNodeTest extends TestCase
protected function getVariableGetterWithoutStrictCheck($name)
{
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? null)', $name, $name);
return sprintf('($context["%s"] ?? null)', $name);
}
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
}
return sprintf('$this->getContext($context, "%s", true)', $name);
@ -58,15 +58,15 @@ class TransNodeTest extends TestCase
protected function getVariableGetterWithStrictCheck($name)
{
if (Environment::MAJOR_VERSION >= 2) {
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%s" does not exist.\', 0, $this->getSourceContext()); })())', $name, $name, $name, $name);
return sprintf('(isset($context["%s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new Twig_Error_Runtime(\'Variable "%1$s" does not exist.\', 0, $this->getSourceContext()); })())', $name);
}
if (\PHP_VERSION_ID >= 70000) {
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
return sprintf('($context["%s"] ?? $this->getContext($context, "%1$s"))', $name);
}
if (\PHP_VERSION_ID >= 50400) {
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : $this->getContext($context, "%1$s"))', $name);
}
return sprintf('$this->getContext($context, "%s")', $name);

View File

@ -60,9 +60,9 @@ class CodeHelper extends Helper
list($class, $method) = explode('::', $method, 2);
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
} elseif ('Closure' === $method) {
$result = sprintf('<abbr title="%s">%s</abbr>', $method, $method);
$result = sprintf('<abbr title="%s">%1$s</abbr>', $method);
} else {
$result = sprintf('<abbr title="%s">%s</abbr>()', $method, $method);
$result = sprintf('<abbr title="%s">%1$s</abbr>()', $method);
}
return $result;

View File

@ -160,9 +160,6 @@ class SecurityExtension extends Extension
$container->setParameter('security.acl.dbal.sid_table_name', $config['tables']['security_identity']);
}
/**
* Loads the web configuration.
*/
private function createRoleHierarchy(array $config, ContainerBuilder $container)
{
if (!isset($config['role_hierarchy']) || 0 === count($config['role_hierarchy'])) {

View File

@ -26,9 +26,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
*/
class TwigExtension extends Extension
{
/**
* Responds to the twig configuration parameter.
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

View File

@ -12,8 +12,8 @@
namespace Symfony\Component\BrowserKit\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Response;
class CookieJarTest extends TestCase
@ -94,7 +94,7 @@ class CookieJarTest extends TestCase
{
$timestamp = time() + 3600;
$date = gmdate('D, d M Y H:i:s \G\M\T', $timestamp);
$setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%s', $date, $date));
$setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%1$s', $date));
$cookieJar = new CookieJar();
$cookieJar->updateFromSetCookie($setCookies);

View File

@ -682,7 +682,7 @@ class Crawler extends \SplObjectStorage
public function selectButton($value)
{
$translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')).
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, static::xpathLiteral(' '.$value.' ')).
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)).
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value));

View File

@ -433,7 +433,7 @@ class Form extends Link implements \ArrayAccess
// corresponding elements are either descendants or have a matching HTML5 form attribute
$formId = Crawler::xpathLiteral($this->node->getAttribute('id'));
$fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]', $formId, $formId, $formId, $formId, $formId, $formId, $formId, $formId));
$fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%1$s] | descendant::textarea[@form=%1$s] | descendant::select[@form=%1$s] | //form[@id=%1$s]//input[not(@form)] | //form[@id=%1$s]//button[not(@form)] | //form[@id=%1$s]//textarea[not(@form)] | //form[@id=%1$s]//select[not(@form)]', $formId));
foreach ($fieldNodes as $node) {
$this->addField($node);
}

View File

@ -87,7 +87,10 @@ class FileBag extends ParameterBag
$file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);
}
} else {
$file = array_filter(array_map(array($this, 'convertFileInformation'), $file));
$file = array_map(array($this, 'convertFileInformation'), $file);
if (array_keys($keys) === $keys) {
$file = array_filter($file);
}
}
}

View File

@ -44,7 +44,13 @@ class RedirectResponse extends Response
}
/**
* {@inheritdoc}
* Factory method for chainability.
*
* @param string $url The url to redirect to
* @param int $status The response status code
* @param array $headers An array of response headers
*
* @return static
*/
public static function create($url = '', $status = 302, $headers = array())
{

View File

@ -62,7 +62,7 @@ class FileBagTest extends TestCase
public function testShouldRemoveEmptyUploadedFilesForMultiUpload()
{
$bag = new FileBag(array('file' => array(
$bag = new FileBag(array('files' => array(
'name' => array(''),
'type' => array(''),
'tmp_name' => array(''),
@ -70,7 +70,20 @@ class FileBagTest extends TestCase
'size' => array(0),
)));
$this->assertSame(array(), $bag->get('file'));
$this->assertSame(array(), $bag->get('files'));
}
public function testShouldNotRemoveEmptyUploadedFilesForAssociativeArray()
{
$bag = new FileBag(array('files' => array(
'name' => array('file1' => ''),
'type' => array('file1' => ''),
'tmp_name' => array('file1' => ''),
'error' => array('file1' => UPLOAD_ERR_NO_FILE),
'size' => array('file1' => 0),
)));
$this->assertSame(array('file1' => null), $bag->get('files'));
}
public function testShouldConvertUploadedFilesWithPhpBug()

View File

@ -13,8 +13,8 @@ namespace Symfony\Component\PropertyAccess;
use Symfony\Component\PropertyAccess\Exception\AccessException;
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException;
/**
@ -439,7 +439,7 @@ class PropertyAccessor implements PropertyAccessorInterface
private function readProperty($zval, $property)
{
if (!is_object($zval[self::VALUE])) {
throw new NoSuchPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you intended to write the property path as "[%s]" instead.', $property, $property));
throw new NoSuchPropertyException(sprintf('Cannot read property "%s" from an array. Maybe you intended to write the property path as "[%1$s]" instead.', $property));
}
$result = self::$resultProto;
@ -581,7 +581,7 @@ class PropertyAccessor implements PropertyAccessorInterface
private function writeProperty($zval, $property, $value)
{
if (!is_object($zval[self::VALUE])) {
throw new NoSuchPropertyException(sprintf('Cannot write property "%s" to an array. Maybe you should write the property path as "[%s]" instead?', $property, $property));
throw new NoSuchPropertyException(sprintf('Cannot write property "%s" to an array. Maybe you should write the property path as "[%1$s]" instead?', $property));
}
$object = $zval[self::VALUE];