Revert "fix: resolve PHPStan static analysis warnings"

This reverts commit 2d3e4b4a95.
This commit is contained in:
xboard
2025-04-14 21:23:08 +08:00
parent 2d3e4b4a95
commit db235c10e8
84 changed files with 1190 additions and 2330 deletions
+8 -7
View File
@@ -5,7 +5,6 @@ namespace App\Http\Middleware;
use App\Exceptions\ApiException;
use Illuminate\Support\Facades\Auth;
use Closure;
use App\Models\User;
class Admin
{
@@ -18,13 +17,15 @@ class Admin
*/
public function handle($request, Closure $next)
{
/** @var User|null $user */
$user = Auth::guard('sanctum')->user();
if (!$user || !$user->is_admin) {
return response()->json(['message' => 'Unauthorized'], 403);
if (!Auth::guard('sanctum')->check()) {
throw new ApiException('未登录或登陆已过期', 403);
}
$user = Auth::guard('sanctum')->user();
if (!$user->is_admin) {
throw new ApiException('无管理员权限', 403);
}
return $next($request);
}
}
@@ -2,17 +2,16 @@
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends PreventRequestsDuringMaintenance
class CheckForMaintenanceMode extends Middleware
{
/**
* 维护模式白名单URI
* @var array<int, string>
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
// 示例:
// '/api/health-check',
// '/status'
//
];
}
+3 -2
View File
@@ -7,8 +7,9 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* 不需要加密的Cookie名称列表
* @var array<int, string>
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
+3 -4
View File
@@ -7,13 +7,12 @@ use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* 不需要去除前后空格的字段名
* @var array<int, string>
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
'encrypted_data',
'signature'
];
}
+5 -3
View File
@@ -8,8 +8,9 @@ use Illuminate\Http\Request;
class TrustProxies extends Middleware
{
/**
* 可信代理列表
* @var array<int, string>|string|null
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies = [
"173.245.48.0/20",
@@ -35,7 +36,8 @@ class TrustProxies extends Middleware
];
/**
* 代理头映射
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers =
+5 -3
View File
@@ -7,14 +7,16 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* 是否在响应中设置XSRF-TOKEN cookie
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* 不需要CSRF验证的URI列表
* @var array<int, string>
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
//