Ver Fonte

Refactoring, replace is_null() wuth null ===

George Giannoulopoulos há 14 anos atrás
pai
commit
81e1d4f11d

+ 1 - 1
src/Symfony/Component/Locale/Resources/data/update-data.php

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

+ 2 - 2
src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php

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

+ 2 - 2
src/Symfony/Component/Locale/Stub/StubNumberFormatter.php

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

+ 1 - 1
tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php

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

+ 1 - 1
tests/Symfony/Tests/Component/HttpKernel/KernelTest.php

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

+ 2 - 5
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

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

+ 4 - 4
tests/Symfony/Tests/Component/Locale/Stub/StubNumberFormatterTest.php

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