diff --git a/src/Php/AstNodeType.php b/src/Php/AstNodeType.php index 8c651d11..a1aac1b9 100644 --- a/src/Php/AstNodeType.php +++ b/src/Php/AstNodeType.php @@ -102,12 +102,12 @@ trait AstNodeType protected function isScalarBool(NodeAbstract $expr): bool { - return $expr instanceof Expr\ConstFetch and in_array($expr->name->toString(), ['true', 'false']); + return $expr instanceof Expr\ConstFetch and in_array(strtolower($expr->name->toString()), ['true', 'false']); } protected function getBoolValue(Expr\ConstFetch $expr): string { - return $expr->name->toString() === 'true' ? self::VALUE_TRUE : self::VALUE_FALSE; + return strcasecmp($expr->name->toString(), 'true') === 0 ? self::VALUE_TRUE : self::VALUE_FALSE; } protected function isMatchExpr(NodeAbstract $expr): bool @@ -175,6 +175,6 @@ trait AstNodeType protected function isNull(NodeAbstract $expr): bool { - return $expr instanceof Expr\ConstFetch && $expr->name->toString() === 'null'; + return $expr instanceof Expr\ConstFetch && strcasecmp($expr->name->toString(), 'null') === 0; } } diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index aec62adb..11db8417 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1419,6 +1419,9 @@ class CompilerBase extends \PhpAot\Core\Translator case 'Stmt_Class': $this->fatalError($v, 'Cannot declare class in function'); break; + case 'Stmt_Function': + $this->fatalError($v, 'Cannot declare function in function'); + break; default: abort($v); break; @@ -3550,13 +3553,13 @@ class CompilerBase extends \PhpAot\Core\Translator return $this->getConstant($importedName); } } - if ($name === 'null') { + if (strcasecmp($name, 'null') === 0) { return self::VALUE_NULL; } - if ($name === 'true') { + if (strcasecmp($name, 'true') === 0) { return 'true'; } - if ($name === 'false') { + if (strcasecmp($name, 'false') === 0) { return 'false'; } if ($name === 'PHP_EOL') { @@ -4151,10 +4154,10 @@ class CompilerBase extends \PhpAot\Core\Translator if ($this->isInternalConstant($name)) { return $this->getTypeFromZendType(gettype($this->internalConstants[$name])); } - if ($name === 'true') { + if (strcasecmp($name, 'true') === 0) { return self::TYPE_BOOL; } - if ($name === 'false') { + if (strcasecmp($name, 'false') === 0) { return self::TYPE_BOOL; } if ($name === 'NAN' or $name === 'INF') { diff --git a/tests/aot/array/008.phpt b/tests/aot/array/008.phpt new file mode 100644 index 00000000..b3594e05 --- /dev/null +++ b/tests/aot/array/008.phpt @@ -0,0 +1,17 @@ +--TEST-- +Array 007 +--FILE-- + true, false => false, TRUE => TRUE, FALSE => FALSE); +$temp_array = $bool_values; +var_dump(krsort($temp_array) ); +var_dump($temp_array); +?> +--EXPECT-- +bool(true) +array(2) { + [1]=> + bool(true) + [0]=> + bool(false) +} \ No newline at end of file