Commit 9c90d349 authored by Fabien Potencier's avatar Fabien Potencier

feature #1338 removed support for Symfony 2.7 in Silex 2.0 (fabpot)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

removed support for Symfony 2.7 in Silex 2.0

As 2.8 is a LTS and compatible with 3.0, it's going to be much easier to maintain both the code and the documentation for Silex 2.0 if we drop support for Symfony 2.7.

Commits
-------

155cb751 removed support for Symfony 2.7
parents 27764071 155cb751
...@@ -9,9 +9,8 @@ cache: ...@@ -9,9 +9,8 @@ cache:
before_script: before_script:
# symfony/* # symfony/*
- sh -c "if [ '$TWIG_VERSION' != '2.0' ]; then sed -i 's/~1.8|~2.0/~1.8/g' composer.json; composer update; fi" - sh -c "if [ '$TWIG_VERSION' != '2.0' ]; then sed -i 's/~1.8|~2.0/~1.8/g' composer.json; composer update; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '3.0' ]; then sed -i 's/~2\.7|3\.0\.\*/3.0.*@dev/g' composer.json; composer update; fi" - sh -c "if [ '$SYMFONY_DEPS_VERSION' = '3.0' ]; then sed -i 's/~2\.8|3\.0\.\*/3.0.*@dev/g' composer.json; composer update; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.8' ]; then sed -i 's/~2\.7|3\.0\.\*/2.8.*@dev/g' composer.json; composer update; fi" - sh -c "if [ '$SYMFONY_DEPS_VERSION' = '' ]; then sed -i 's/~2\.8|3\.0\.\*/2.8.*@dev/g' composer.json; composer update; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '' ]; then sed -i 's/~2\.7|3\.0\.\*/2.7.*@dev/g' composer.json; composer update; fi"
- composer install - composer install
script: phpunit script: phpunit
...@@ -21,8 +20,6 @@ matrix: ...@@ -21,8 +20,6 @@ matrix:
- php: 5.5 - php: 5.5
- php: 5.6 - php: 5.6
env: TWIG_VERSION=2.0 env: TWIG_VERSION=2.0
- php: 5.6
env: SYMFONY_DEPS_VERSION=2.8
- php: 5.6 - php: 5.6
env: SYMFONY_DEPS_VERSION=3.0 env: SYMFONY_DEPS_VERSION=3.0
- php: 7.0 - php: 7.0
......
...@@ -17,31 +17,31 @@ ...@@ -17,31 +17,31 @@
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"pimple/pimple": "~3.0", "pimple/pimple": "~3.0",
"symfony/event-dispatcher": "~2.7|3.0.*", "symfony/event-dispatcher": "~2.8|3.0.*",
"symfony/http-foundation": "~2.7|3.0.*", "symfony/http-foundation": "~2.8|3.0.*",
"symfony/http-kernel": "~2.7|3.0.*", "symfony/http-kernel": "~2.8|3.0.*",
"symfony/routing": "~2.7|3.0.*" "symfony/routing": "~2.8|3.0.*"
}, },
"require-dev": { "require-dev": {
"symfony/asset": "~2.7|3.0.*", "symfony/asset": "~2.8|3.0.*",
"symfony/security": "~2.7|3.0.*", "symfony/security": "~2.8|3.0.*",
"symfony/config": "~2.7|3.0.*", "symfony/config": "~2.8|3.0.*",
"symfony/locale": "~2.7|3.0.*", "symfony/locale": "~2.8|3.0.*",
"symfony/form": "~2.7|3.0.*", "symfony/form": "~2.8|3.0.*",
"symfony/browser-kit": "~2.7|3.0.*", "symfony/browser-kit": "~2.8|3.0.*",
"symfony/css-selector": "~2.7|3.0.*", "symfony/css-selector": "~2.8|3.0.*",
"symfony/debug": "~2.7|3.0.*", "symfony/debug": "~2.8|3.0.*",
"symfony/dom-crawler": "~2.7|3.0.*", "symfony/dom-crawler": "~2.8|3.0.*",
"symfony/finder": "~2.7|3.0.*", "symfony/finder": "~2.8|3.0.*",
"symfony/monolog-bridge": "~2.7|3.0.*", "symfony/monolog-bridge": "~2.8|3.0.*",
"symfony/doctrine-bridge": "~2.7|3.0.*", "symfony/doctrine-bridge": "~2.8|3.0.*",
"symfony/options-resolver": "~2.7|3.0.*", "symfony/options-resolver": "~2.8|3.0.*",
"symfony/process": "~2.7|3.0.*", "symfony/process": "~2.8|3.0.*",
"symfony/serializer": "~2.7|3.0.*", "symfony/serializer": "~2.8|3.0.*",
"symfony/translation": "~2.7|3.0.*", "symfony/translation": "~2.8|3.0.*",
"symfony/twig-bridge": "~2.7|3.0.*", "symfony/twig-bridge": "~2.8|3.0.*",
"symfony/validator": "~2.7|3.0.*", "symfony/validator": "~2.8|3.0.*",
"symfony/var-dumper": "~2.7|3.0.*", "symfony/var-dumper": "~2.8|3.0.*",
"twig/twig": "~1.8|~2.0", "twig/twig": "~1.8|~2.0",
"doctrine/dbal": "~2.2", "doctrine/dbal": "~2.2",
"swiftmailer/swiftmailer": "~5", "swiftmailer/swiftmailer": "~5",
......
...@@ -9,7 +9,7 @@ Changelog ...@@ -9,7 +9,7 @@ Changelog
* [BC BREAK] CSRF has been moved to a standalone provider (``form.secret`` is not available anymore) * [BC BREAK] CSRF has been moved to a standalone provider (``form.secret`` is not available anymore)
* added support for the Symfony HttpFoundation Twig bridge extension * added support for the Symfony HttpFoundation Twig bridge extension
* added support for the Symfony Asset Component * added support for the Symfony Asset Component
* bumped minimum version of Symfony to 2.7 * bumped minimum version of Symfony to 2.8
* bumped minimum version of PHP to 5.5.0 * bumped minimum version of PHP to 5.5.0
* Updated Pimple to 3.0 * Updated Pimple to 3.0
* Updated session listeners to extends HttpKernel ones * Updated session listeners to extends HttpKernel ones
......
...@@ -645,9 +645,9 @@ Symfony `cookbook`_. ...@@ -645,9 +645,9 @@ Symfony `cookbook`_.
.. note:: .. note::
Since Symfony 2.8, the Guard component simplify the creation of custom The Guard component simplifies the creation of custom authentication
authentication providers. providers. :doc:`How to Create a Custom Authentication System with Guard
:doc:`How to Create a Custom Authentication System with Guard <cookbook/guard_authentication>` <cookbook/guard_authentication>`
Stateless Authentication Stateless Authentication
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -32,8 +32,7 @@ trait FormTrait ...@@ -32,8 +32,7 @@ trait FormTrait
public function form($data = null, array $options = array(), $type = null) public function form($data = null, array $options = array(), $type = null)
{ {
if (null === $type) { if (null === $type) {
// BC with Symfony < 2.8 $type = 'Symfony\Component\Form\Extension\Core\Type\FormType';
$type = class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form';
} }
return $this['form.factory']->createBuilder($type, $data, $options); return $this['form.factory']->createBuilder($type, $data, $options);
......
...@@ -36,17 +36,12 @@ class ExceptionHandler implements EventSubscriberInterface ...@@ -36,17 +36,12 @@ class ExceptionHandler implements EventSubscriberInterface
{ {
$handler = new DebugExceptionHandler($this->debug); $handler = new DebugExceptionHandler($this->debug);
if (method_exists($handler, 'getHtml')) {
$exception = $event->getException(); $exception = $event->getException();
if (!$exception instanceof FlattenException) { if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception); $exception = FlattenException::create($exception);
} }
$response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset')); $response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset'));
} else {
// BC with Symfony < 2.8
$response = $handler->createResponse($event->getException());
}
$event->setResponse($response); $event->setResponse($response);
} }
......
...@@ -33,11 +33,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList ...@@ -33,11 +33,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList
public function register(Container $app) public function register(Container $app)
{ {
$app['fragment.handler'] = function ($app) { $app['fragment.handler'] = function ($app) {
if (Kernel::VERSION_ID >= 20800) {
return new FragmentHandler($app['request_stack'], $app['fragment.renderers'], $app['debug']); return new FragmentHandler($app['request_stack'], $app['fragment.renderers'], $app['debug']);
}
return new FragmentHandler($app['fragment.renderers'], $app['debug'], $app['request_stack']);
}; };
$app['fragment.renderer.inline'] = function ($app) { $app['fragment.renderer.inline'] = function ($app) {
......
...@@ -21,7 +21,6 @@ use Symfony\Component\Routing\RouteCollection; ...@@ -21,7 +21,6 @@ use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
use Symfony\Component\HttpKernel\EventListener\RouterListener; use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/** /**
...@@ -76,11 +75,7 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -76,11 +75,7 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP
return $app['request_matcher']; return $app['request_matcher'];
}); });
if (Kernel::VERSION_ID >= 20800) {
return new RouterListener($urlMatcher, $app['request_stack'], $app['request_context'], $app['logger']); return new RouterListener($urlMatcher, $app['request_stack'], $app['request_context'], $app['logger']);
}
return new RouterListener($urlMatcher, $app['request_context'], $app['logger'], $app['request_stack']);
}; };
} }
......
...@@ -21,7 +21,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; ...@@ -21,7 +21,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RequestMatcher; use Symfony\Component\HttpFoundation\RequestMatcher;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserChecker; use Symfony\Component\Security\Core\User\UserChecker;
use Symfony\Component\Security\Core\User\InMemoryUserProvider; use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Symfony\Component\Security\Core\Encoder\EncoderFactory; use Symfony\Component\Security\Core\Encoder\EncoderFactory;
...@@ -374,19 +373,14 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -374,19 +373,14 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
}; };
$app['security.last_error'] = $app->protect(function (Request $request) { $app['security.last_error'] = $app->protect(function (Request $request) {
if (class_exists('Symfony\Component\Security\Core\Security')) { if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
$error = Security::AUTHENTICATION_ERROR; return $request->attributes->get(Security::AUTHENTICATION_ERROR)->getMessage();
} else {
$error = SecurityContextInterface::AUTHENTICATION_ERROR;
}
if ($request->attributes->has($error)) {
return $request->attributes->get($error)->getMessage();
} }
$session = $request->getSession(); $session = $request->getSession();
if ($session && $session->has($error)) { if ($session && $session->has(Security::AUTHENTICATION_ERROR)) {
$message = $session->get($error)->getMessage(); $message = $session->get(Security::AUTHENTICATION_ERROR)->getMessage();
$session->remove($error); $session->remove(Security::AUTHENTICATION_ERROR);
return $message; return $message;
} }
......
...@@ -46,8 +46,8 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -46,8 +46,8 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase
return $extensions; return $extensions;
}); });
$form = $app['form.factory']->createBuilder(class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())
->add('dummy', class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Silex\Tests\Provider\DummyFormType' : 'dummy') ->add('dummy', 'Silex\Tests\Provider\DummyFormType')
->getForm(); ->getForm();
$this->assertInstanceOf('Symfony\Component\Form\Form', $form); $this->assertInstanceOf('Symfony\Component\Form\Form', $form);
...@@ -65,8 +65,8 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -65,8 +65,8 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase
return $extensions; return $extensions;
}); });
$form = $app['form.factory']->createBuilder(class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())
->add('file', class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FileType' : 'file', array('image_path' => 'webPath')) ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', array('image_path' => 'webPath'))
->getForm(); ->getForm();
$this->assertInstanceOf('Symfony\Component\Form\Form', $form); $this->assertInstanceOf('Symfony\Component\Form\Form', $form);
...@@ -106,7 +106,7 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -106,7 +106,7 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase
return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); return $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
}; };
$form = $app['form.factory']->createBuilder(class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form', array()) $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())
->getForm(); ->getForm();
$form->handleRequest($req = Request::create('/', 'POST', array('form' => array( $form->handleRequest($req = Request::create('/', 'POST', array('form' => array(
...@@ -153,27 +153,14 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -153,27 +153,14 @@ class FormServiceProviderTest extends \PHPUnit_Framework_TestCase
$app->register(new CsrfServiceProvider()); $app->register(new CsrfServiceProvider());
$app['session.test'] = true; $app['session.test'] = true;
$form = $app['form.factory']->createBuilder(class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form', array())->getForm(); $form = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array())->getForm();
$this->assertTrue(isset($form->createView()['_token'])); $this->assertTrue(isset($form->createView()['_token']));
} }
} }
if (class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType')) { class DummyFormType extends AbstractType
class DummyFormType extends AbstractType {
{
}
} else {
class DummyFormType extends AbstractType
{
/**
* @return string The name of this type
*/
public function getName()
{
return 'dummy';
}
}
} }
if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
...@@ -181,7 +168,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { ...@@ -181,7 +168,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
{ {
public function getExtendedType() public function getExtendedType()
{ {
return class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FileType' : 'file'; return 'Symfony\Component\Form\Extension\Core\Type\FileType';
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
...@@ -194,7 +181,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { ...@@ -194,7 +181,7 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
{ {
public function getExtendedType() public function getExtendedType()
{ {
return class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FileType' : 'file'; return 'Symfony\Component\Form\Extension\Core\Type\FileType';
} }
public function setDefaultOptions(OptionsResolverInterface $resolver) public function setDefaultOptions(OptionsResolverInterface $resolver)
......
...@@ -122,11 +122,6 @@ class SecurityServiceProviderTest extends WebTestCase ...@@ -122,11 +122,6 @@ class SecurityServiceProviderTest extends WebTestCase
public function testGuardAuthentication() public function testGuardAuthentication()
{ {
if (!class_exists('Symfony\\Component\\Security\\Guard\\AbstractGuardAuthenticator')) {
$this->markTestSkipped(
'The guard component require Symfony 2.8+'
);
}
$app = $this->createApplication('guard'); $app = $this->createApplication('guard');
$client = new Client($app); $client = new Client($app);
......
...@@ -71,10 +71,6 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -71,10 +71,6 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase
*/ */
public function testConstraintValidatorFactoryWithExpression($app) public function testConstraintValidatorFactoryWithExpression($app)
{ {
if (!class_exists('Symfony\Component\Validator\Constraints\Expression')) {
$this->markTestSkipped('Expression are not supported by this version of Symfony');
}
$constraint = new Assert\Expression('true'); $constraint = new Assert\Expression('true');
$validator = $app['validator.validator_factory']->getInstance($constraint); $validator = $app['validator.validator_factory']->getInstance($constraint);
$this->assertInstanceOf('Symfony\Component\Validator\Constraints\ExpressionValidator', $validator); $this->assertInstanceOf('Symfony\Component\Validator\Constraints\ExpressionValidator', $validator);
...@@ -101,12 +97,12 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -101,12 +97,12 @@ class ValidatorServiceProviderTest extends \PHPUnit_Framework_TestCase
), ),
)); ));
$builder = $app['form.factory']->createBuilder(class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form', array(), array( $builder = $app['form.factory']->createBuilder('Symfony\Component\Form\Extension\Core\Type\FormType', array(), array(
'constraints' => $constraints, 'constraints' => $constraints,
)); ));
$form = $builder $form = $builder
->add('email', class_exists('Symfony\Component\Form\Extension\Core\Type\RangeType') ? 'Symfony\Component\Form\Extension\Core\Type\EmailType' : 'email', array('label' => 'Email')) ->add('email', 'Symfony\Component\Form\Extension\Core\Type\EmailType', array('label' => 'Email'))
->getForm() ->getForm()
; ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment