From 515741a8e05bb5265f179e8c5ae4cb808b280ebd Mon Sep 17 00:00:00 2001 From: stloyd Date: Wed, 24 Nov 2010 21:29:49 +0100 Subject: [PATCH] replace all is_null($value) with null === $value --- lib/Twig/Compiler.php | 2 +- lib/Twig/Extension/Core.php | 10 +++++----- lib/Twig/Node/For.php | 6 +++--- lib/Twig/Parser.php | 6 +++--- lib/Twig/Token.php | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index 4fcbf40..72d791d 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -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'); diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 97db509..4c81fd5 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -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); } diff --git a/lib/Twig/Node/For.php b/lib/Twig/Node/For.php index 592737a..2f7a2df 100644 --- a/lib/Twig/Node/For.php +++ b/lib/Twig/Node/For.php @@ -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() diff --git a/lib/Twig/Parser.php b/lib/Twig/Parser.php index c79a476..cb224d0 100644 --- a/lib/Twig/Parser.php +++ b/lib/Twig/Parser.php @@ -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; diff --git a/lib/Twig/Token.php b/lib/Twig/Token.php index 3b36b66..0b4e0cb 100644 --- a/lib/Twig/Token.php +++ b/lib/Twig/Token.php @@ -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 ); -- 1.7.2.5