Completed
Pull Request — master (#147)
by Joel
13:14
created

ContainerManagerTest   B

Complexity

Total Complexity 39

Size/Duplication

Total Lines 642
Duplicated Lines 21.34 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 39
c 2
b 0
f 0
lcom 1
cbo 7
dl 137
loc 642
rs 8.2

32 Methods

Rating   Name   Duplication   Size   Complexity  
A getManager() 0 4 1
A testFindAll() 0 7 1
A testCreate() 0 9 1
B testInteract() 0 37 2
A testCreateThrowsRightFormedException() 0 14 2
A testStart() 12 12 1
B testRunDefault() 0 28 1
B testRunAttach() 0 41 1
B testRunDaemon() 0 26 1
A testAttach() 20 20 1
A testAttachStderr() 20 20 1
A testWait() 12 12 1
A testWaitWithTimeout() 13 13 2
A testTimeoutExceptionHasRequest() 17 17 3
A testExposeFixedPort() 14 14 1
A testExposeRandomPort() 13 13 1
A testInspect() 0 11 1
A testRemove() 0 13 1
B testForceRemove() 0 24 3
A testRemoveContainers() 0 16 1
A testForceRemoveContainers() 16 16 1
A testTop() 0 17 1
A testChanges() 0 15 1
B testExport() 0 25 1
A testCopyToDisk() 0 16 1
A testLogs() 0 17 1
A testRestart() 0 16 1
B testKill() 0 26 1
B testExec() 0 33 1
A testExecInspect() 0 20 1
A testRename() 0 15 1
B testPause() 0 28 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Docker\Tests\Manager;
4
5
use Docker\API\Model\Container;
6
use Docker\Context\ContextBuilder;
7
use Docker\Tests\TestCase;
8
9
class ContainerManagerTest extends TestCase
10
{
11
    /**
12
     * Return the container manager
13
     *
14
     * @return \Docker\API\Resource\ContainerResource
15
     */
16
    private function getManager()
17
    {
18
        return $this->getDocker()->getContainerManager();
19
    }
20
21
    public function testFindAll()
22
    {
23
        $manager    = $this->getManager();
24
        $containers = $manager->findAll();
25
26
        $this->assertInternalType('array', $containers);
27
    }
28
29
    public function testCreate()
30
    {
31
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
32
33
        $manager = $this->getManager();
34
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
36
        $this->assertNotEmpty($container->getId());
37
    }
38
39
    public function testInteract()
40
    {
41
        $container = new Container([
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...=> true, 'Tty' => true).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
42
            'Image' => 'ubuntu:precise',
43
            'Cmd'   => ['/bin/bash'],
44
            'AttachStdin'  => false,
45
            'AttachStdout' => true,
46
            'AttachStderr' => true,
47
            'OpenStdin'    => true,
48
            'Tty'          => true,
49
        ]);
50
51
        $manager = $this->getManager();
52
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53
        $stream = $manager->interact($container);
0 ignored issues
show
Bug introduced by
The method interact() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
54
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
56
        $this->assertNotEmpty($container->getId());
57
        $this->assertInstanceOf('\Docker\Http\Stream\InteractiveStream', $stream);
58
59
        stream_set_blocking($stream->getSocket(), 0);
60
61
        $read   = [$stream->getSocket()];
62
        $write  = null;
63
        $expect = null;
64
65
        $stream->write("echo test\n");
66
        $data = "";
67
        do {
68
            $frame = $stream->receive(true);
69
            $data .= $frame['data'];
70
        } while (stream_select($read, $write, $expect, 1) > 0);
71
72
        $manager->stop($container, 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
73
74
        $this->assertRegExp('#root@'.substr($container->getId(), 0, 12).':/\# echo test#', $data, $data);
75
    }
76
77
    public function testCreateThrowsRightFormedException()
78
    {
79
        $container = new Container(['Image' => 'non-existent']);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'non-existent').

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
80
81
        $manager = $this->getManager();
82
83
        try {
84
            $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
85
        } catch (\GuzzleHttp\Exception\RequestException $e) {
0 ignored issues
show
Bug introduced by
The class GuzzleHttp\Exception\RequestException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
86
            $this->assertTrue($e->hasResponse());
87
            $this->assertEquals("404", $e->getResponse()->getStatusCode());
88
            $this->assertContains('No such image', $e->getMessage());
89
        }
90
    }
91
92 View Code Duplication
    public function testStart()
0 ignored issues
show
Duplication introduced by
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...
93
    {
94
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
95
96
        $manager = $this->getManager();
97
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
98
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
99
100
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
102
        $this->assertEquals(0, $runtimeInformations['State']['ExitCode']);
103
    }
104
105
    public function testRunDefault()
106
    {
107
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
108
        $manager = $this
109
            ->getMockBuilder('\Docker\Manager\ContainerManager')
110
            ->setMethods(['create', 'start', 'wait'])
111
            ->disableOriginalConstructor()
112
            ->getMock();
113
114
        $container->setExitCode(0);
0 ignored issues
show
Bug introduced by
The method setExitCode() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
116
        $manager->expects($this->once())
117
            ->method('create')
118
            ->with($this->isInstanceOf('\Docker\Container'))
119
            ->will($this->returnSelf());
120
121
        $manager->expects($this->once())
122
            ->method('start')
123
            ->with($this->isInstanceOf('\Docker\Container'))
124
            ->will($this->returnSelf());
125
126
        $manager->expects($this->once())
127
            ->method('wait')
128
            ->with($this->isInstanceOf('\Docker\Container'))
129
            ->will($this->returnSelf());
130
131
        $this->assertTrue($manager->run($container));
132
    }
133
134
    public function testRunAttach()
135
    {
136
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
137
        $manager = $this
138
            ->getMockBuilder('\Docker\Manager\ContainerManager')
139
            ->setMethods(['create', 'start', 'wait', 'attach'])
140
            ->disableOriginalConstructor()
141
            ->getMock();
142
143
        $response = $this->getMockBuilder('\GuzzleHttp\Message\Response')->disableOriginalConstructor()->getMock();
144
        $stream   = $this->getMockBuilder('\GuzzleHttp\Stream\Stream')->disableOriginalConstructor()->getMock();
145
146
        $container->setExitCode(0);
0 ignored issues
show
Bug introduced by
The method setExitCode() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147
        $callback = function () {};
148
149
        $manager->expects($this->once())
150
            ->method('create')
151
            ->with($this->isInstanceOf('\Docker\Container'))
152
            ->will($this->returnSelf());
153
154
        $manager->expects($this->once())
155
            ->method('attach')
156
            ->with($this->isInstanceOf('\Docker\Container'), $this->equalTo($callback), $this->equalTo(true), $this->equalTo(true), $this->equalTo(true), $this->equalTo(true), $this->equalTo(true), $this->equalTo(null))
157
            ->will($this->returnValue($response));
158
159
        $manager->expects($this->once())
160
            ->method('start')
161
            ->with($this->isInstanceOf('\Docker\Container'))
162
            ->will($this->returnSelf());
163
164
        $response->expects($this->once())
165
            ->method('getBody')
166
            ->will($this->returnValue($stream));
167
168
        $manager->expects($this->once())
169
            ->method('wait')
170
            ->with($this->isInstanceOf('\Docker\Container'))
171
            ->will($this->returnSelf());
172
173
        $this->assertTrue($manager->run($container, $callback));
174
    }
175
176
    public function testRunDaemon()
177
    {
178
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
179
        $manager = $this
180
            ->getMockBuilder('\Docker\Manager\ContainerManager')
181
            ->setMethods(['create', 'start', 'wait'])
182
            ->disableOriginalConstructor()
183
            ->getMock();
184
185
        $container->setExitCode(0);
0 ignored issues
show
Bug introduced by
The method setExitCode() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
186
187
        $manager->expects($this->once())
188
            ->method('create')
189
            ->with($this->isInstanceOf('\Docker\Container'))
190
            ->will($this->returnSelf());
191
192
        $manager->expects($this->once())
193
            ->method('start')
194
            ->with($this->isInstanceOf('\Docker\Container'))
195
            ->will($this->returnSelf());
196
197
        $manager->expects($this->never())
198
            ->method('wait');
199
200
        $this->assertNull($manager->run($container, null, [], true));
201
    }
202
203 View Code Duplication
    public function testAttach()
0 ignored issues
show
Duplication introduced by
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...
204
    {
205
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/bash', '-c', 'echo -n "output"']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...', 'echo -n "output"')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
206
        $manager = $this->getManager();
207
208
        $type   = 0;
209
        $output = "";
210
211
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
212
        $response = $manager->attach($container, function ($log, $stdtype) use (&$type, &$output) {
0 ignored issues
show
Documentation introduced by
function ($log, $stdtype...; $output = $log; } is of type object<Closure>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
213
            $type = $stdtype;
214
            $output = $log;
215
        });
216
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
217
218
        $response->getBody()->getContents();
219
220
        $this->assertEquals(1, $type);
221
        $this->assertEquals('output', $output);
222
    }
223
224 View Code Duplication
    public function testAttachStderr()
0 ignored issues
show
Duplication introduced by
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...
225
    {
226
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/bash', '-c', 'echo -n "error" 1>&2']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...echo -n "error" 1>&2')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
227
        $manager = $this->getManager();
228
229
        $type   = 0;
230
        $output = "";
231
232
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
233
        $response = $manager->attach($container, function ($log, $stdtype) use (&$type, &$output) {
0 ignored issues
show
Documentation introduced by
function ($log, $stdtype...; $output = $log; } is of type object<Closure>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
234
            $type = $stdtype;
235
            $output = $log;
236
        });
237
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
238
239
        $response->getBody()->getContents();
240
241
        $this->assertEquals(2, $type);
242
        $this->assertEquals('error', $output);
243
    }
244
245
    /**
246
     * Not sure how to reliably test that we actually waited for the container
247
     * but this should at least ensure no exception is thrown
248
     */
249 View Code Duplication
    public function testWait()
0 ignored issues
show
Duplication introduced by
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...
250
    {
251
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '1']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '1')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
252
253
        $manager = $this->getManager();
254
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
255
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
256
257
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
258
259
        $this->assertEquals(0, $runtimeInformations['State']['ExitCode']);
260
    }
261
262
    /**
263
     * @expectedException GuzzleHttp\Exception\RequestException
264
     */
265 View Code Duplication
    public function testWaitWithTimeout()
0 ignored issues
show
Duplication introduced by
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...
266
    {
267
        if (getenv('DOCKER_TLS_VERIFY')) {
268
            $this->markTestSkipped('This test failed when using ssl due to this bug : https://bugs.php.net/bug.php?id=41631');
269
        }
270
271
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '2']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '2')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
272
273
        $manager = $this->getManager();
274
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
275
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
276
        $manager->wait($container, 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
277
    }
278
279 View Code Duplication
    public function testTimeoutExceptionHasRequest()
0 ignored issues
show
Duplication introduced by
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...
280
    {
281
        if (getenv('DOCKER_TLS_VERIFY')) {
282
            $this->markTestSkipped('This test failed when using ssl due to this bug : https://bugs.php.net/bug.php?id=41631');
283
        }
284
285
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '2']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '2')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
286
287
        $manager = $this->getManager();
288
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
289
290
        try {
291
            $manager->wait($container, 1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
292
        } catch (RequestException $e) {
0 ignored issues
show
Bug introduced by
The class Docker\Tests\Manager\RequestException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
293
            $this->assertInstanceOf('Docker\\Http\\Request', $e->getRequest());
294
        }
295
    }
296
297 View Code Duplication
    public function testExposeFixedPort()
0 ignored issues
show
Duplication introduced by
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...
298
    {
299
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '1']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '1')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
300
301
        $port = new Port('8888:80/tcp');
302
303
        $container->setExposedPorts($port);
0 ignored issues
show
Bug introduced by
The method setExposedPorts() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
304
305
        $manager = $this->getManager();
306
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
307
        $manager->start($container, ['PortBindings' => $port->toSpec()]);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
308
309
        $this->assertEquals(8888, $container->getMappedPort(80)->getHostPort());
0 ignored issues
show
Bug introduced by
The method getMappedPort() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
310
    }
311
312 View Code Duplication
    public function testExposeRandomPort()
0 ignored issues
show
Duplication introduced by
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...
313
    {
314
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '1']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '1')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
315
316
        $port = new Port('80/tcp');
317
        $container->setExposedPorts($port);
0 ignored issues
show
Bug introduced by
The method setExposedPorts() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
318
319
        $manager = $this->getManager();
320
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
321
        $manager->start($container, ['PortBindings' => $port->toSpec()]);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
322
323
        $this->assertInternalType('integer', $container->getMappedPort(80)->getHostPort());
0 ignored issues
show
Bug introduced by
The method getMappedPort() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
324
    }
325
326
    public function testInspect()
327
    {
328
        $manager = $this->getManager();
329
330
        $this->assertEquals(null, $manager->find('foo'));
331
332
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
333
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
334
335
        $this->assertInstanceOf('Docker\\Container', $manager->find($container->getId()));
336
    }
337
338
    public function testRemove()
339
    {
340
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['date']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...'Cmd' => array('date')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
341
342
        $manager = $this->getManager();
343
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
344
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
345
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
346
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
347
348
        $this->setExpectedException('\\Docker\\Exception\\ContainerNotFoundException', 'Container not found');
349
        $manager->inspect($container);
0 ignored issues
show
Bug introduced by
The method inspect() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
350
    }
351
    
352
    public function testForceRemove()
353
    {
354
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['tail', '-f', '/var/log/lastlog']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...', '/var/log/lastlog')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
355
356
        $manager = $this->getManager();
357
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
358
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
359
360
        try {
361
            $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
362
            $this->assertTrue(false);
363
        } catch (APIException $e) {
0 ignored issues
show
Bug introduced by
The class Docker\Tests\Manager\APIException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
364
            $this->assertTrue(true);
365
        }
366
367
        $manager->remove($container, false, true);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
368
369
        try {
370
            $manager->inspect($container);
0 ignored issues
show
Bug introduced by
The method inspect() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
371
            $this->assertTrue(false);
372
        } catch (ContainerNotFoundException $e) {
0 ignored issues
show
Bug introduced by
The class Docker\Tests\Manager\ContainerNotFoundException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
373
            $this->assertTrue(true);
374
        }
375
    }
376
377
    public function testRemoveContainers()
378
    {
379
        $containers = ['3360ea744df2', 'a412d121d015'];
380
        $manager = $this
381
            ->getMockBuilder('\Docker\Manager\ContainerManager')
382
            ->setMethods(['remove'])
383
            ->disableOriginalConstructor()
384
            ->getMock();
385
386
        $manager->expects($this->exactly(2))
387
            ->method('remove')
388
            ->with($this->isInstanceOf('\Docker\Container'), false)
389
            ->will($this->returnSelf());
390
391
        $manager->removeContainers($containers);
392
    }
393
    
394 View Code Duplication
    public function testForceRemoveContainers()
0 ignored issues
show
Duplication introduced by
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...
395
    {
396
        $containers = ['3360ea744df2', 'a412d121d015'];
397
        $manager = $this
398
            ->getMockBuilder('\Docker\Manager\ContainerManager')
399
            ->setMethods(['remove'])
400
            ->disableOriginalConstructor()
401
            ->getMock();
402
403
        $manager->expects($this->exactly(2))
404
            ->method('remove')
405
            ->with($this->isInstanceOf('\Docker\Container'), false, true)
406
            ->will($this->returnSelf());
407
408
        $manager->removeContainers($containers, false, true);
409
    }
410
411
    public function testTop()
412
    {
413
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['sleep', '5']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...=> array('sleep', '5')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
414
        $manager = $this->getManager();
415
        $manager->run($container, null, [], true);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
416
417
        sleep(1);
418
419
        $processes = $manager->top($container);
0 ignored issues
show
Bug introduced by
The method top() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
420
421
        $this->assertCount(1, $processes);
422
        $this->assertArrayHasKey('COMMAND', $processes[0]);
423
        $this->assertEquals('sleep 5', $processes[0]['COMMAND']);
424
425
        $manager->kill($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
426
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
427
    }
428
429
    public function testChanges()
430
    {
431
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['touch', '/docker-php-test']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...', '/docker-php-test')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
432
        $manager = $this->getManager();
433
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
434
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
435
436
        $changes = $manager->changes($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
437
438
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
439
440
        $this->assertCount(1, $changes);
441
        $this->assertEquals('/docker-php-test', $changes[0]['Path']);
442
        $this->assertEquals(1, $changes[0]['Kind']);
443
    }
444
445
    public function testExport()
446
    {
447
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['touch', '/docker-php-test']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...', '/docker-php-test')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
448
        $manager = $this->getManager();
449
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
450
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
451
452
        $exportStream = $manager->export($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
453
454
        $this->assertInstanceOf('\GuzzleHttp\Stream\Stream', $exportStream);
455
456
        $tarFileName  = tempnam(sys_get_temp_dir(), 'docker-php-export-test-');
457
        $tarFile      = fopen($tarFileName, 'w+');
458
459
        stream_copy_to_stream($exportStream->detach(), $tarFile);
0 ignored issues
show
Bug introduced by
The method detach() does not seem to exist on object<Psr\Http\Message\ResponseInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
460
        fclose($tarFile);
461
462
        exec('/usr/bin/env tar -tf '.$tarFileName, $output);
463
464
        $this->assertContains('docker-php-test', $output);
465
        $this->assertContains('.dockerinit', $output);
466
467
        unlink($tarFileName);
468
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
469
    }
470
471
    public function testCopyToDisk()
472
    {
473
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['touch', '/etc/default/docker-php-test']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ault/docker-php-test')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
474
        $manager = $this->getManager();
475
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
476
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
477
478
        $tarFileName  = tempnam(sys_get_temp_dir(), 'testcopyToDisk.tar');
479
        $manager->copyToDisk($container, '/etc/default', $tarFileName);
0 ignored issues
show
Bug introduced by
The method copyToDisk() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
480
481
        exec('/usr/bin/env tar -tf '.$tarFileName, $output);
482
        $this->assertContains('default/docker-php-test', $output);
483
484
        unlink($tarFileName);
485
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
486
    }
487
488
    public function testLogs()
489
    {
490
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['echo', 'test']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... array('echo', 'test')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
491
        $manager = $this->getManager();
492
        $manager->run($container);
0 ignored issues
show
Bug introduced by
The method run() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
493
        $manager->stop($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
494
        $logs = $manager->logs($container, false, true);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
495
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
496
497
        $this->assertGreaterThanOrEqual(1, count($logs));
498
499
        $logs = array_map(function ($value) {
500
            return $value['output'];
501
        }, $logs);
502
503
        $this->assertContains("test", implode("", $logs));
504
    }
505
506
    public function testRestart()
507
    {
508
        $manager = $this->getManager();
509
510
        $container = new Container(['Image' => 'busybox', 'Cmd' => ['sleep', '10']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'busybo...> array('sleep', '10')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
511
512
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
513
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
514
        $this->assertEquals('0001-01-01T00:00:00Z', $container->getRuntimeInformations()['State']['FinishedAt']);
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
515
516
        $manager->restart($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
517
        $this->assertNotEquals('0001-01-01T00:00:00Z', $container->getRuntimeInformations()['State']['FinishedAt']);
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
518
519
        $manager->stop($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
520
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
521
    }
522
523
    public function testKill()
524
    {
525
        $manager = $this->getManager();
526
        $dockerFileBuilder = new ContextBuilder();
527
        $dockerFileBuilder->from('ubuntu:precise');
528
        $dockerFileBuilder->add('/kill.sh', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'script' . DIRECTORY_SEPARATOR . 'kill.sh'));
529
        $dockerFileBuilder->run('chmod +x /kill.sh');
530
531
        $this->getDocker()->build($dockerFileBuilder->getContext(), 'docker-php-kill-test', null, true, false, true);
532
533
        $container = new Container(['Image' => 'docker-php-kill-test:latest', 'Cmd' => ['/kill.sh']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'docker...' => array('/kill.sh')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
534
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
535
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
536
        $manager->kill($container, "SIGHUP");
0 ignored issues
show
Documentation introduced by
'SIGHUP' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
537
        $manager->wait($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
538
539
        $logs = $manager->logs($container, false, true);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
540
        $logs = array_map(function ($value) {
541
            return $value['output'];
542
        }, $logs);
543
544
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
545
        $this->getDocker()->getImageManager()->remove($container->getImage());
546
547
        $this->assertContains('HUP', implode("", $logs));
548
    }
549
550
    public function testExec()
551
    {
552
        $manager = $this->getManager();
553
        $dockerFileBuilder = new ContextBuilder();
554
        $dockerFileBuilder->from('ubuntu:precise');
555
        $dockerFileBuilder->add('/daemon.sh', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'script' . DIRECTORY_SEPARATOR . 'daemon.sh'));
556
        $dockerFileBuilder->run('chmod +x /daemon.sh');
557
558
        $this->getDocker()->build($dockerFileBuilder->getContext(), 'docker-php-restart-test', null, true, false, true);
559
560
        $container = new Container(['Image' => 'docker-php-restart-test', 'Cmd' => ['/daemon.sh']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'docker...=> array('/daemon.sh')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
561
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
562
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
563
564
        $type   = 0;
565
        $output = "";
566
        $execId = $manager->exec($container, ['/bin/bash', '-c', 'echo -n "output"']);
0 ignored issues
show
Bug introduced by
The method exec() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
567
568
        $this->assertNotNull($execId);
569
570
        $response = $manager->execstart($execId, function ($log, $stdtype) use (&$type, &$output) {
0 ignored issues
show
Bug introduced by
The method execstart() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
571
            $type = $stdtype;
572
            $output = $log;
573
        });
574
575
        $response->getBody()->getContents();
576
577
        $manager->kill($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
578
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
579
580
        $this->assertEquals(1, $type);
581
        $this->assertEquals('output', $output);
582
    }
583
584
    public function testExecInspect()
585
    {
586
        $manager = $this->getManager();
587
        $dockerFileBuilder = new ContextBuilder();
588
        $dockerFileBuilder->from('ubuntu:precise');
589
        $dockerFileBuilder->add('/daemon.sh', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'script' . DIRECTORY_SEPARATOR . 'daemon.sh'));
590
        $dockerFileBuilder->run('chmod +x /daemon.sh');
591
592
        $this->getDocker()->build($dockerFileBuilder->getContext(), 'docker-php-restart-test', null, true, false, true);
593
594
        $container = new Container(['Image' => 'docker-php-restart-test', 'Cmd' => ['/daemon.sh']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'docker...=> array('/daemon.sh')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
595
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
596
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
597
598
        $execId = $manager->exec($container, ['/bin/bash', '-c', 'echo -n "output"']);
0 ignored issues
show
Bug introduced by
The method exec() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
599
        $inspection = $manager->execinspect($execId);
0 ignored issues
show
Bug introduced by
The method execinspect() does not seem to exist on object<Docker\API\Resource\ContainerResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
600
601
        $this->assertEquals(0, $inspection->ExitCode);
602
        $this->assertEquals(false, $inspection->Running);
603
    }
604
605
    public function testRename()
606
    {
607
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/true']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu... => array('/bin/true')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
608
609
        $manager = $this->getManager();
610
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
611
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
612
        $manager->rename($container, 'FoobarRenamed');
0 ignored issues
show
Documentation introduced by
'FoobarRenamed' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
613
614
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Unused Code introduced by
$runtimeInformations is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
615
		
616
        $this->assertInstanceOf('Docker\\Container', $manager->find('FoobarRenamed'));
617
        $manager->stop($container);   // cleanup
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
618
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
619
    }
620
621
    public function testPause()
622
    {
623
        $container = new Container(['Image' => 'ubuntu:precise', 'Cmd' => ['/bin/sleep', '1']]);
0 ignored issues
show
Unused Code introduced by
The call to Container::__construct() has too many arguments starting with array('Image' => 'ubuntu...ray('/bin/sleep', '1')).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
624
625
        $manager = $this->getManager();
626
        $manager->create($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a object<Docker\API\Model\ContainerConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
627
        $manager->start($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
628
629
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
630
        $this->assertEquals(false, $runtimeInformations['State']['Paused']);
631
        $this->assertEquals(true, $runtimeInformations['State']['Running']);
632
633
        $manager->pause($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
634
635
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
636
        $this->assertEquals(true, $runtimeInformations['State']['Paused']);
637
        $this->assertEquals(true, $runtimeInformations['State']['Running']);
638
639
        $manager->unpause($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
640
641
        $runtimeInformations = $container->getRuntimeInformations();
0 ignored issues
show
Bug introduced by
The method getRuntimeInformations() does not seem to exist on object<Docker\API\Model\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
642
        $this->assertEquals(false, $runtimeInformations['State']['Paused']);
643
        $this->assertEquals(true, $runtimeInformations['State']['Running']);
644
645
        // cleanup
646
        $manager->stop($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
647
        $manager->remove($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<Docker\API\Model\Container>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
648
    }
649
650
}
651