Merge branch '3.3' into 3.4
* 3.3: Have weak_vendors ignore deprecations from outside [HttpFoundation] fixed return type of method HeaderBag::get [HttpFoundation] Added "resource" type on Request::create docblock [Process] Skip environment variables with false value in Process Revert "bug #25789 Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)" Formatting fix in upgrade 3.0 document don't split lines on carriage returns when dumping Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)" [DI] compilation perf tweak [Validator] Conflict with egulias/email-validator 2.0 [Validator] add missing parent isset and add test
This commit is contained in:
commit
8d4e3c52c0
@ -75,9 +75,12 @@ class DeprecationErrorHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
$path = realpath($path) ?: $path;
|
||||
$realPath = realpath($path);
|
||||
if (false === $realPath && '-' !== $path && 'Standard input code' !== $path) {
|
||||
return true;
|
||||
}
|
||||
foreach ($vendors as $vendor) {
|
||||
if (0 === strpos($path, $vendor) && false !== strpbrk(substr($path, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
|
||||
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
@trigger_error('I come from… afar! :D', E_USER_DEPRECATED);
|
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$phar = new Phar(__DIR__.DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar');
|
||||
$phar->buildFromDirectory(__DIR__.DIRECTORY_SEPARATOR.'deprecation');
|
@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
|
||||
putenv('ANSICON');
|
||||
putenv('ConEmuANSI');
|
||||
putenv('TERM');
|
||||
|
||||
$vendor = __DIR__;
|
||||
while (!file_exists($vendor.'/vendor')) {
|
||||
$vendor = dirname($vendor);
|
||||
}
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
require_once __DIR__.'/../../bootstrap.php';
|
||||
eval("@trigger_error('who knows where I come from?', E_USER_DEPRECATED);")
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Other deprecation notices (1)
|
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Test DeprecationErrorHandler in weak vendors mode on eval()'d deprecation
|
||||
The phar can be regenerated by running php src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/generate_phar.php
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
|
||||
putenv('ANSICON');
|
||||
putenv('ConEmuANSI');
|
||||
putenv('TERM');
|
||||
|
||||
$vendor = __DIR__;
|
||||
while (!file_exists($vendor.'/vendor')) {
|
||||
$vendor = dirname($vendor);
|
||||
}
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
require_once __DIR__.'/../../bootstrap.php';
|
||||
\Phar::loadPhar(__DIR__.'/deprecation.phar', 'deprecation.phar');
|
||||
include 'phar://deprecation.phar/deprecation.php';
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Other deprecation notices (1)
|
@ -283,9 +283,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function ($v) {
|
||||
if (!isset($v['enabled'])) {
|
||||
$v['enabled'] = !empty($v);
|
||||
}
|
||||
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
|
||||
|
||||
return $v;
|
||||
})
|
||||
|
@ -207,20 +207,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
|
||||
}
|
||||
|
||||
public function testEnableableNodeIsDisabledForEmptyConfigurationWhenNormalized()
|
||||
{
|
||||
$config = array();
|
||||
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node->canBeEnabled();
|
||||
|
||||
$this->assertEquals(
|
||||
array('enabled' => false),
|
||||
$node->getNode()->normalize($config),
|
||||
'An enableable node is disabled by default'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIgnoreExtraKeys()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
@ -296,7 +282,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'),
|
||||
array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'),
|
||||
array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'),
|
||||
array(array('enabled' => false, 'foo' => 'bar'), array(), 'enableable node is disabled by default'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
@ -132,22 +131,4 @@ class TreeBuilderTest extends TestCase
|
||||
$this->assertInternalType('array', $tree->getExample());
|
||||
$this->assertEquals('example', $children['child']->getExample());
|
||||
}
|
||||
|
||||
public function testRootNodeThatCanBeEnabledIsDisabledByDefault()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
$builder->root('test')
|
||||
->canBeEnabled();
|
||||
|
||||
$tree = $builder->buildTree();
|
||||
$children = $tree->getChildren();
|
||||
|
||||
$this->assertFalse($children['enabled']->getDefaultValue());
|
||||
|
||||
$processor = new Processor();
|
||||
$result = $processor->process($tree, array());
|
||||
|
||||
$this->assertEquals(array('enabled' => false), $result);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
|
||||
*/
|
||||
protected function processValue($value, $isRoot = false)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
if (\is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
if ($isRoot) {
|
||||
$this->currentId = $k;
|
||||
|
@ -102,10 +102,10 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
* Returns a header value by name.
|
||||
*
|
||||
* @param string $key The header name
|
||||
* @param mixed $default The default value
|
||||
* @param string|string[] $default The default value
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
*
|
||||
* @return string|array The first header value if $first is true, an array of values otherwise
|
||||
* @return string|string[] The first header value or default value if $first is true, an array of values otherwise
|
||||
*/
|
||||
public function get($key, $default = null, $first = true)
|
||||
{
|
||||
@ -131,7 +131,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
* Sets a header by name.
|
||||
*
|
||||
* @param string $key The key
|
||||
* @param string|array $values The value or an array of values
|
||||
* @param string|string[] $values The value or an array of values
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*/
|
||||
public function set($key, $values, $replace = true)
|
||||
|
@ -335,7 +335,7 @@ class Request
|
||||
* @param array $cookies The request cookies ($_COOKIE)
|
||||
* @param array $files The request files ($_FILES)
|
||||
* @param array $server The server parameters ($_SERVER)
|
||||
* @param string $content The raw body data
|
||||
* @param string|resource $content The raw body data
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
|
@ -331,9 +331,11 @@ class Process implements \IteratorAggregate
|
||||
} else {
|
||||
$envPairs = array();
|
||||
foreach ($env as $k => $v) {
|
||||
if (false !== $v) {
|
||||
$envPairs[] = $k.'='.$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_dir($this->cwd)) {
|
||||
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', E_USER_DEPRECATED);
|
||||
|
@ -214,6 +214,16 @@ abstract class Constraint
|
||||
throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option The option name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($option)
|
||||
{
|
||||
return 'groups' === $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given group if this constraint is in the Default group.
|
||||
*
|
||||
|
@ -26,6 +26,16 @@ class FileTest extends TestCase
|
||||
|
||||
$this->assertSame($bytes, $file->maxSize);
|
||||
$this->assertSame($binaryFormat, $file->binaryFormat);
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
}
|
||||
|
||||
public function testMagicIsset()
|
||||
{
|
||||
$file = new File(array('maxSize' => 1));
|
||||
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
$this->assertTrue($file->__isset('groups'));
|
||||
$this->assertFalse($file->__isset('toto'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,7 +97,7 @@ class Dumper
|
||||
$dumpAsMap = Inline::isHash($input);
|
||||
|
||||
foreach ($input as $key => $value) {
|
||||
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n")) {
|
||||
if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
|
||||
$output .= sprintf("%s%s%s |\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '');
|
||||
|
||||
foreach (preg_split('/\n|\r\n/', $value) as $row) {
|
||||
|
@ -443,7 +443,8 @@ YAML;
|
||||
$data = array(
|
||||
'data' => array(
|
||||
'single_line' => 'foo bar baz',
|
||||
'multi_line' => "foo\nline with trailing spaces:\n \nbar\r\ninteger like line:\n123456789\nempty line:\n\nbaz",
|
||||
'multi_line' => "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz",
|
||||
'multi_line_with_carriage_return' => "foo\nbar\r\nbaz",
|
||||
'nested_inlined_multi_line_string' => array(
|
||||
'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz",
|
||||
),
|
||||
@ -453,6 +454,11 @@ YAML;
|
||||
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
|
||||
{
|
||||
$this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage The indentation must be greater than zero
|
||||
|
@ -10,4 +10,5 @@ data:
|
||||
empty line:
|
||||
|
||||
baz
|
||||
multi_line_with_carriage_return: "foo\nbar\r\nbaz"
|
||||
nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
|
||||
|
Reference in New Issue
Block a user