Conditions | 5 |
Paths | 3 |
Total Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function __construct(KernelInterface $kernel, ?string $baseUrl) |
||
15 | { |
||
16 | if (!$kernel->getContainer()->has('test.client')) { |
||
17 | throw new \RuntimeException(sprintf( |
||
18 | 'Kernel "%s" used by Behat with "%s" environment and debug %s does not have "test.client" service. ' . "\n" . |
||
19 | 'Please make sure the kernel is using "test" environment or have "framework.test" configuration option enabled.', |
||
20 | get_class($kernel), |
||
21 | $kernel->getEnvironment(), |
||
22 | $kernel->isDebug() ? 'enabled' : 'disabled' |
||
23 | )); |
||
24 | } |
||
25 | |||
26 | /** @var object $testClient */ |
||
27 | $testClient = $kernel->getContainer()->get('test.client'); |
||
28 | |||
29 | if (!$testClient instanceof Client && !$testClient instanceof AbstractBrowser) { |
||
|
|||
30 | throw new \RuntimeException(sprintf( |
||
31 | 'Service "test.client" should be an instance of "%s" or "%s", "%s" given.', |
||
32 | Client::class, |
||
33 | AbstractBrowser::class, |
||
34 | get_class($testClient) |
||
35 | )); |
||
36 | } |
||
37 | |||
38 | parent::__construct($testClient, $baseUrl); |
||
39 | } |
||
40 | } |
||
41 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.