Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / event-dispatcher / Debug / WrappedListener.php
index e16627d6ad91bd29a2be0bbf74e824d4b4a9e84f..45208a19b2440fa8d8023a0797cae61fecc39590 100644 (file)
@@ -14,6 +14,8 @@ namespace Symfony\Component\EventDispatcher\Debug;
 use Symfony\Component\Stopwatch\Stopwatch;
 use Symfony\Component\EventDispatcher\Event;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\VarDumper\Caster\ClassStub;
+use Symfony\Component\VarDumper\Cloner\VarCloner;
 
 /**
  * @author Fabien Potencier <fabien@symfony.com>
@@ -26,6 +28,10 @@ class WrappedListener
     private $stoppedPropagation;
     private $stopwatch;
     private $dispatcher;
+    private $pretty;
+    private $data;
+
+    private static $cloner;
 
     public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
     {
@@ -35,6 +41,26 @@ class WrappedListener
         $this->dispatcher = $dispatcher;
         $this->called = false;
         $this->stoppedPropagation = false;
+
+        if (is_array($listener)) {
+            $this->name = is_object($listener[0]) ? get_class($listener[0]) : $listener[0];
+            $this->pretty = $this->name.'::'.$listener[1];
+        } elseif ($listener instanceof \Closure) {
+            $this->pretty = $this->name = 'closure';
+        } elseif (is_string($listener)) {
+            $this->pretty = $this->name = $listener;
+        } else {
+            $this->name = get_class($listener);
+            $this->pretty = $this->name.'::__invoke';
+        }
+
+        if (null !== $name) {
+            $this->name = $name;
+        }
+
+        if (null === self::$cloner) {
+            self::$cloner = class_exists(ClassStub::class) ? new VarCloner() : false;
+        }
     }
 
     public function getWrappedListener()
@@ -52,6 +78,25 @@ class WrappedListener
         return $this->stoppedPropagation;
     }
 
+    public function getPretty()
+    {
+        return $this->pretty;
+    }
+
+    public function getInfo($eventName)
+    {
+        if (null === $this->data) {
+            $this->data = false !== self::$cloner ? self::$cloner->cloneVar(array(new ClassStub($this->pretty.'()', $this->listener)))->seek(0) : $this->pretty;
+        }
+
+        return array(
+            'event' => $eventName,
+            'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null,
+            'pretty' => $this->pretty,
+            'data' => $this->data,
+        );
+    }
+
     public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
     {
         $this->called = true;