GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9e4218...09e05d )
by Cees-Jan
04:46
created

src/TestCase.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types=1);
3
4
namespace ApiClients\Tools\ResourceTestUtilities;
5
6
use GeneratedHydrator\Configuration;
7
use Phake;
8
use ApiClients\Foundation\Transport\Client;
9
use ApiClients\Foundation\Transport\Hydrator;
10
11
abstract class TestCase extends \PHPUnit_Framework_TestCase
12
{
13
    /**
14
     * @var string
15
     */
16
    private $tmpDir;
17
18
    /**
19
     * @var string
20
     */
21
    private $tmpNamespace;
22
23 6
    public function setUp()
24
    {
25 6
        parent::setUp();
26 6
        $this->tmpDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('api-clients-tests-') . DIRECTORY_SEPARATOR;
27 6
        mkdir($this->tmpDir, 0777, true);
28 6
        $this->tmpNamespace = Configuration::DEFAULT_GENERATED_CLASS_NAMESPACE . uniqid('ApiClientsTestNamespace');
29 6
    }
30
31 6
    public function tearDown()
32
    {
33 6
        parent::tearDown();
34 6
        $this->rmdir($this->tmpDir);
35 6
    }
36
37 6
    protected function rmdir($dir)
38
    {
39 6
        $directory = dir($dir);
40 6
        while (false !== ($entry = $directory->read())) {
41 6
            if (in_array($entry, ['.', '..'])) {
42 6
                continue;
43
            }
44
45
            if (is_dir($dir . $entry)) {
46
                $this->rmdir($dir . $entry . DIRECTORY_SEPARATOR);
47
                continue;
48
            }
49
50
            if (is_file($dir . $entry)) {
51
                unlink($dir . $entry);
52
                continue;
53
            }
54
        }
55 6
        $directory->close();
56 6
        rmdir($dir);
57 6
    }
58
59
    protected function getTmpDir(): string
60
    {
61
        return $this->tmpDir;
62
    }
63
64
    protected function getRandomNameSpace(): string
65
    {
66
        return $this->tmpNamespace;
67
    }
68
69
    public function hydrate($class, $json, $namespace)
70
    {
71
        return (new Hydrator(Phake::mock(Client::class), [
0 ignored issues
show
\Phake::mock(\ApiClients...ransport\Client::class) is of type object<Phake_IMock>, but the function expects a object<ApiClients\Foundation\Transport\Client>.

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...
72
            'resource_namespace' => $namespace,
73
            'resource_hydrator_cache_dir' => $this->getTmpDir(),
74
            'resource_hydrator_namespace' => $this->getRandomNameSpace(),
75
        ]))->hydrateFQCN($class, $json);
76
    }
77
}
78