Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update symfony dependencies to 5.3 #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build

on:
pull_request:
push:
branches:
- "master"

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"
- "8.0"

steps:
- uses: actions/checkout@v2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
ini-values: "memory_limit=-1, phar.readonly=0"
php-version: "${{ matrix.php-version }}"

- name: Composer Cache Directory
id: composer-cache
uses: actions/cache@v1
with:
path: ~/.composer
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: PHPUnit
run: ./vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/phpunit.xml
/.phpunit.result.cache
/vendor
/build
/composer.lock
Expand Down
59 changes: 31 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,41 @@
"require": {
"php": ">=7.1.3",
"pimple/pimple": "^3.0",
"symfony/event-dispatcher": "^4.0",
"symfony/http-foundation": "^4.0",
"symfony/http-kernel": "^4.0",
"symfony/routing": "^4.0"
"symfony/event-dispatcher": "^5.3",
"symfony/http-foundation": "^5.3",
"symfony/http-kernel": "^5.3",
"symfony/routing": "^5.3",
"symfony/monolog-bridge": "^5.3",
"monolog/monolog": "^2.3"
},
"require-dev": {
"symfony/asset": "^4.0",
"symfony/expression-language": "^4.0",
"symfony/security": "^4.0",
"symfony/config": "^4.0",
"symfony/form": "^4.0",
"symfony/browser-kit": "^4.0",
"symfony/css-selector": "^4.0",
"symfony/debug": "^4.0",
"symfony/dom-crawler": "^4.0",
"symfony/finder": "^4.0",
"symfony/intl": "^4.0",
"symfony/monolog-bridge": "^4.0",
"symfony/doctrine-bridge": "^4.0",
"symfony/options-resolver": "^4.0",
"symfony/phpunit-bridge": "^3.2",
"symfony/process": "^4.0",
"symfony/serializer": "^4.0",
"symfony/translation": "^4.0",
"symfony/twig-bridge": "^4.0",
"symfony/validator": "^4.0",
"symfony/var-dumper": "^4.0",
"phpunit/phpunit": "^9.5",
"symfony/asset": "^5.3",
"symfony/expression-language": "^5.3",
"symfony/security-core": "^5.3",
"symfony/security-csrf": "^5.3",
"symfony/security-http": "^5.3",
"symfony/security-guard": "^5.3",
"symfony/config": "^5.3",
"symfony/form": "^5.3",
"symfony/browser-kit": "^5.3",
"symfony/css-selector": "^5.3",
"symfony/error-handler": "^5.3",
"symfony/dom-crawler": "^5.3",
"symfony/finder": "^5.3",
"symfony/intl": "^5.3",
"symfony/doctrine-bridge": "^5.3",
"symfony/options-resolver": "^5.3",
"symfony/process": "^5.3",
"symfony/serializer": "^5.3",
"symfony/translation": "^5.3",
"symfony/twig-bridge": "^5.3",
"symfony/validator": "^5.3",
"symfony/var-dumper": "^5.3",
"twig/twig": "^2.0",
"doctrine/dbal": "^2.2",
"swiftmailer/swiftmailer": "^5",
"monolog/monolog": "^1.4.1",
"symfony/web-link": "^4.0"
"swiftmailer/swiftmailer": "^6",
"symfony/web-link": "^5.3"
},
"replace": {
"silex/api": "self.version",
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
Expand Down
19 changes: 10 additions & 9 deletions src/Silex/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use Pimple\ServiceProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -65,6 +65,7 @@ public function __construct(array $values = [])
$this['debug'] = false;
$this['charset'] = 'UTF-8';
$this['logger'] = null;
$this['psr_container'] = new \Pimple\Psr11\Container($this);

$this->register(new HttpKernelServiceProvider());
$this->register(new RoutingServiceProvider());
Expand Down Expand Up @@ -246,8 +247,8 @@ public function before($callback, $priority = 0)
{
$app = $this;

$this->on(KernelEvents::REQUEST, function (GetResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
$this->on(KernelEvents::REQUEST, function (RequestEvent $event) use ($callback, $app) {
if (!$event->isMainRequest()) {
return;
}

Expand All @@ -272,8 +273,8 @@ public function after($callback, $priority = 0)
{
$app = $this;

$this->on(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use ($callback, $app) {
if (!$event->isMasterRequest()) {
$this->on(KernelEvents::RESPONSE, function (ResponseEvent $event) use ($callback, $app) {
if (!$event->isMainRequest()) {
return;
}

Expand All @@ -299,7 +300,7 @@ public function finish($callback, $priority = 0)
{
$app = $this;

$this->on(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($callback, $app) {
$this->on(KernelEvents::TERMINATE, function (TerminateEvent $event) use ($callback, $app) {
call_user_func($app['callback_resolver']->resolveCallback($callback), $event->getRequest(), $event->getResponse(), $app);
}, $priority);
}
Expand Down Expand Up @@ -485,7 +486,7 @@ public function run(Request $request = null)
* If you call this method directly instead of run(), you must call the
* terminate() method yourself if you want the finish filters to be run.
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true)
{
if (!$this->booted) {
$this->boot();
Expand Down
16 changes: 0 additions & 16 deletions src/Silex/Application/TranslationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,4 @@ public function trans($id, array $parameters = [], $domain = 'messages', $locale
{
return $this['translator']->trans($id, $parameters, $domain, $locale);
}

/**
* Translates the given choice message by choosing a translation according to a number.
*
* @param string $id The message id
* @param int $number The number to use to find the indice of the message
* @param array $parameters An array of parameters for the message
* @param string $domain The domain for the message
* @param string $locale The locale
*
* @return string The translated string
*/
public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null)
{
return $this['translator']->transChoice($id, $number, $parameters, $domain, $locale);
}
}
6 changes: 3 additions & 3 deletions src/Silex/EventListener/ConverterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Silex\CallbackResolver;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\RouteCollection;

Expand Down Expand Up @@ -42,9 +42,9 @@ public function __construct(RouteCollection $routes, CallbackResolver $callbackR
/**
* Handles converters.
*
* @param FilterControllerEvent $event The event to handle
* @param ControllerEvent $event The event to handle
*/
public function onKernelController(FilterControllerEvent $event)
public function onKernelController(ControllerEvent $event)
{
$request = $event->getRequest();
$route = $this->routes->get($request->attributes->get('_route'));
Expand Down
24 changes: 12 additions & 12 deletions src/Silex/EventListener/LogListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -50,11 +50,11 @@ public function __construct(LoggerInterface $logger, $exceptionLogFilter = null)
/**
* Logs master requests on event KernelEvents::REQUEST.
*
* @param GetResponseEvent $event
* @param RequestEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMasterRequest()) {
if (!$event->isMainRequest()) {
return;
}

Expand All @@ -64,9 +64,9 @@ public function onKernelRequest(GetResponseEvent $event)
/**
* Logs master response on event KernelEvents::RESPONSE.
*
* @param FilterResponseEvent $event
* @param ResponseEvent $event
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand All @@ -78,11 +78,11 @@ public function onKernelResponse(FilterResponseEvent $event)
/**
* Logs uncaught exceptions on event KernelEvents::EXCEPTION.
*
* @param GetResponseForExceptionEvent $event
* @param ExceptionEvent $event
*/
public function onKernelException(GetResponseForExceptionEvent $event)
public function onKernelException(ExceptionEvent $event)
{
$this->logException($event->getException());
$this->logException($event->getThrowable());
}

/**
Expand Down Expand Up @@ -114,7 +114,7 @@ protected function logResponse(Response $response)
/**
* Logs an exception.
*/
protected function logException(\Exception $e)
protected function logException(\Throwable $e)
{
$this->logger->log(call_user_func($this->exceptionLogFilter, $e), sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), ['exception' => $e]);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Silex/EventListener/MiddlewareListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Silex\EventListener;

use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Silex\Application;
Expand All @@ -40,9 +40,9 @@ public function __construct(Application $app)
/**
* Runs before filters.
*
* @param GetResponseEvent $event The event to handle
* @param RequestEvent $event The event to handle
*/
public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(RequestEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
Expand All @@ -65,13 +65,13 @@ public function onKernelRequest(GetResponseEvent $event)
/**
* Runs after filters.
*
* @param FilterResponseEvent $event The event to handle
* @param ResponseEvent $event The event to handle
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
$request = $event->getRequest();
$routeName = $request->attributes->get('_route');
if (!$route = $this->app['routes']->get($routeName)) {
if (!$route = $this->app['routes']->get((string) $routeName)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Silex/EventListener/StringToResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Silex\EventListener;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -26,9 +26,9 @@ class StringToResponseListener implements EventSubscriberInterface
/**
* Handles string responses.
*
* @param GetResponseForControllerResultEvent $event The event to handle
* @param ViewEvent $event The event to handle
*/
public function onKernelView(GetResponseForControllerResultEvent $event)
public function onKernelView(ViewEvent $event)
{
$response = $event->getControllerResult();

Expand Down
17 changes: 9 additions & 8 deletions src/Silex/ExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace Silex;

use Symfony\Component\Debug\ExceptionHandler as DebugExceptionHandler;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
Expand All @@ -32,16 +32,17 @@ public function __construct($debug)
$this->debug = $debug;
}

public function onSilexError(GetResponseForExceptionEvent $event)
public function onSilexError(ExceptionEvent $event)
{
$handler = new DebugExceptionHandler($this->debug);
$handler = new HtmlErrorRenderer($this->debug);

$exception = $event->getException();
$exception = $event->getThrowable();
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
$exception = FlattenException::createFromThrowable($exception);
}

$response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset'));
$response = new Response($handler->getBody($exception), $exception->getStatusCode(), $exception->getHeaders());
$response->setCharset(ini_get('default_charset'));

$event->setResponse($response);
}
Expand Down
Loading