inspirum /
balikobot-php
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Inspirum\Balikobot\Model\Country; |
||
| 6 | |||
| 7 | use Inspirum\Arrayable\BaseModel; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @extends \Inspirum\Arrayable\BaseModel<string,mixed> |
||
| 11 | */ |
||
| 12 | final class DefaultCountry extends BaseModel implements Country |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @param array<string,string> $names |
||
| 16 | * @param list<string> $phonePrefixes |
||
|
0 ignored issues
–
show
|
|||
| 17 | */ |
||
| 18 | 4 | public function __construct( |
|
| 19 | private readonly array $names, |
||
| 20 | private readonly string $code, |
||
| 21 | private readonly string $currencyCode, |
||
| 22 | private readonly array $phonePrefixes, |
||
| 23 | private readonly string $continent, |
||
| 24 | ) { |
||
| 25 | 4 | } |
|
| 26 | |||
| 27 | /** @inheritDoc */ |
||
| 28 | 1 | public function getNames(): array |
|
| 29 | { |
||
| 30 | 1 | return $this->names; |
|
| 31 | } |
||
| 32 | |||
| 33 | 1 | public function getName(string $locale): ?string |
|
| 34 | { |
||
| 35 | 1 | return $this->names[$locale] ?? null; |
|
| 36 | } |
||
| 37 | |||
| 38 | 1 | public function getCode(): string |
|
| 39 | { |
||
| 40 | 1 | return $this->code; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | public function getCurrencyCode(): string |
|
| 44 | { |
||
| 45 | 1 | return $this->currencyCode; |
|
| 46 | } |
||
| 47 | |||
| 48 | /** @inheritDoc */ |
||
| 49 | 1 | public function getPhonePrefixes(): array |
|
| 50 | { |
||
| 51 | 1 | return $this->phonePrefixes; |
|
| 52 | } |
||
| 53 | |||
| 54 | 1 | public function getPhonePrefix(): string |
|
| 55 | { |
||
| 56 | 1 | return $this->phonePrefixes[0]; |
|
| 57 | } |
||
| 58 | |||
| 59 | 1 | public function getContinent(): string |
|
| 60 | { |
||
| 61 | 1 | return $this->continent; |
|
| 62 | } |
||
| 63 | |||
| 64 | /** @inheritDoc */ |
||
| 65 | 1 | public function __toArray(): array |
|
| 66 | { |
||
| 67 | 1 | return [ |
|
|
0 ignored issues
–
show
The expression
return array('names' => ...t' => $this->continent) returns the type array<string,array|string> which is incompatible with the return type mandated by Inspirum\Arrayable\BaseModel::__toArray() of Inspirum\Arrayable\TValue[].
In the issue above, the returned value is violating the contract defined by the mentioned interface. Let's take a look at an example: interface HasName {
/** @return string */
public function getName();
}
class Name {
public $name;
}
class User implements HasName {
/** @return string|Name */
public function getName() {
return new Name('foo'); // This is a violation of the ``HasName`` interface
// which only allows a string value to be returned.
}
}
Loading history...
|
|||
| 68 | 1 | 'names' => $this->names, |
|
| 69 | 1 | 'code' => $this->code, |
|
| 70 | 1 | 'currencyCode' => $this->currencyCode, |
|
| 71 | 1 | 'phonePrefixes' => $this->phonePrefixes, |
|
| 72 | 1 | 'continent' => $this->continent, |
|
| 73 | 1 | ]; |
|
| 74 | } |
||
| 75 | } |
||
| 76 |
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