update v1.0.6
This commit is contained in:
@@ -38,7 +38,7 @@ interface EventSubscriberInterface
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2')))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*/
|
||||
|
2
vendor/symfony/event-dispatcher/LICENSE
vendored
2
vendor/symfony/event-dispatcher/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
6
vendor/symfony/filesystem/Filesystem.php
vendored
6
vendor/symfony/filesystem/Filesystem.php
vendored
@@ -446,7 +446,7 @@ class Filesystem
|
||||
return strspn($file, '/\\', 0, 1)
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& substr($file, 1, 1) === ':'
|
||||
&& (strspn($file, '/\\', 2, 1))
|
||||
&& strspn($file, '/\\', 2, 1)
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
;
|
||||
@@ -530,14 +530,14 @@ class Filesystem
|
||||
throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
|
||||
}
|
||||
|
||||
$this->rename($tmpFile, $filename, true);
|
||||
if (null !== $mode) {
|
||||
if (func_num_args() > 2) {
|
||||
@trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
$this->chmod($filename, $mode);
|
||||
$this->chmod($tmpFile, $mode);
|
||||
}
|
||||
$this->rename($tmpFile, $filename, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
vendor/symfony/filesystem/LICENSE
vendored
2
vendor/symfony/filesystem/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
6
vendor/symfony/filesystem/LockHandler.php
vendored
6
vendor/symfony/filesystem/LockHandler.php
vendored
@@ -68,9 +68,8 @@ class LockHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
// Silence both userland and native PHP error handlers
|
||||
$errorLevel = error_reporting(0);
|
||||
set_error_handler('var_dump', 0);
|
||||
// Silence error reporting
|
||||
set_error_handler(function() {});
|
||||
|
||||
if (!$this->handle = fopen($this->file, 'r')) {
|
||||
if ($this->handle = fopen($this->file, 'x')) {
|
||||
@@ -81,7 +80,6 @@ class LockHandler
|
||||
}
|
||||
}
|
||||
restore_error_handler();
|
||||
error_reporting($errorLevel);
|
||||
|
||||
if (!$this->handle) {
|
||||
$error = error_get_last();
|
||||
|
@@ -60,11 +60,11 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
protected $startTime;
|
||||
protected $loadClassCache;
|
||||
|
||||
const VERSION = '2.6.12';
|
||||
const VERSION_ID = '20612';
|
||||
const VERSION = '2.6.13';
|
||||
const VERSION_ID = '20613';
|
||||
const MAJOR_VERSION = '2';
|
||||
const MINOR_VERSION = '6';
|
||||
const RELEASE_VERSION = '12';
|
||||
const RELEASE_VERSION = '13';
|
||||
const EXTRA_VERSION = '';
|
||||
|
||||
/**
|
||||
|
2
vendor/symfony/polyfill-php56/LICENSE
vendored
2
vendor/symfony/polyfill-php56/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014-2015 Fabien Potencier
|
||||
Copyright (c) 2014-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
4
vendor/symfony/polyfill-php56/README.md
vendored
4
vendor/symfony/polyfill-php56/README.md
vendored
@@ -6,10 +6,10 @@ This component provides functions unavailable in releases prior to PHP 5.6:
|
||||
- [`hash_equals`](http://php.net/hash_equals) (part of [hash](http://php.net/hash) extension)
|
||||
- [`ldap_escape`](http://php.net/ldap_escape) (part of [ldap](http://php.net/ldap) extension)
|
||||
|
||||
More information can be found in the
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
|
2
vendor/symfony/polyfill-php56/composer.json
vendored
2
vendor/symfony/polyfill-php56/composer.json
vendored
@@ -26,7 +26,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
vendor/symfony/polyfill-util/LICENSE
vendored
2
vendor/symfony/polyfill-util/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014-2015 Fabien Potencier
|
||||
Copyright (c) 2014-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
6
vendor/symfony/polyfill-util/README.md
vendored
6
vendor/symfony/polyfill-util/README.md
vendored
@@ -1,13 +1,13 @@
|
||||
Symfony Polyfill / Util
|
||||
=======================
|
||||
|
||||
This component provides binary-safe string functions, using the
|
||||
This component provides binary-safe string functions, using the
|
||||
[mbstring](https://php.net/mbstring) extension when available.
|
||||
|
||||
More information can be found in the
|
||||
More information can be found in the
|
||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
This library is released under the [MIT license](LICENSE).
|
||||
|
@@ -44,6 +44,9 @@ class TestListener extends \PHPUnit_Framework_TestSuite implements \PHPUnit_Fram
|
||||
$mainSuite->addTest(self::warning('Unknown naming convention for '.$testClass));
|
||||
continue;
|
||||
}
|
||||
if (!class_exists($m[1].$m[2])) {
|
||||
continue;
|
||||
}
|
||||
$testedClass = new \ReflectionClass($m[1].$m[2]);
|
||||
$bootstrap = new \SplFileObject(dirname($testedClass->getFileName()).'/bootstrap.php');
|
||||
$warnings = array();
|
||||
|
2
vendor/symfony/polyfill-util/composer.json
vendored
2
vendor/symfony/polyfill-util/composer.json
vendored
@@ -24,7 +24,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,201 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Security\Core\Tests\Util;
|
||||
|
||||
use Symfony\Component\Security\Core\Util\SecureRandom;
|
||||
|
||||
class SecureRandomTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* T1: Monobit test.
|
||||
*
|
||||
* @dataProvider getSecureRandoms
|
||||
*/
|
||||
public function testMonobit($secureRandom)
|
||||
{
|
||||
$nbOnBits = substr_count($this->getBitSequence($secureRandom, 20000), '1');
|
||||
$this->assertTrue($nbOnBits > 9654 && $nbOnBits < 10346, 'Monobit test failed, number of turned on bits: '.$nbOnBits);
|
||||
}
|
||||
|
||||
/**
|
||||
* T2: Chi-square test with 15 degrees of freedom (chi-Quadrat-Anpassungstest).
|
||||
*
|
||||
* @dataProvider getSecureRandoms
|
||||
*/
|
||||
public function testPoker($secureRandom)
|
||||
{
|
||||
$b = $this->getBitSequence($secureRandom, 20000);
|
||||
$c = array();
|
||||
for ($i = 0; $i <= 15; ++$i) {
|
||||
$c[$i] = 0;
|
||||
}
|
||||
|
||||
for ($j = 1; $j <= 5000; ++$j) {
|
||||
$k = 4 * $j - 1;
|
||||
++$c[8 * $b[$k - 3] + 4 * $b[$k - 2] + 2 * $b[$k - 1] + $b[$k]];
|
||||
}
|
||||
|
||||
$f = 0;
|
||||
for ($i = 0; $i <= 15; ++$i) {
|
||||
$f += $c[$i] * $c[$i];
|
||||
}
|
||||
|
||||
$Y = 16 / 5000 * $f - 5000;
|
||||
|
||||
$this->assertTrue($Y > 1.03 && $Y < 57.4, 'Poker test failed, Y = '.$Y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run test.
|
||||
*
|
||||
* @dataProvider getSecureRandoms
|
||||
*/
|
||||
public function testRun($secureRandom)
|
||||
{
|
||||
$b = $this->getBitSequence($secureRandom, 20000);
|
||||
|
||||
$runs = array();
|
||||
for ($i = 1; $i <= 6; ++$i) {
|
||||
$runs[$i] = 0;
|
||||
}
|
||||
|
||||
$addRun = function ($run) use (&$runs) {
|
||||
if ($run > 6) {
|
||||
$run = 6;
|
||||
}
|
||||
|
||||
++$runs[$run];
|
||||
};
|
||||
|
||||
$currentRun = 0;
|
||||
$lastBit = null;
|
||||
for ($i = 0; $i < 20000; ++$i) {
|
||||
if ($lastBit === $b[$i]) {
|
||||
++$currentRun;
|
||||
} else {
|
||||
if ($currentRun > 0) {
|
||||
$addRun($currentRun);
|
||||
}
|
||||
|
||||
$lastBit = $b[$i];
|
||||
$currentRun = 0;
|
||||
}
|
||||
}
|
||||
if ($currentRun > 0) {
|
||||
$addRun($currentRun);
|
||||
}
|
||||
|
||||
$this->assertTrue($runs[1] > 2267 && $runs[1] < 2733, 'Runs of length 1 outside of defined interval: '.$runs[1]);
|
||||
$this->assertTrue($runs[2] > 1079 && $runs[2] < 1421, 'Runs of length 2 outside of defined interval: '.$runs[2]);
|
||||
$this->assertTrue($runs[3] > 502 && $runs[3] < 748, 'Runs of length 3 outside of defined interval: '.$runs[3]);
|
||||
$this->assertTrue($runs[4] > 233 && $runs[4] < 402, 'Runs of length 4 outside of defined interval: '.$runs[4]);
|
||||
$this->assertTrue($runs[5] > 90 && $runs[5] < 223, 'Runs of length 5 outside of defined interval: '.$runs[5]);
|
||||
$this->assertTrue($runs[6] > 90 && $runs[6] < 233, 'Runs of length 6 outside of defined interval: '.$runs[6]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Long-run test.
|
||||
*
|
||||
* @dataProvider getSecureRandoms
|
||||
*/
|
||||
public function testLongRun($secureRandom)
|
||||
{
|
||||
$b = $this->getBitSequence($secureRandom, 20000);
|
||||
|
||||
$longestRun = $currentRun = 0;
|
||||
$lastBit = null;
|
||||
for ($i = 0; $i < 20000; ++$i) {
|
||||
if ($lastBit === $b[$i]) {
|
||||
++$currentRun;
|
||||
} else {
|
||||
if ($currentRun > $longestRun) {
|
||||
$longestRun = $currentRun;
|
||||
}
|
||||
$lastBit = $b[$i];
|
||||
$currentRun = 0;
|
||||
}
|
||||
}
|
||||
if ($currentRun > $longestRun) {
|
||||
$longestRun = $currentRun;
|
||||
}
|
||||
|
||||
$this->assertTrue($longestRun < 34, 'Failed longest run test: '.$longestRun);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serial Correlation (Autokorrelationstest).
|
||||
*
|
||||
* @dataProvider getSecureRandoms
|
||||
*/
|
||||
public function testSerialCorrelation($secureRandom)
|
||||
{
|
||||
$shift = mt_rand(1, 5000);
|
||||
$b = $this->getBitSequence($secureRandom, 20000);
|
||||
|
||||
$Z = 0;
|
||||
for ($i = 0; $i < 5000; ++$i) {
|
||||
$Z += $b[$i] === $b[$i + $shift] ? 1 : 0;
|
||||
}
|
||||
|
||||
$this->assertTrue($Z > 2326 && $Z < 2674, 'Failed serial correlation test: '.$Z);
|
||||
}
|
||||
|
||||
public function getSecureRandoms()
|
||||
{
|
||||
$secureRandoms = array();
|
||||
|
||||
// only add if openssl is indeed present
|
||||
$secureRandom = new SecureRandom();
|
||||
if ($this->hasOpenSsl($secureRandom)) {
|
||||
$secureRandoms[] = array($secureRandom);
|
||||
}
|
||||
|
||||
// no-openssl with custom seed provider
|
||||
$secureRandom = new SecureRandom(sys_get_temp_dir().'/_sf2.seed');
|
||||
$this->disableOpenSsl($secureRandom);
|
||||
$secureRandoms[] = array($secureRandom);
|
||||
|
||||
return $secureRandoms;
|
||||
}
|
||||
|
||||
protected function disableOpenSsl($secureRandom)
|
||||
{
|
||||
$ref = new \ReflectionProperty($secureRandom, 'useOpenSsl');
|
||||
$ref->setAccessible(true);
|
||||
$ref->setValue($secureRandom, false);
|
||||
$ref->setAccessible(false);
|
||||
}
|
||||
|
||||
protected function hasOpenSsl($secureRandom)
|
||||
{
|
||||
$ref = new \ReflectionProperty($secureRandom, 'useOpenSsl');
|
||||
$ref->setAccessible(true);
|
||||
|
||||
$ret = $ref->getValue($secureRandom);
|
||||
|
||||
$ref->setAccessible(false);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function getBitSequence($secureRandom, $length)
|
||||
{
|
||||
$bitSequence = '';
|
||||
for ($i = 0; $i < $length; $i += 40) {
|
||||
$value = unpack('H*', $secureRandom->nextBytes(5));
|
||||
$value = str_pad(base_convert($value[1], 16, 2), 40, '0', STR_PAD_LEFT);
|
||||
$bitSequence .= $value;
|
||||
}
|
||||
|
||||
return substr($bitSequence, 0, $length);
|
||||
}
|
||||
}
|
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core\Util;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* A secure random number generator implementation.
|
||||
*
|
||||
@@ -21,94 +19,11 @@ use Psr\Log\LoggerInterface;
|
||||
*/
|
||||
final class SecureRandom implements SecureRandomInterface
|
||||
{
|
||||
private $logger;
|
||||
private $useOpenSsl;
|
||||
private $seed;
|
||||
private $seedUpdated;
|
||||
private $seedLastUpdatedAt;
|
||||
private $seedFile;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Be aware that a guessable seed will severely compromise the PRNG
|
||||
* algorithm that is employed.
|
||||
*
|
||||
* @param string $seedFile
|
||||
* @param LoggerInterface $logger
|
||||
*/
|
||||
public function __construct($seedFile = null, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->seedFile = $seedFile;
|
||||
$this->logger = $logger;
|
||||
|
||||
// determine whether to use OpenSSL
|
||||
if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID < 50304) {
|
||||
$this->useOpenSsl = false;
|
||||
} elseif (!function_exists('openssl_random_pseudo_bytes')) {
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->notice('It is recommended that you enable the "openssl" extension for random number generation.');
|
||||
}
|
||||
$this->useOpenSsl = false;
|
||||
} else {
|
||||
$this->useOpenSsl = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function nextBytes($nbBytes)
|
||||
{
|
||||
// try OpenSSL
|
||||
if ($this->useOpenSsl) {
|
||||
$bytes = openssl_random_pseudo_bytes($nbBytes, $strong);
|
||||
|
||||
if (false !== $bytes && true === $strong) {
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->info('OpenSSL did not produce a secure random number.');
|
||||
}
|
||||
}
|
||||
|
||||
// initialize seed
|
||||
if (null === $this->seed) {
|
||||
if (null === $this->seedFile) {
|
||||
throw new \RuntimeException('You need to specify a file path to store the seed.');
|
||||
}
|
||||
|
||||
if (is_file($this->seedFile)) {
|
||||
list($this->seed, $this->seedLastUpdatedAt) = $this->readSeed();
|
||||
} else {
|
||||
$this->seed = uniqid(mt_rand(), true);
|
||||
$this->updateSeed();
|
||||
}
|
||||
}
|
||||
|
||||
$bytes = '';
|
||||
while (strlen($bytes) < $nbBytes) {
|
||||
static $incr = 1;
|
||||
$bytes .= hash('sha512', $incr++.$this->seed.uniqid(mt_rand(), true).$nbBytes, true);
|
||||
$this->seed = base64_encode(hash('sha512', $this->seed.$bytes.$nbBytes, true));
|
||||
$this->updateSeed();
|
||||
}
|
||||
|
||||
return substr($bytes, 0, $nbBytes);
|
||||
}
|
||||
|
||||
private function readSeed()
|
||||
{
|
||||
return json_decode(file_get_contents($this->seedFile));
|
||||
}
|
||||
|
||||
private function updateSeed()
|
||||
{
|
||||
if (!$this->seedUpdated && $this->seedLastUpdatedAt < time() - mt_rand(1, 10)) {
|
||||
file_put_contents($this->seedFile, json_encode(array($this->seed, microtime(true))));
|
||||
}
|
||||
|
||||
$this->seedUpdated = true;
|
||||
return random_bytes($nbBytes);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": ">=5.3.3",
|
||||
"paragonie/random_compat": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "~2.7",
|
||||
|
4
vendor/symfony/yaml/Escaper.php
vendored
4
vendor/symfony/yaml/Escaper.php
vendored
@@ -33,13 +33,13 @@ class Escaper
|
||||
"\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",);
|
||||
"\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9");
|
||||
private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
|
||||
'\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
|
||||
'\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
|
||||
'\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
|
||||
'\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
|
||||
'\\N', '\\_', '\\L', '\\P',);
|
||||
'\\N', '\\_', '\\L', '\\P');
|
||||
|
||||
/**
|
||||
* Determines if a PHP value would require double quoting in YAML.
|
||||
|
12
vendor/symfony/yaml/Inline.php
vendored
12
vendor/symfony/yaml/Inline.php
vendored
@@ -105,7 +105,7 @@ class Inline
|
||||
return 'null';
|
||||
case is_object($value):
|
||||
if ($objectSupport) {
|
||||
return '!!php/object:'.serialize($value);
|
||||
return '!php/object:'.serialize($value);
|
||||
}
|
||||
|
||||
if ($exceptionOnInvalidType) {
|
||||
@@ -476,6 +476,16 @@ class Inline
|
||||
return (string) substr($scalar, 5);
|
||||
case 0 === strpos($scalar, '! '):
|
||||
return (int) self::parseScalar(substr($scalar, 2));
|
||||
case 0 === strpos($scalar, '!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
return unserialize(substr($scalar, 12));
|
||||
}
|
||||
|
||||
if (self::$exceptionOnInvalidType) {
|
||||
throw new ParseException('Object support when parsing a YAML file has been disabled.');
|
||||
}
|
||||
|
||||
return;
|
||||
case 0 === strpos($scalar, '!!php/object:'):
|
||||
if (self::$objectSupport) {
|
||||
return unserialize(substr($scalar, 13));
|
||||
|
2
vendor/symfony/yaml/LICENSE
vendored
2
vendor/symfony/yaml/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2015 Fabien Potencier
|
||||
Copyright (c) 2004-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
37
vendor/symfony/yaml/Parser.php
vendored
37
vendor/symfony/yaml/Parser.php
vendored
@@ -238,10 +238,6 @@ class Parser
|
||||
if ($isRef) {
|
||||
$this->refs[$isRef] = $data[$key];
|
||||
}
|
||||
|
||||
if ($objectForMap && !is_object($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
} else {
|
||||
// multiple documents are not supported
|
||||
if ('---' === $this->currentLine) {
|
||||
@@ -305,6 +301,10 @@ class Parser
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
|
||||
if ($objectForMap && !is_object($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
|
||||
return empty($data) ? null : $data;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,11 @@ class Parser
|
||||
private function getNextEmbedBlock($indentation = null, $inSequence = false)
|
||||
{
|
||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
$blockScalarIndentations = array();
|
||||
|
||||
if ($this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
return;
|
||||
@@ -378,8 +382,8 @@ class Parser
|
||||
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
if (!$insideBlockScalar) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
$previousLineIndentation = $this->getCurrentLineIndentation();
|
||||
@@ -387,8 +391,17 @@ class Parser
|
||||
while ($this->moveToNextLine()) {
|
||||
$indent = $this->getCurrentLineIndentation();
|
||||
|
||||
if (!$insideBlockScalar && $indent === $previousLineIndentation) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
// terminate all block scalars that are more indented than the current line
|
||||
if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && trim($this->currentLine) !== '') {
|
||||
foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
|
||||
if ($blockScalarIndentation >= $this->getCurrentLineIndentation()) {
|
||||
unset($blockScalarIndentations[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
|
||||
$blockScalarIndentations[] = $this->getCurrentLineIndentation();
|
||||
}
|
||||
|
||||
$previousLineIndentation = $indent;
|
||||
@@ -404,7 +417,7 @@ class Parser
|
||||
}
|
||||
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (!$insideBlockScalar && $this->isCurrentLineComment()) {
|
||||
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -569,7 +582,7 @@ class Parser
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
|
||||
for ($i = 0; $i < count($blockLines); $i++) {
|
||||
for ($i = 0; $i < count($blockLines); ++$i) {
|
||||
if ('' === $blockLines[$i]) {
|
||||
$text .= "\n";
|
||||
$previousLineIndented = false;
|
||||
@@ -664,7 +677,7 @@ class Parser
|
||||
//checking explicitly the first char of the trim is faster than loops or strpos
|
||||
$ltrimmedLine = ltrim($this->currentLine, ' ');
|
||||
|
||||
return $ltrimmedLine[0] === '#';
|
||||
return '' !== $ltrimmedLine && $ltrimmedLine[0] === '#';
|
||||
}
|
||||
|
||||
/**
|
||||
|
14
vendor/symfony/yaml/Tests/DumperTest.php
vendored
14
vendor/symfony/yaml/Tests/DumperTest.php
vendored
@@ -54,7 +54,7 @@ class DumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->dumper->setIndentation(7);
|
||||
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
@@ -103,13 +103,13 @@ EOF;
|
||||
|
||||
public function testInlineLevel()
|
||||
{
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
@@ -119,7 +119,7 @@ foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
@@ -134,7 +134,7 @@ foobar:
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
@@ -153,7 +153,7 @@ foobar:
|
||||
EOF;
|
||||
$this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
|
||||
|
||||
$expected = <<<EOF
|
||||
$expected = <<<'EOF'
|
||||
'': bar
|
||||
foo: '#bar'
|
||||
'foo''bar': { }
|
||||
@@ -180,7 +180,7 @@ EOF;
|
||||
{
|
||||
$dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
|
||||
|
||||
$this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
$this->assertEquals('{ foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
|
@@ -515,7 +515,7 @@ yaml: |
|
||||
php: |
|
||||
array(
|
||||
'canonical' => 12345,
|
||||
'decimal' => 12345,
|
||||
'decimal' => 12345.0,
|
||||
'octal' => 014,
|
||||
'hexadecimal' => 0xC
|
||||
)
|
||||
@@ -1538,7 +1538,7 @@ yaml: |
|
||||
php: |
|
||||
array(
|
||||
'canonical' => 12345,
|
||||
'decimal' => 12345,
|
||||
'decimal' => 12345.0,
|
||||
'octal' => 12,
|
||||
'hexadecimal' => 12
|
||||
)
|
||||
|
@@ -182,8 +182,8 @@ php: |
|
||||
array(
|
||||
'zero' => 0,
|
||||
'simple' => 12,
|
||||
'one-thousand' => 1000,
|
||||
'negative one-thousand' => -1000
|
||||
'one-thousand' => 1000.0,
|
||||
'negative one-thousand' => -1000.0
|
||||
)
|
||||
---
|
||||
test: Integers as Map Keys
|
||||
|
138
vendor/symfony/yaml/Tests/ParserTest.php
vendored
138
vendor/symfony/yaml/Tests/ParserTest.php
vendored
@@ -90,7 +90,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testEndOfTheDocumentMarker()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
$yaml = <<<'EOF'
|
||||
--- %YAML:1.0
|
||||
foo
|
||||
...
|
||||
@@ -426,15 +426,19 @@ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
public function testObjectSupportDisabledButNoExceptions()
|
||||
{
|
||||
$input = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
|
||||
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidDumpedObjectProvider
|
||||
*/
|
||||
public function testObjectSupportDisabledButNoExceptions($input)
|
||||
{
|
||||
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
|
||||
}
|
||||
|
||||
@@ -460,12 +464,39 @@ EOF;
|
||||
$this->assertEquals('cat', $result->fiz);
|
||||
}
|
||||
|
||||
public function testObjectForMapIsAppliedAfterParsing()
|
||||
{
|
||||
$expected = new \stdClass();
|
||||
$expected->foo = 'bar';
|
||||
$expected->baz = 'foobar';
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidDumpedObjectProvider
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testObjectsSupportDisabledWithExceptions()
|
||||
public function testObjectsSupportDisabledWithExceptions($yaml)
|
||||
{
|
||||
$this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false);
|
||||
$this->parser->parse($yaml, true, false);
|
||||
}
|
||||
|
||||
public function invalidDumpedObjectProvider()
|
||||
{
|
||||
$yamlTag = <<<EOF
|
||||
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
$localTag = <<<EOF
|
||||
foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
|
||||
bar: 1
|
||||
EOF;
|
||||
|
||||
return array(
|
||||
'yaml-tag' => array($yamlTag),
|
||||
'local-tag' => array($localTag),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,7 +526,7 @@ EOF;
|
||||
*/
|
||||
public function testUnindentedCollectionException()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
$yaml = <<<'EOF'
|
||||
|
||||
collection:
|
||||
-item1
|
||||
@@ -512,7 +543,7 @@ EOF;
|
||||
*/
|
||||
public function testShortcutKeyUnindentedCollectionException()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
$yaml = <<<'EOF'
|
||||
|
||||
collection:
|
||||
- key: foo
|
||||
@@ -529,7 +560,7 @@ EOF;
|
||||
*/
|
||||
public function testMultipleDocumentsNotSupportedException()
|
||||
{
|
||||
Yaml::parse(<<<EOL
|
||||
Yaml::parse(<<<'EOL'
|
||||
# Ranking of 1998 home runs
|
||||
---
|
||||
- Mark McGwire
|
||||
@@ -549,7 +580,7 @@ EOL
|
||||
*/
|
||||
public function testSequenceInAMapping()
|
||||
{
|
||||
Yaml::parse(<<<EOF
|
||||
Yaml::parse(<<<'EOF'
|
||||
yaml:
|
||||
hash: me
|
||||
- array stuff
|
||||
@@ -562,7 +593,7 @@ EOF
|
||||
*/
|
||||
public function testMappingInASequence()
|
||||
{
|
||||
Yaml::parse(<<<EOF
|
||||
Yaml::parse(<<<'EOF'
|
||||
yaml:
|
||||
- array stuff
|
||||
hash: me
|
||||
@@ -629,7 +660,7 @@ EOD;
|
||||
|
||||
public function testEmptyValue()
|
||||
{
|
||||
$input = <<<EOF
|
||||
$input = <<<'EOF'
|
||||
hash:
|
||||
EOF;
|
||||
|
||||
@@ -647,7 +678,7 @@ EOF;
|
||||
'class' => 'Bar',
|
||||
),
|
||||
),
|
||||
), Yaml::parse(<<<EOF
|
||||
), Yaml::parse(<<<'EOF'
|
||||
# comment 1
|
||||
services:
|
||||
# comment 2
|
||||
@@ -664,7 +695,7 @@ EOF
|
||||
|
||||
public function testStringBlockWithComments()
|
||||
{
|
||||
$this->assertEquals(array('content' => <<<EOT
|
||||
$this->assertEquals(array('content' => <<<'EOT'
|
||||
# comment 1
|
||||
header
|
||||
|
||||
@@ -675,7 +706,7 @@ header
|
||||
|
||||
footer # comment3
|
||||
EOT
|
||||
), Yaml::parse(<<<EOF
|
||||
), Yaml::parse(<<<'EOF'
|
||||
content: |
|
||||
# comment 1
|
||||
header
|
||||
@@ -692,7 +723,7 @@ EOF
|
||||
|
||||
public function testFoldedStringBlockWithComments()
|
||||
{
|
||||
$this->assertEquals(array(array('content' => <<<EOT
|
||||
$this->assertEquals(array(array('content' => <<<'EOT'
|
||||
# comment 1
|
||||
header
|
||||
|
||||
@@ -703,7 +734,7 @@ header
|
||||
|
||||
footer # comment3
|
||||
EOT
|
||||
)), Yaml::parse(<<<EOF
|
||||
)), Yaml::parse(<<<'EOF'
|
||||
-
|
||||
content: |
|
||||
# comment 1
|
||||
@@ -723,7 +754,7 @@ EOF
|
||||
{
|
||||
$this->assertEquals(array(array(
|
||||
'title' => 'some title',
|
||||
'content' => <<<EOT
|
||||
'content' => <<<'EOT'
|
||||
# comment 1
|
||||
header
|
||||
|
||||
@@ -734,7 +765,7 @@ header
|
||||
|
||||
footer # comment3
|
||||
EOT
|
||||
)), Yaml::parse(<<<EOF
|
||||
)), Yaml::parse(<<<'EOF'
|
||||
-
|
||||
title: some title
|
||||
content: |
|
||||
@@ -763,7 +794,7 @@ EOF
|
||||
'map' => array('key' => 'var-value'),
|
||||
'list_in_map' => array('key' => array('var-value')),
|
||||
'map_in_map' => array('foo' => array('bar' => 'var-value')),
|
||||
), Yaml::parse(<<<EOF
|
||||
), Yaml::parse(<<<'EOF'
|
||||
var: &var var-value
|
||||
scalar: *var
|
||||
list: [ *var ]
|
||||
@@ -779,7 +810,7 @@ EOF
|
||||
|
||||
public function testYamlDirective()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
$yaml = <<<'EOF'
|
||||
%YAML 1.2
|
||||
---
|
||||
foo: 1
|
||||
@@ -790,7 +821,7 @@ EOF;
|
||||
|
||||
public function testFloatKeys()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
$yaml = <<<'EOF'
|
||||
foo:
|
||||
1.2: "bar"
|
||||
1.3: "baz"
|
||||
@@ -839,7 +870,9 @@ EOT;
|
||||
|
||||
public function getCommentLikeStringInScalarBlockData()
|
||||
{
|
||||
$yaml1 = <<<EOT
|
||||
$tests = array();
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
pages:
|
||||
-
|
||||
title: some title
|
||||
@@ -854,11 +887,11 @@ pages:
|
||||
|
||||
footer # comment3
|
||||
EOT;
|
||||
$expected1 = array(
|
||||
$expected = array(
|
||||
'pages' => array(
|
||||
array(
|
||||
'title' => 'some title',
|
||||
'content' => <<<EOT
|
||||
'content' => <<<'EOT'
|
||||
# comment 1
|
||||
header
|
||||
|
||||
@@ -873,8 +906,9 @@ EOT
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests[] = array($yaml, $expected);
|
||||
|
||||
$yaml2 = <<<EOT
|
||||
$yaml = <<<'EOT'
|
||||
test: |
|
||||
foo
|
||||
# bar
|
||||
@@ -889,8 +923,8 @@ collection:
|
||||
# bar
|
||||
baz
|
||||
EOT;
|
||||
$expected2 = array(
|
||||
'test' => <<<EOT
|
||||
$expected = array(
|
||||
'test' => <<<'EOT'
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
@@ -899,7 +933,7 @@ EOT
|
||||
,
|
||||
'collection' => array(
|
||||
array(
|
||||
'one' => <<<EOT
|
||||
'one' => <<<'EOT'
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
@@ -907,7 +941,7 @@ EOT
|
||||
,
|
||||
),
|
||||
array(
|
||||
'two' => <<<EOT
|
||||
'two' => <<<'EOT'
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
@@ -916,11 +950,47 @@ EOT
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests[] = array($yaml, $expected);
|
||||
|
||||
return array(
|
||||
array($yaml1, $expected1),
|
||||
array($yaml2, $expected2),
|
||||
$yaml = <<<EOT
|
||||
foo:
|
||||
bar:
|
||||
scalar-block: >
|
||||
line1
|
||||
line2>
|
||||
baz:
|
||||
# comment
|
||||
foobar: ~
|
||||
EOT;
|
||||
$expected = array(
|
||||
'foo' => array(
|
||||
'bar' => array(
|
||||
'scalar-block' => 'line1 line2>',
|
||||
),
|
||||
'baz' => array(
|
||||
'foobar' => null,
|
||||
),
|
||||
),
|
||||
);
|
||||
$tests[] = array($yaml, $expected);
|
||||
|
||||
$yaml = <<<'EOT'
|
||||
a:
|
||||
b: hello
|
||||
# c: |
|
||||
# first row
|
||||
# second row
|
||||
d: hello
|
||||
EOT;
|
||||
$expected = array(
|
||||
'a' => array(
|
||||
'b' => 'hello',
|
||||
'd' => 'hello',
|
||||
),
|
||||
);
|
||||
$tests[] = array($yaml, $expected);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||
|
2
vendor/symfony/yaml/Unescaper.php
vendored
2
vendor/symfony/yaml/Unescaper.php
vendored
@@ -26,7 +26,7 @@ class Unescaper
|
||||
/**
|
||||
* Regex fragment that matches an escaped character in a double quoted string.
|
||||
*/
|
||||
const REGEX_ESCAPED_CHARACTER = "\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)";
|
||||
const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
|
||||
|
||||
/**
|
||||
* Unescapes a single quoted string.
|
||||
|
7
vendor/symfony/yaml/Yaml.php
vendored
7
vendor/symfony/yaml/Yaml.php
vendored
@@ -21,10 +21,7 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
||||
class Yaml
|
||||
{
|
||||
/**
|
||||
* Parses YAML into a PHP array.
|
||||
*
|
||||
* The parse method, when supplied with a YAML stream (string or file),
|
||||
* will do its best to convert YAML in a file into a PHP array.
|
||||
* Parses YAML into a PHP value.
|
||||
*
|
||||
* Usage:
|
||||
* <code>
|
||||
@@ -37,7 +34,7 @@ class Yaml
|
||||
* @param bool $objectSupport True if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap True if maps should return a stdClass instead of array()
|
||||
*
|
||||
* @return array The YAML converted to a PHP array
|
||||
* @return mixed The YAML converted to a PHP value
|
||||
*
|
||||
* @throws ParseException If the YAML is not valid
|
||||
*/
|
||||
|
Reference in New Issue
Block a user