From ff3cb9cb2708f1b6ec8b480055c4f52798529f1e Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Fri, 7 Apr 2017 15:10:19 +0200 Subject: [PATCH 1/5] [Console] Inherit phpdoc from OutputFormatterInterface --- .../Console/Formatter/OutputFormatter.php | 33 ++++--------------- .../Formatter/OutputFormatterInterface.php | 2 ++ 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 22c13d551e..dc192711e6 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -79,9 +79,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Sets the decorated flag. - * - * @param bool $decorated Whether to decorate the messages or not + * {@inheritdoc} */ public function setDecorated($decorated) { @@ -89,9 +87,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Gets the decorated flag. - * - * @return bool true if the output will decorate messages, false otherwise + * {@inheritdoc} */ public function isDecorated() { @@ -99,10 +95,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) { @@ -110,11 +103,7 @@ class OutputFormatter implements OutputFormatterInterface } /** - * Checks if output formatter has style with specified name. - * - * @param string $name - * - * @return bool + * {@inheritdoc} */ public function hasStyle($name) { @@ -122,13 +111,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) { @@ -140,11 +123,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) { diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php index 5a52ba096b..281e240c5f 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php @@ -55,6 +55,8 @@ interface OutputFormatterInterface * @param string $name * * @return OutputFormatterStyleInterface + * + * @throws \InvalidArgumentException When style isn't defined */ public function getStyle($name); From 130ee327d4ea5030073af04c4ae3ea5d7a3aaa2c Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sun, 9 Apr 2017 15:37:32 +0200 Subject: [PATCH 2/5] Add `use_strict_mode` in validOptions for session --- .../HttpFoundation/Session/Storage/NativeSessionStorage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 32979e8b45..4deb58eca2 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -81,6 +81,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" @@ -335,7 +336,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', From 72d25ccca7896c7f3038c34e15286845deceddbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 10 Apr 2017 14:16:01 +0200 Subject: [PATCH 3/5] [HttpFoundation] Fix and test status codes according to IANA's data --- .../Component/HttpFoundation/Response.php | 8 +-- .../HttpFoundation/Tests/ResponseTest.php | 61 +++++++++++++++++++ 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index b19d2122ff..f9512d6706 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -158,10 +158,10 @@ class Response 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', + 413 => 'Payload Too Large', + 414 => 'URI Too Long', 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', + 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', // RFC2324 421 => 'Misdirected Request', // RFC7540 @@ -180,7 +180,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 diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index d73dd3d344..165e1fcf5f 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -882,6 +882,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 From c891413f6c82257777eb3673827eea3ee47f0501 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 11 Apr 2017 09:48:47 +0200 Subject: [PATCH 4/5] [Yaml] release memory after parsing --- src/Symfony/Component/Yaml/Parser.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index e4d7fe2839..90a2f34e02 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -86,6 +86,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; } From 86b685f6174c7f5fe2513977447d31375b0de01c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 11 Apr 2017 11:19:47 +0200 Subject: [PATCH 5/5] fix risky tests --- .../Tests/Helper/LegacyTableHelperTest.php | 8 ++-- .../Tests/Compiler/AutowirePassTest.php | 4 ++ .../Intl/Tests/Locale/LocaleTest.php | 2 + .../Component/Yaml/Tests/InlineTest.php | 37 +++++++++++++------ 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php index 7ea75036ef..7587011151 100644 --- a/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php @@ -34,7 +34,7 @@ class LegacyTableHelperTest extends TestCase } /** - * @dataProvider testRenderProvider + * @dataProvider renderProvider */ public function testRender($headers, $rows, $layout, $expected) { @@ -50,7 +50,7 @@ class LegacyTableHelperTest extends TestCase } /** - * @dataProvider testRenderProvider + * @dataProvider renderProvider */ public function testRenderAddRows($headers, $rows, $layout, $expected) { @@ -66,7 +66,7 @@ class LegacyTableHelperTest extends TestCase } /** - * @dataProvider testRenderProvider + * @dataProvider renderProvider */ public function testRenderAddRowsOneByOne($headers, $rows, $layout, $expected) { @@ -83,7 +83,7 @@ class LegacyTableHelperTest extends TestCase $this->assertEquals($expected, $this->getOutputContent($output)); } - public function testRenderProvider() + public function renderProvider() { $books = array( array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index 60b73c18f2..ad89c5b9b1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -452,6 +452,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() diff --git a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php index 94572e6f2a..5ee414a1c2 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php @@ -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) diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index e17df0616f..7ca692dd10 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -193,27 +193,42 @@ class InlineTest extends TestCase /** * @group legacy - * @dataProvider getReservedIndicators + * @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 testParseUnquotedScalarStartingWithReservedIndicator($indicator) + public function testParseUnquotedScalarStartingWithReservedAtIndicator() { - Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); - } - - public function getReservedIndicators() - { - return array(array('@'), array('`')); + Inline::parse('{ foo: @foo }'); } /** * @group legacy - * @dataProvider getScalarIndicators + * @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 testParseUnquotedScalarStartingWithScalarIndicator($indicator) + public function testParseUnquotedScalarStartingWithReservedBacktickIndicator() { - Inline::parse(sprintf('{ foo: %sfoo }', $indicator)); + 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 }'); + } + + /** + * @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 testParseUnquotedScalarStartingWithFoldedStyleIndicator() + { + Inline::parse('{ foo: >foo }'); } public function getScalarIndicators()