Skip to content

Commit fb5a31d

Browse files
authored
Cleanup docblocks added return types (#285)
1 parent 87cabcf commit fb5a31d

File tree

54 files changed

+178
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+178
-304
lines changed

src/ActionPendingChain.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Lorisleiva\Actions;
44

55
use Illuminate\Foundation\Bus\PendingChain;
6+
use Illuminate\Foundation\Bus\PendingDispatch;
67
use Lorisleiva\Actions\Concerns\AsJob;
78

89
class ActionPendingChain extends PendingChain
910
{
10-
public function dispatch()
11+
public function dispatch(): ?PendingDispatch
1112
{
1213
/** @var $job AsJob */
1314
if ($this->usesAsJobTrait($job = $this->job)) {
@@ -17,7 +18,7 @@ public function dispatch()
1718
return parent::dispatch();
1819
}
1920

20-
public function usesAsJobTrait($job)
21+
public function usesAsJobTrait($job): bool
2122
{
2223
return is_string($job)
2324
&& class_exists($job)

src/ActionRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ActionRequest extends FormRequest
99
{
1010
use ValidateActions;
1111

12-
public function validateResolved()
12+
public function validateResolved(): void
1313
{
1414
// Cancel the auto-resolution trait.
1515
}

src/ActionServiceProvider.php

+11-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
class ActionServiceProvider extends ServiceProvider
1313
{
14-
public function register()
14+
/**
15+
* Register any application services.
16+
*/
17+
public function register(): void
1518
{
1619
$this->app->scoped(ActionManager::class, function () {
1720
return new ActionManager([
@@ -24,10 +27,13 @@ public function register()
2427
$this->extendActions();
2528
}
2629

27-
public function boot()
30+
/**
31+
* Bootstrap any application services.
32+
*/
33+
public function boot(): void
2834
{
2935
if ($this->app->runningInConsole()) {
30-
// publish Stubs File
36+
// Publish Stubs File
3137
$this->publishes([
3238
__DIR__ . '/Console/stubs/action.stub' => base_path('stubs/action.stub'),
3339
], 'stubs');
@@ -39,7 +45,7 @@ public function boot()
3945
}
4046
}
4147

42-
protected function extendActions()
48+
protected function extendActions(): void
4349
{
4450
$this->app->beforeResolving(function ($abstract, $parameters, Application $app) {
4551
if ($abstract === ActionManager::class) {
@@ -50,7 +56,7 @@ protected function extendActions()
5056
// Fix conflict with package: barryvdh/laravel-ide-helper.
5157
// @see https://github.com/lorisleiva/laravel-actions/issues/142
5258
$classExists = class_exists($abstract);
53-
} catch (\ReflectionException $exception) {
59+
} catch (\ReflectionException) {
5460
return;
5561
}
5662

src/BacktraceFrame.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class BacktraceFrame
99
public ?string $class;
1010
public ?string $function;
1111
public bool $isStatic;
12-
13-
/** @var mixed|null */
14-
public $object;
12+
public mixed $object;
1513

1614
public function __construct(array $frame)
1715
{
@@ -36,9 +34,9 @@ public function instanceOf(string $superClass): bool
3634
|| is_subclass_of($this->class, $superClass);
3735
}
3836

39-
public function matches(string $class, string $method, ?bool $isStatic = null)
37+
public function matches(string $class, string $method, ?bool $isStatic = null): bool
4038
{
41-
$matchesStatic = is_null($isStatic) ? true : ($this->isStatic === $isStatic);
39+
$matchesStatic = is_null($isStatic) || $this->isStatic === $isStatic;
4240

4341
return $this->instanceOf($class)
4442
&& $this->function === $method

src/Concerns/AsController.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,17 @@ trait AsController
1313
{
1414
/**
1515
* @see static::handle()
16-
* @param mixed ...$arguments
17-
* @return mixed
1816
*/
19-
public function __invoke(...$arguments)
17+
public function __invoke(mixed ...$arguments): mixed
2018
{
2119
return $this->handle(...$arguments);
2220
}
2321

2422
/**
2523
* This empty method is required to enable controller middleware on the action.
2624
* @see https://github.com/lorisleiva/laravel-actions/issues/199
27-
* @return array
2825
*/
29-
public function getMiddleware()
26+
public function getMiddleware(): array
3027
{
3128
return [];
3229
}

src/Concerns/AsFake.php

+3-34
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
trait AsFake
1212
{
13-
/**
14-
* @return MockInterface
15-
*/
1613
public static function mock(): MockInterface
1714
{
1815
if (static::isFake()) {
@@ -25,9 +22,6 @@ public static function mock(): MockInterface
2522
return static::setFakeResolvedInstance($mock);
2623
}
2724

28-
/**
29-
* @return MockInterface
30-
*/
3125
public static function spy(): MockInterface
3226
{
3327
if (static::isFake()) {
@@ -37,41 +31,26 @@ public static function spy(): MockInterface
3731
return static::setFakeResolvedInstance(Mockery::spy(static::class));
3832
}
3933

40-
/**
41-
* @return MockInterface
42-
*/
4334
public static function partialMock(): MockInterface
4435
{
4536
return static::mock()->makePartial();
4637
}
4738

48-
/**
49-
* @return Expectation|ExpectationInterface|HigherOrderMessage
50-
*/
51-
public static function shouldRun()
39+
public static function shouldRun(): Expectation|ExpectationInterface|HigherOrderMessage
5240
{
5341
return static::mock()->shouldReceive('handle');
5442
}
5543

56-
/**
57-
* @return Expectation|ExpectationInterface|HigherOrderMessage
58-
*/
59-
public static function shouldNotRun()
44+
public static function shouldNotRun(): Expectation|ExpectationInterface|HigherOrderMessage
6045
{
6146
return static::mock()->shouldNotReceive('handle');
6247
}
6348

64-
/**
65-
* @return Expectation|ExpectationInterface|HigherOrderMessage|MockInterface
66-
*/
67-
public static function allowToRun()
49+
public static function allowToRun(): Expectation|ExpectationInterface|HigherOrderMessage|MockInterface
6850
{
6951
return static::spy()->allows('handle');
7052
}
7153

72-
/**
73-
* @return bool
74-
*/
7554
public static function isFake(): bool
7655
{
7756
return app()->isShared(static::getFakeResolvedInstanceKey());
@@ -85,26 +64,16 @@ public static function clearFake(): void
8564
app()->forgetInstance(static::getFakeResolvedInstanceKey());
8665
}
8766

88-
/**
89-
* @param MockInterface $fake
90-
* @return MockInterface
91-
*/
9267
protected static function setFakeResolvedInstance(MockInterface $fake): MockInterface
9368
{
9469
return app()->instance(static::getFakeResolvedInstanceKey(), $fake);
9570
}
9671

97-
/**
98-
* @return MockInterface|null
99-
*/
10072
protected static function getFakeResolvedInstance(): ?MockInterface
10173
{
10274
return app(static::getFakeResolvedInstanceKey());
10375
}
10476

105-
/**
106-
* @return string
107-
*/
10877
protected static function getFakeResolvedInstanceKey(): string
10978
{
11079
return 'LaravelActions:AsFake:' . static::class;

src/Concerns/AsJob.php

+24-74
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,34 @@
2424
* @method void configureJob(JobDecorator|UniqueJobDecorator $job)
2525
*
2626
* @property-read int|array $jobBackoff
27-
* @method int|array getJobBackoff(...$parameters)
27+
* @method int|array getJobBackoff()
2828
*
2929
* @property-read \DateTime|int $jobRetryUntil
30-
* @method \DateTime|int getJobRetryUntil(...$parameters)
30+
* @method \DateTime|int getJobRetryUntil()
3131
*
32-
* @method array getJobMiddleware(...$parameters)
32+
* @method array getJobMiddleware()
3333
*
34-
* @method void jobFailed(Throwable $e, ...$parameters)
34+
* @method void jobFailed(Throwable $e)
3535
*
36-
* @method string getJobDisplayName(...$parameters)
36+
* @method string getJobDisplayName()
3737
*
38-
* @method array getJobTags(...$parameters)
38+
* @method array getJobTags()
3939
*
4040
* @property-read int $jobUniqueFor
41-
* @method int getJobUniqueFor(...$parameters)
41+
* @method int getJobUniqueFor()
4242
*
4343
* @property-read int $jobUniqueId
44-
* @method int getJobUniqueId(...$parameters)
44+
* @method int getJobUniqueId()
4545
*
46-
* @method int getJobUniqueVia(...$parameters)
46+
* @method int getJobUniqueVia()
47+
*
48+
* @property-read bool $jobDeleteWhenMissingModels
49+
* @method bool getJobDeleteWhenMissingModels()
4750
*
4851
*/
4952
trait AsJob
5053
{
51-
/**
52-
* @param mixed ...$arguments
53-
* @return JobDecorator|UniqueJobDecorator
54-
*/
55-
public static function makeJob(...$arguments): JobDecorator
54+
public static function makeJob(mixed ...$arguments): JobDecorator
5655
{
5756
if (static::jobShouldBeUnique()) {
5857
return static::makeUniqueJob(...$arguments);
@@ -61,93 +60,52 @@ public static function makeJob(...$arguments): JobDecorator
6160
return new ActionManager::$jobDecorator(static::class, ...$arguments);
6261
}
6362

64-
/**
65-
* @param mixed ...$arguments
66-
* @return UniqueJobDecorator
67-
*/
68-
public static function makeUniqueJob(...$arguments): UniqueJobDecorator
63+
public static function makeUniqueJob(mixed ...$arguments): UniqueJobDecorator
6964
{
7065
return new ActionManager::$uniqueJobDecorator(static::class, ...$arguments);
7166
}
7267

73-
/**
74-
* @return bool
75-
*/
7668
protected static function jobShouldBeUnique(): bool
7769
{
7870
return is_subclass_of(static::class, ShouldBeUnique::class);
7971
}
8072

81-
/**
82-
* @param mixed ...$arguments
83-
* @return PendingDispatch
84-
*/
85-
public static function dispatch(...$arguments): PendingDispatch
73+
public static function dispatch(mixed ...$arguments): PendingDispatch
8674
{
8775
return new PendingDispatch(static::makeJob(...$arguments));
8876
}
8977

90-
/**
91-
* @param $boolean
92-
* @param mixed ...$arguments
93-
* @return PendingDispatch|Fluent
94-
*/
95-
public static function dispatchIf($boolean, ...$arguments)
78+
public static function dispatchIf(bool $boolean, mixed ...$arguments): PendingDispatch|Fluent
9679
{
9780
return $boolean ? static::dispatch(...$arguments) : new Fluent;
9881
}
9982

100-
/**
101-
* @param $boolean
102-
* @param mixed ...$arguments
103-
* @return PendingDispatch|Fluent
104-
*/
105-
public static function dispatchUnless($boolean, ...$arguments)
83+
public static function dispatchUnless(bool $boolean, mixed ...$arguments): PendingDispatch|Fluent
10684
{
10785
return static::dispatchIf(! $boolean, ...$arguments);
10886
}
10987

110-
/**
111-
* @param mixed ...$arguments
112-
* @return mixed
113-
*/
114-
public static function dispatchSync(...$arguments)
88+
public static function dispatchSync(mixed ...$arguments): mixed
11589
{
11690
return app(Dispatcher::class)->dispatchSync(static::makeJob(...$arguments));
11791
}
11892

119-
/**
120-
* @param mixed ...$arguments
121-
* @return mixed
122-
*/
123-
public static function dispatchNow(...$arguments)
93+
public static function dispatchNow(mixed ...$arguments): mixed
12494
{
12595
return static::dispatchSync(...$arguments);
12696
}
12797

128-
/**
129-
* @param mixed ...$arguments
130-
* @return void
131-
*/
132-
public static function dispatchAfterResponse(...$arguments): void
98+
public static function dispatchAfterResponse(mixed ...$arguments): void
13399
{
134100
static::dispatch(...$arguments)->afterResponse();
135101
}
136102

137-
/**
138-
* @param $chain
139-
* @return ActionPendingChain
140-
*/
141-
public static function withChain($chain): ActionPendingChain
103+
public static function withChain(array $chain): ActionPendingChain
142104
{
143105
return new ActionPendingChain(static::class, $chain);
144106
}
145107

146-
/**
147-
* @param Closure|int|null $times
148-
* @param Closure|null $callback
149-
*/
150-
public static function assertPushed($times = null, Closure $callback = null): void
108+
public static function assertPushed(Closure|int|null $times = null, Closure|null $callback = null): void
151109
{
152110
if ($times instanceof Closure) {
153111
$callback = $times;
@@ -191,20 +149,12 @@ public static function assertPushed($times = null, Closure $callback = null): vo
191149
}
192150
}
193151

194-
/**
195-
* @param Closure|null $callback
196-
*/
197-
public static function assertNotPushed(Closure $callback = null): void
152+
public static function assertNotPushed(Closure|null $callback = null): void
198153
{
199154
static::assertPushed(0, $callback);
200155
}
201156

202-
/**
203-
* @param string $queue
204-
* @param Closure|int|null $times
205-
* @param Closure|null $callback
206-
*/
207-
public static function assertPushedOn(string $queue, $times = null, Closure $callback = null): void
157+
public static function assertPushedOn(string $queue, Closure|int|null $times = null, Closure|null $callback = null): void
208158
{
209159
if ($times instanceof Closure) {
210160
$callback = $times;

0 commit comments

Comments
 (0)