Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Dec 18, 2023
1 parent 22c2b45 commit 484b7d0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/Interfaces/ActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ interface ActionInterface
public function __invoke(mixed ...$argument): CastInterface;

/**
* Defines expected return parameter when executing `RUN_METHOD` method.
* Defines expected return parameter when executing target run method.
*/
public static function return(): ParameterInterface;

/**
* Assert for static context.
*/
public static function assert(): void;

/**
* Determines run method to use.
*/
public static function runMethod(): string;
}
19 changes: 11 additions & 8 deletions src/Traits/ActionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
*/
trait ActionTrait
{
public const RUN_METHOD = 'run';

protected ?ParametersInterface $parameters = null;

protected ?ParameterInterface $return = null;
Expand All @@ -50,7 +48,7 @@ final public function __invoke(mixed ...$argument): CastInterface
$run = $this->run(...$arguments);

try {
static::return()(...)($run);
static::return()->__invoke($run);
} catch (Throwable $e) {
$message = (string) message(
'`%method%` → %message%',
Expand Down Expand Up @@ -84,21 +82,26 @@ final public static function assert(): void
static::assertStatic();
}

public static function runMethod(): string
{
return 'run';
}

/**
* @return array<object> [$method, $return]
*/
final protected static function assertMethod(): array
{
if (! method_exists(static::class, static::RUN_METHOD)) {
if (! method_exists(static::class, static::runMethod())) {
throw new LogicException(
(string) message(
'Action `%action%` does not define a %run% method',
'Action `%action%` does not define `%run%` method',
action: static::class,
run: static::RUN_METHOD,
run: static::runMethod(),
)
);
}
$reflection = new ReflectionMethod(static::class, static::RUN_METHOD);
$reflection = new ReflectionMethod(static::class, static::runMethod());
$attributes = $reflection->getAttributes(ReturnAttr::class);
if ($attributes === []) {
$return = static::return();
Expand Down Expand Up @@ -151,7 +154,7 @@ final protected function parameters(): ParametersInterface

final protected static function runMethodFQN(): string
{
return static::class . '::' . static::RUN_METHOD;
return static::class . '::' . static::runMethod();
}

final protected static function assertTypes(
Expand Down
2 changes: 1 addition & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

function getParameters(string $action): ParametersInterface
{
$reflection = new ReflectionMethod($action, Action::RUN_METHOD);
$reflection = new ReflectionMethod($action, $action::runMethod());

return reflectionToParameters($reflection);
}

0 comments on commit 484b7d0

Please sign in to comment.