Skip to content

Commit fb6cd69

Browse files
committed
OXDEV-10175 Fix failing tests and deprecations
1 parent f2c3fcc commit fb6cd69

12 files changed

Lines changed: 28 additions & 20 deletions

CHANGELOG-2.x.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
### Fixed
1515
- Rendering template extensions for module templates
1616

17+
### Deprecated
18+
- Node `$tag` constructor parameter
19+
1720
### Removed
1821
- PHP v8.2 support
1922
- PHPUnit v11 support

src/Node/CaptureNode.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ class CaptureNode extends Node
3030
*/
3131
private $variableName;
3232

33+
/**
34+
* @deprecated $tag will be removed in next major version, the tag is now automatically set by the Parser.
35+
*/
3336
public function __construct(string $attributeName, string $variableName, Node $body, int $line, ?string $tag = null)
3437
{
3538
parent::__construct(
3639
['body' => $body],
3740
['attributeName' => $attributeName, 'variableName' => $variableName],
38-
$line,
39-
$tag
41+
$line
4042
);
4143
}
4244

src/Node/HasRightsNode.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414

1515
class HasRightsNode extends Node
1616
{
17-
public function __construct(Node $body, Node $parameters, int $lineno, $tag = 'hasrights')
17+
/**
18+
* @deprecated $tag will be removed in next major version, the tag is now automatically set by the Parser.
19+
*/
20+
public function __construct(Node $body, Node $parameters, int $lineno, ?string $tag = null)
1821
{
19-
parent::__construct(['body' => $body, 'parameters' => $parameters], [], $lineno, $tag);
22+
parent::__construct(['body' => $body, 'parameters' => $parameters], [], $lineno);
2023
}
2124

2225
/**

src/Node/IfContentNode.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515

1616
class IfContentNode extends Node
1717
{
18-
public function __construct(Node $body, array $reference, Node $variable, int $lineno, string $tag = 'ifcontent')
18+
/**
19+
* @deprecated $tag will be removed in next major version, the tag is now automatically set by the Parser.
20+
*/
21+
public function __construct(Node $body, array $reference, Node $variable, int $lineno, ?string $tag = null)
1922
{
2023
$nodes = [
2124
'body' => $body,
2225
'variable' => $variable
2326
] + $reference;
2427

25-
parent::__construct($nodes, [], $lineno, $tag);
28+
parent::__construct($nodes, [], $lineno);
2629
}
2730

2831
/**

src/TokenParser/CaptureTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function parse(Token $token): CaptureNode
3838
$body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
3939
$stream->expect(Token::BLOCK_END_TYPE);
4040

41-
return new CaptureNode($attributeName, $variableName, $body, $token->getLine(), $this->getTag());
41+
return new CaptureNode($attributeName, $variableName, $body, $token->getLine());
4242
}
4343

4444
/**

src/TokenParser/HasRightsTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function parse(Token $token)
5656
$stream->expect(Token::BLOCK_END_TYPE);
5757
}
5858

59-
return new $this->nodeClass($body, $variables, $lineno, $this->getTag());
59+
return new $this->nodeClass($body, $variables, $lineno);
6060
}
6161

6262
/**

src/TokenParser/IfContentTokenParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use OxidEsales\Twig\Node\IfContentNode;
1313
use Twig\Error\SyntaxError;
14-
use Twig\Node\Expression\AssignNameExpression;
14+
use Twig\Node\Expression\Variable\AssignContextVariable;
1515
use Twig\Node\Node;
1616
use Twig\TokenParser\AbstractTokenParser;
1717
use Twig\Token;
@@ -48,14 +48,14 @@ public function parse(Token $token): IfContentNode
4848
/** @var Node $variable */
4949
$variable = $this->parser->getExpressionParser()->parseAssignmentExpression();
5050
} else {
51-
$variable = new AssignNameExpression('oCont', $lineno);
51+
$variable = new AssignContextVariable('oCont', $lineno);
5252
}
5353

5454
$stream->expect(Token::BLOCK_END_TYPE);
5555
$body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
5656
$stream->expect(Token::BLOCK_END_TYPE);
5757

58-
return new IfContentNode($body, $reference, $variable, $lineno, $this->getTag());
58+
return new IfContentNode($body, $reference, $variable, $lineno);
5959
}
6060

6161
/**

tests/Integration/Extensions/IncludeContentExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace OxidEsales\Twig\Tests\Integration\Extensions;
1111

12-
use OxidEsales\EshopCommunity\Application\Model\Content;
12+
use OxidEsales\Eshop\Application\Model\Content;
1313
use OxidEsales\EshopCommunity\Core\Di\ContainerFacade;
1414
use OxidEsales\EshopCommunity\Internal\Framework\Html\HtmlSanitizerInterface;
1515
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\ContentFactory;

tests/Unit/Loader/CmsLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace OxidEsales\Twig\Tests\Unit\Loader;
1111

12-
use OxidEsales\EshopCommunity\Application\Model\Content;
12+
use OxidEsales\Eshop\Application\Model\Content;
1313
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\ContentFactory;
1414
use OxidEsales\Twig\Loader\CmsLoader;
1515
use OxidEsales\Twig\Loader\CmsTemplateNameParser;

tests/Unit/Node/CaptureNodeTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public static function compileDataProvider(): array
6868
variableName: 'foo',
6969
body: $body,
7070
line: 1,
71-
tag: 'capture'
7271
),
7372
self::EXPECTED_NAME_ATTRIBUTE_SOURCE,
7473
],
@@ -78,7 +77,6 @@ public static function compileDataProvider(): array
7877
variableName: 'foo',
7978
body: $body,
8079
line: 1,
81-
tag: 'capture'
8280
),
8381
self::EXPECTED_ASSIGN_ATTRIBUTE_SOURCE,
8482
],
@@ -88,7 +86,6 @@ public static function compileDataProvider(): array
8886
variableName: 'foo',
8987
body: $body,
9088
line: 1,
91-
tag: 'capture'
9289
),
9390
self::EXPECTED_APPEND_ATTRIBUTE_SOURCE,
9491
]

0 commit comments

Comments
 (0)