Skip to content

Commit

Permalink
chore: Enum marked as deprecated (please use native PHP enums inste…
Browse files Browse the repository at this point in the history
…ad).
  • Loading branch information
LastDragon-ru committed Aug 20, 2022
1 parent 5216948 commit f71dd59
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 28 deletions.
3 changes: 3 additions & 0 deletions packages/core/src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use function count;
use function sprintf;

/**
* @deprecated Please use native PHP enums.
*/
abstract class Enum implements JsonSerializable {
/**
* @var array<class-string<static>,array<string|int,static>>
Expand Down
3 changes: 3 additions & 0 deletions packages/eloquent/src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use LastDragon_ru\LaraASP\Core\Enum as BaseEnum;
use LastDragon_ru\LaraASP\Eloquent\Casts\EnumCast;

/**
* @deprecated Please use native PHP enums.
*/
abstract class Enum extends BaseEnum implements Castable {
/**
* @param array<mixed> $arguments
Expand Down
28 changes: 0 additions & 28 deletions packages/graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,31 +328,3 @@ class Comment extends Model {
}

```


# Enums

Package also provides the helper to register [`Enum`](https://github.com/LastDragon-ru/lara-asp/blob/master/packages/core/src/Enum.php) as GraphQL Enum:

```php
<?php declare(strict_types = 1);

namespace LastDragon_ru\LaraASP\GraphQL;

use App\MyEnum;
use Illuminate\Support\ServiceProvider;
use LastDragon_ru\LaraASP\GraphQL\Utils\Enum\EnumType;
use Nuwave\Lighthouse\Schema\TypeRegistry;

class Provider extends ServiceProvider {
public function register(): void {
$this->callAfterResolving(
TypeRegistry::class,
static function (TypeRegistry $registry): void {
$registry->register(new EnumType(MyEnum::class));
},
);
}
}

```
2 changes: 2 additions & 0 deletions packages/graphql/src/Utils/Enum/EnumType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* {@see \Nuwave\Lighthouse\Schema\TypeRegistry}.
*
* @see https://lighthouse-php.com/master/the-basics/types.html#enum
*
* @deprecated Please use native PHP enums
*/
class EnumType extends GraphQLEnumType {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/src/Utils/Enum/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/**
* @internal {@see \LastDragon_ru\LaraASP\GraphQL\Utils\Enum\EnumType}
* @deprecated Please use native PHP enums
*/
class Factory extends Enum {
/**
Expand Down

0 comments on commit f71dd59

Please sign in to comment.