Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Symfony 5 to the long list of supported versions #211
Conversation
24448bd
to
0e83eff
This comment has been minimized.
This comment has been minimized.
Tests are ok on PHP 7.1+, still need to figure out why |
This comment has been minimized.
This comment has been minimized.
Thanks for the work, let me know once you figure out the build failure and I happily merge.. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Tests are now green but PHP 5.4 has been removed. It does not mean the bundle does not work anymore, it's just we can't run the tests on this version. |
@@ -36,7 +38,12 @@ public function testItWorksDynamically() | |||
$collectedShas['style-src'][] = $shaComputer->computeForStyle($style); | |||
})); | |||
$twig = new \Twig_Environment(new \Twig_Loader_Filesystem(__DIR__.'/templates')); | |||
if (class_exists('Twig\Environment')) { |
This comment has been minimized.
This comment has been minimized.
stof
Dec 3, 2019
Contributor
this can be simplified. Namespaced class names exist in Twig 1.x and 2.x too (I don't remember which minor version, but Symfony requires such minor version in all maintained branches anyway as it uses namespaced classes everywhere)
This comment has been minimized.
This comment has been minimized.
damienalexandre
Dec 3, 2019
Author
This bundle is tested against un-maintained versions of Symfony, when installing with composer update --prefer-lowest
we get Twig version 1.24.0 where there is no class Twig\Environment
:
https://github.com/twigphp/Twig/blob/v1.24.0/lib/Twig/Environment.php
Maybe we should bump Twig minimal version but that will be a BC Break.
This condition is only here to avoid a direct deprecation notices:
1x: Using the "Twig_Environment" class is deprecated since Twig version 2.7, use "Twig\Environment" instead.
1x in IntegrationTest::testItWorksDynamically from Nelmio\SecurityBundle\Tests\Twig1x: Using the "Twig_Loader_Filesystem" class is deprecated since Twig version 2.7, use "Twig\Loader\FilesystemLoader" instead.
1x in IntegrationTest::testItWorksDynamically from Nelmio\SecurityBundle\Tests\Twig
This comment has been minimized.
This comment has been minimized.
stof
Dec 3, 2019
Contributor
Maybe we should bump Twig minimal version but that will be a BC Break.
I would not consider it as a BC break, given that composer will take care of preventing to install these old unmaintained Twig releases alongside the new version of this bundle.
{ | ||
// Compatibility with Symfony < 5 and Symfony >=5 | ||
if (!$e instanceof FilterResponseEvent && !$e instanceof ResponseEvent) { | ||
return; |
This comment has been minimized.
This comment has been minimized.
stof
Dec 3, 2019
Contributor
this should be a throw new TypeError
(or throw new InvalidArgumentException
if PHP 5.x support is needed) rather than a silent failure. Otherwise, switching back to a typehint when dropping support for Symfony < 4.4
would be a BC break.
Btw, I suggest tagging all listener classes as @final
, otherwise this typehint removal is a BC break.
### To release | ||
|
||
* Symfony 5 compatibility added | ||
* Drop tests for PHP 5.4 |
This comment has been minimized.
This comment has been minimized.
stof
Dec 3, 2019
Contributor
Dropping tests for PHP 5.4 without dropping support for it in composer.json is a bad idea IMO. Projects running on PHP 5.4 should rather get an old test release than an uptodate release for which no testing has been done (as it might be incompatible).
This comment has been minimized.
This comment has been minimized.
Thanks for the review, I just switched all the |
This comment has been minimized.
This comment has been minimized.
Twig is now bumped to 1.38, which is the minimal version we can use with support for the namespaced classes. I also changed all Twig related code to use the namespaced classes to avoid some errors and make it "clean".
|
"twig/twig": "^1.24", | ||
"symfony/yaml": "~2.3|~3.0|~4.0", | ||
"symfony/phpunit-bridge": "^3.4.24|~4.0" | ||
"twig/twig": "^1.38|^2.10", |
damienalexandre commentedNov 25, 2019
•
edited
This PR supersede #209 as the logic is different, here we keep support for all versions by using
class_exists
a lot.Thanks to @lyrixx I discovered that the😍
setUp() : void
from PHPUnit issue is normally managed by the PHPUnit Bridge!