mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
replace all is_null($value) with null === $value
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
+3
-3
@@ -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;
|
||||
|
||||
+2
-2
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user