Test Failed
Push — master ( 1b8cd6...6d13a4 )
by Mariano
09:42
created

Phiremock::mustRunForSuite()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 2
nc 2
nop 2
1
<?php
2
/**
3
 * This file is part of phiremock-codeception-extension.
4
 *
5
 * phiremock-codeception-extension is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * phiremock-codeception-extension is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with phiremock-codeception-extension.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace Codeception\Extension;
20
21
use Codeception\Event\SuiteEvent;
22
use Codeception\Exception\ConfigurationException;
23
use Codeception\Extension as CodeceptionExtension;
24
use Codeception\Suite;
25
use Mcustiel\Phiremock\Codeception\Extension\Config;
26
use Mcustiel\Phiremock\Codeception\Extension\PhiremockProcessManager;
27
use Mcustiel\Phiremock\Codeception\Extension\ReadinessCheckerFactory;
28
use Mcustiel\Phiremock\Codeception\Extension\Phiremock72;
0 ignored issues
show
Bug introduced by
The type Mcustiel\Phiremock\Codec...n\Extension\Phiremock72 was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
This use statement conflicts with another class in this namespace, Codeception\Extension\Phiremock72. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
29
use Mcustiel\Phiremock\Codeception\Extension\Phiremock74p;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Codeception\Extension\Phiremock74p. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
Bug introduced by
The type Mcustiel\Phiremock\Codec...\Extension\Phiremock74p was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
31
class Phiremock extends CodeceptionExtension
32
{
33
    /** @var array */
34
    public static $events = [
35
        'suite.before' => 'startProcess',
36
        'suite.after'  => 'stopProcess',
37
    ];
38
39
    /** Phiremock72|Phiremock74p */
40
    private $instance;
41
42
    /**  @throws ConfigurationException */
43
    public function __construct(
44
        array $config,
45
        array $options,
46
        PhiremockProcessManager $process = null
47
    ) {
48
        if (version_compare(PHP_VERSION, '7.4.0') >= 0) {
49
            $this->instance = new Phiremock74p($config, $options, $process);
50
        } else {
51
            $this->instance = new Phiremock72($config, $options, $process);
52
        }
53
    }
54
55
    public function startProcess(SuiteEvent $event): void
56
    {
57
        $this->instance->startProcess($event);
58
    }
59
60
    public function stopProcess(): void
61
    {
62
        $this->instance->stopProcess();
63
    }
64
}
65