3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace AppBundle\Session; use Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag, Symfony\Component\EventDispatcher\EventSubscriberInterface, Symfony\Component\HttpKernel\Event\GetResponseEvent, Symfony\Component\HttpKernel\KernelEvents; class LegacySessionHandler implements EventSubscriberInterface { /** * @var string The name of the bag name containing all the brunel values */ const LEGACY_SESSION_BAG_NAME = 'old_app'; /** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ KernelEvents::REQUEST => 'onKernelRequest' ]; } /** * Transfer all the legacy session variables into a session bag, so $_SESSION['user_id'] will be accessible * via $session->getBag('old_app')->get('user_id'). The first bag name is defined as the class constant above * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { /** There might not be a session, in the case of the profiler / wdt (_profiler, _wdt) **/ if (!isset($_SESSION)) { return; } $session = $event->getRequest()->getSession(); /** Only create the old_app bag if it doesn't already exist **/ try { $bag = $session->getBag(self::LEGACY_SESSION_BAG_NAME); } catch (\InvalidArgumentException $e) { $bag = new NamespacedAttributeBag(self::LEGACY_SESSION_BAG_NAME); $bag->setName(self::LEGACY_SESSION_BAG_NAME); $session->registerBag($bag); } foreach ($_SESSION as $key => $value) { /** Symfony prefixes default session vars with an underscore thankfully, so ignore these **/ if (substr($key, 0, 1) === '_' && $key !== self::LEGACY_SESSION_BAG_NAME) { continue; } $bag->set($key, $value); } } }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
170.34 ms | 2775 KiB | 9 Q