Merge branch '2.8' into 3.2

* 2.8:
  fix risky tests
  [Yaml] release memory after parsing
  [HttpFoundation] Fix and test status codes according to IANA's data
  Add `use_strict_mode` in validOptions for session
  [Console] Inherit phpdoc from OutputFormatterInterface
This commit is contained in:
Nicolas Grekas 2017-04-11 20:36:00 +02:00
commit a2bd375f60
9 changed files with 105 additions and 35 deletions

View File

@ -81,9 +81,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Sets the decorated flag.
*
* @param bool $decorated Whether to decorate the messages or not
* {@inheritdoc}
*/
public function setDecorated($decorated)
{
@ -91,9 +89,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Gets the decorated flag.
*
* @return bool true if the output will decorate messages, false otherwise
* {@inheritdoc}
*/
public function isDecorated()
{
@ -101,10 +97,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Sets a new style.
*
* @param string $name The style name
* @param OutputFormatterStyleInterface $style The style instance
* {@inheritdoc}
*/
public function setStyle($name, OutputFormatterStyleInterface $style)
{
@ -112,11 +105,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Checks if output formatter has style with specified name.
*
* @param string $name
*
* @return bool
* {@inheritdoc}
*/
public function hasStyle($name)
{
@ -124,13 +113,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Gets style options from style with specified name.
*
* @param string $name
*
* @return OutputFormatterStyleInterface
*
* @throws InvalidArgumentException When style isn't defined
* {@inheritdoc}
*/
public function getStyle($name)
{
@ -142,11 +125,7 @@ class OutputFormatter implements OutputFormatterInterface
}
/**
* Formats a message according to the given styles.
*
* @param string $message The message to style
*
* @return string The styled message
* {@inheritdoc}
*/
public function format($message)
{

View File

@ -55,6 +55,8 @@ interface OutputFormatterInterface
* @param string $name
*
* @return OutputFormatterStyleInterface
*
* @throws \InvalidArgumentException When style isn't defined
*/
public function getStyle($name);

View File

@ -503,6 +503,10 @@ class AutowirePassTest extends TestCase
$pass = new AutowirePass();
$pass->process($container);
$this->assertTrue($container->hasDefinition('deprecated'));
$this->assertTrue($container->hasDefinition('foo'));
$this->assertTrue($container->hasDefinition('bar'));
}
public function testEmptyStringIsKept()

View File

@ -179,7 +179,7 @@ class Response
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
506 => 'Variant Also Negotiates (Experimental)', // RFC2295
506 => 'Variant Also Negotiates', // RFC2295
507 => 'Insufficient Storage', // RFC4918
508 => 'Loop Detected', // RFC5842
510 => 'Not Extended', // RFC2774

View File

@ -80,6 +80,7 @@ class NativeSessionStorage implements SessionStorageInterface
* name, "PHPSESSID"
* referer_check, ""
* serialize_handler, "php"
* use_strict_mode, "0"
* use_cookies, "1"
* use_only_cookies, "1"
* use_trans_sid, "0"
@ -311,7 +312,7 @@ class NativeSessionStorage implements SessionStorageInterface
'entropy_file', 'entropy_length', 'gc_divisor',
'gc_maxlifetime', 'gc_probability', 'hash_bits_per_character',
'hash_function', 'name', 'referer_check',
'serialize_handler', 'use_cookies',
'serialize_handler', 'use_strict_mode', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min-freq', 'url_rewriter.tags',

View File

@ -907,6 +907,67 @@ class ResponseTest extends ResponseTestCase
{
return new Response();
}
/**
* @see http://github.com/zendframework/zend-diactoros for the canonical source repository
*
* @author Fábio Pacheco
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
*/
public function ianaCodesReasonPhrasesProvider()
{
if (!in_array('https', stream_get_wrappers(), true)) {
$this->markTestSkipped('The "https" wrapper is not available');
}
$ianaHttpStatusCodes = new \DOMDocument();
libxml_set_streams_context(stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 30,
),
)));
$ianaHttpStatusCodes->load('https://www.iana.org/assignments/http-status-codes/http-status-codes.xml');
if (!$ianaHttpStatusCodes->relaxNGValidate('https://www.iana.org/assignments/http-status-codes/http-status-codes.rng')) {
self::fail('Invalid IANA\'s HTTP status code list.');
}
$ianaCodesReasonPhrases = array();
$xpath = new \DomXPath($ianaHttpStatusCodes);
$xpath->registerNamespace('ns', 'http://www.iana.org/assignments');
$records = $xpath->query('//ns:record');
foreach ($records as $record) {
$value = $xpath->query('.//ns:value', $record)->item(0)->nodeValue;
$description = $xpath->query('.//ns:description', $record)->item(0)->nodeValue;
if (in_array($description, array('Unassigned', '(Unused)'), true)) {
continue;
}
if (preg_match('/^([0-9]+)\s*\-\s*([0-9]+)$/', $value, $matches)) {
for ($value = $matches[1]; $value <= $matches[2]; ++$value) {
$ianaCodesReasonPhrases[] = array($value, $description);
}
} else {
$ianaCodesReasonPhrases[] = array($value, $description);
}
}
return $ianaCodesReasonPhrases;
}
/**
* @dataProvider ianaCodesReasonPhrasesProvider
*/
public function testReasonPhraseDefaultsAgainstIana($code, $reasonPhrase)
{
$this->assertEquals($reasonPhrase, Response::$statusTexts[$code]);
}
}
class StringableObject

View File

@ -153,6 +153,8 @@ class LocaleTest extends AbstractLocaleTest
public function testSetDefaultAcceptsEn()
{
$this->call('setDefault', 'en');
$this->assertSame('en', $this->call('getDefault'));
}
protected function call($methodName)

View File

@ -109,6 +109,12 @@ class Parser
mb_internal_encoding($mbEncoding);
}
$this->lines = array();
$this->currentLine = '';
$this->refs = array();
$this->skippedLineNumbers = array();
$this->locallySkippedLineNumbers = array();
if (null !== $e) {
throw $e;
}

View File

@ -277,14 +277,29 @@ class InlineTest extends TestCase
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
*/
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
public function testParseUnquotedScalarStartingWithReservedAtIndicator()
{
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
Inline::parse('{ foo: @foo }');
}
public function getReservedIndicators()
/**
* @group legacy
* @expectedDeprecation Not quoting the scalar "`foo " starting with "`" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithReservedBacktickIndicator()
{
return array(array('@'), array('`'));
Inline::parse('{ foo: `foo }');
}
/**
* @group legacy
* @expectedDeprecation Not quoting the scalar "|foo " starting with "|" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
*/
public function testParseUnquotedScalarStartingWithLiteralStyleIndicator()
{
Inline::parse('{ foo: |foo }');
}
/**
@ -292,9 +307,9 @@ class InlineTest extends TestCase
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
*/
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
public function testParseUnquotedScalarStartingWithFoldedStyleIndicator()
{
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
Inline::parse('{ foo: >foo }');
}
public function getScalarIndicators()