minor #11481 Unify null comparisons (WouterJ)
This PR was merged into the 2.3 branch.
Discussion
----------
Unify null comparisons
| Q | A
| ------------- | ---
| Fixed tickets | -
| License | MIT
Commits
-------
be04c50
Unify null comparisons
This commit is contained in:
commit
8b051f9daa
@ -49,7 +49,7 @@ class ContainerAwareEventManager extends EventManager
|
|||||||
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
|
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
|
||||||
{
|
{
|
||||||
if (isset($this->listeners[$eventName])) {
|
if (isset($this->listeners[$eventName])) {
|
||||||
$eventArgs = $eventArgs === null ? EventArgs::getEmptyInstance() : $eventArgs;
|
$eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs;
|
||||||
|
|
||||||
$initialized = isset($this->initialized[$eventName]);
|
$initialized = isset($this->initialized[$eventName]);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('trusted_proxies')
|
->arrayNode('trusted_proxies')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->ifTrue(function ($v) { return !is_array($v) && !is_null($v); })
|
->ifTrue(function ($v) { return !is_array($v) && null !== $v; })
|
||||||
->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); })
|
||||||
->end()
|
->end()
|
||||||
->prototype('scalar')
|
->prototype('scalar')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<select
|
<select
|
||||||
<?php if ($required && $empty_value === null && $empty_value_in_choices === false && $multiple === false):
|
<?php if ($required && null === $empty_value && $empty_value_in_choices === false && $multiple === false):
|
||||||
$required = false;
|
$required = false;
|
||||||
endif; ?>
|
endif; ?>
|
||||||
<?php echo $view['form']->block($form, 'widget_attributes', array(
|
<?php echo $view['form']->block($form, 'widget_attributes', array(
|
||||||
|
@ -69,14 +69,14 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dir = static::getPhpUnitCliConfigArgument();
|
$dir = static::getPhpUnitCliConfigArgument();
|
||||||
if ($dir === null &&
|
if (null === $dir &&
|
||||||
(is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml') ||
|
(is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml') ||
|
||||||
is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml.dist'))) {
|
is_file(getcwd().DIRECTORY_SEPARATOR.'phpunit.xml.dist'))) {
|
||||||
$dir = getcwd();
|
$dir = getcwd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't continue
|
// Can't continue
|
||||||
if ($dir === null) {
|
if (null === $dir) {
|
||||||
throw new \RuntimeException('Unable to guess the Kernel directory.');
|
throw new \RuntimeException('Unable to guess the Kernel directory.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@
|
|||||||
this.getThreshold = function() {
|
this.getThreshold = function() {
|
||||||
var threshold = Sfjs.getPreference(_storagePrefix + 'threshold');
|
var threshold = Sfjs.getPreference(_storagePrefix + 'threshold');
|
||||||
|
|
||||||
if (threshold === null) {
|
if (null === threshold) {
|
||||||
return _threshold;
|
return _threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,20 +68,20 @@
|
|||||||
menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'),
|
menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'),
|
||||||
displayState, elem, className;
|
displayState, elem, className;
|
||||||
|
|
||||||
if (savedState == null) {
|
if (null === savedState) {
|
||||||
savedState = 'block';
|
savedState = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
displayState = state || (savedState == 'block' ? 'none' : 'block');
|
displayState = state || ('block' === savedState ? 'none' : 'block');
|
||||||
|
|
||||||
if (typeof doSave === 'undefined') {
|
if ('undefined' === typeof doSave) {
|
||||||
doSave = true;
|
doSave = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('searchBar').style.display = displayState;
|
document.getElementById('searchBar').style.display = displayState;
|
||||||
document.getElementById('adminBar').style.display = displayState;
|
document.getElementById('adminBar').style.display = displayState;
|
||||||
|
|
||||||
if (displayState == 'block') {
|
if ('block' === displayState) {
|
||||||
Sfjs.removeClass(menu, 'collapsed-menu');
|
Sfjs.removeClass(menu, 'collapsed-menu');
|
||||||
Sfjs.removeClass(menu.parentNode.parentNode, 'collapsed-menu-parents');
|
Sfjs.removeClass(menu.parentNode.parentNode, 'collapsed-menu-parents');
|
||||||
|
|
||||||
@ -107,7 +107,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
if (document.getElementById('menu-profiler') == null) {
|
if (null === document.getElementById('menu-profiler')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,12 +119,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (elem in menuItems) {
|
for (elem in menuItems) {
|
||||||
if (typeof(menuItems[elem].children) != 'undefined' &&
|
if (typeof(menuItems[elem].children) !== 'undefined' &&
|
||||||
menuItems[elem].children.length > 0) {
|
menuItems[elem].children.length > 0) {
|
||||||
child = menuItems[elem].children[0]
|
child = menuItems[elem].children[0]
|
||||||
|
|
||||||
if (child.getAttribute('title') == '' ||
|
if ('' === child.getAttribute('title') ||
|
||||||
child.getAttribute('title') == null) {
|
null === child.getAttribute('title')) {
|
||||||
value = child.text.replace(/^\s+/g, '').split('\n')[0].replace(/\s+$/g, '');
|
value = child.text.replace(/^\s+/g, '').split('\n')[0].replace(/\s+$/g, '');
|
||||||
child.setAttribute('title', value);
|
child.setAttribute('title', value);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->buildTree()
|
->buildTree()
|
||||||
->finalize($config === null ? array('key'=>'value') : $config)
|
->finalize(null === $config ? array('key'=>'value') : $config)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
|
|
||||||
public function isFile()
|
public function isFile()
|
||||||
{
|
{
|
||||||
if ($this->type === null) {
|
if (null === $this->type) {
|
||||||
return preg_match('/file/', $this->getFilename());
|
return preg_match('/file/', $this->getFilename());
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
|
|
||||||
public function isDir()
|
public function isDir()
|
||||||
{
|
{
|
||||||
if ($this->type === null) {
|
if (null === $this->type) {
|
||||||
return preg_match('/directory/', $this->getFilename());
|
return preg_match('/directory/', $this->getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class MockSplFileInfo extends \SplFileInfo
|
|||||||
|
|
||||||
public function isReadable()
|
public function isReadable()
|
||||||
{
|
{
|
||||||
if ($this->mode === null) {
|
if (null === $this->mode) {
|
||||||
return preg_match('/r\+/', $this->getFilename());
|
return preg_match('/r\+/', $this->getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class ViolationPathTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testGetParent($violationPath, $parentPath)
|
public function testGetParent($violationPath, $parentPath)
|
||||||
{
|
{
|
||||||
$path = new ViolationPath($violationPath);
|
$path = new ViolationPath($violationPath);
|
||||||
$parent = $parentPath === null ? null : new ViolationPath($parentPath);
|
$parent = null === $parentPath ? null : new ViolationPath($parentPath);
|
||||||
|
|
||||||
$this->assertEquals($parent, $path->getParent());
|
$this->assertEquals($parent, $path->getParent());
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ abstract class AbstractRememberMeServices implements RememberMeServicesInterface
|
|||||||
|
|
||||||
$parameter = $request->get($this->options['remember_me_parameter'], null, true);
|
$parameter = $request->get($this->options['remember_me_parameter'], null, true);
|
||||||
|
|
||||||
if ($parameter === null && null !== $this->logger) {
|
if (null === $parameter && null !== $this->logger) {
|
||||||
$this->logger->debug(sprintf('Did not send remember-me cookie (remember-me parameter "%s" was not sent).', $this->options['remember_me_parameter']));
|
$this->logger->debug(sprintf('Did not send remember-me cookie (remember-me parameter "%s" was not sent).', $this->options['remember_me_parameter']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user