Issues (163)

src/Patcher/PatcherChain.php (3 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper\Patcher;
16
17
use function array_reduce;
18
19
final class PatcherChain implements Patcher
20
{
21
    /**
22
     * @var array<(callable(string, string, string): string)|Patcher>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<(callable(string, ...ring): string)|Patcher> at position 3 could not be parsed: Expected ')' at position 3, but found 'callable'.
Loading history...
23
     */
24
    private array $patchers;
25
26
    /**
27
     * @param array<(callable(string, string, string): string)|Patcher> $patchers
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<(callable(string, ...ring): string)|Patcher> at position 3 could not be parsed: Expected ')' at position 3, but found 'callable'.
Loading history...
28
     */
29
    public function __construct(array $patchers = [])
30
    {
31
        $this->patchers = $patchers;
32
    }
33
34
    public function __invoke(string $filePath, string $prefix, string $contents): string
35
    {
36
        return array_reduce(
37
            $this->patchers,
38
            static fn (string $contents, callable $patcher) => $patcher($filePath, $prefix, $contents),
39
            $contents,
40
        );
41
    }
42
43
    /**
44
     * @internal
45
     *
46
     * @return array<(callable(string, string, string): string)|Patcher>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<(callable(string, ...ring): string)|Patcher> at position 3 could not be parsed: Expected ')' at position 3, but found 'callable'.
Loading history...
47
     */
48
    public function getPatchers(): array
49
    {
50
        return $this->patchers;
51
    }
52
}
53