Merge branch '2.7' into 2.8

* 2.7:
  [HttpFoundation] fixed return type of method HeaderBag::get
  [HttpFoundation] Added "resource" type on Request::create docblock
  Revert "bug #25789  Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)"
  Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)"
  [Validator] add missing parent isset and add test
This commit is contained in:
Nicolas Grekas 2018-01-21 20:03:25 +01:00
commit 75894936ac
9 changed files with 35 additions and 55 deletions

View File

@ -93,7 +93,6 @@
"sensio/framework-extra-bundle": "^3.0.2"
},
"conflict": {
"egulias/email-validator": ">=2.0",
"phpdocumentor/reflection": "<1.0.7",
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0"
},

View File

@ -227,9 +227,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;
})

View File

@ -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');
@ -254,7 +240,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'),
);
}

View File

@ -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);
}
}

View File

@ -101,11 +101,11 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns a header value by name.
*
* @param string $key The header name
* @param mixed $default The default value
* @param bool $first Whether to return the first value or all header values
* @param string $key The header name
* @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)
{
@ -129,9 +129,9 @@ 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 bool $replace Whether to replace the actual value or not (true by default)
* @param string $key The key
* @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)
{

View File

@ -303,13 +303,13 @@ class Request
* The information contained in the URI always take precedence
* over the other information (server and parameters).
*
* @param string $uri The URI
* @param string $method The HTTP method
* @param array $parameters The query (GET) or request (POST) parameters
* @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 $uri The URI
* @param string $method The HTTP method
* @param array $parameters The query (GET) or request (POST) parameters
* @param array $cookies The request cookies ($_COOKIE)
* @param array $files The request files ($_FILES)
* @param array $server The server parameters ($_SERVER)
* @param string|resource $content The raw body data
*
* @return static
*/

View File

@ -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.
*

View File

@ -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'));
}
/**

View File

@ -42,9 +42,6 @@
"symfony/property-access": "For using the 2.4 Validator API",
"symfony/expression-language": "For using the 2.4 Expression validator"
},
"conflict": {
"egulias/email-validator": ">=2.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Validator\\": "" },
"exclude-from-classmap": [