update 1.0.8.0

Commits for version update
This commit is contained in:
Manish Verma
2016-10-17 12:02:27 +05:30
parent dec927987b
commit 76e85db070
9674 changed files with 495757 additions and 58922 deletions

View File

@@ -40,7 +40,7 @@ class Dumper
/**
* Sets the indentation.
*
* @param int $num The amount of spaces to use for indentation of nested nodes.
* @param int $num The amount of spaces to use for indentation of nested nodes
*/
public function setIndentation($num)
{

View File

@@ -46,7 +46,7 @@ class Escaper
*
* @param string $value A PHP value
*
* @return bool True if the value would require double quotes.
* @return bool True if the value would require double quotes
*/
public static function requiresDoubleQuoting($value)
{
@@ -70,7 +70,7 @@ class Escaper
*
* @param string $value A PHP value
*
* @return bool True if the value would require single quotes.
* @return bool True if the value would require single quotes
*/
public static function requiresSingleQuoting($value)
{

View File

@@ -317,7 +317,7 @@ class Inline
}
if ($output && '%' === $output[0]) {
@trigger_error('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
@trigger_error(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.' , $output), E_USER_DEPRECATED);
}
if ($evaluate) {
@@ -397,7 +397,7 @@ class Inline
$value = self::parseScalar($sequence, $flags, array(',', ']'), array('"', "'"), $i, true, $references);
// the value can be an array if a reference has been resolved to an array var
if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) {
if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$pos = 0;

View File

@@ -278,17 +278,6 @@ class Parser
throw $e;
}
if (is_array($value)) {
$first = reset($value);
if (is_string($first) && 0 === strpos($first, '*')) {
$data = array();
foreach ($value as $alias) {
$data[] = $this->refs[substr($alias, 1)];
}
$value = $data;
}
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}

View File

@@ -296,7 +296,6 @@ EOF;
*/
public function testDumpObjectAsMap($object, $expected)
{
$yaml = $this->dumper->dump($object, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
$this->assertEquals($expected, Yaml::parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));

View File

@@ -11,6 +11,7 @@
namespace Symfony\Component\Yaml\Tests;
use Symfony\Bridge\PhpUnit\ErrorAssert;
use Symfony\Component\Yaml\Inline;
use Symfony\Component\Yaml\Yaml;
@@ -254,27 +255,14 @@ class InlineTest extends \PHPUnit_Framework_TestCase
/**
* @group legacy
* @requires function Symfony\Bridge\PhpUnit\ErrorAssert::assertDeprecationsAreTriggered
* throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
*/
public function testParseUnquotedScalarStartingWithPercentCharacter()
{
$deprecations = array();
set_error_handler(function ($type, $msg) use (&$deprecations) {
if (E_USER_DEPRECATED !== $type) {
restore_error_handler();
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
}
$deprecations[] = $msg;
ErrorAssert::assertDeprecationsAreTriggered('Not quoting the scalar "%foo " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () {
Inline::parse('{ foo: %foo }');
});
Inline::parse('{ foo: %foo }');
restore_error_handler();
$this->assertCount(1, $deprecations);
$this->assertContains('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $deprecations[0]);
}
/**
@@ -537,6 +525,22 @@ class InlineTest extends \PHPUnit_Framework_TestCase
);
}
/**
* @dataProvider getTimestampTests
*/
public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second)
{
$expected = new \DateTime($yaml);
$expected->setTimeZone(new \DateTimeZone('UTC'));
$expected->setDate($year, $month, $day);
$expected->setTime($hour, $minute, $second);
$expectedNested = array('nested' => array($expected));
$yamlNested = "{nested: [$yaml]}";
$this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME));
}
/**
* @dataProvider getDateTimeDumpTests
*/

View File

@@ -31,9 +31,9 @@ class Unescaper
/**
* Unescapes a single quoted string.
*
* @param string $value A single quoted string.
* @param string $value A single quoted string
*
* @return string The unescaped string.
* @return string The unescaped string
*/
public function unescapeSingleQuotedString($value)
{
@@ -43,9 +43,9 @@ class Unescaper
/**
* Unescapes a double quoted string.
*
* @param string $value A double quoted string.
* @param string $value A double quoted string
*
* @return string The unescaped string.
* @return string The unescaped string
*/
public function unescapeDoubleQuotedString($value)
{

View File

@@ -79,19 +79,19 @@ class Yaml
}
/**
* Dumps a PHP array to a YAML string.
* Dumps a PHP value to a YAML string.
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML.
*
* @param array $array PHP array
* @param mixed $input The PHP value
* @param int $inline The level where you switch to inline YAML
* @param int $indent The amount of spaces to use for indentation of nested nodes.
* @param int $indent The amount of spaces to use for indentation of nested nodes
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string
*
* @return string A YAML string representing the original PHP array
* @return string A YAML string representing the original PHP value
*/
public static function dump($array, $inline = 2, $indent = 4, $flags = 0)
public static function dump($input, $inline = 2, $indent = 4, $flags = 0)
{
if (is_bool($flags)) {
@trigger_error('Passing a boolean flag to toggle exception handling is deprecated since version 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
@@ -113,6 +113,6 @@ class Yaml
$yaml = new Dumper($indent);
return $yaml->dump($array, $inline, 0, $flags);
return $yaml->dump($input, $inline, 0, $flags);
}
}