GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (14)

src/Enum.php (2 issues)

1
<?php
2
3
namespace Spatie\Enum\Laravel;
4
5
use Illuminate\Contracts\Database\Eloquent\Castable;
6
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
7
use Illuminate\Contracts\Support\Jsonable;
8
use Spatie\Enum\Enum as BaseEnum;
9
use Spatie\Enum\Laravel\Casts\EnumCast;
10
use Spatie\Enum\Laravel\Casts\EnumCollectionCast;
11
12
abstract class Enum extends BaseEnum implements Jsonable, Castable
13
{
14
    public static function castUsing(array $arguments): CastsAttributes
15
    {
16
        if (in_array('collection', $arguments)) {
17
            return new EnumCollectionCast(static::class, ...$arguments);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new Spatie\Enum\L...tic::class, $arguments) returns the type Spatie\Enum\Laravel\Casts\EnumCollectionCast which is incompatible with the return type mandated by Illuminate\Contracts\Dat...t\Castable::castUsing() of string.

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...
18
        }
19
20
        return new EnumCast(static::class, ...$arguments);
0 ignored issues
show
Bug Best Practice introduced by
The expression return new Spatie\Enum\L...tic::class, $arguments) returns the type Spatie\Enum\Laravel\Casts\EnumCast which is incompatible with the return type mandated by Illuminate\Contracts\Dat...t\Castable::castUsing() of string.

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...
21
    }
22
23
    public function toJson($options = 0): string
24
    {
25
        return json_encode($this->jsonSerialize(), $options);
26
    }
27
}
28