Skip to content

Commit cfb2181

Browse files
committed
[#.x] - phpstan corrections
1 parent 585ca25 commit cfb2181

File tree

13 files changed

+86
-21
lines changed

13 files changed

+86
-21
lines changed

src/Domain/ADR/ActionHandler.php renamed to src/Domain/ADR/Action/ActionHandler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Phalcon\Api\Domain\Services;
14+
namespace Phalcon\Api\Domain\ADR\Action;
1515

16-
use Phalcon\Api\Domain\Interfaces\ActionInterface;
17-
use Phalcon\Api\Domain\Interfaces\DomainInterface;
18-
use Phalcon\Api\Domain\Interfaces\ResponderInterface;
16+
use Phalcon\Api\Domain\ADR\Domain\DomainInterface;
17+
use Phalcon\Api\Domain\ADR\Responder\ResponderInterface;
1918

2019
final readonly class ActionHandler implements ActionInterface
2120
{

src/Domain/Interfaces/ADR/ActionInterface.php renamed to src/Domain/ADR/Action/ActionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Phalcon\Api\Domain\Interfaces;
14+
namespace Phalcon\Api\Domain\ADR\Action;
1515

1616
interface ActionInterface
1717
{

src/Domain/Interfaces/ADR/DomainInterface.php renamed to src/Domain/ADR/Domain/DomainInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Phalcon\Api\Domain\Interfaces;
14+
namespace Phalcon\Api\Domain\ADR\Domain;
1515

1616
use Phalcon\Domain\Payload;
1717

src/Responder/JsonResponder.php renamed to src/Domain/ADR/Responder/JsonResponder.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Phalcon\Api\Responder;
14+
namespace Phalcon\Api\Domain\ADR\Responder;
1515

16-
use Phalcon\Api\Domain\Interfaces\ResponderInterface;
1716
use Phalcon\Api\Domain\Services\Http\Response;
1817
use Phalcon\Domain\Payload;
1918

src/Domain/Interfaces/ADR/ResponderInterface.php renamed to src/Domain/ADR/Responder/ResponderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace Phalcon\Api\Domain\Interfaces;
14+
namespace Phalcon\Api\Domain\ADR\Responder;
1515

1616
use Phalcon\Domain\Payload;
1717
use Phalcon\Http\ResponseInterface;

src/Domain/Hello/HelloService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
namespace Phalcon\Api\Domain\Hello;
1515

1616
use PayloadInterop\DomainStatus;
17-
use Phalcon\Api\Domain\Interfaces\DomainInterface;
17+
use Phalcon\Api\Domain\ADR\Domain\DomainInterface;
18+
use Phalcon\Api\Domain\Constants\Dates;
1819
use Phalcon\Domain\Payload;
1920

2021
use function date;
@@ -26,7 +27,7 @@ public function __invoke(): Payload
2627
return new Payload(
2728
DomainStatus::SUCCESS,
2829
[
29-
'results' => "Hello World!!! - " . date("Y-m-d H:i:s"),
30+
'results' => "Hello World!!! - " . date(Dates::DATE_TIME_FORMAT),
3031
]
3132
);
3233
}

src/Domain/Middleware/AbstractMiddleware.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,29 @@
1515

1616
use Phalcon\Api\Domain\Services\Container;
1717
use Phalcon\Api\Domain\Services\Http\Response;
18+
use Phalcon\Api\Domain\Services\Http\ResponseTypes;
19+
use Phalcon\Events\Exception as EventsException;
20+
use Phalcon\Http\Response\Exception as ResponseException;
1821
use Phalcon\Mvc\Micro;
1922
use Phalcon\Mvc\Micro\MiddlewareInterface;
2023

24+
/**
25+
* @phpstan-import-type TData from ResponseTypes
26+
* @phpstan-import-type TErrors from ResponseTypes
27+
*/
2128
abstract class AbstractMiddleware implements MiddlewareInterface
2229
{
30+
/**
31+
* @param Micro $application
32+
* @param int $code
33+
* @param string $message
34+
* @param TData $data
35+
* @param TErrors $errors
36+
*
37+
* @return void
38+
* @throws EventsException
39+
* @throws ResponseException
40+
*/
2341
protected function halt(
2442
Micro $application,
2543
int $code,

src/Domain/Middleware/NotFoundMiddleware.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121

2222
final class NotFoundMiddleware extends AbstractMiddleware
2323
{
24+
/**
25+
* @param Event $event
26+
* @param Micro $application
27+
*
28+
* @return bool
29+
* @throws EventsException
30+
* @throws Exception
31+
*/
2432
public function beforeNotFound(Event $event, Micro $application): bool
2533
{
2634
$this->halt(
2735
$application,
2836
HttpCodesEnum::NotFound->value,
2937
'error',
3038
[],
31-
HttpCodesEnum::AppResourceNotFound->error()
39+
[HttpCodesEnum::AppResourceNotFound->error()]
3240
);
3341

3442
return false;
@@ -38,8 +46,6 @@ public function beforeNotFound(Event $event, Micro $application): bool
3846
* @param Micro $application
3947
*
4048
* @return true
41-
* @throws EventsException
42-
* @throws Exception
4349
*/
4450
public function call(Micro $application): bool
4551
{

src/Domain/Services/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
namespace Phalcon\Api\Domain\Services;
1515

16+
use Phalcon\Api\Domain\ADR\Responder\JsonResponder;
1617
use Phalcon\Api\Domain\Health\HealthService;
1718
use Phalcon\Api\Domain\Hello\HelloService;
1819
use Phalcon\Api\Domain\Middleware\HealthMiddleware;
1920
use Phalcon\Api\Domain\Middleware\NotFoundMiddleware;
2021
use Phalcon\Api\Domain\Middleware\ResponseSenderMiddleware;
2122
use Phalcon\Api\Domain\Services\Env\EnvManager;
2223
use Phalcon\Api\Domain\Services\Http\Response;
23-
use Phalcon\Api\Responder\JsonResponder;
2424
use Phalcon\Di\Di;
2525
use Phalcon\Di\Service;
2626
use Phalcon\Events\Manager as EventsManager;

src/Domain/Services/Http/Response.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121
use function json_encode;
2222
use function sha1;
2323

24+
/**
25+
* @phpstan-import-type TData from ResponseTypes
26+
* @phpstan-import-type TErrors from ResponseTypes
27+
* @phpstan-import-type TResponsePayload from ResponseTypes
28+
*/
2429
class Response extends PhalconResponse
2530
{
26-
private array $payload = [];
31+
/** @var TResponsePayload */
32+
private array $payload;
2733

2834
/**
2935
* @return $this
@@ -54,7 +60,7 @@ public function withCode(int $code, string $message = ''): self
5460
}
5561

5662
/**
57-
* @param array $data
63+
* @param TData $data
5864
*
5965
* @return $this
6066
* @throws Exception
@@ -71,7 +77,7 @@ public function withPayloadData(array $data): self
7177
}
7278

7379
/**
74-
* @param array $errors
80+
* @param TErrors $errors
7581
*
7682
* @return $this
7783
*/

0 commit comments

Comments
 (0)