diff --git a/Nette/Latte/Macros/CoreMacros.php b/Nette/Latte/Macros/CoreMacros.php index 51ab61f9d5..90af9149d1 100644 --- a/Nette/Latte/Macros/CoreMacros.php +++ b/Nette/Latte/Macros/CoreMacros.php @@ -253,7 +253,7 @@ public function macroCaptureEnd(MacroNode $node, PhpWriter $writer) public function macroEndForeach(MacroNode $node, PhpWriter $writer) { if ($node->modifiers !== '|noiterator' && preg_match('#\W(\$iterator|include|require|get_defined_vars)\W#', $this->getCompiler()->expandTokens($node->content))) { - $node->openingCode = 'its[] = new Nette\Iterators\CachingIterator(' + $node->openingCode = 'its[] = new Nette\Latte\Runtime\CachingIterator(' . preg_replace('#(.*)\s+as\s+#i', '$1) as ', $writer->formatArgs(), 1) . ') { ?>'; $node->closingCode = 'its); $iterator = end($_l->its) ?>'; } else { diff --git a/Nette/Iterators/CachingIterator.php b/Nette/Latte/Runtime/CachingIterator.php similarity index 99% rename from Nette/Iterators/CachingIterator.php rename to Nette/Latte/Runtime/CachingIterator.php index 75e933b485..8687c3bc75 100644 --- a/Nette/Iterators/CachingIterator.php +++ b/Nette/Latte/Runtime/CachingIterator.php @@ -5,7 +5,7 @@ * Copyright (c) 2004 David Grudl (http://davidgrudl.com) */ -namespace Nette\Iterators; +namespace Nette\Latte\Runtime; use Nette; diff --git a/Nette/Loaders/NetteLoader.php b/Nette/Loaders/NetteLoader.php index 7da3ca1e94..b62152da12 100644 --- a/Nette/Loaders/NetteLoader.php +++ b/Nette/Loaders/NetteLoader.php @@ -33,6 +33,7 @@ class NetteLoader 'Nette\Utils\PhpGenerator\Parameter' => 'Nette\PhpGenerator\Parameter', 'Nette\Utils\PhpGenerator\PhpLiteral' => 'Nette\PhpGenerator\PhpLiteral', 'Nette\Utils\PhpGenerator\Property' => 'Nette\PhpGenerator\Property', + 'Nette\Iterators\CachingIterator' => 'Nette\Latte\Runtime\CachingIterator', ); /** @var array */ diff --git a/tests/Nette/Iterators/CachingIterator.basic.phpt b/tests/Nette/Latte/CachingIterator.basic.phpt similarity index 87% rename from tests/Nette/Iterators/CachingIterator.basic.phpt rename to tests/Nette/Latte/CachingIterator.basic.phpt index 7a7e57c66f..451010e8bd 100644 --- a/tests/Nette/Iterators/CachingIterator.basic.phpt +++ b/tests/Nette/Latte/CachingIterator.basic.phpt @@ -1,12 +1,12 @@ Two items in array $arr = array('Nette', 'Framework'); - $iterator = new Iterators\CachingIterator($arr); + $iterator = new CachingIterator($arr); $iterator->rewind(); Assert::true( $iterator->valid() ); Assert::true( $iterator->isFirst() ); @@ -44,7 +44,7 @@ test(function() { // ==> Two items in array test(function() { $arr = array('Nette'); - $iterator = new Iterators\CachingIterator($arr); + $iterator = new CachingIterator($arr); $iterator->rewind(); Assert::true( $iterator->valid() ); Assert::true( $iterator->isFirst() ); @@ -65,7 +65,7 @@ test(function() { test(function() { $arr = array(); - $iterator = new Iterators\CachingIterator($arr); + $iterator = new CachingIterator($arr); $iterator->next(); $iterator->next(); Assert::false( $iterator->isFirst() ); diff --git a/tests/Nette/Iterators/CachingIterator.construct.phpt b/tests/Nette/Latte/CachingIterator.construct.phpt similarity index 67% rename from tests/Nette/Iterators/CachingIterator.construct.phpt rename to tests/Nette/Latte/CachingIterator.construct.phpt index fe767a14f0..4deda28232 100644 --- a/tests/Nette/Iterators/CachingIterator.construct.phpt +++ b/tests/Nette/Latte/CachingIterator.construct.phpt @@ -1,12 +1,12 @@ array $arr = array('Nette', 'Framework'); $tmp = array(); - foreach (new Iterators\CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; + foreach (new CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; Assert::same( array( '0 => Nette', '1 => Framework', @@ -27,7 +27,7 @@ test(function() { // ==> array test(function() { // ==> stdClass $arr = (object) array('Nette', 'Framework'); $tmp = array(); - foreach (new Iterators\CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; + foreach (new CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; Assert::same( array( '0 => Nette', '1 => Framework', @@ -38,7 +38,7 @@ test(function() { // ==> stdClass test(function() { // ==> IteratorAggregate $arr = new ArrayObject(array('Nette', 'Framework')); $tmp = array(); - foreach (new Iterators\CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; + foreach (new CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; Assert::same( array( '0 => Nette', '1 => Framework', @@ -49,7 +49,7 @@ test(function() { // ==> IteratorAggregate test(function() { // ==> Iterator $arr = new ArrayObject(array('Nette', 'Framework')); $tmp = array(); - foreach (new Iterators\CachingIterator($arr->getIterator()) as $k => $v) $tmp[] = "$k => $v"; + foreach (new CachingIterator($arr->getIterator()) as $k => $v) $tmp[] = "$k => $v"; Assert::same( array( '0 => Nette', '1 => Framework', @@ -60,7 +60,7 @@ test(function() { // ==> Iterator test(function() { // ==> SimpleXMLElement $arr = new SimpleXMLElement('NetteFramework'); $tmp = array(); - foreach (new Iterators\CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; + foreach (new CachingIterator($arr) as $k => $v) $tmp[] = "$k => $v"; Assert::same( array( 'item => Nette', 'item => Framework', @@ -71,6 +71,6 @@ test(function() { // ==> SimpleXMLElement test(function() { // ==> object Assert::exception(function() { $arr = dir('.'); - foreach (new Iterators\CachingIterator($arr) as $k => $v); + foreach (new CachingIterator($arr) as $k => $v); }, 'InvalidArgumentException', NULL); }); diff --git a/tests/Nette/Iterators/CachingIterator.width.phpt b/tests/Nette/Latte/CachingIterator.width.phpt similarity index 88% rename from tests/Nette/Iterators/CachingIterator.width.phpt rename to tests/Nette/Latte/CachingIterator.width.phpt index 79ca478800..9b7fdfc0b9 100644 --- a/tests/Nette/Iterators/CachingIterator.width.phpt +++ b/tests/Nette/Latte/CachingIterator.width.phpt @@ -1,12 +1,12 @@ rewind(); $iterator->rewind(); @@ -52,7 +52,7 @@ test(function() { test(function() { - $iterator = new Iterators\CachingIterator(array()); + $iterator = new CachingIterator(array()); Assert::false( $iterator->isFirst(0) ); Assert::true( $iterator->isLast(0) ); Assert::false( $iterator->isFirst(1) ); diff --git a/tests/Nette/Latte/CoreMacros.foreach.phpt b/tests/Nette/Latte/CoreMacros.foreach.phpt index 54fc64fc48..e067ab429a 100644 --- a/tests/Nette/Latte/CoreMacros.foreach.phpt +++ b/tests/Nette/Latte/CoreMacros.foreach.phpt @@ -16,7 +16,7 @@ require __DIR__ . '/../bootstrap.php'; $compiler = new Nette\Latte\Compiler; CoreMacros::install($compiler); -$prefix = 'its[] = new Nette\Iterators\CachingIterator('; +$prefix = 'its[] = new Nette\Latte\Runtime\CachingIterator('; function expandMacro($compiler, $args, $modifiers = NULL) { $node = $compiler->expandMacro('foreach', $args, $modifiers); diff --git a/tests/Nette/Latte/expected/macros.dynamicblock.phtml b/tests/Nette/Latte/expected/macros.dynamicblock.phtml index 72616b91c4..6732a84bdf 100644 --- a/tests/Nette/Latte/expected/macros.dynamicblock.phtml +++ b/tests/Nette/Latte/expected/macros.dynamicblock.phtml @@ -33,7 +33,7 @@ $var = 10 ?> call_user_func(reset($_l->blocks['static']), $_l, get_defined_vars()) ?> -its[] = new Nette\Iterators\CachingIterator(array('dynamic', 'static')) as $name) { +its[] = new Nette\Latte\Runtime\CachingIterator(array('dynamic', 'static')) as $name) { // // block $name diff --git a/tests/Nette/Latte/expected/macros.first-sep-last.phtml b/tests/Nette/Latte/expected/macros.first-sep-last.phtml index 0d4fbd9b2e..a9e33ceb70 100644 --- a/tests/Nette/Latte/expected/macros.first-sep-last.phtml +++ b/tests/Nette/Latte/expected/macros.first-sep-last.phtml @@ -12,28 +12,28 @@ if (%A%} // ?> -its[] = new Nette\Iterators\CachingIterator($people) as $person) { ?> +its[] = new Nette\Latte\Runtime\CachingIterator($people) as $person) { ?> isFirst()) { ?>( isLast()) { ?> , isLast()) { ?>) its); $iterator = end($_l->its) ?> -its[] = new Nette\Iterators\CachingIterator($people) as $person) { ?> +its[] = new Nette\Latte\Runtime\CachingIterator($people) as $person) { ?> isFirst(2)) { ?>( isLast(2)) { ?> , isLast(2)) { ?>) its); $iterator = end($_l->its) ?> -its[] = new Nette\Iterators\CachingIterator($people) as $person) { ?> +its[] = new Nette\Latte\Runtime\CachingIterator($people) as $person) { ?> isFirst(1)) { ?>( isLast(1)) { ?> , isLast(1)) { ?>) its); $iterator = end($_l->its) ?> -its[] = new Nette\Iterators\CachingIterator($people) as $person) { if ($iterator->isFirst(0)) { ?> +its[] = new Nette\Latte\Runtime\CachingIterator($people) as $person) { if ($iterator->isFirst(0)) { ?> ( isLast()) { ?> , diff --git a/tests/Nette/Latte/expected/macros.general.html.phtml b/tests/Nette/Latte/expected/macros.general.html.phtml index ca56ad8e80..29fb1fca0e 100644 --- a/tests/Nette/Latte/expected/macros.general.html.phtml +++ b/tests/Nette/Latte/expected/macros.general.html.phtml @@ -8,7 +8,7 @@ list($_l, $_g) = Nette\Latte\Macros\CoreMacros::initRuntime($template, 'xxx') // if (!function_exists($_l->blocks['menu'][] = '_xxx_menu')) { function _xxx_menu($_l, $_args) { foreach ($_args as $__k => $__v) $$__k = $__v ?>