Issue #2548135 by hussainweb, neclimdul: Upgrade to Symfony 2.7.3

8.0.x
Alex Pott 2015-08-18 23:57:39 +01:00
parent d3d9300b79
commit bc7d4ebb77
26 changed files with 1243 additions and 1082 deletions

92
core/composer.lock generated
View File

@ -796,7 +796,7 @@
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/e4046d42e6abc055c16d47bfbae573ae4c8646d1",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/d687700d601f8b5f19b99ffc1c0f6af835a3c7b7",
"reference": "1879fbe853b0c64d109e369c7aeff09849e62d1e",
"shasum": ""
},
@ -2117,7 +2117,7 @@
},
{
"name": "symfony/browser-kit",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
@ -2172,7 +2172,7 @@
},
{
"name": "symfony/class-loader",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
@ -2222,16 +2222,16 @@
},
{
"name": "symfony/console",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "8cf484449130cabfd98dcb4694ca9945802a21ed"
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/8cf484449130cabfd98dcb4694ca9945802a21ed",
"reference": "8cf484449130cabfd98dcb4694ca9945802a21ed",
"url": "https://api.github.com/repos/symfony/Console/zipball/d6cf02fe73634c96677e428f840704bfbcaec29e",
"reference": "d6cf02fe73634c96677e428f840704bfbcaec29e",
"shasum": ""
},
"require": {
@ -2275,11 +2275,11 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-07-28 15:18:12"
},
{
"name": "symfony/css-selector",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/CssSelector.git",
@ -2332,7 +2332,7 @@
},
{
"name": "symfony/debug",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
@ -2392,16 +2392,16 @@
},
{
"name": "symfony/dependency-injection",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/DependencyInjection.git",
"reference": "d56b1b89a0c8b34a6eca6211ec76c43256ec4030"
"reference": "851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/d56b1b89a0c8b34a6eca6211ec76c43256ec4030",
"reference": "d56b1b89a0c8b34a6eca6211ec76c43256ec4030",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6",
"reference": "851e3ffe8a366b1590bdaf3df2c1395f2d27d8a6",
"shasum": ""
},
"require": {
@ -2448,11 +2448,11 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-07-28 14:07:07"
},
{
"name": "symfony/dom-crawler",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
@ -2505,7 +2505,7 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
@ -2563,16 +2563,16 @@
},
{
"name": "symfony/http-foundation",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "88903c0531b90d4ecd90282b18f08c0c77bde0b2"
"reference": "863af6898081b34c65d42100c370b9f3c51b70ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/88903c0531b90d4ecd90282b18f08c0c77bde0b2",
"reference": "88903c0531b90d4ecd90282b18f08c0c77bde0b2",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/863af6898081b34c65d42100c370b9f3c51b70ca",
"reference": "863af6898081b34c65d42100c370b9f3c51b70ca",
"shasum": ""
},
"require": {
@ -2612,27 +2612,27 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2015-07-09 16:07:40"
"time": "2015-07-22 10:11:00"
},
{
"name": "symfony/http-kernel",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "4a8a6f2a847475b3a38da50363a07f69b5cbf37e"
"reference": "405d3e7a59ff7a28ec469441326a0ac79065ea98"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/4a8a6f2a847475b3a38da50363a07f69b5cbf37e",
"reference": "4a8a6f2a847475b3a38da50363a07f69b5cbf37e",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/405d3e7a59ff7a28ec469441326a0ac79065ea98",
"reference": "405d3e7a59ff7a28ec469441326a0ac79065ea98",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"psr/log": "~1.0",
"symfony/debug": "~2.6,>=2.6.2",
"symfony/event-dispatcher": "~2.5.9|~2.6,>=2.6.2",
"symfony/event-dispatcher": "~2.6,>=2.6.7",
"symfony/http-foundation": "~2.5,>=2.5.4"
},
"conflict": {
@ -2692,11 +2692,11 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2015-07-13 19:27:49"
"time": "2015-07-31 13:24:45"
},
{
"name": "symfony/process",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
@ -2799,7 +2799,7 @@
},
{
"name": "symfony/routing",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
@ -2870,16 +2870,16 @@
},
{
"name": "symfony/serializer",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Serializer.git",
"reference": "4ce2211d3a5d3a3605de7cc040af2808882f3c95"
"reference": "143d318457ecc298a846506acc8e80dea30d2548"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/4ce2211d3a5d3a3605de7cc040af2808882f3c95",
"reference": "4ce2211d3a5d3a3605de7cc040af2808882f3c95",
"url": "https://api.github.com/repos/symfony/Serializer/zipball/143d318457ecc298a846506acc8e80dea30d2548",
"reference": "143d318457ecc298a846506acc8e80dea30d2548",
"shasum": ""
},
"require": {
@ -2927,11 +2927,11 @@
],
"description": "Symfony Serializer Component",
"homepage": "https://symfony.com",
"time": "2015-07-08 06:12:51"
"time": "2015-07-22 19:42:44"
},
{
"name": "symfony/translation",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
@ -2992,16 +2992,16 @@
},
{
"name": "symfony/validator",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
"reference": "26a190dbdf7a19fc2251c2d59547a717918b6c77"
"reference": "646df03e635a8a232804274401449ccdf5f03cad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Validator/zipball/26a190dbdf7a19fc2251c2d59547a717918b6c77",
"reference": "26a190dbdf7a19fc2251c2d59547a717918b6c77",
"url": "https://api.github.com/repos/symfony/Validator/zipball/646df03e635a8a232804274401449ccdf5f03cad",
"reference": "646df03e635a8a232804274401449ccdf5f03cad",
"shasum": ""
},
"require": {
@ -3058,20 +3058,20 @@
],
"description": "Symfony Validator Component",
"homepage": "https://symfony.com",
"time": "2015-07-02 06:17:05"
"time": "2015-07-31 06:49:15"
},
{
"name": "symfony/yaml",
"version": "v2.7.2",
"version": "v2.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860"
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/4bfbe0ed3909bfddd75b70c094391ec1f142f860",
"reference": "4bfbe0ed3909bfddd75b70c094391ec1f142f860",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/71340e996171474a53f3d29111d046be4ad8a0ff",
"reference": "71340e996171474a53f3d29111d046be4ad8a0ff",
"shasum": ""
},
"require": {
@ -3107,7 +3107,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2015-07-01 11:25:50"
"time": "2015-07-28 14:07:07"
},
{
"name": "twig/twig",

File diff suppressed because it is too large Load Diff

View File

@ -215,8 +215,8 @@ class ArgvInput extends Input
$option = $this->definition->getOption($name);
// Convert false values (from a previous call to substr()) to null
if (false === $value) {
// Convert empty values to null
if (!isset($value[0])) {
$value = null;
}

View File

@ -46,12 +46,9 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
*/
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
{
$outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
$errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter);
$this->stderr = new StreamOutput(fopen($errorStream, 'w'), $verbosity, $decorated, $this->getFormatter());
$this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
}
/**
@ -129,4 +126,24 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
{
return 'OS400' === php_uname('s');
}
/**
* @return resource
*/
private function openOutputStream()
{
$outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
}
/**
* @return resource
*/
private function openErrorStream()
{
$errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
return fopen($errorStream, 'w');
}
}

View File

@ -162,7 +162,7 @@ class ChoiceQuestion extends Question
throw new \InvalidArgumentException(sprintf($errorMessage, $value));
}
$multiselectChoices[] = $choices[(string) $result];
$multiselectChoices[] = (string) $result;
}
if ($multiselect) {

View File

@ -379,7 +379,7 @@ class SymfonyStyle extends OutputStyle
{
$chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
if (false === $chars) {
if (!isset($chars[0])) {
return $this->newLine(); //empty history, so we should start with a new line.
}
//Prepend new line for each non LF chars (This means no blank line was output before)

View File

@ -36,15 +36,18 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
$questionHelper->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n"));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '2');
$question->setMaxAttempts(1);
// first answer is an empty answer, we're supposed to receive the default value
$this->assertEquals('Spiderman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
$question->setMaxAttempts(1);
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
$question->setErrorMessage('Input "%s" is not a superhero!');
$question->setMaxAttempts(2);
$this->assertEquals('Batman', $questionHelper->ask($this->createInputInterfaceMock(), $output = $this->createOutputInterface(), $question));
rewind($output->getStream());
@ -61,6 +64,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
}
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
$question->setMaxAttempts(1);
$question->setMultiselect(true);
$this->assertEquals(array('Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
@ -68,11 +72,13 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0,1');
$question->setMaxAttempts(1);
$question->setMultiselect(true);
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
$question = new ChoiceQuestion('What is your favorite superhero?', $heroes, ' 0 , 1 ');
$question->setMaxAttempts(1);
$question->setMultiselect(true);
$this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question));
@ -227,6 +233,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
$dialog->setHelperSet($helperSet);
$question = new ChoiceQuestion('Please select the environment to load', $possibleChoices);
$question->setMaxAttempts(1);
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
$this->assertSame($expectedValue, $answer);

View File

@ -49,7 +49,7 @@ class XmlFileLoader extends FileLoader
$this->parseImports($xml, $path);
// parameters
$this->parseParameters($xml, $path);
$this->parseParameters($xml);
// extensions
$this->loadFromExtensions($xml);
@ -70,9 +70,8 @@ class XmlFileLoader extends FileLoader
* Parses parameters.
*
* @param \DOMDocument $xml
* @param string $file
*/
private function parseParameters(\DOMDocument $xml, $file)
private function parseParameters(\DOMDocument $xml)
{
if ($parameters = $this->getChildren($xml->documentElement, 'parameters')) {
$this->container->getParameterBag()->add($this->getArgumentsAsPhp($parameters[0], 'parameter'));

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\DependencyInjection\ParameterBag;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
/**
@ -25,6 +26,8 @@ interface ParameterBagInterface
/**
* Clears all parameters.
*
* @throws LogicException if the ParameterBagInterface can not be cleared
*
* @api
*/
public function clear();
@ -34,6 +37,8 @@ interface ParameterBagInterface
*
* @param array $parameters An array of parameters
*
* @throws LogicException if the parameter can not be added
*
* @api
*/
public function add(array $parameters);
@ -66,6 +71,8 @@ interface ParameterBagInterface
* @param string $name The parameter name
* @param mixed $value The parameter value
*
* @throws LogicException if the parameter can not be set
*
* @api
*/
public function set($name, $value);

View File

@ -57,4 +57,13 @@ class FrozenParameterBagTest extends \PHPUnit_Framework_TestCase
$bag = new FrozenParameterBag(array());
$bag->add(array());
}
/**
* @expectedException \LogicException
*/
public function testRemove()
{
$bag = new FrozenParameterBag(array('foo' => 'bar'));
$bag->remove('foo');
}
}

View File

@ -224,13 +224,13 @@ class Request
/**
* Constructor.
*
* @param array $query The GET parameters
* @param array $request The POST parameters
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string $content The raw body data
* @param array $query The GET parameters
* @param array $request The POST parameters
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string|resource $content The raw body data
*
* @api
*/
@ -244,13 +244,13 @@ class Request
*
* This method also re-initializes all properties.
*
* @param array $query The GET parameters
* @param array $request The POST parameters
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string $content The raw body data
* @param array $query The GET parameters
* @param array $request The POST parameters
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
* @param array $cookies The COOKIE parameters
* @param array $files The FILES parameters
* @param array $server The SERVER parameters
* @param string|resource $content The raw body data
*
* @api
*/
@ -1563,16 +1563,38 @@ class Request
*/
public function getContent($asResource = false)
{
if (PHP_VERSION_ID < 50600 && (false === $this->content || (true === $asResource && null !== $this->content))) {
$currentContentIsResource = is_resource($this->content);
if (PHP_VERSION_ID < 50600 && false === $this->content) {
throw new \LogicException('getContent() can only be called once when using the resource return type and PHP below 5.6.');
}
if (true === $asResource) {
if ($currentContentIsResource) {
rewind($this->content);
return $this->content;
}
// Content passed in parameter (test)
if (is_string($this->content)) {
$resource = fopen('php://temp','r+');
fwrite($resource, $this->content);
rewind($resource);
return $resource;
}
$this->content = false;
return fopen('php://input', 'rb');
}
if ($currentContentIsResource) {
rewind($this->content);
return stream_get_contents($this->content);
}
if (null === $this->content) {
$this->content = file_get_contents('php://input');
}
@ -1902,7 +1924,8 @@ class Request
$requestUri = substr($requestUri, 0, $pos);
}
if (null !== $baseUrl && false === $pathInfo = substr($requestUri, strlen($baseUrl))) {
$pathInfo = substr($requestUri, strlen($baseUrl));
if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {

View File

@ -1242,7 +1242,7 @@ class Response
{
$status = ob_get_status(true);
$level = count($status);
$flags = PHP_VERSION_ID >= 50400 ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
$flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) {
if ($flush) {

View File

@ -969,6 +969,26 @@ class RequestTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(feof($retval));
}
public function testGetContentReturnsResourceWhenContentSetInConstructor()
{
$req = new Request(array(), array(), array(), array(), array(), array(), 'MyContent');
$resource = $req->getContent(true);
$this->assertTrue(is_resource($resource));
$this->assertEquals('MyContent', stream_get_contents($resource));
}
public function testContentAsResource()
{
$resource = fopen('php://memory','r+');
fwrite($resource, 'My other content');
rewind($resource);
$req = new Request(array(), array(), array(), array(), array(), array(), $resource);
$this->assertEquals('My other content', stream_get_contents($req->getContent(true)));
$this->assertEquals('My other content', $req->getContent());
}
/**
* @expectedException \LogicException
* @dataProvider getContentCantBeCalledTwiceWithResourcesProvider
@ -1013,7 +1033,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
return array(
'Resource then fetch' => array(true, false),
'Resource then resource' => array(true, true),
'Fetch then resource' => array(false, true),
);
}

View File

@ -101,7 +101,7 @@ class Client extends BaseClient
$r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader');
$requirePath = str_replace("'", "\\'", $r->getFileName());
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
$symfonyPath = str_replace("'", "\\'", dirname(dirname(dirname(__DIR__))));
$errorReporting = error_reporting();
$code = <<<EOF

View File

@ -140,7 +140,7 @@ class RouterListener implements EventSubscriberInterface
}
if (null !== $this->logger) {
$this->logger->info(sprintf('Matched route "%s".', $parameters['_route']), array(
$this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array(
'route_parameters' => $parameters,
'request_uri' => $request->getUri(),
));

View File

@ -160,7 +160,11 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*/
public function getSurrogate()
{
return $this->getEsi();
if (!$this->surrogate instanceof Esi) {
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
}
return $this->surrogate;
}
/**
@ -176,11 +180,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getSurrogate() method instead.', E_USER_DEPRECATED);
if (!$this->surrogate instanceof Esi) {
throw new \LogicException('This instance of HttpCache was not set up to use ESI as surrogate handler. You must overwrite and use createSurrogate');
}
return $this->surrogate;
return $this->getSurrogate();
}
/**

View File

@ -60,11 +60,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
protected $startTime;
protected $loadClassCache;
const VERSION = '2.7.2';
const VERSION_ID = '20702';
const VERSION = '2.7.3';
const VERSION_ID = '20703';
const MAJOR_VERSION = '2';
const MINOR_VERSION = '7';
const RELEASE_VERSION = '2';
const RELEASE_VERSION = '3';
const EXTRA_VERSION = '';
const END_OF_MAINTENANCE = '05/2018';

View File

@ -128,4 +128,34 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('GET', $context->getMethod());
}
/**
* @dataProvider getLoggingParameterData
*/
public function testLoggingParameter($parameter, $log)
{
$requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
$requestMatcher->expects($this->once())
->method('matchRequest')
->will($this->returnValue($parameter));
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())
->method('info')
->with($this->equalTo($log));
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$request = Request::create('http://localhost/');
$listener = new RouterListener($requestMatcher, new RequestContext(), $logger, $this->requestStack);
$listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
}
public function getLoggingParameterData()
{
return array(
array(array('_route' => 'foo'), 'Matched route "foo".'),
array(array(), 'Matched route "n/a".'),
);
}
}

View File

@ -17,7 +17,7 @@
],
"require": {
"php": ">=5.3.9",
"symfony/event-dispatcher": "~2.5.9|~2.6,>=2.6.2",
"symfony/event-dispatcher": "~2.6,>=2.6.7",
"symfony/http-foundation": "~2.5,>=2.5.4",
"symfony/debug": "~2.6,>=2.6.2",
"psr/log": "~1.0"

View File

@ -272,19 +272,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
*/
protected function prepareForDenormalization($data)
{
if (is_array($data) || is_object($data) && $data instanceof \ArrayAccess) {
$normalizedData = $data;
} elseif (is_object($data)) {
$normalizedData = array();
foreach ($data as $attribute => $value) {
$normalizedData[$attribute] = $value;
}
} else {
$normalizedData = array();
}
return $normalizedData;
return (array) $data;
}
/**
@ -303,7 +291,7 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N
*
* @throws RuntimeException
*/
protected function instantiateObject(array $data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
if (
isset($context['object_to_populate']) &&

View File

@ -102,6 +102,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer
$reflectionClass = new \ReflectionClass($class);
$object = $this->instantiateObject($normalizedData, $class, $context, $reflectionClass, $allowedAttributes);
$classMethods = get_class_methods($object);
foreach ($normalizedData as $attribute => $value) {
if ($this->nameConverter) {
$attribute = $this->nameConverter->denormalize($attribute);
@ -113,7 +114,7 @@ class GetSetMethodNormalizer extends AbstractNormalizer
if ($allowed && !$ignored) {
$setter = 'set'.ucfirst($attribute);
if (method_exists($object, $setter)) {
if (in_array($setter, $classMethods)) {
$object->$setter($value);
}
}

View File

@ -228,6 +228,12 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('bar', $obj->getBar());
}
public function testConstructorWArgWithPrivateMutator()
{
$obj = $this->normalizer->denormalize(array('foo' => 'bar'), __NAMESPACE__.'\ObjectConstructorArgsWithPrivateMutatorDummy', 'any');
$this->assertEquals('bar', $obj->getFoo());
}
public function testGroupsNormalize()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
@ -511,8 +517,8 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
public function testDenormalizeNonExistingAttribute()
{
$this->assertEquals(
new PropertyDummy(),
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\PropertyDummy')
new GetSetDummy(),
$this->normalizer->denormalize(array('non_existing' => true), __NAMESPACE__.'\GetSetDummy')
);
}
@ -520,6 +526,12 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
{
$this->assertFalse($this->normalizer->supportsNormalization(new \ArrayObject()));
}
public function testPrivateSetter()
{
$obj = $this->normalizer->denormalize(array('foo' => 'foobar'), __NAMESPACE__.'\ObjectWithPrivateSetterDummy');
$this->assertEquals('bar', $obj->getFoo());
}
}
class GetSetDummy
@ -726,3 +738,37 @@ class GetCamelizedDummy
return $this->bar_foo;
}
}
class ObjectConstructorArgsWithPrivateMutatorDummy
{
private $foo;
public function __construct($foo)
{
$this->setFoo($foo);
}
public function getFoo()
{
return $this->foo;
}
private function setFoo($foo)
{
$this->foo = $foo;
}
}
class ObjectWithPrivateSetterDummy
{
private $foo = 'bar';
public function getFoo()
{
return $this->foo;
}
private function setFoo($foo)
{
}
}

View File

@ -175,7 +175,7 @@
<target>画像の高さが小さすぎます({{ height }}ピクセル)。{{ min_height }}ピクセル以上にしてください。</target>
</trans-unit>
<trans-unit id="47">
<source>This value should be the user current password.</source>
<source>This value should be the user's current password.</source>
<target>ユーザーの現在のパスワードでなければなりません。</target>
</trans-unit>
<trans-unit id="48">

View File

@ -175,7 +175,7 @@
<target>ความสูงของภาพไม่ได้ขนาด ({{ height }}px) อนุญาตให้สูงอย่างน้อยที่สุด {{ min_height }}px</target>
</trans-unit>
<trans-unit id="47">
<source>This value should be the user current password.</source>
<source>This value should be the user's current password.</source>
<target>ค่านี้ควรจะเป็นรหัสผ่านปัจจุบันของผู้ใช้</target>
</trans-unit>
<trans-unit id="48">

View File

@ -234,7 +234,7 @@ class Parser
}
// 1-liner optionally followed by newline(s)
if ($this->lines[0] === trim($value)) {
if (is_string($value) && $this->lines[0] === trim($value)) {
try {
$value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
} catch (ParseException $e) {
@ -356,7 +356,7 @@ class Parser
return;
}
if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) {
if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) {
// the previous line contained a dash but no item content, this line is a sequence item with the same indentation
// and therefore no nested list or mapping
$this->moveToPreviousLine();

View File

@ -551,6 +551,21 @@ EOF
);
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage missing colon
*/
public function testScalarInSequence()
{
Yaml::parse(<<<EOF
foo:
- bar
"missing colon"
foo: bar
EOF
);
}
/**
* > It is an error for two equal keys to appear in the same mapping node.
* > In such a case the YAML processor may continue, ignoring the second