Skip to content

Commit 3883295

Browse files
authored
Merge pull request #12 from JBlond/twig-trans-11
Twig trans 11
2 parents 2209ec3 + 0f9973d commit 3883295

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ echo $tpl->render(['key1' => 'value1', 'key2' => 'value2']);
8383
## Requirements
8484

8585
* PHP 7.2 or greater
86-
* PHP Multibyte String ' gettext'
86+
* PHP Multibyte String
87+
* 'gettext'
8788
* Twig >= 3.0
8889

8990
### Optional Requirements

Diff for: src/jblond/TwigTrans/TransNode.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace jblond\TwigTrans;
44

5+
use Twig\Attribute\YieldReady;
56
use Twig\Compiler;
67
use Twig\Node\Expression\AbstractExpression;
78
use Twig\Node\Expression\ConstantExpression;
@@ -15,6 +16,7 @@
1516
* Class TransNode
1617
* @package jblond\TwigTrans
1718
*/
19+
#[YieldReady]
1820
class TransNode extends Node
1921
{
2022
/**
@@ -24,15 +26,13 @@ class TransNode extends Node
2426
* @param AbstractExpression|null $count
2527
* @param Node|null $notes
2628
* @param int $lineNo
27-
* @param string|null $tag
2829
*/
2930
public function __construct(
3031
Node $body,
31-
Node $plural = null,
32-
AbstractExpression $count = null,
33-
Node $notes = null,
34-
int $lineNo = 0,
35-
?string $tag = null
32+
?Node $plural = null,
33+
?AbstractExpression $count = null,
34+
?Node $notes = null,
35+
int $lineNo = 0
3636
) {
3737
$nodes = ['body' => $body];
3838
if (null !== $count) {
@@ -45,7 +45,7 @@ public function __construct(
4545
$nodes['notes'] = $notes;
4646
}
4747

48-
parent::__construct($nodes, [], $lineNo, $tag);
48+
parent::__construct($nodes, [], $lineNo);
4949
}
5050

5151
/**

Diff for: tests/TwigTrans/Node/TransTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getTests(): array
5252

5353
$body = new NameExpression('foo', 0);
5454
$node = new TransNode($body, null, null, null, 0);
55-
$tests[] = [$node, sprintf('echo gettext(%s);', $this->getVariableGetter('foo'))];
55+
$tests[] = [$node, sprintf('echo gettext(%s);', NodeTestCase::createVariableGetter('foo'))];
5656

5757
$body = new ConstantExpression('Hello', 0);
5858
$node = new TransNode($body, null, null, null, 0);
@@ -74,7 +74,7 @@ public function getTests(): array
7474
$node,
7575
sprintf(
7676
'echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));',
77-
$this->getVariableGetter('foo')
77+
NodeTestCase::createVariableGetter('foo')
7878
)
7979
];
8080

@@ -97,8 +97,8 @@ public function getTests(): array
9797
sprintf(
9898
'echo strtr(ngettext("Hey %%name%%, I have one apple", "Hey %%name%%, I have %%count%% apples", ' .
9999
'abs(12)), array("%%name%%" => %s, "%%name%%" => %s, "%%count%%" => abs(12), ));',
100-
$this->getVariableGetter('name'),
101-
$this->getVariableGetter('name')
100+
NodeTestCase::createVariableGetter('name'),
101+
NodeTestCase::createVariableGetter('name')
102102
)
103103
];
104104

@@ -122,7 +122,7 @@ public function getTests(): array
122122
$node,
123123
sprintf(
124124
'echo strtr(gettext("J\'ai %%foo%% pommes"), array("%%foo%%" => %s, ));',
125-
$this->getVariableGetter('foo')
125+
NodeTestCase::createVariableGetter('foo')
126126
)
127127
];
128128

0 commit comments

Comments
 (0)