mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/16649] Upgrade to Symfony 5
PHPBB3-16649
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace phpbb\event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
class data extends Event implements \ArrayAccess
|
||||
{
|
||||
|
@@ -14,7 +14,6 @@
|
||||
namespace phpbb\event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Extension of the Symfony EventDispatcher
|
||||
@@ -43,26 +42,24 @@ class dispatcher extends EventDispatcher implements dispatcher_interface
|
||||
public function trigger_event($eventName, $data = [])
|
||||
{
|
||||
$event = new \phpbb\event\data($data);
|
||||
$this->dispatch($eventName, $event);
|
||||
foreach ((array) $eventName as $name)
|
||||
{
|
||||
$this->dispatch($event, $name);
|
||||
}
|
||||
return $event->get_data_filtered(array_keys($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dispatch($eventName, Event $event = null)
|
||||
public function dispatch(object $event, string $eventName = null) : object
|
||||
{
|
||||
if ($this->disabled)
|
||||
{
|
||||
return $event;
|
||||
}
|
||||
|
||||
foreach ((array) $eventName as $name)
|
||||
{
|
||||
$event = parent::dispatch($name, $event);
|
||||
}
|
||||
|
||||
return $event;
|
||||
return parent::dispatch($event, $eventName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class kernel_exception_subscriber implements EventSubscriberInterface
|
||||
@@ -65,12 +65,12 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||
/**
|
||||
* This listener is run when the KernelEvents::EXCEPTION event is triggered
|
||||
*
|
||||
* @param GetResponseForExceptionEvent $event
|
||||
* @param ExceptionEvent $event
|
||||
* @return null
|
||||
*/
|
||||
public function on_kernel_exception(GetResponseForExceptionEvent $event)
|
||||
public function on_kernel_exception(ExceptionEvent $event)
|
||||
{
|
||||
$exception = $event->getException();
|
||||
$exception = $event->getThrowable();
|
||||
|
||||
$message = $exception->getMessage();
|
||||
$this->type_caster->set_var($message, $message, 'string', true, false);
|
||||
|
@@ -15,7 +15,7 @@ namespace phpbb\event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||
|
||||
class kernel_terminate_subscriber implements EventSubscriberInterface
|
||||
{
|
||||
@@ -24,10 +24,10 @@ class kernel_terminate_subscriber implements EventSubscriberInterface
|
||||
* This comes after a Response has been sent to the server; this is
|
||||
* primarily cleanup stuff.
|
||||
*
|
||||
* @param PostResponseEvent $event
|
||||
* @param TerminateEvent $event
|
||||
* @return void
|
||||
*/
|
||||
public function on_kernel_terminate(PostResponseEvent $event)
|
||||
public function on_kernel_terminate(TerminateEvent $event)
|
||||
{
|
||||
garbage_collection();
|
||||
|
||||
|
@@ -203,16 +203,20 @@ class php_exporter
|
||||
{
|
||||
$event_line = false;
|
||||
$found_trigger_event = strpos($this->file_lines[$i], 'dispatcher->trigger_event(');
|
||||
$found_use_vars = strpos($this->file_lines[$i], ', compact($vars)');
|
||||
$arguments = array();
|
||||
if ($found_trigger_event !== false)
|
||||
{
|
||||
$event_line = $i;
|
||||
$this->set_current_event($this->get_event_name($event_line, false), $event_line);
|
||||
|
||||
// Find variables of the event
|
||||
$arguments = $this->get_vars_from_array();
|
||||
$doc_vars = $this->get_vars_from_docblock();
|
||||
$this->validate_vars_docblock_array($arguments, $doc_vars);
|
||||
if ($found_use_vars)
|
||||
{
|
||||
// Find variables of the event
|
||||
$arguments = $this->get_vars_from_array();
|
||||
$doc_vars = $this->get_vars_from_docblock();
|
||||
$this->validate_vars_docblock_array($arguments, $doc_vars);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -346,10 +350,10 @@ class php_exporter
|
||||
}
|
||||
else
|
||||
{
|
||||
$regex = '#extract\(\$[a-z](?:[a-z0-9_]|->)*';
|
||||
$regex = '#(?:extract\()?\$[a-z](?:[a-z0-9_]|->)*';
|
||||
$regex .= '->trigger_event\((\[)?';
|
||||
$regex .= '\'' . $this->preg_match_event_name() . '(?(1)\', \'(?2))+\'';
|
||||
$regex .= '(?(1)\]), compact\(\$vars\)\)\);#';
|
||||
$regex .= '(?(1)\])(?:, compact\(\$vars\)\))?\);#';
|
||||
}
|
||||
|
||||
$match = array();
|
||||
|
Reference in New Issue
Block a user