diff --git a/src/Fenom.php b/src/Fenom.php index fef4523..0b4cbac 100644 --- a/src/Fenom.php +++ b/src/Fenom.php @@ -405,9 +405,6 @@ class Fenom $this->_provider = $provider; } - public function setCachePerms() { - } - /** * Set compile directory * diff --git a/src/Fenom/Compiler.php b/src/Fenom/Compiler.php index 32a07c3..08b2c08 100644 --- a/src/Fenom/Compiler.php +++ b/src/Fenom/Compiler.php @@ -9,11 +9,9 @@ */ namespace Fenom; +use Doctrine\Instantiator\Exception\InvalidArgumentException; use Fenom\Error\InvalidUsageException; use Fenom\Error\UnexpectedTokenException; -use Fenom\Tokenizer; -use Fenom\Template; -use Fenom\Scope; /** * Compilers collection @@ -116,7 +114,7 @@ class Compiler * @param Tag $scope * @return string */ - public static function tagElse(Tokenizer $tokens, Tag $scope) + public static function tagElse($tokens, Tag $scope) { $scope["else"] = true; return '} else {'; @@ -247,8 +245,8 @@ class Compiler "last" => false, "step" => 1, "to" => false, - "max" => false, - "min" => false +// "max" => false, +// "min" => false ); $scope["after"] = $before = $body = array(); $i = array('', ''); @@ -312,7 +310,7 @@ class Compiler * @param Tag $scope * @return string */ - public static function forElse(Tokenizer $tokens, Tag $scope) + public static function forElse($tokens, Tag $scope) { $scope["no-break"] = $scope["no-continue"] = true; $scope["else"] = true; @@ -436,7 +434,7 @@ class Compiler * @param Tag $scope * @return string */ - public static function switchClose(Tokenizer $tokens, Tag $scope) + public static function switchClose($tokens, Tag $scope) { self::_caseResort($scope); $expr = $scope["var"]; @@ -776,7 +774,7 @@ class Compiler * @param Tag $scope * @return string */ - public static function setClose(Tokenizer $tokens, Tag $scope) + public static function setClose($tokens, Tag $scope) { return $scope["name"] . '=' . $scope["value"] . ';'; } @@ -787,7 +785,7 @@ class Compiler * @param Tag $scope * @return string */ - public static function filterOpen(Tokenizer $tokens, Tag $scope) + public static function filterOpen($tokens, Tag $scope) { $scope["filter"] = $scope->tpl->parseModifier($tokens, "ob_get_clean()"); return "ob_start();"; @@ -962,7 +960,7 @@ class Compiler * @param Tokenizer $tokens * @param Tag $scope */ - public static function macroClose(Tokenizer $tokens, Tag $scope) + public static function macroClose($tokens, Tag $scope) { if ($scope["recursive"]) { $scope["macro"]["recursive"] = true; @@ -1017,7 +1015,7 @@ class Compiler * @param Tokenizer $tokens * @param Tag $tag */ - public static function ignoreOpen(Tokenizer $tokens, Tag $tag) + public static function ignoreOpen($tokens, Tag $tag) { $tag->tpl->ignore('ignore'); } diff --git a/src/Fenom/Template.php b/src/Fenom/Template.php index 2b9de83..3d6df8f 100644 --- a/src/Fenom/Template.php +++ b/src/Fenom/Template.php @@ -1467,13 +1467,13 @@ class Template extends Render if ($tokens->is(Tokenizer::MACRO_STRING)) { $key = $tokens->getAndNext(); if ($defaults && !isset($defaults[$key])) { - throw new \Exception("Unknown parameter '$key'"); + throw new InvalidUsageException("Unknown parameter '$key'"); } if ($tokens->is("=")) { $tokens->next(); $params[$key] = $this->parseExpr($tokens); } else { - $params[$key] = 'true'; + throw new InvalidUsageException("Invalid value for parameter '$key'"); } } elseif ($tokens->is(Tokenizer::MACRO_SCALAR, '"', T_VARIABLE, "[", '(')) { $params[] = $this->parseExpr($tokens); diff --git a/tests/cases/Fenom/SandboxTest.php b/tests/cases/Fenom/SandboxTest.php index 30492c7..811efca 100644 --- a/tests/cases/Fenom/SandboxTest.php +++ b/tests/cases/Fenom/SandboxTest.php @@ -8,14 +8,13 @@ class SandboxTest extends TestCase { public function test() { - // $this->assertEquals([1, 2, 4, "as" => 767, "df" => ["qert"]], [1, 2, 4, "as" => 767, "df" => ["qet"]]); // $this->fenom->addBlockCompiler('php', 'Fenom\Compiler::nope', function ($tokens, Tag $tag) { // return 'cutContent(); // }); // $this->tpl('welcome.tpl', '{$a}'); // try { -// var_dump($this->fenom->compileCode('{$.fetch("welcome.tpl", ["a" => 1])}')->getBody()); +// var_dump($this->fenom->compileCode('{for $i=0 to 3} {/for}')->getBody()); // } catch (\Exception $e) { // print_r($e->getMessage() . "\n" . $e->getTraceAsString()); // while ($e->getPrevious()) { diff --git a/tests/cases/Fenom/TagsTest.php b/tests/cases/Fenom/TagsTest.php index 8431770..780b429 100644 --- a/tests/cases/Fenom/TagsTest.php +++ b/tests/cases/Fenom/TagsTest.php @@ -5,15 +5,12 @@ namespace Fenom; class TagsTest extends TestCase { - - public function _testSandbox() + /** + * @group test-for + */ + public function testFor() { - try { - var_dump($this->fenom->compileCode("{var \$a=12313}\nVar: {\$a}")->getBody()); - } catch (\Exception $e) { - echo "$e"; - } - exit; + $this->assertRender('{for $i=0 to=3}{$i},{/for}', "0,1,2,3,"); } /**