Skip to content

Commit

Permalink
bug #75 Replace eval by require_once in ForwardCompatTypeExtensionTra…
Browse files Browse the repository at this point in the history
…it (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
  • Loading branch information
HeahDude committed Mar 10, 2020
2 parents 7a55d73 + 98d3456 commit c2266f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 1 addition & 18 deletions src/Form/TypeExtension/ForwardCompatTypeExtensionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,7 @@
use Symfony\Component\Form\FormTypeExtensionInterface;

if (method_exists(FormTypeExtensionInterface::class, 'getExtendedTypes')) {
eval('
namespace Exercise\HTMLPurifierBundle\Form\TypeExtension;
/**
* @internal
*/
trait ForwardCompatTypeExtensionTrait
{
private static function doGetExtendedTypes(): iterable
{
}
public static function getExtendedTypes(): iterable
{
return self::doGetExtendedTypes();
}
}
');
require_once __DIR__.'/forward_compat_trait.inc.php';
} else {
/**
* @internal
Expand Down
18 changes: 18 additions & 0 deletions src/Form/TypeExtension/forward_compat_trait.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Exercise\HTMLPurifierBundle\Form\TypeExtension;

/**
* @internal
*/
trait ForwardCompatTypeExtensionTrait
{
private static function doGetExtendedTypes(): iterable
{
}

public static function getExtendedTypes(): iterable
{
return self::doGetExtendedTypes();
}
}

0 comments on commit c2266f3

Please sign in to comment.