Skip to content
Merged
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
28 changes: 17 additions & 11 deletions src/Codeception/Lib/Connector/Symfony.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
<?php

namespace Codeception\Lib\Connector;

use InvalidArgumentException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
use Symfony\Component\HttpKernel\Kernel;

//Alias for Symfony < 4.3
if (!class_exists('Symfony\Component\HttpKernel\HttpKernelBrowser') && class_exists('Symfony\Component\HttpKernel\Client')) {
if (Kernel::VERSION_ID < 40300) {
class_alias('Symfony\Component\HttpKernel\Client', 'Symfony\Component\HttpKernel\HttpKernelBrowser');
}

class Symfony extends HttpKernelBrowser
{
/**
* @var boolean
* @var bool
*/
private $rebootable = true;

/**
* @var boolean
* @var bool
*/
private $hasPerformedRequest = false;

/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
* @var ContainerInterface
*/
private $container = null;

Expand All @@ -33,11 +38,11 @@ class Symfony extends HttpKernelBrowser
/**
* Constructor.
*
* @param \Symfony\Component\HttpKernel\Kernel $kernel A booted HttpKernel instance
* @param array $services An injected services
* @param boolean $rebootable
* @param Kernel $kernel A booted HttpKernel instance
* @param array $services An injected services
* @param bool $rebootable
*/
public function __construct(\Symfony\Component\HttpKernel\Kernel $kernel, array $services = [], $rebootable = true)
public function __construct(Kernel $kernel, array $services = [], $rebootable = true)
{
parent::__construct($kernel);
$this->followRedirects(true);
Expand All @@ -48,7 +53,8 @@ public function __construct(\Symfony\Component\HttpKernel\Kernel $kernel, array
}

/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @param Request $request
* @return Response
*/
protected function doRequest($request)
{
Expand Down Expand Up @@ -86,7 +92,7 @@ public function rebootKernel()
foreach ($this->persistentServices as $serviceName => $service) {
try {
$this->container->set($serviceName, $service);
} catch (\InvalidArgumentException $e) {
} catch (InvalidArgumentException $e) {
//Private services can't be set in Symfony 4
codecept_debug("[Symfony] Can't set persistent service $serviceName: " . $e->getMessage());
}
Expand Down