merged branch vicb/resolver_options (PR #5110)
Commits
-------
a47922b
[OptionsResolver] Fix Options::has() when the value is null
Discussion
----------
[OptionsResolver] Fix Options::has() when the value is null
`isset()` would have returned `false` when the value is `null`
This commit is contained in:
commit
cbd03ec4c6
@ -247,7 +247,7 @@ class Options implements \ArrayAccess, \Iterator, \Countable
|
||||
*/
|
||||
public function has($option)
|
||||
{
|
||||
return isset($this->options[$option]);
|
||||
return array_key_exists($option, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,4 +462,11 @@ class OptionsTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($expectedResult, iterator_to_array($this->options, true));
|
||||
}
|
||||
|
||||
public function testHasWithNullValue()
|
||||
{
|
||||
$this->options->set('foo', null);
|
||||
|
||||
$this->assertTrue($this->options->has('foo'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user