These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | use AspectMock\Test as test; |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | class CodeceptionTest extends \Codeception\TestCase\Test |
||
5 | { |
||
6 | protected $container; |
||
7 | |||
8 | /** |
||
9 | * @var \AspectMock\Proxy\ClassProxy |
||
10 | */ |
||
11 | protected $codecept; |
||
12 | |||
13 | protected function _before() |
||
14 | { |
||
15 | $this->codecept = test::double('Robo\Task\Testing\Codecept', [ |
||
0 ignored issues
–
show
It seems like
\AspectMock\Test::double...e\Output\NullOutput())) can also be of type object<AspectMock\Proxy\InstanceProxy> . However, the property $codecept is declared as type object<AspectMock\Proxy\ClassProxy> . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
16 | 'executeCommand' => null, |
||
17 | 'output' => new \Symfony\Component\Console\Output\NullOutput() |
||
18 | ]); |
||
19 | } |
||
20 | |||
21 | // tests |
||
22 | public function testCodeceptionCommand() |
||
23 | { |
||
24 | verify(trim((new \Robo\Task\Testing\Codecept('codecept.phar'))->getCommand()))->equals('codecept.phar run'); |
||
25 | } |
||
26 | |||
27 | public function testCodeceptionRun() |
||
28 | { |
||
29 | $task = new \Robo\Task\Testing\Codecept('codecept.phar'); |
||
30 | $task->setLogger(new \Psr\Log\NullLogger()); |
||
31 | |||
32 | $task->run(); |
||
33 | $this->codecept->verifyInvoked('executeCommand'); |
||
34 | } |
||
35 | |||
36 | public function testCodeceptOptions() |
||
37 | { |
||
38 | verify((new \Robo\Task\Testing\Codecept('codecept')) |
||
39 | ->suite('unit') |
||
40 | ->test('Codeception/Command') |
||
41 | ->group('core') |
||
42 | ->env('process1') |
||
43 | ->coverage() |
||
44 | ->getCommand() |
||
45 | )->equals('codecept run unit Codeception/Command --group core --env process1 --coverage'); |
||
46 | |||
47 | $failGroupName = 'failed1'; |
||
48 | verify((new \Robo\Task\Testing\Codecept('codecept')) |
||
49 | ->test('tests/unit/Codeception') |
||
50 | ->configFile('~/Codeception') |
||
51 | ->xml('result.xml') |
||
52 | ->html() |
||
53 | ->noRebuild() |
||
54 | ->failGroup($failGroupName) |
||
55 | ->getCommand() |
||
56 | )->regExp("|^codecept run tests/unit/Codeception -c ~/Codeception --xml result\\.xml --html --no-rebuild --override ['\"]extensions: config: Codeception\\\\Extension\\\\RunFailed: fail-group: {$failGroupName}['\"]$|"); |
||
57 | |||
58 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->debug()->getCommand())->contains(' --debug'); |
||
59 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->silent()->getCommand())->contains(' --silent'); |
||
60 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->excludeGroup('g')->getCommand())->contains(' --skip-group g'); |
||
61 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->tap()->getCommand())->contains('--tap'); |
||
62 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->json()->getCommand())->contains('--json'); |
||
63 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->noRebuild()->getCommand())->contains('--no-rebuild'); |
||
64 | $failGroupName = 'failed2'; |
||
65 | verify((new \Robo\Task\Testing\Codecept('codecept.phar'))->failGroup($failGroupName)->getCommand()) |
||
66 | ->regExp("|--override ['\"]extensions: config: Codeception\\\\Extension\\\\RunFailed: fail-group: {$failGroupName}['\"]|"); |
||
67 | } |
||
68 | |||
69 | } |
||
70 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: