Skip to content

Commit

Permalink
修复基础错误
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Dec 22, 2024
1 parent e3839c5 commit 2676d8d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 54 deletions.
4 changes: 2 additions & 2 deletions app/Infra/Exceptions/BusinessException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
int|object $code = 0,
string|array $message = '',
bool $overrideMessage = false,
\Throwable $previous = null,
?\Throwable $previous = null,
float $duration = 5,
) {
[$code, $message] = $this->prepareCodeAndMessage($code, $message, $overrideMessage);
Expand Down Expand Up @@ -53,7 +53,7 @@ protected function reportToLog(): void
{
try {
/** @var \Leevel\Log\ILog $log */
$log = \App::make('log');
$log = \App::proxy()->make('log');
$log->error($this->getMessage(), ['exception' => (string) $this]);
} catch (Throwable) {
}
Expand Down
2 changes: 1 addition & 1 deletion app/Infra/Exceptions/LockException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
int|object $code = 0,
string|array $message = '',
bool $overrideMessage = false,
\Throwable $previous = null
?\Throwable $previous = null
) {
[$code, $message] = $this->prepareCodeAndMessage($code, $message, $overrideMessage);
parent::__construct(Response::HTTP_FAILED_DEPENDENCY, $message, $code, $previous);
Expand Down
2 changes: 1 addition & 1 deletion app/Infra/Exceptions/UnauthorizedHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
int|object $code = 0,
string|array $message = '',
bool $overrideMessage = false,
\Throwable $previous = null
?\Throwable $previous = null
) {
[$code, $message] = $this->prepareCodeAndMessage($code, $message, $overrideMessage);
parent::__construct($message, $code, $previous);
Expand Down
2 changes: 1 addition & 1 deletion app/Infra/Helper/ForceCloseDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function handle(): void

public static function restore(): void
{
Config::set('debug', static::$debug);
Config::proxy()->set('debug', static::$debug);

$debugBar = static::getDebugBar();
if (static::$debugBar) {
Expand Down
13 changes: 1 addition & 12 deletions app/Infra/Helper/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use App\Infra\Module\RoadRunner\RoadRunnerDump;
use App\Infra\Proxy\Permission;
use Leevel\Cache\Manager;
use Leevel\Cache\Redis;
use Leevel\Database\IDatabase;
Expand All @@ -22,16 +21,6 @@ function enabledCoroutine(): bool
}
}

if (!function_exists('permission')) {
/**
* 校验权限.
*/
function permission(string $resource, ?string $method = null): bool
{
return Permission::handle($resource, $method);
}
}

if (!function_exists('sql_listener')) {
/**
* SQL 监听器.
Expand Down Expand Up @@ -241,7 +230,7 @@ function response_add_cors_headers(Response $response): Response
function redis_cache(): \Redis
{
/** @var Manager $manager */
$manager = \App::make('caches');
$manager = \App::proxy()->make('caches');

/** @var Redis $phpRedis */
$phpRedis = $manager->connect('redis');
Expand Down
31 changes: 31 additions & 0 deletions app/Infra/Proxy/Demo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Infra\Proxy;

use App\Infra\Service\Demo as DemoService;

/**
* 代理 Demo.
*/
class Demo
{
/**
* call.
*
* @return mixed
*/
public static function __callStatic(string $method, array $args)
{
return self::proxy()->{$method}(...$args);
}

/**
* 代理服务.
*/
public static function proxy(): DemoService
{
return new DemoService();
}
}
35 changes: 0 additions & 35 deletions app/Infra/Proxy/Permission.php

This file was deleted.

4 changes: 2 additions & 2 deletions app/Infra/Service/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace App\Infra\Service;

class Page
class Demo
{
public function handle(DemoParams $params): array
{
$params->validate();

return [
'hello' => 'world',
];
Expand Down

0 comments on commit 2676d8d

Please sign in to comment.