Skip to content

Commit 8247905

Browse files
alexsyvolapvmikhav
authored andcommitted
hyperf-3.1: Update code with detailed comments and improve code style
1 parent 3a471e4 commit 8247905

35 files changed

+387
-98
lines changed

composer.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@
2121
"php": ">=8.1",
2222
"ext-json": "*",
2323
"fakerphp/faker": "^1.0",
24-
"hyperf/async-queue": "^3.0",
25-
"hyperf/event": "^3.0",
26-
"hyperf/command": "^3.0",
27-
"hyperf/config": "^3.0",
28-
"hyperf/constants": "^3.0",
29-
"hyperf/contract": "^3.0",
30-
"hyperf/database": "^3.0",
31-
"hyperf/db-connection": "^3.0",
32-
"hyperf/di": "^3.0",
33-
"hyperf/framework": "^3.0",
34-
"hyperf/http-server": "^3.0",
35-
"hyperf/logger": "^3.0",
36-
"hyperf/resource": "^3.0",
37-
"hyperf/socketio-server": "^3.0",
38-
"hyperf/testing": "^3.0",
39-
"hyperf/validation": "^3.0",
40-
"hyperf/utils": "^3.0",
24+
"hyperf/async-queue": "^3.1",
25+
"hyperf/event": "^3.1",
26+
"hyperf/command": "^3.1",
27+
"hyperf/config": "^3.1",
28+
"hyperf/constants": "^3.1",
29+
"hyperf/contract": "^3.1",
30+
"hyperf/database": "^3.1",
31+
"hyperf/db-connection": "^3.1",
32+
"hyperf/di": "^3.1",
33+
"hyperf/framework": "^3.1",
34+
"hyperf/http-server": "^3.1",
35+
"hyperf/logger": "^3.1",
36+
"hyperf/resource": "^3.1",
37+
"hyperf/socketio-server": "^3.1",
38+
"hyperf/testing": "^3.1",
39+
"hyperf/validation": "^3.1",
4140
"yzen.dev/plain-to-class": "^1.0",
4241
"zircote/swagger-php": "^4.5"
4342
},

publish/anonymization.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
412
return [
513
// Use array key as anonymization config name
614
'main' => [

publish/core.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<?php
22

33
declare(strict_types=1);
4-
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
512
return [
613
'user_model' => \App\User\Model\User::class,
714
];

publish/swagger.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
412
return [
513
'app/',
614
'vendor/onix-systems-php/hyperf-core/',

src/Command/AnonymizeDataCommand.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Command;
514

615
use Hyperf\Command\Annotation\Command;
@@ -17,13 +26,13 @@ public function __construct(
1726
parent::__construct('seed:anonymize');
1827
}
1928

20-
public function configure()
29+
public function configure(): void
2130
{
2231
parent::configure();
2332
$this->setDescription('Anonymize sensitive data');
2433
}
2534

26-
public function handle()
35+
public function handle(): void
2736
{
2837
$mode = $this->input->getArgument('mode');
2938
if (empty($mode)) {

src/Command/SwaggerGenCommand.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Command;
514

615
use Hyperf\Command\Annotation\Command;
716
use Hyperf\Command\Command as HyperfCommand;
817
use Hyperf\Contract\ConfigInterface;
9-
use OpenApi\Analysers\TokenAnalyser;
1018
use OpenApi\Generator;
1119
use Symfony\Component\Console\Input\InputOption;
1220

13-
1421
#[Command]
1522
class SwaggerGenCommand extends HyperfCommand
1623
{
@@ -20,13 +27,13 @@ public function __construct(
2027
parent::__construct('swagger:gen');
2128
}
2229

23-
public function configure()
30+
public function configure(): void
2431
{
2532
parent::configure();
2633
$this->setDescription('Generate swagger API doc');
2734
}
2835

29-
public function handle()
36+
public function handle(): void
3037
{
3138
$outputDir = $this->input->getOption('output');
3239
$format = $this->input->getOption('format');

src/ConfigProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore;
514

615
class ConfigProvider

src/Constants/ErrorCode.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
2+
23
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
312

413
namespace OnixSystemsPHP\HyperfCore\Constants;
514

@@ -19,7 +28,6 @@ class ErrorCode extends AbstractConstants
1928
*/
2029
public const UNAUTHORIZED_ERROR = 401;
2130

22-
2331
/**
2432
* @Message("Forbidden!")
2533
*/

src/Constants/Time.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Constants;
514

615
use Hyperf\Constants\AbstractConstants;

src/Contract/CoreAuthenticatable.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Contract;
514

615
interface CoreAuthenticatable
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Contract;
514

615
interface CoreAuthenticatableProvider
716
{
8-
public function user(): CoreAuthenticatable|null;
17+
public function user(): null|CoreAuthenticatable;
918
}

src/Contract/CoreDataGuard.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Contract;
514

615
use Hyperf\Database\Model\Builder;

src/Contract/CorePolicyGuard.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Contract;
514

615
use OnixSystemsPHP\HyperfCore\Exception\BusinessException;

src/Controller/AbstractController.php

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?php
22

33
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact [email protected]
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
413
namespace OnixSystemsPHP\HyperfCore\Controller;
514

615
use Hyperf\Di\Annotation\Inject;
@@ -11,7 +20,7 @@
1120

1221
/**
1322
* Documentation Init
14-
* https://editor.swagger.io
23+
* https://editor.swagger.io.
1524
*/
1625
#[OA\Server(url: 'http://localhost/', description: 'Local Server')]
1726
#[OA\SecurityScheme(securityScheme: 'bearerAuth', type: 'http', bearerFormat: 'JWT', scheme: 'bearer')]
@@ -33,43 +42,55 @@
3342
example: 'en-US',
3443
)]
3544
#[OA\Response(response: 200, description: 'Success')]
36-
#[OA\Response(response: 400, description: 'Bad Request', content:
37-
new OA\JsonContent(properties: [
45+
#[OA\Response(
46+
response: 400,
47+
description: 'Bad Request',
48+
content: new OA\JsonContent(properties: [
3849
new OA\Property(property: 'status', type: 'number'),
3950
new OA\Property(property: 'title', type: 'string'),
4051
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),
4152
])
4253
)]
43-
#[OA\Response(response: 401, description: 'Unauthorized', content:
44-
new OA\JsonContent(properties: [
54+
#[OA\Response(
55+
response: 401,
56+
description: 'Unauthorized',
57+
content: new OA\JsonContent(properties: [
4558
new OA\Property(property: 'status', type: 'number'),
4659
new OA\Property(property: 'title', type: 'string'),
4760
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),
4861
])
4962
)]
50-
#[OA\Response(response: 403, description: 'Forbidden', content:
51-
new OA\JsonContent(properties: [
63+
#[OA\Response(
64+
response: 403,
65+
description: 'Forbidden',
66+
content: new OA\JsonContent(properties: [
5267
new OA\Property(property: 'status', type: 'number'),
5368
new OA\Property(property: 'title', type: 'string'),
5469
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),
5570
])
5671
)]
57-
#[OA\Response(response: 404, description: 'Not Found', content:
58-
new OA\JsonContent(properties: [
72+
#[OA\Response(
73+
response: 404,
74+
description: 'Not Found',
75+
content: new OA\JsonContent(properties: [
5976
new OA\Property(property: 'status', type: 'number'),
6077
new OA\Property(property: 'title', type: 'string'),
6178
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),
6279
])
6380
)]
64-
#[OA\Response(response: 422, description: 'Validation error.', content:
65-
new OA\JsonContent(properties: [
81+
#[OA\Response(
82+
response: 422,
83+
description: 'Validation error.',
84+
content: new OA\JsonContent(properties: [
6685
new OA\Property(property: 'status', type: 'number'),
6786
new OA\Property(property: 'title', type: 'string'),
6887
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),
6988
])
7089
)]
71-
#[OA\Response(response: 500, description: 'Server error.', content:
72-
new OA\JsonContent(properties: [
90+
#[OA\Response(
91+
response: 500,
92+
description: 'Server error.',
93+
content: new OA\JsonContent(properties: [
7394
new OA\Property(property: 'status', type: 'number'),
7495
new OA\Property(property: 'title', type: 'string'),
7596
new OA\Property(property: 'data', type: 'array', items: new OA\Items()),

0 commit comments

Comments
 (0)