pheature-flags /
toggle-model
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Pheature\Model\Toggle; |
||
| 6 | |||
| 7 | use Pheature\Core\Toggle\Read\Segment; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @psalm-import-type SegmentPayload from Segment |
||
| 11 | */ |
||
| 12 | final class StrictMatchingSegment implements Segment |
||
| 13 | { |
||
| 14 | public const NAME = 'strict_matching_segment'; |
||
| 15 | private string $id; |
||
| 16 | /** @var SegmentPayload */ |
||
|
0 ignored issues
–
show
|
|||
| 17 | private array $criteria; |
||
| 18 | |||
| 19 | /** @param SegmentPayload $criteria */ |
||
| 20 | 15 | public function __construct(string $id, array $criteria) |
|
| 21 | { |
||
| 22 | 15 | $this->id = $id; |
|
| 23 | 15 | $this->criteria = $criteria; |
|
|
0 ignored issues
–
show
It seems like
$criteria of type array is incompatible with the declared type Pheature\Model\Toggle\SegmentPayload of property $criteria.
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...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | 7 | public function id(): string |
|
| 27 | { |
||
| 28 | 7 | return $this->id; |
|
| 29 | } |
||
| 30 | |||
| 31 | 7 | public function type(): string |
|
| 32 | { |
||
| 33 | 7 | return self::NAME; |
|
| 34 | } |
||
| 35 | |||
| 36 | 7 | public function criteria(): array |
|
| 37 | { |
||
| 38 | 7 | return $this->criteria; |
|
| 39 | } |
||
| 40 | |||
| 41 | 12 | public function match(array $payload): bool |
|
| 42 | { |
||
| 43 | 12 | $match = false; |
|
| 44 | |||
| 45 | /** @var mixed $value */ |
||
| 46 | 12 | foreach ($this->criteria as $key => $value) { |
|
| 47 | 10 | if (array_key_exists($key, $payload) && $value === $payload[$key]) { |
|
| 48 | 6 | $match = true; |
|
| 49 | 6 | continue; |
|
| 50 | } |
||
| 51 | |||
| 52 | 4 | return false; |
|
| 53 | } |
||
| 54 | |||
| 55 | 8 | return $match; |
|
| 56 | } |
||
| 57 | |||
| 58 | 8 | public function toArray(): array |
|
| 59 | { |
||
| 60 | return [ |
||
| 61 | 8 | 'id' => $this->id, |
|
| 62 | 'type' => self::NAME, |
||
| 63 | 8 | 'criteria' => $this->criteria, |
|
| 64 | ]; |
||
| 65 | } |
||
| 66 | |||
| 67 | 7 | public function jsonSerialize(): array |
|
| 68 | { |
||
| 69 | 7 | return $this->toArray(); |
|
| 70 | } |
||
| 71 | } |
||
| 72 |
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