Skip to content

Commit 2aa8a13

Browse files
committed
OXDEV-9925 Fix Twig deprecations
1 parent d4306dc commit 2aa8a13

29 files changed

Lines changed: 59 additions & 163 deletions

CHANGELOG-3.x.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Change Log for OXID Twig engine component
22

3+
## Unreleased
4+
5+
### Removed
6+
- Usage of deprecated Twig APIs (EscaperExtension::setEscaper, ExpressionParser methods, Parser::getParent(), AssignNameExpression)
7+
8+
### Changed
9+
- EscaperInterface signature to `escape(string $string, string $charset)`
10+
311
## v3.0.0-alpha.1 - 2025-02-03
412

513
### Removed
614
- `SmartyCycleExtension` was removed
7-
- Short template names (without file extensions `".html.twig"`) are no longer supported.
15+
- Short template names (without file extensions ".html.twig") are no longer supported.
816
- Deprecated `DateFormatExtension`

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
}

src/Escaper/UrlPathInfoEscaper.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 UrlPathInfoEscaper implements EscaperInterface
1513
{
1614
/**
@@ -21,14 +19,7 @@ public function getStrategy(): string
2119
return 'urlpathinfo';
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('%2F', '/', rawurlencode($string));
3425
}

0 commit comments

Comments
 (0)