humbug /
box
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * This file is part of the box project. |
||
| 7 | * |
||
| 8 | * (c) Kevin Herrera <[email protected]> |
||
| 9 | * Théo Fidry <[email protected]> |
||
| 10 | * |
||
| 11 | * This source file is subject to the MIT license that is bundled |
||
| 12 | * with this source code in the file LICENSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | namespace KevinGH\Box\PhpScoper; |
||
| 16 | |||
| 17 | use Humbug\PhpScoper\Configuration\Configuration as PhpScoperConfiguration; |
||
| 18 | use Humbug\PhpScoper\Container as PhpScoperContainer; |
||
| 19 | use Humbug\PhpScoper\Scoper\Scoper as PhpScoperScoper; |
||
| 20 | use Humbug\PhpScoper\Symbol\SymbolsRegistry; |
||
| 21 | use function count; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @private |
||
| 25 | */ |
||
| 26 | final class SerializableScoper implements Scoper |
||
| 27 | { |
||
| 28 | private PhpScoperContainer $scoperContainer; |
||
| 29 | private PhpScoperScoper $scoper; |
||
| 30 | private SymbolsRegistry $symbolsRegistry; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var list<string> |
||
|
0 ignored issues
–
show
|
|||
| 34 | */ |
||
| 35 | public array $excludedFilePaths; |
||
| 36 | |||
| 37 | public function __construct( |
||
| 38 | private readonly PhpScoperConfiguration $scoperConfig, |
||
| 39 | string ...$excludedFilePaths, |
||
| 40 | ) { |
||
| 41 | $this->excludedFilePaths = $excludedFilePaths; |
||
|
0 ignored issues
–
show
It seems like
$excludedFilePaths of type array<integer,string> is incompatible with the declared type KevinGH\Box\PhpScoper\list of property $excludedFilePaths.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 42 | $this->symbolsRegistry = new SymbolsRegistry(); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function scope(string $filePath, string $contents): string |
||
| 46 | { |
||
| 47 | return $this->getScoper()->scope( |
||
| 48 | $filePath, |
||
| 49 | $contents, |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function changeSymbolsRegistry(SymbolsRegistry $symbolsRegistry): void |
||
| 54 | { |
||
| 55 | $this->symbolsRegistry = $symbolsRegistry; |
||
| 56 | |||
| 57 | unset($this->scoper); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function getSymbolsRegistry(): SymbolsRegistry |
||
| 61 | { |
||
| 62 | return $this->symbolsRegistry; |
||
| 63 | } |
||
| 64 | |||
| 65 | public function getPrefix(): string |
||
| 66 | { |
||
| 67 | return $this->scoperConfig->getPrefix(); |
||
| 68 | } |
||
| 69 | |||
| 70 | private function getScoper(): PhpScoperScoper |
||
| 71 | { |
||
| 72 | if (isset($this->scoper)) { |
||
| 73 | return $this->scoper; |
||
| 74 | } |
||
| 75 | |||
| 76 | if (!isset($this->scoperContainer)) { |
||
| 77 | $this->scoperContainer = new PhpScoperContainer(); |
||
| 78 | } |
||
| 79 | |||
| 80 | $this->scoper = $this->createScoper(); |
||
| 81 | |||
| 82 | return $this->scoper; |
||
| 83 | } |
||
| 84 | |||
| 85 | private function createScoper(): PhpScoperScoper |
||
| 86 | { |
||
| 87 | $scoper = $this->scoperContainer |
||
| 88 | ->getScoperFactory() |
||
| 89 | ->createScoper( |
||
| 90 | $this->scoperConfig, |
||
| 91 | $this->symbolsRegistry, |
||
| 92 | ); |
||
| 93 | |||
| 94 | if (0 === count($this->excludedFilePaths)) { |
||
| 95 | return $scoper; |
||
| 96 | } |
||
| 97 | |||
| 98 | return new ExcludedFilesScoper( |
||
| 99 | $scoper, |
||
| 100 | ...$this->excludedFilePaths, |
||
| 101 | ); |
||
| 102 | } |
||
| 103 | |||
| 104 | public function getExcludedFilePaths(): array |
||
| 105 | { |
||
| 106 | return $this->excludedFilePaths; |
||
| 107 | } |
||
| 108 | |||
| 109 | public function __serialize(): array |
||
| 110 | { |
||
| 111 | return [ |
||
| 112 | $this->scoperConfig->getPath(), |
||
| 113 | $this->scoperConfig->getPrefix(), |
||
| 114 | $this->excludedFilePaths, |
||
| 115 | ]; |
||
| 116 | } |
||
| 117 | |||
| 118 | public function __unserialize(array $data): void |
||
| 119 | { |
||
| 120 | [$configPath, $configPrefix, $excludedFilePaths] = $data; |
||
| 121 | |||
| 122 | $config = ConfigurationFactory::create($configPath)->withPrefix($configPrefix); |
||
| 123 | |||
| 124 | $this->__construct( |
||
| 125 | $config, |
||
| 126 | ...$excludedFilePaths, |
||
| 127 | ); |
||
| 128 | } |
||
| 129 | } |
||
| 130 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths