diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-04-28 19:29:41 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-04-28 19:29:41 +0200 |
commit | 2d26169b367af60cbc03d417c09918f50aa3b882 (patch) | |
tree | b27542d3ecc6dd02fbb768297b2a097014e35d7f | |
parent | bfd4763b4f831ed9eccbdd4717c98b7d95999d2e (diff) | |
download | ste-2d26169b367af60cbc03d417c09918f50aa3b882.tar.gz ste-2d26169b367af60cbc03d417c09918f50aa3b882.tar.bz2 ste-2d26169b367af60cbc03d417c09918f50aa3b882.zip |
Fix parser stumbling over "0" in names
PHPs type juggling strikes again :(
-rw-r--r-- | src/ste/Parser.php | 2 | ||||
-rw-r--r-- | tests/test_tagname/.gitignore | 3 | ||||
-rw-r--r-- | tests/test_tagname/code.php | 20 | ||||
-rw-r--r-- | tests/test_tagname/test.tpl | 4 | ||||
-rw-r--r-- | tests/test_tagname/want | 4 |
5 files changed, 32 insertions, 1 deletions
diff --git a/src/ste/Parser.php b/src/ste/Parser.php index 5e5ef0a..7226c60 100644 --- a/src/ste/Parser.php +++ b/src/ste/Parser.php @@ -89,7 +89,7 @@ class Parser { private function take_while($cb) { $s = ""; - while($c = $this->next()) { + while(($c = $this->next()) !== "") { if(!call_user_func($cb, $c)) { $this->back(); return $s; diff --git a/tests/test_tagname/.gitignore b/tests/test_tagname/.gitignore new file mode 100644 index 0000000..de2a41b --- /dev/null +++ b/tests/test_tagname/.gitignore @@ -0,0 +1,3 @@ +have +*.ast +*.transc.php diff --git a/tests/test_tagname/code.php b/tests/test_tagname/code.php new file mode 100644 index 0000000..6001358 --- /dev/null +++ b/tests/test_tagname/code.php @@ -0,0 +1,20 @@ +<?php + +use kch42\ste\STECore; + +function test_func(STECore $ste) { + $names = array( + "foo", + "ab_cd", + "foo123baz", + "x0123", + ); + + foreach ($names as $name) { + $ste->register_tag( + $name, + function ($ste, $params, $sub) use ($name) { return $name; } + ); + } + +} diff --git a/tests/test_tagname/test.tpl b/tests/test_tagname/test.tpl new file mode 100644 index 0000000..30ca889 --- /dev/null +++ b/tests/test_tagname/test.tpl @@ -0,0 +1,4 @@ +<ste:foo /> +<ste:ab_cd /> +<ste:foo123baz /> +<ste:x0123 />
\ No newline at end of file diff --git a/tests/test_tagname/want b/tests/test_tagname/want new file mode 100644 index 0000000..3233294 --- /dev/null +++ b/tests/test_tagname/want @@ -0,0 +1,4 @@ +foo +ab_cd +foo123baz +x0123 |