Passed
Pull Request — master (#429)
by Théo
02:35
created

demo.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
use function Humbug\PhpScoper\json_decode;
6
use function KevinGH\Box\FileSystem\file_contents;
7
use function KevinGH\Box\parallel_map;
8
9
require __DIR__.'/vendor/autoload.php';
10
11
$config = KevinGH\Box\Configuration\Configuration::create(
12
    __DIR__.'/requirement-checker/box.json.dist',
13
    json_decode(
0 ignored issues
show
It seems like json_decode(file_get_con...hecker/box.json.dist')) can also be of type array; however, parameter $raw of KevinGH\Box\Configuration\Configuration::create() does only seem to accept stdClass, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

13
    /** @scrutinizer ignore-type */ json_decode(
Loading history...
14
        file_get_contents(__DIR__.'/requirement-checker/box.json.dist')
15
    )
16
);
17
18
$mapFile = $config->getFileMapper();
19
$compactors = $config->getCompactors();
20
$cwd = getcwd();
21
22
$processFile = static function (string $file) use ($cwd, $mapFile, $compactors): array {
23
    chdir($cwd);
24
25
    // Keep the fully qualified call here since this function may be executed without the right autoloading
26
    // mechanism
27
    \KevinGH\Box\register_aliases();
28
    if (true === \KevinGH\Box\is_parallel_processing_enabled()) {
29
        \KevinGH\Box\register_error_handler();
30
    }
31
32
    $contents = file_contents($file);
33
34
    $local = $mapFile($file);
35
36
    $processedContents = $compactors->compact($local, $contents);
37
38
    return [$local, $processedContents, $compactors->getScoperWhitelist()];
39
};
40
41
$files = [__DIR__.'/requirement-checker/composer.json'];
42
43
parallel_map($files, $processFile);
44