From 41eac92c63e4a2bd7b62dbeedb7cc94a93853911 Mon Sep 17 00:00:00 2001 From: Jacek Karczmarczyk Date: Wed, 17 Apr 2024 17:24:20 +0700 Subject: [PATCH] feat: eqq (===) and nee (!==) operators --- classes/PHPTAL/Php/Transformer.php | 3 ++- doc/de/book.xml | 6 ++++++ doc/en/book.xml | 6 ++++++ doc/ja/book.xml | 6 ++++++ doc/ru/book.xml | 6 ++++++ tests/PhpTransformerTest.php | 3 ++- 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/classes/PHPTAL/Php/Transformer.php b/classes/PHPTAL/Php/Transformer.php index eae4ecd5..c3e74049 100644 --- a/classes/PHPTAL/Php/Transformer.php +++ b/classes/PHPTAL/Php/Transformer.php @@ -406,6 +406,7 @@ private static function isVarNameChar($c) private static $TranslationTable = array( 'not' => '!', 'ne' => '!=', + 'nee' => '!==', 'and' => '&&', 'or' => '||', 'lt' => '<', @@ -413,6 +414,6 @@ private static function isVarNameChar($c) 'ge' => '>=', 'le' => '<=', 'eq' => '==', + 'eqq' => '===', ); } - diff --git a/doc/de/book.xml b/doc/de/book.xml index 12a90401..9de4f973 100644 --- a/doc/de/book.xml +++ b/doc/de/book.xml @@ -1452,9 +1452,15 @@ this page has been readed ${page/countRead} times"/> == : EQ (gleich) + + === : EQQ (exakt gleich) + != : NE (ungleich) + + !== : NEE (exakt ungleich) + && : AND diff --git a/doc/en/book.xml b/doc/en/book.xml index 1fa87e5f..5a0f8154 100644 --- a/doc/en/book.xml +++ b/doc/en/book.xml @@ -1517,9 +1517,15 @@ this page has been readed ${page/countRead} times"/> == : EQ (equal) + === : EQQ (strictly equal) + + != : NE (not equal) + != : NEE (strictly not equal) + + && : AND diff --git a/doc/ja/book.xml b/doc/ja/book.xml index 0bb9db16..38f54cd8 100644 --- a/doc/ja/book.xml +++ b/doc/ja/book.xml @@ -1350,9 +1350,15 @@ this page has been readed ${page/countRead} times"/> == : EQ (等しい) + === : EQQ (厳密に等しい) + + != : NE (等しくない) + !== : NEE (厳密に等しくない) + + && : AND diff --git a/doc/ru/book.xml b/doc/ru/book.xml index 23fb12b5..c5b1c7f2 100644 --- a/doc/ru/book.xml +++ b/doc/ru/book.xml @@ -1117,9 +1117,15 @@ this page has been readed ${page/countRead} times"/> == : EQ (equal) + === : EQQ (strictly equal) + + != : NE (not equal) + !== : NEE (strictly not equal) + + && : AND diff --git a/tests/PhpTransformerTest.php b/tests/PhpTransformerTest.php index 97311a57..bb3642c2 100644 --- a/tests/PhpTransformerTest.php +++ b/tests/PhpTransformerTest.php @@ -123,6 +123,8 @@ function testKeywords() { $this->assertEquals('true != false', PHPTAL_Php_Transformer::transform('true ne false')); $this->assertEquals('$test == null', PHPTAL_Php_Transformer::transform('test eq null')); + $this->assertEquals('true !== false', PHPTAL_Php_Transformer::transform('true nee false')); + $this->assertEquals('$test === null', PHPTAL_Php_Transformer::transform('test eqq null')); } function testTernaryOperator() @@ -188,4 +190,3 @@ function testCatchesInvalidNumber2() $tpl->execute(); } } -