Merge branch '2.8' into 3.3
* 2.8: [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:
commit
e7b555e2c9
@ -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)
|
||||
|
@ -70,9 +70,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;
|
||||
|
@ -74,9 +74,9 @@ 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);
|
||||
}
|
||||
|
||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
|
||||
}
|
||||
}
|
||||
|
@ -272,9 +272,9 @@ 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);
|
||||
}
|
||||
|
||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
|
||||
}
|
||||
}
|
||||
|
@ -45,22 +45,22 @@ 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);
|
||||
}
|
||||
|
||||
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
|
||||
return sprintf('(isset($context["%s"]) ? $context["%1$s"] : null)', $name);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,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;
|
||||
|
@ -180,9 +180,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'])) {
|
||||
|
@ -30,9 +30,6 @@ use Twig\Loader\LoaderInterface;
|
||||
*/
|
||||
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'));
|
||||
|
@ -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);
|
||||
|
@ -743,7 +743,7 @@ class Crawler implements \Countable, \IteratorAggregate
|
||||
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));
|
||||
|
||||
|
@ -443,7 +443,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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,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())
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -20,8 +20,8 @@ use Symfony\Component\Cache\Adapter\NullAdapter;
|
||||
use Symfony\Component\Inflector\Inflector;
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -462,7 +462,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;
|
||||
@ -613,7 +613,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];
|
||||
|
Reference in New Issue
Block a user