replace all is_null($value) with null === $value
authorstloyd <stloyd@gmail.com>
Wed, 24 Nov 2010 20:29:49 +0000 (21:29 +0100)
committerFabien Potencier <fabien.potencier@gmail.com>
Thu, 25 Nov 2010 16:12:39 +0000 (17:12 +0100)
lib/Twig/Compiler.php
lib/Twig/Extension/Core.php
lib/Twig/Node/For.php
lib/Twig/Parser.php
lib/Twig/Token.php

index 4fcbf40..72d791d 100644 (file)
@@ -153,7 +153,7 @@ class Twig_Compiler implements Twig_CompilerInterface
     {
         if (is_int($value) || is_float($value)) {
             $this->raw($value);
-        } else if (is_null($value)) {
+        } else if (null === $value) {
             $this->raw('null');
         } else if (is_bool($value)) {
             $this->raw($value ? 'true' : 'false');
index 97db509..4c81fd5 100644 (file)
@@ -139,7 +139,7 @@ function twig_join_filter($value, $glue = '')
 
 function twig_default_filter($value, $default = '')
 {
-    return is_null($value) ? $default : $value;
+    return null === $value ? $default : $value;
 }
 
 function twig_get_array_keys_filter($array)
@@ -309,7 +309,7 @@ if (function_exists('mb_get_info')) {
 
     function twig_upper_filter(Twig_Environment $env, $string)
     {
-        if (!is_null($charset = $env->getCharset())) {
+        if (null !== ($charset = $env->getCharset())) {
             return mb_strtoupper($string, $charset);
         }
 
@@ -318,7 +318,7 @@ if (function_exists('mb_get_info')) {
 
     function twig_lower_filter(Twig_Environment $env, $string)
     {
-        if (!is_null($charset = $env->getCharset())) {
+        if (null !== ($charset = $env->getCharset())) {
             return mb_strtolower($string, $charset);
         }
 
@@ -327,7 +327,7 @@ if (function_exists('mb_get_info')) {
 
     function twig_title_string_filter(Twig_Environment $env, $string)
     {
-        if (!is_null($charset = $env->getCharset())) {
+        if (null !== ($charset = $env->getCharset())) {
             return mb_convert_case($string, MB_CASE_TITLE, $charset);
         }
 
@@ -336,7 +336,7 @@ if (function_exists('mb_get_info')) {
 
     function twig_capitalize_string_filter(Twig_Environment $env, $string)
     {
-        if (!is_null($charset = $env->getCharset())) {
+        if (null !== ($charset = $env->getCharset())) {
             return mb_strtoupper(mb_substr($string, 0, 1, $charset)).
                          mb_strtolower(mb_substr($string, 1, mb_strlen($string), $charset), $charset);
         }
index 592737a..2f7a2df 100644 (file)
@@ -36,7 +36,7 @@ class Twig_Node_For extends Twig_Node
             ->write('$context[\'_parent\'] = (array) $context;'."\n")
         ;
 
-        if (!is_null($this->getNode('else'))) {
+        if (null !== $this->getNode('else')) {
             $compiler->write("\$context['_iterated'] = false;\n");
         }
 
@@ -77,7 +77,7 @@ class Twig_Node_For extends Twig_Node
             ->indent()
         ;
 
-        if (!is_null($this->getNode('else'))) {
+        if (null !== $this->getNode('else')) {
             $compiler->write("\$context['_iterated'] = true;\n");
         }
 
@@ -103,7 +103,7 @@ class Twig_Node_For extends Twig_Node
             ->write("}\n")
         ;
 
-        if (!is_null($this->getNode('else'))) {
+        if (null !== $this->getNode('else')) {
             $compiler
                 ->write("if (!\$context['_iterated']) {\n")
                 ->indent()
index c79a476..cb224d0 100644 (file)
@@ -62,7 +62,7 @@ class Twig_Parser implements Twig_ParserInterface
         try {
             $body = $this->subparse(null);
         } catch (Twig_Error_Syntax $e) {
-            if (is_null($e->getFilename())) {
+            if (null === $e->getFilename()) {
                 $e->setFilename($this->stream->getFilename());
             }
 
@@ -106,7 +106,7 @@ class Twig_Parser implements Twig_ParserInterface
                         throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine());
                     }
 
-                    if (!is_null($test) && call_user_func($test, $token)) {
+                    if (null !== $test && call_user_func($test, $token)) {
                         if ($dropNeedle) {
                             $this->stream->next();
                         }
@@ -122,7 +122,7 @@ class Twig_Parser implements Twig_ParserInterface
                     $this->stream->next();
 
                     $node = $subparser->parse($token);
-                    if (!is_null($node)) {
+                    if (null !== $node) {
                         $rv[] = $node;
                     }
                     break;
index 3b36b66..0b4e0cb 100644 (file)
@@ -47,13 +47,13 @@ class Twig_Token
      */
     public function test($type, $values = null)
     {
-        if (is_null($values) && !is_int($type)) {
+        if (null === $values && !is_int($type)) {
             $values = $type;
             $type = self::NAME_TYPE;
         }
 
         return ($this->type === $type) && (
-            is_null($values) ||
+            null === $values ||
             (is_array($values) && in_array($this->value, $values)) ||
             $this->value == $values
         );