Skip to content

Commit 4a1d18d

Browse files
author
何平
committed
🎨 Phpstan
1 parent 6109006 commit 4a1d18d

File tree

12 files changed

+36
-30
lines changed

12 files changed

+36
-30
lines changed

cloud-admin/Annotation/EnumMessage.php

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
final class EnumMessage extends AbstractAnnotation
1919
{
2020
/**
21-
* @param string $message
2221
* @phpstan-param string $message
2322
*/
2423
public function __construct(public readonly string $message = '') {}

cloud-admin/Annotation/HttpCode.php

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
final class HttpCode extends AbstractAnnotation
2020
{
2121
/**
22-
* @param int $code
2322
* @phpstan-param int $code
2423
*/
2524
public function __construct(public readonly int $code = Status::OK) {}

cloud-admin/Context/Coroutine.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
final class Coroutine
2626
{
2727
/**
28-
* @var LoggerInterface|StdoutLoggerInterface|mixed $logger
28+
* @var LoggerInterface|mixed|StdoutLoggerInterface
2929
*/
3030
private readonly LoggerInterface $logger;
3131

3232
/**
33-
* @param ContainerInterface $container
3433
* @throws ContainerExceptionInterface
3534
* @throws NotFoundExceptionInterface
3635
*/

cloud-admin/Http2/Config/Ssl.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ public function __construct(/**
4141
* @var array{certificate:string,certificate_key:string,verify_peer:bool,verify_peer_name:bool,allow_self_signed:bool,alpn_protocols:string}
4242
*/
4343
protected array $config = [])
44-
{
45-
// $this
46-
// ->setCertificate($this->config['certificate'] ?? '')
47-
// ->setCertificateKey($config['certificate_key'] ?? '')
48-
// ->setVerifyPeer($this->config['verify_peer'] ?? false)
49-
// ->setVerifyPeerName($this->config['verify_peer_name'] ?? false)
50-
// ->setAllowSelfSigned($this->config['allow_self_signed'] ?? false);
44+
{;
5145
}
5246

5347
/**

cloud-admin/Interfaces/LockInterface.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
interface LockInterface
1515
{
1616
/**
17-
* @return mixed
1817
* @phpstan-return mixed
1918
*/
20-
public function lock():mixed;
19+
public function lock(): mixed;
2120

2221
/**
23-
* @return bool
2422
* @phpstan-return bool
2523
*/
26-
public function unlock():bool;
24+
public function unlock(): bool;
2725
}

cloud-admin/Log/SwowSocketHandler.php

-6
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public function __construct(
4545
}
4646

4747
/**
48-
* @param LogRecord $record
49-
* @return void
5048
* @phpstan-param LogRecord $record
5149
*/
5250
protected function write(LogRecord $record): void
@@ -57,8 +55,6 @@ protected function write(LogRecord $record): void
5755
}
5856

5957
/**
60-
* @param string $level
61-
* @return Color
6258
* @phpstan-return Color
6359
*/
6460
protected function getColorFromLevel(string $level = LogLevel::DEBUG): Color
@@ -74,8 +70,6 @@ protected function getColorFromLevel(string $level = LogLevel::DEBUG): Color
7470
}
7571

7672
/**
77-
* @param LogRecord $record
78-
* @return string
7973
* @phpstan-param LogRecord $record
8074
* @phpstan-return string
8175
*/

cloud-admin/Lru/LRUMemoizer.php

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function __construct(
3535
* @template T
3636
* @param callable(): T $factory
3737
* @return T
38+
* @phpstan-return T
39+
* @phpstan-param callable(): T $factory
3840
*/
3941
public function get(string $key, callable $factory): mixed
4042
{

cloud-admin/Middleware/ProfilerMiddleware.php

+6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
use Hyperf\Context\Context;
1919
use Hyperf\Contract\ConfigInterface;
2020
use Hyperf\HttpServer\Request;
21+
use Psr\Container\ContainerExceptionInterface;
2122
use Psr\Container\ContainerInterface;
23+
use Psr\Container\NotFoundExceptionInterface;
2224
use Psr\Http\Message\ResponseInterface;
2325
use Psr\Http\Message\ServerRequestInterface;
2426
use Psr\Http\Server\MiddlewareInterface;
@@ -55,6 +57,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5557
return $response;
5658
}
5759

60+
/**
61+
* @throws ContainerExceptionInterface
62+
* @throws NotFoundExceptionInterface
63+
*/
5864
private function logAndSave(string $startTime, ?ServerRequestInterface $request, ?ResponseInterface $response): bool
5965
{
6066
$times = explode(' ', $startTime);

cloud-admin/RateLimit/TokenBucket.php

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public function __construct(private readonly int $capacity, private int $tokenRa
4141
$this->runTicker();
4242
}
4343

44+
/**
45+
* @phpstan-return void
46+
*/
4447
public function acquireToken(): void
4548
{
4649
if ($this->tokens < 1) {

cloud-admin/SDB/Business/Route.php

+19
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@
3535
*/
3636
final class Route
3737
{
38+
/**
39+
* @phpstan-param ContainerInterface $container
40+
* @phpstan-param ConfigInterface $config
41+
*/
3842
public function __construct(
3943
private readonly ContainerInterface $container,
4044
private readonly ConfigInterface $config,
4145
) {}
4246

47+
/**
48+
* @phpstan-return array<array-key, mixed>
49+
*/
4350
public function getRoute(): array
4451
{
4552
$factory = $this->container->get(DispatcherFactory::class);
@@ -56,6 +63,12 @@ public function getRoute(): array
5663
return array_slice($rows, 0, count($rows) - 1);
5764
}
5865

66+
/**
67+
* @phpstan-param string $server
68+
* @phpstan-param RouteCollector $router
69+
* @phpstan-param string|null $path
70+
* @phpstan-return array<array-key, mixed>
71+
*/
5972
private function analyzeRouter(
6073
string $server,
6174
RouteCollector $router,
@@ -89,6 +102,12 @@ private function analyzeRouter(
89102
return $data;
90103
}
91104

105+
/**
106+
* @phpstan-param string $server
107+
* @phpstan-param RouteCollector $router
108+
* @phpstan-param string|null $path
109+
* @phpstan-return array<array-key, mixed>
110+
*/
92111
private function analyzeHandler(
93112
array &$data,
94113
string $serverName,

cloud-admin/Server/SslConfig.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@ public function __construct(/**
3737
* @var array{certificate:string,certificate_key:string,verify_peer:bool,verify_peer_name:bool,allow_self_signed:bool}
3838
*/
3939
private array $config = []
40-
) {
41-
// $this
42-
// ->setCertificate($this->config['certificate'] ?? '')
43-
// ->setCertificateKey($config['certificate_key'] ?? '')
44-
// ->setVerifyPeer($this->config['verify_peer'] ?? false)
45-
// ->setVerifyPeerName($this->config['verify_peer_name'] ?? false)
46-
// ->setAllowSelfSigned($this->config['allow_self_signed'] ?? false);
47-
}
40+
) {}
4841

4942
/**
5043
* @return bool

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"post-root-package-install": [
103103
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
104104
],
105-
"analyse": "@php vendor/bin/phpstan analyse --memory-limit 512M -l 0 -c phpstan.neon",
105+
"analyse": "@php vendor/bin/phpstan analyse --memory-limit 1024M -l 0 -c phpstan.neon",
106106
"cs-fix": "@php vendor/bin/php-cs-fixer fix $1",
107107
"rector": "rector process --clear-cache",
108108
"route": "@php bin/hyperf.php describe:routes",

0 commit comments

Comments
 (0)