Skip to content

Commit

Permalink
Merge pull request #247 from lorenzolosa/generics
Browse files Browse the repository at this point in the history
Generics PHPDoc annotations for State class
  • Loading branch information
freekmurze authored Feb 7, 2024
2 parents b690bb6 + 6003f6d commit fc07851
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Spatie\ModelStates\Exceptions\CouldNotPerformTransition;
use Spatie\ModelStates\Exceptions\InvalidConfig;

/**
* @template TModel of \Illuminate\Database\Eloquent\Model
*/
abstract class State implements Castable, JsonSerializable
{
private $model;
Expand All @@ -23,7 +26,7 @@ abstract class State implements Castable, JsonSerializable
private static array $stateMapping = [];

/**
* @param \Illuminate\Database\Eloquent\Model $model
* @param TModel $model
*/
public function __construct($model)
{
Expand Down Expand Up @@ -100,7 +103,7 @@ public static function resolveStateClass($state): ?string

/**
* @param string $name
* @param \Illuminate\Database\Eloquent\Model $model
* @param TModel $model
* @return State
*/
public static function make(string $name, $model): State
Expand All @@ -115,7 +118,7 @@ public static function make(string $name, $model): State
}

/**
* @return \Illuminate\Database\Eloquent\Model
* @return TModel
*/
public function getModel()
{
Expand Down Expand Up @@ -145,7 +148,7 @@ public function setField(string $field): self
/**
* @param string|State $newState
* @param mixed ...$transitionArgs
* @return \Illuminate\Database\Eloquent\Model
* @return TModel
*/
public function transitionTo($newState, ...$transitionArgs)
{
Expand All @@ -171,7 +174,7 @@ public function transitionTo($newState, ...$transitionArgs)

/**
* @param Transition $transition
* @return \Illuminate\Database\Eloquent\Model
* @return TModel
* @throws ClassDoesNotExtendBaseClass
*/
public function transition(Transition $transition)
Expand Down

0 comments on commit fc07851

Please sign in to comment.