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 DockerTest extends \Codeception\TestCase\Test |
||
5 | { |
||
6 | protected $container; |
||
7 | |||
8 | /** |
||
9 | * @var \AspectMock\Proxy\ClassProxy |
||
10 | */ |
||
11 | protected $baseDocker; |
||
12 | |||
13 | protected function _before() |
||
14 | { |
||
15 | $this->baseDocker = test::double('Robo\Task\Docker\Base', [ |
||
0 ignored issues
–
show
It seems like
\AspectMock\Test::double...\Psr\Log\NullLogger())) can also be of type object<AspectMock\Proxy\InstanceProxy> . However, the property $baseDocker 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;
}
Loading history...
|
|||
16 | 'output' => new \Symfony\Component\Console\Output\NullOutput(), |
||
17 | 'logger' => new \Psr\Log\NullLogger(), |
||
18 | ]); |
||
19 | } |
||
20 | // tests |
||
21 | View Code Duplication | public function testDockerBuild() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
22 | { |
||
23 | $docker = test::double('Robo\Task\Docker\Build', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
24 | |||
25 | (new \Robo\Task\Docker\Build())->run(); |
||
26 | $docker->verifyInvoked('executeCommand', ['docker build .']); |
||
27 | |||
28 | (new \Robo\Task\Docker\Build())->tag('something')->run(); |
||
29 | $docker->verifyInvoked('executeCommand', ['docker build -t something .']); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | public function testDockerCommit() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
33 | { |
||
34 | $docker = test::double('Robo\Task\Docker\Commit', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
35 | |||
36 | (new \Robo\Task\Docker\Commit('cid'))->run(); |
||
37 | $docker->verifyInvoked('executeCommand', ['docker commit cid ']); |
||
38 | |||
39 | (new \Robo\Task\Docker\Commit('cid'))->name('somename')->run(); |
||
40 | $docker->verifyInvoked('executeCommand', ['docker commit cid somename ']); |
||
41 | } |
||
42 | |||
43 | View Code Duplication | public function testDockerExec() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
44 | { |
||
45 | $docker = test::double('Robo\Task\Docker\Exec', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
46 | |||
47 | (new \Robo\Task\Docker\Exec('cid'))->run(); |
||
48 | $docker->verifyInvoked('executeCommand', ['docker exec cid ']); |
||
49 | |||
50 | (new \Robo\Task\Docker\Exec('cid'))->exec('pwd')->run(); |
||
51 | $docker->verifyInvoked('executeCommand', ['docker exec cid pwd']); |
||
52 | } |
||
53 | |||
54 | View Code Duplication | public function testDockerPull() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
55 | { |
||
56 | $docker = test::double('Robo\Task\Docker\Pull', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
57 | |||
58 | (new \Robo\Task\Docker\Pull('image'))->run(); |
||
59 | $docker->verifyInvoked('executeCommand', ['docker pull image ']); |
||
60 | } |
||
61 | |||
62 | View Code Duplication | public function testDockerRemove() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
63 | { |
||
64 | $docker = test::double('Robo\Task\Docker\Remove', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
65 | |||
66 | (new \Robo\Task\Docker\Remove('container'))->run(); |
||
67 | $docker->verifyInvoked('executeCommand', ['docker rm container ']); |
||
68 | } |
||
69 | |||
70 | View Code Duplication | public function testDockerRun() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
71 | { |
||
72 | $docker = test::double('Robo\Task\Docker\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger(), 'getUniqId' => '12345']); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
73 | |||
74 | (new \Robo\Task\Docker\Run('cid'))->tmpDir('/tmp')->run(); |
||
75 | $docker->verifyInvoked('executeCommand', ['docker run -i --cidfile /tmp/docker_12345.cid cid']); |
||
76 | |||
77 | (new \Robo\Task\Docker\Run('cid'))->tmpDir('/tmp')->exec('pwd')->run(); |
||
78 | $docker->verifyInvoked('executeCommand', ['docker run -i --cidfile /tmp/docker_12345.cid cid pwd']); |
||
79 | } |
||
80 | |||
81 | View Code Duplication | public function testDockerStart() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
82 | { |
||
83 | $docker = test::double('Robo\Task\Docker\Start', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
84 | |||
85 | (new \Robo\Task\Docker\Start('cid'))->run(); |
||
86 | $docker->verifyInvoked('executeCommand', ['docker start cid']); |
||
87 | } |
||
88 | |||
89 | View Code Duplication | public function testDockerStop() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
90 | { |
||
91 | $docker = test::double('Robo\Task\Docker\Stop', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
||
0 ignored issues
–
show
The class
Robo\Config has been deprecated with message: Use \Robo\Config\Config
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.
Loading history...
|
|||
92 | |||
93 | (new \Robo\Task\Docker\Stop('cid'))->run(); |
||
94 | $docker->verifyInvoked('executeCommand', ['docker stop cid']); |
||
95 | } |
||
96 | } |
||
97 |
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: