Skip to content

Commit 43c72cf

Browse files
committed
refactor(scripts): Rename dump-soar-yaml-config to dump-soar-config
- Change the alias name from `@dump-soar-yaml-config` to `@dump-soar-config` in `composer.json`. - Add a new script `dump-soar-original-php-config` to handle PHP configuration. - The modified structure enhances clarity and aligns with the current config naming conventions.
1 parent 55e707b commit 43c72cf

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
"@composer-normalize",
165165
"@composer-validate",
166166
"@check-soar-binary",
167-
"@dump-soar-yaml-config",
167+
"@dump-soar-config",
168168
"@json-lint",
169169
"@md-lint",
170170
"@yaml-lint",
@@ -191,7 +191,9 @@
191191
"@dump-soar-yaml-config",
192192
"@dump-soar-php-config"
193193
],
194+
"dump-soar-original-php-config": "Guanguans\\SoarPHP\\Support\\ComposerScripts::dumpSoarPHPConfig",
194195
"dump-soar-php-config": [
196+
"@dump-soar-original-php-config",
195197
"@rector-soar-options",
196198
"@style-fix"
197199
],

rector-soar-options.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,14 @@
1515
* @see https://github.com/guanguans/soar-php
1616
*/
1717

18-
use Guanguans\SoarPHP\Support\ComposerScripts;
1918
use Guanguans\SoarPHP\Support\Rectors\AddSoarOptionsDocCommentRector;
2019
use Guanguans\SoarPHP\Support\Rectors\SimplifyListIndexRector;
2120
use Rector\Config\RectorConfig;
2221
use Rector\ValueObject\PhpVersion;
2322

24-
file_put_contents(
25-
$path = __DIR__.'/examples/soar-options.php',
26-
$code = \sprintf(
27-
<<<'PHP'
28-
<?php
29-
30-
declare(strict_types=1);
31-
32-
/**
33-
* Copyright (c) 2019-2025 guanguans<ityaozm@gmail.com>
34-
*
35-
* For the full copyright and license information, please view
36-
* the LICENSE file that was distributed with this source code.
37-
*
38-
* @see https://github.com/guanguans/soar-php
39-
*/
40-
41-
// +----------------------------------------------------------------------+//
42-
// | 请参考 @see https://github.com/XiaoMi/soar |//
43-
// +----------------------------------------------------------------------+//
44-
45-
return %s;
46-
PHP,
47-
var_export(ComposerScripts::resolveSoarHelp()->map(static fn (array $help): mixed => $help['default'])->all(), true),
48-
)
49-
);
50-
5123
return RectorConfig::configure()
5224
->withPaths([
53-
$path,
25+
__DIR__.'/examples/soar-options.php',
5426
])
5527
->withPhpVersion(PhpVersion::PHP_80)
5628
->withoutParallel()

src/Support/ComposerScripts.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,48 @@ public static function dumpSoarYamlConfig(Event $event): int
7575
return 0;
7676
}
7777

78+
/**
79+
* @noinspection PhpUnused
80+
* @noinspection DebugFunctionUsageInspection
81+
*
82+
* @throws \Guanguans\SoarPHP\Exceptions\InvalidOptionException
83+
*/
84+
public static function dumpSoarPHPConfig(Event $event): int
85+
{
86+
self::requireAutoload($event);
87+
88+
file_put_contents(
89+
__DIR__.'/../../examples/soar-options.php',
90+
\sprintf(
91+
<<<'PHP'
92+
<?php
93+
94+
declare(strict_types=1);
95+
96+
/**
97+
* Copyright (c) 2019-2025 guanguans<ityaozm@gmail.com>
98+
*
99+
* For the full copyright and license information, please view
100+
* the LICENSE file that was distributed with this source code.
101+
*
102+
* @see https://github.com/guanguans/soar-php
103+
*/
104+
105+
// +----------------------------------------------------------------------+//
106+
// | 请参考 @see https://github.com/XiaoMi/soar |//
107+
// +----------------------------------------------------------------------+//
108+
109+
return %s;
110+
PHP,
111+
var_export(self::resolveSoarHelp()->map(static fn (array $help): mixed => $help['default'])->all(), true),
112+
)
113+
);
114+
115+
self::makeSymfonyStyle()->success('No errors');
116+
117+
return 0;
118+
}
119+
78120
/**
79121
* @throws \Guanguans\SoarPHP\Exceptions\InvalidOptionException
80122
*/

src/Support/OS.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function isWindows(): bool
4343

4444
public static function isMacOS(): bool
4545
{
46-
return str_contains(\php_uname('s'), 'Darwin');
46+
return str_contains(php_uname('s'), 'Darwin');
4747
}
4848

4949
public static function isArm(): bool
@@ -78,6 +78,6 @@ public static function getArchEnum(): string
7878

7979
public static function getArch(): string
8080
{
81-
return \php_uname('m');
81+
return php_uname('m');
8282
}
8383
}

0 commit comments

Comments
 (0)