Skip to content

Commit c2266f3

Browse files
committed
bug #75 Replace eval by require_once in ForwardCompatTypeExtensionTrait (l-vo)
This PR was merged into the 2.0 branch. Discussion ---------- Replace eval by require_once in ForwardCompatTypeExtensionTrait When an application use the ForwardCompatTypeExtensionTrait trait with return types, an error is triggered since the Symfony container can't determine and include the file that created the trait: `Warning: include_once(/var/www/html/vendor/exercise/html-purifier-bundle/src/Form/TypeExtension/ForwardCompatTypeExtensionTrait.php(8) : eval()'d code): failed to open stream: No such file or directory` This PR aims to fix this issue. Commits ------- 98d3456 Replace eval by require_once for ForwardCompatTypeExtensionTrait
2 parents 7a55d73 + 98d3456 commit c2266f3

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/Form/TypeExtension/ForwardCompatTypeExtensionTrait.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,7 @@
55
use Symfony\Component\Form\FormTypeExtensionInterface;
66

77
if (method_exists(FormTypeExtensionInterface::class, 'getExtendedTypes')) {
8-
eval('
9-
namespace Exercise\HTMLPurifierBundle\Form\TypeExtension;
10-
11-
/**
12-
* @internal
13-
*/
14-
trait ForwardCompatTypeExtensionTrait
15-
{
16-
private static function doGetExtendedTypes(): iterable
17-
{
18-
}
19-
20-
public static function getExtendedTypes(): iterable
21-
{
22-
return self::doGetExtendedTypes();
23-
}
24-
}
25-
');
8+
require_once __DIR__.'/forward_compat_trait.inc.php';
269
} else {
2710
/**
2811
* @internal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Exercise\HTMLPurifierBundle\Form\TypeExtension;
4+
5+
/**
6+
* @internal
7+
*/
8+
trait ForwardCompatTypeExtensionTrait
9+
{
10+
private static function doGetExtendedTypes(): iterable
11+
{
12+
}
13+
14+
public static function getExtendedTypes(): iterable
15+
{
16+
return self::doGetExtendedTypes();
17+
}
18+
}

0 commit comments

Comments
 (0)