Skip to content

Commit 35f37ce

Browse files
committed
OXDEV-9925 Fix deprecations
1 parent d71bbe6 commit 35f37ce

31 files changed

Lines changed: 75 additions & 167 deletions

CHANGELOG-3.x.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
## v3.0.0-alpha.2 - Unreleased
44

5+
### Removed
6+
- Deprecated Twig APIs
7+
58
### Changed
6-
- `TemplateChain` DTO `getByModuleId` and `getParent` methods returns `null` when no matching result is found
9+
- `TemplateChain` DTO `getByModuleId` and `getParent` methods return `null` when no matching result is found
10+
- Escaper registration uses `EscaperRuntime`
11+
- Token parsing aligned with Twig deprecations
712

813
## v3.0.0-alpha.1 - 2025-02-03
914

services.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ services:
253253
class: OxidEsales\Twig\TwigEngine
254254
arguments:
255255
$engine: '@twig'
256-
$twigExtensions: !tagged twig.extension
257-
$twigEscaper: !tagged twig.escaper
256+
$twigExtensions: !tagged_iterator twig.extension
257+
$twigEscaper: !tagged_iterator twig.escaper
258258
public: false
259259

260260
OxidEsales\Twig\Resolver\TemplateChain\TemplateChainResolverInterface:

src/Escaper/DecEntityEscaper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
class DecEntityEscaper implements EscaperInterface
1513
{
1614
/**
@@ -21,14 +19,7 @@ public function getStrategy(): string
2119
return 'decentity';
2220
}
2321

24-
/**
25-
* @param Environment $environment
26-
* @param string $string
27-
* @param string $charset
28-
*
29-
* @return string
30-
*/
31-
public function escape(Environment $environment, $string, $charset): string
22+
public function escape(string $string, string $charset): string
3223
{
3324
$return = '';
3425

src/Escaper/EscaperInterface.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
interface EscaperInterface
1513
{
1614
/**
@@ -19,11 +17,8 @@ interface EscaperInterface
1917
public function getStrategy(): string;
2018

2119
/**
22-
* @param Environment $environment
23-
* @param string $string
24-
* @param string $charset
25-
*
26-
* @return string
20+
* Escape a string for the given strategy.
21+
* Matches Twig 3.10+ escaper callable signature (no Environment argument).
2722
*/
28-
public function escape(Environment $environment, $string, $charset): string;
23+
public function escape(string $string, string $charset): string;
2924
}

src/Escaper/HexEntityEscaper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
class HexEntityEscaper implements EscaperInterface
1513
{
1614
/**
@@ -21,14 +19,7 @@ public function getStrategy(): string
2119
return 'hexentity';
2220
}
2321

24-
/**
25-
* @param Environment $environment
26-
* @param string $string
27-
* @param string $charset
28-
*
29-
* @return string
30-
*/
31-
public function escape(Environment $environment, $string, $charset): string
22+
public function escape(string $string, string $charset): string
3223
{
3324
$return = '';
3425

src/Escaper/HexEscaper.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
class HexEscaper implements EscaperInterface
1513
{
1614
/**
@@ -23,14 +21,8 @@ public function getStrategy(): string
2321

2422
/**
2523
* Escape every character into hex
26-
*
27-
* @param Environment $environment
28-
* @param string $string
29-
* @param string $charset
30-
*
31-
* @return string
3224
*/
33-
public function escape(Environment $environment, $string, $charset): string
25+
public function escape(string $string, string $charset): string
3426
{
3527
$return = '';
3628

src/Escaper/HtmlAllEscaper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
class HtmlAllEscaper implements EscaperInterface
1513
{
1614
/**
@@ -21,14 +19,7 @@ public function getStrategy(): string
2119
return 'htmlall';
2220
}
2321

24-
/**
25-
* @param Environment $environment
26-
* @param string $string
27-
* @param string $charset
28-
*
29-
* @return string
30-
*/
31-
public function escape(Environment $environment, $string, $charset): string
22+
public function escape(string $string, string $charset): string
3223
{
3324
return htmlentities($string, ENT_QUOTES, $charset);
3425
}

src/Escaper/MailEscaper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
class MailEscaper implements EscaperInterface
1513
{
1614
/**
@@ -21,14 +19,7 @@ public function getStrategy(): string
2119
return 'mail';
2220
}
2321

24-
/**
25-
* @param Environment $environment
26-
* @param string $string
27-
* @param string $charset
28-
*
29-
* @return string
30-
*/
31-
public function escape(Environment $environment, $string, $charset): string
22+
public function escape(string $string, string $charset): string
3223
{
3324
return str_replace(['@', '.'], [' [AT] ', ' [DOT] '], $string);
3425
}

src/Escaper/NonStdEscaper.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
/**
1513
* Escape non-standard chars, such as ms document quotes
1614
*/
@@ -26,14 +24,8 @@ public function getStrategy(): string
2624

2725
/**
2826
* Escape non-standard chars, such as ms document quotes
29-
*
30-
* @param Environment $environment
31-
* @param string $string
32-
* @param string $charset
33-
*
34-
* @return string
3527
*/
36-
public function escape(Environment $environment, $string, $charset): string
28+
public function escape(string $string, string $charset): string
3729
{
3830
$return = '';
3931

src/Escaper/QuotesEscaper.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace OxidEsales\Twig\Escaper;
1111

12-
use Twig\Environment;
13-
1412
/**
1513
* Escape unescaped single quotes
1614
*/
@@ -26,14 +24,8 @@ public function getStrategy(): string
2624

2725
/**
2826
* Escape unescaped single quotes
29-
*
30-
* @param Environment $environment
31-
* @param string $string
32-
* @param string $charset
33-
*
34-
* @return string
3527
*/
36-
public function escape(Environment $environment, $string, $charset): string
28+
public function escape(string $string, string $charset): string
3729
{
3830
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
3931
}

0 commit comments

Comments
 (0)