Skip to content

Commit fa868a8

Browse files
committed
compatibility with nette/latte v3
1 parent ec29311 commit fa868a8

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"nette/tester": "^2.0",
2424
"nette/di": "^2.4 || ~3.0.0",
25-
"latte/latte": "^2.4",
25+
"latte/latte": "^3.0",
2626
"tracy/tracy": "^2.4"
2727
},
2828
"suggest": {

src/Bridges/CacheLatte/CacheMacro.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ final class CacheMacro implements Latte\IMacro
2727

2828
/**
2929
* Initializes before template parsing.
30-
* @return void
3130
*/
32-
public function initialize()
31+
public function initialize(): void
3332
{
3433
$this->used = false;
3534
}
@@ -39,19 +38,16 @@ public function initialize()
3938
* Finishes template parsing.
4039
* @return array(prolog, epilog)
4140
*/
42-
public function finalize()
41+
public function finalize(): ?array
4342
{
44-
if ($this->used) {
45-
return ['Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);'];
46-
}
43+
return $this->used ? ['Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);'] : null;
4744
}
4845

4946

5047
/**
5148
* New node is found.
52-
* @return bool
5349
*/
54-
public function nodeOpened(Latte\MacroNode $node)
50+
public function nodeOpened(Latte\MacroNode $node): ?bool
5551
{
5652
if ($node->modifiers) {
5753
throw new Latte\CompileException('Modifiers are not allowed in ' . $node->getNotation());
@@ -62,14 +58,14 @@ public function nodeOpened(Latte\MacroNode $node)
6258
->write('<?php if (Nette\Bridges\CacheLatte\CacheMacro::createCache($this->global->cacheStorage, %var, $this->global->cacheStack, %node.array?)) { ?>',
6359
Nette\Utils\Random::generate()
6460
);
61+
return null;
6562
}
6663

6764

6865
/**
6966
* Node is closed.
70-
* @return void
7167
*/
72-
public function nodeClosed(Latte\MacroNode $node)
68+
public function nodeClosed(Latte\MacroNode $node): void
7369
{
7470
$node->closingCode = Latte\PhpWriter::using($node)
7571
->write('<?php Nette\Bridges\CacheLatte\CacheMacro::endCache($this->global->cacheStack, %node.array?); } ?>');

0 commit comments

Comments
 (0)