alps-asd /
app-state-diagram
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Koriym\AppStateDiagram; |
||
| 6 | |||
| 7 | use Koriym\AppStateDiagram\Exception\InvalidSemanticsException; |
||
| 8 | use stdClass; |
||
| 9 | |||
| 10 | use function assert; |
||
| 11 | use function explode; |
||
| 12 | use function is_string; |
||
| 13 | use function json_encode; |
||
| 14 | use function property_exists; |
||
| 15 | use function sprintf; |
||
| 16 | |||
| 17 | abstract class AbstractDescriptor |
||
| 18 | { |
||
| 19 | /** @var string */ |
||
| 20 | public $id; |
||
| 21 | |||
| 22 | /** @var ?string */ |
||
| 23 | public $def; |
||
| 24 | |||
| 25 | /** @var stdClass|null */ |
||
| 26 | public $doc; |
||
| 27 | |||
| 28 | /** @var list<stdClass> */ |
||
|
0 ignored issues
–
show
|
|||
| 29 | public $descriptor; |
||
| 30 | |||
| 31 | /** @var string */ |
||
| 32 | public $type = 'semantic'; |
||
| 33 | |||
| 34 | /** @var ?string */ |
||
| 35 | public $rel; |
||
| 36 | |||
| 37 | /** @var stdClass|SemanticDescriptor|null */ |
||
| 38 | public $parent; |
||
| 39 | |||
| 40 | /** @var list<string> */ |
||
| 41 | public $tags; |
||
| 42 | |||
| 43 | /** @var string */ |
||
| 44 | public $title; |
||
| 45 | |||
| 46 | /** @var object */ |
||
| 47 | public $source; |
||
| 48 | |||
| 49 | /** @var string|null */ |
||
| 50 | public $href; |
||
| 51 | |||
| 52 | /** @var LinkRelations */ |
||
| 53 | public $linkRelations; |
||
| 54 | |||
| 55 | public function __construct(object $descriptor, ?stdClass $parentDescriptor = null) |
||
| 56 | { |
||
| 57 | if (! isset($descriptor->id)) { |
||
| 58 | throw new InvalidSemanticsException((string) json_encode($descriptor)); |
||
| 59 | } |
||
| 60 | |||
| 61 | $this->source = $descriptor; |
||
|
0 ignored issues
–
show
It seems like
$descriptor of type object is incompatible with the declared type object of property $source.
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...
|
|||
| 62 | $this->id = (string) $descriptor->id; |
||
| 63 | /** @psalm-suppress MixedAssignment */ |
||
| 64 | $this->def = $descriptor->def ?? $descriptor->ref ?? $descriptor->src ?? null; |
||
| 65 | /** @psalm-suppress MixedAssignment */ |
||
| 66 | $this->doc = $descriptor->doc ?? null; |
||
| 67 | /** @psalm-suppress MixedAssignment */ |
||
| 68 | $this->descriptor = $descriptor->descriptor ?? []; |
||
|
0 ignored issues
–
show
It seems like
$descriptor->descriptor ?? array() can also be of type array. However, the property $descriptor is declared as type Koriym\AppStateDiagram\list. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 69 | $this->parent = $parentDescriptor; |
||
| 70 | /** @var string|list<string> $tag */ |
||
| 71 | $tag = $descriptor->tag ?? []; |
||
| 72 | /** @psalm-suppress MixedAssignment */ |
||
| 73 | $this->tags = is_string($tag) ? explode(' ', $tag) : $tag; |
||
|
0 ignored issues
–
show
It seems like
is_string($tag) ? explode(' ', $tag) : $tag can also be of type string[]. However, the property $tags is declared as type Koriym\AppStateDiagram\list. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 74 | /** @psalm-suppress MixedAssignment */ |
||
| 75 | $this->title = $descriptor->title ?? ''; |
||
| 76 | if (isset($descriptor->rel)) { |
||
| 77 | $this->rel = (string) $descriptor->rel; |
||
| 78 | } |
||
| 79 | |||
| 80 | if (property_exists($descriptor, 'href')) { |
||
| 81 | assert(is_string($descriptor->href) || $descriptor->href === null); |
||
| 82 | $this->href = $descriptor->href; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** @psalm-suppress all */ |
||
| 86 | $this->linkRelations = new LinkRelations($descriptor->link ?? null); |
||
| 87 | } |
||
| 88 | |||
| 89 | public function htmlLink(string $ext): string |
||
| 90 | { |
||
| 91 | return sprintf('[%s](%s.%s.%s)', $this->id, $this->type, $this->id, $ext); |
||
| 92 | } |
||
| 93 | } |
||
| 94 |
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