Refactoring, replace is_null() wuth null ===

This commit is contained in:
George Giannoulopoulos 2011-04-07 10:45:39 +03:00 committed by Fabien Potencier
parent 6c8e4a567c
commit 81e1d4f11d
7 changed files with 13 additions and 16 deletions

View File

@ -109,7 +109,7 @@ function get_data($index, $dataDir, $locale = 'en', $constraint = null)
$bundle = load_resource_bundle($locale, __DIR__.DIRECTORY_SEPARATOR.$dataDir);
foreach ($bundle->get($index) as $code => $name) {
if (!is_null($constraint)) {
if (null !== $constraint) {
if ($constraint($code)) {
$data[$code] = $name;
}

View File

@ -307,7 +307,7 @@ class StubIntlDateFormatter
public function parse($value, &$position = null)
{
// We don't calculate the position when parsing the value
if (!is_null($position)) {
if (null !== $position) {
throw new MethodArgumentNotImplementedException(__METHOD__, 'position');
}
@ -375,7 +375,7 @@ class StubIntlDateFormatter
*/
public function setTimeZoneId($timeZoneId)
{
if (is_null($timeZoneId)) {
if (null === $timeZoneId) {
$timeZoneId = date_default_timezone_get();
$this->unitializedTimeZoneId = true;
}

View File

@ -227,7 +227,7 @@ class StubNumberFormatter
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'style', $style, $message);
}
if (!is_null($pattern)) {
if (null !== $pattern) {
throw new MethodArgumentNotImplementedException(__METHOD__, 'pattern');
}
@ -446,7 +446,7 @@ class StubNumberFormatter
}
// We don't calculate the position when parsing the value
if (!is_null($position)) {
if (null !== $position) {
throw new MethodArgumentNotImplementedException(__METHOD__, 'position');
}

View File

@ -131,7 +131,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
*/
public function testGetMimeTypeFromFormat($format, $mimeTypes)
{
if (!is_null($format)) {
if (null !== $format) {
$request = new Request();
$this->assertEquals($mimeTypes[0], $request->getMimeType($format));
}

View File

@ -668,7 +668,7 @@ EOF;
$bundle
->expects($this->any())
->method('getName')
->will($this->returnValue(is_null($bundleName) ? get_class($bundle) : $bundleName))
->will($this->returnValue(null === $bundleName ? get_class($bundle) : $bundleName))
;
$bundle

View File

@ -833,12 +833,9 @@ class StubIntlDateFormatterTest extends LocaleTestCase
protected function createDateTime($timestamp = null, $timeZone = null)
{
$timestamp = is_null($timestamp) ? time() : $timestamp;
$timeZone = is_null($timeZone) ? date_default_timezone_get() : $timeZone;
$dateTime = new \DateTime();
$dateTime->setTimestamp($timestamp);
$dateTime->setTimeZone(new \DateTimeZone($timeZone));
$dateTime->setTimestamp(null === $timestamp ? time() : $timestamp);
$dateTime->setTimeZone(new \DateTimeZone(null === $timeZone ? date_default_timezone_get() : $timeZone));
return $dateTime;
}

View File

@ -384,7 +384,7 @@ class StubNumberFormatterTest extends LocaleTestCase
{
$formatter = $this->getStubFormatterWithDecimalStyle();
if (!is_null($fractionDigits)) {
if (null !== $fractionDigits) {
$attributeRet = $formatter->setAttribute(StubNumberFormatter::FRACTION_DIGITS, $fractionDigits);
}
@ -405,7 +405,7 @@ class StubNumberFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->getIntlFormatterWithDecimalStyle();
if (!is_null($fractionDigits)) {
if (null !== $fractionDigits) {
$attributeRet = $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $fractionDigits);
}
@ -437,7 +437,7 @@ class StubNumberFormatterTest extends LocaleTestCase
{
$formatter = $this->getStubFormatterWithDecimalStyle();
if (!is_null($groupingUsed)) {
if (null !== $groupingUsed) {
$attributeRet = $formatter->setAttribute(StubNumberFormatter::GROUPING_USED, $groupingUsed);
}
@ -458,7 +458,7 @@ class StubNumberFormatterTest extends LocaleTestCase
$this->skipIfIntlExtensionIsNotLoaded();
$formatter = $this->getIntlFormatterWithDecimalStyle();
if (!is_null($groupingUsed)) {
if (null !== $groupingUsed) {
$attributeRet = $formatter->setAttribute(\NumberFormatter::GROUPING_USED, $groupingUsed);
}