Skip to content

Commit c9fa657

Browse files
committed
update: apply php-cs-fixer fix
1 parent 733e905 commit c9fa657

10 files changed

+37
-25
lines changed

.gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/tests export-ignore
22
.php_cs.dist export-ignore
3-
phpstan.neon export-ignore
3+
.php-cs-fixer.php export-ignore
4+
phpstan.neon export-ignore

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/vendor
33
/composer.lock
44
/*.phar
5-
.php_cs.cache
5+
.php_cs.cache
6+
.php-cs-fixer.cache

.php-cs-fixer.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in([
5+
'src',
6+
]);
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@PSR12' => true,
11+
'@PHP74Migration' => true,
12+
'normalize_index_brace' => true,
13+
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
14+
'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'],
15+
'standardize_not_equals' => true,
16+
'unary_operator_spaces' => true,
17+
// risky
18+
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'all', 'strict' => true],
19+
'function_to_constant' => true,
20+
// 暂时不要发生过大的变动范围
21+
'blank_line_between_import_groups' => false,
22+
])
23+
->setRiskyAllowed(true)
24+
->setFinder($finder);

.php_cs.dist

-14
This file was deleted.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# ThinkPHP 6.0 - CORS 跨域控制扩展
22

33
### 全局启用
4-
- 配置服务注册 (app/service.php):``\HZEX\Think\Cors\Service::class``
4+
- 配置服务注册 (app/service.php):``\Zxin\Think\Cors\Service::class``
55
### 局部启用
6-
1. 配置服务注册 (app/service.php):``\HZEX\Think\Cors\Service::class``
6+
1. 配置服务注册 (app/service.php):``\Zxin\Think\Cors\Service::class``
77
2. 禁用自动注册中间件:``config.cors.auto_register_middleware => false``
8-
3. 注册中间件:``\HZEX\Think\Cors\CorsMiddleware::class``
8+
3. 注册中间件:``\Zxin\Think\Cors\CorsMiddleware::class``
99
4. 确保优先级:``config.middleware.priority``
1010

1111
## 代码引用

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"topthink/framework": "^6.1|~8.0.1"
2121
},
2222
"require-dev": {
23+
"php-cs-fixer/shim": "^3.22",
2324
"phpstan/phpstan": "^1.10.28",
2425
"phpunit/phpunit": "^9",
2526
"symfony/var-dumper": "^5.4|^6.0"

src/CorsConfig.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace HZEX\Think\Cors;
5+
namespace Zxin\Think\Cors;
66

77
use think\App;
88
use function array_map;

src/CorsCore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace HZEX\Think\Cors;
5+
namespace Zxin\Think\Cors;
66

77
use think\Request;
88
use think\Response;

src/CorsMiddleware.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace HZEX\Think\Cors;
5+
namespace Zxin\Think\Cors;
66

77
use Closure;
8-
use think\App;
98
use think\Request;
109
use think\Response;
1110

@@ -21,7 +20,7 @@ class CorsMiddleware
2120
*/
2221
public function handle(Request $request, Closure $next, ?CorsConfig $config = null): Response
2322
{
24-
$config = $config ?? CorsConfig::getConfigFromContainer();
23+
$config ??= CorsConfig::getConfigFromContainer();
2524
$cors = new CorsCore($config);
2625
if ($cors->isPreflightRequest($request)) {
2726
$response = $cors->handlePreflightRequest($request);

src/Service.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace HZEX\Think\Cors;
5+
namespace Zxin\Think\Cors;
66

77
use think\App;
88

0 commit comments

Comments
 (0)