Skip to content

Commit 8fc3537

Browse files
committed
refactor(zoho): Improve token generation and update dependencies
- Refactored the Token class constructor for better readability. - Updated Guzzle dependency version from ^7.9 to ^7.10. - Enhanced PHP CS Fixer configuration with new rules and updated dependencies. - Adjusted various PHPDoc comments for clarity and accuracy. Signed-off-by: guanguans <ityaozm@gmail.com>
1 parent 8444b30 commit 8fc3537

13 files changed

Lines changed: 192 additions & 91 deletions

.ai-commit.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
":!*-lock.json",
44
":!*.lock",
55
":!*.sum",
6-
":!/baselines/*.neon"
7-
]
8-
}
6+
":!/baselines/*.neon",
7+
":(exclude)public/vendor/",
8+
":(exclude)tests/__snapshots__/"
9+
],
10+
"no_verify": true,
11+
"generator": "github_models_cli",
12+
"generators": {
13+
"github_models_cli": {
14+
"model": "openai/gpt-4.1-mini"
15+
}
16+
}
17+
}

.php-cs-fixer.php

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Ergebnis\PhpCsFixer\Config\RuleSet\Php80;
2323
use PhpCsFixer\Finder;
2424
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
25-
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
2625
use PhpCsFixerCustomFixers\Fixer\AbstractFixer;
2726

2827
$license = MIT::text(
@@ -40,15 +39,15 @@
4039
$ruleSet = Php80::create()
4140
->withHeader($license->header())
4241
->withRules(Rules::fromArray([
43-
'@PHP70Migration' => true,
44-
'@PHP70Migration:risky' => true,
45-
'@PHP71Migration' => true,
46-
'@PHP71Migration:risky' => true,
47-
'@PHP73Migration' => true,
48-
'@PHP74Migration' => true,
49-
'@PHP74Migration:risky' => true,
50-
'@PHP80Migration' => true,
51-
'@PHP80Migration:risky' => true,
42+
'@PHP7x0Migration' => true,
43+
'@PHP7x0Migration:risky' => true,
44+
'@PHP7x1Migration' => true,
45+
'@PHP7x1Migration:risky' => true,
46+
'@PHP7x3Migration' => true,
47+
'@PHP7x4Migration' => true,
48+
'@PHP7x4Migration:risky' => true,
49+
'@PHP8x0Migration' => true,
50+
'@PHP8x0Migration:risky' => true,
5251
// '@PHP81Migration' => true,
5352
// '@PHP82Migration' => true,
5453
// '@PHP83Migration' => true,
@@ -143,6 +142,24 @@
143142
'anonymous_class' => false,
144143
'named_class' => false,
145144
],
145+
'no_extra_blank_lines' => [
146+
'tokens' => [
147+
'attribute',
148+
'break',
149+
'case',
150+
// 'comma',
151+
'continue',
152+
'curly_brace_block',
153+
'default',
154+
'extra',
155+
'parenthesis_brace_block',
156+
'return',
157+
'square_brace_block',
158+
'switch',
159+
'throw',
160+
'use',
161+
],
162+
],
146163
'ordered_traits' => [
147164
'case_sensitive' => true,
148165
],
@@ -194,6 +211,25 @@
194211
'return',
195212
],
196213
],
214+
'phpdoc_order_by_value' => [
215+
'annotations' => [
216+
'author',
217+
'covers',
218+
'coversNothing',
219+
'dataProvider',
220+
'depends',
221+
'group',
222+
'internal',
223+
'method',
224+
'mixin',
225+
'property',
226+
'property-read',
227+
'property-write',
228+
'requires',
229+
'throws',
230+
'uses',
231+
],
232+
],
197233
'phpdoc_to_param_type' => [
198234
'scalar_types' => true,
199235
'types_map' => [],
@@ -216,6 +252,7 @@
216252
'stick_comment_to_next_continuous_control_statement' => true,
217253
],
218254
'static_lambda' => false, // pest
255+
'static_private_method' => false,
219256
]));
220257

221258
$ruleSet->withCustomFixers(Fixers::fromFixers(
@@ -252,5 +289,4 @@
252289
)
253290
->setRiskyAllowed(true)
254291
->setUsingCache(true)
255-
->setParallelConfig(ParallelConfigFactory::detect())
256292
->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# total 1 error
2+
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: '#^Call to function property_exists\(\) with \$this\(Guanguans\\Notify\\Foundation\\Message\) and ''ignoreUndefined'' will always evaluate to true\.$#'
7+
count: 1
8+
path: ../src/Foundation/Message.php

baselines/loader.neon

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# total 14 errors
1+
# total 15 errors
2+
23
includes:
34
- assign.propertyType.neon
45
- disallowed.function.neon
6+
- function.alreadyNarrowedType.neon
57
- new.static.neon
68
- typePerfect.narrowPublicClassMethodParamType.neon

composer-dependency-analyser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
],
5050
[ErrorType::SHADOW_DEPENDENCY]
5151
)
52-
->ignoreErrorsOnPackageAndPath(
53-
'guanguans/ai-commit',
54-
__DIR__.'/src/Foundation/Support/Str.php',
55-
[ErrorType::DEV_DEPENDENCY_IN_PROD]
56-
)
52+
// ->ignoreErrorsOnPackageAndPath(
53+
// 'guanguans/ai-commit',
54+
// __DIR__.'/src/Foundation/Support/Str.php',
55+
// [ErrorType::DEV_DEPENDENCY_IN_PROD]
56+
// )
5757
->ignoreErrorsOnPackages(
5858
[
5959
'illuminate/collections',

composer-updater

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ $status = (new SingleCommandApplication)
5858
private string $composerBinary;
5959
private array $exceptPackages;
6060
private array $exceptDependencyVersions;
61-
private bool $dryRun;
6261
private SymfonyStyle $symfonyStyle;
6362
private Differ $differ;
6463

@@ -71,7 +70,7 @@ $status = (new SingleCommandApplication)
7170
?string $composerBinary = null,
7271
array $exceptPackages = [],
7372
array $exceptDependencyVersions = [],
74-
bool $dryRun = false,
73+
private bool $dryRun = false,
7574
?SymfonyStyle $symfonyStyle = null,
7675
?Differ $differ = null
7776
) {
@@ -92,7 +91,6 @@ $status = (new SingleCommandApplication)
9291
'*@*',
9392
// '*|*',
9493
], $exceptDependencyVersions);
95-
$this->dryRun = $dryRun;
9694
$this->symfonyStyle = $symfonyStyle ?? new SymfonyStyle(new ArgvInput, new ConsoleOutput);
9795
$this->differ = $differ ?? new Differ;
9896
}
@@ -145,6 +143,9 @@ $status = (new SingleCommandApplication)
145143
return $this;
146144
}
147145

146+
/**
147+
* @noinspection PhpUnusedPrivateMethodInspection
148+
*/
148149
private function normalizeComposerJson(): self
149150
{
150151
$this->mustRunCommand("$this->composerBinary normalize --diff --ansi");
@@ -163,7 +164,7 @@ $status = (new SingleCommandApplication)
163164
private function getOutdatedDecodedComposerJson(): array
164165
{
165166
$outdatedComposerPackages = $this->getOutdatedComposerPackages();
166-
$decodedComposerJson = json_decode(file_get_contents($this->composerJsonPath), true);
167+
$decodedComposerJson = json_decode(file_get_contents($this->composerJsonPath), true, 512, \JSON_THROW_ON_ERROR);
167168
InstalledVersions::reload([]);
168169

169170
foreach ($decodedComposerJson as $name => &$value) {
@@ -203,20 +204,22 @@ $status = (new SingleCommandApplication)
203204
$output = $this
204205
->mustRunCommand("$this->highestComposerBinary outdated --format=json --direct --ansi")
205206
->getOutput(),
206-
strpos($output, '{'.\PHP_EOL)
207+
(int) strpos($output, '{'.\PHP_EOL)
207208
),
208-
true
209+
true,
210+
512,
211+
\JSON_THROW_ON_ERROR
209212
)['installed'],
210213
function (array $carry, array $package): array {
211214
$lowestArrayVersion = $this->toArrayVersion($package['version']);
212215
$highestArrayVersion = $this->toArrayVersion($package['latest']);
213216
$dependencyVersions = [$this->toDependencyVersion($package['version'])];
214217

215218
if ($lowestArrayVersion[0] !== $highestArrayVersion[0]) {
216-
$dependencyVersions = array_merge($dependencyVersions, array_map(
219+
$dependencyVersions = [...$dependencyVersions, ...array_map(
217220
static fn (string $major): string => "^$major.0",
218221
range($lowestArrayVersion[0] + 1, $highestArrayVersion[0])
219-
));
222+
)];
220223
}
221224

222225
$package['dependency_version'] = implode(' || ', $dependencyVersions);
@@ -232,8 +235,8 @@ $status = (new SingleCommandApplication)
232235
{
233236
return \sprintf(
234237
'%s %s',
235-
$phpBinary ?? (new PhpExecutableFinder)->find(),
236-
$composerBinary ?? (new ExecutableFinder)->find('composer')
238+
escapeshellarg($phpBinary ?? (new PhpExecutableFinder)->find()),
239+
escapeshellarg((string) ($composerBinary ?? (new ExecutableFinder)->find('composer')))
237240
);
238241
}
239242

@@ -247,7 +250,7 @@ $status = (new SingleCommandApplication)
247250
?string $cwd = null,
248251
?array $env = null,
249252
mixed $input = null,
250-
?float $timeout = 300
253+
?float $timeout = 600
251254
): Process {
252255
$additionalOptions = [
253256
'--no-interaction',
@@ -256,6 +259,8 @@ $status = (new SingleCommandApplication)
256259
'--ansi',
257260
];
258261

262+
$cwd ??= \dirname($this->composerJsonPath);
263+
259264
$process = \is_string($command)
260265
? Process::fromShellCommandline(\sprintf("$command %s", implode(' ', $additionalOptions)), $cwd, $env, $input, $timeout)
261266
: new Process($command + $additionalOptions, $cwd, $env, $input, $timeout);
@@ -282,27 +287,14 @@ $status = (new SingleCommandApplication)
282287

283288
private function formatDiff(string $diff): string
284289
{
285-
$lines = explode(
286-
"\n",
287-
$diff,
288-
);
289-
290-
$formatted = array_map(static fn (string $line): string => preg_replace(
291-
[
292-
'/^(\+.*)$/',
293-
'/^(-.*)$/',
294-
],
295-
[
296-
'<fg=green>$1</>',
297-
'<fg=red>$1</>',
298-
],
299-
$line,
300-
), $lines);
301-
302-
return implode(
303-
"\n",
304-
$formatted,
305-
);
290+
return implode(\PHP_EOL, array_map(
291+
static fn (string $line): string => preg_replace(
292+
['/^(\+.*)$/', '/^(-.*)$/'],
293+
['<fg=green>$1</>', '<fg=red>$1</>'],
294+
$line,
295+
),
296+
explode(\PHP_EOL, $diff)
297+
));
306298
}
307299
})();
308300
})

composer.json

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,45 +77,45 @@
7777
"require": {
7878
"php": ">=8.0",
7979
"ext-simplexml": "*",
80-
"guzzlehttp/guzzle": "^7.9",
80+
"guzzlehttp/guzzle": "^7.10",
8181
"guzzlehttp/uri-template": "^1.0",
8282
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0"
8383
},
8484
"require-dev": {
85-
"azjezz/psl": "^1.9 || ^2.0 || ^3.0",
85+
"azjezz/psl": "^0.0 || ^1.0 || ^2.0",
8686
"bamarni/composer-bin-plugin": "^1.8",
8787
"brainmaestro/composer-git-hooks": "^3.0",
8888
"composer/composer": "^2.8",
89-
"ergebnis/composer-normalize": "^2.45",
90-
"ergebnis/license": "^2.6",
89+
"ergebnis/composer-normalize": "^2.48",
90+
"ergebnis/license": "^2.7",
9191
"ergebnis/php-cs-fixer-config": "dev-main",
92-
"ergebnis/rector-rules": "^1.3",
93-
"guanguans/monorepo-builder-worker": "^1.4",
92+
"ergebnis/rector-rules": "^1.6",
93+
"guanguans/monorepo-builder-worker": "^2.1",
9494
"illuminate/collections": "^9.52 || ^10.0 || ^11.0 || ^12.0",
9595
"illuminate/support": "^9.52 || ^10.0 || ^11.0 || ^12.0",
9696
"infection/extension-installer": "^0.1",
9797
"infection/infection": "^0.26",
9898
"mockery/mockery": "^1.6",
9999
"nette/utils": "^4.0",
100-
"pestphp/pest": "^1.23 || ^2.0 || ^3.0",
101-
"pestphp/pest-plugin-faker": "^1.0 || ^2.0 || ^3.0",
100+
"pestphp/pest": "^1.23 || ^2.0 || ^3.0 || ^4.0",
101+
"pestphp/pest-plugin-faker": "^1.0 || ^2.0 || ^3.0 || ^4.0",
102102
"php-mock/php-mock-phpunit": "^2.13",
103103
"phpbench/phpbench": "^1.2",
104104
"phpstan/extension-installer": "^1.4",
105105
"phpstan/phpstan": "^2.1",
106106
"phpstan/phpstan-deprecation-rules": "^2.0",
107107
"phpstan/phpstan-webmozart-assert": "^2.0",
108108
"povils/phpmnd": "^3.6",
109-
"rector/rector": "^2.0",
110-
"rector/swiss-knife": "^2.1",
111-
"rector/type-perfect": "^2.0",
109+
"rector/rector": "^2.2",
110+
"rector/swiss-knife": "^2.3",
111+
"rector/type-perfect": "^2.1",
112112
"shipmonk/composer-dependency-analyser": "^1.8",
113-
"shipmonk/phpstan-baseline-per-identifier": "^2.1",
114-
"spaze/phpstan-disallowed-calls": "^4.4",
113+
"shipmonk/phpstan-baseline-per-identifier": "^2.2",
114+
"spaze/phpstan-disallowed-calls": "^4.7",
115115
"symfony/var-dumper": "^6.0 || ^7.0",
116116
"symfony/yaml": "^6.0 || ^7.0",
117117
"symplify/phpstan-extensions": "^12.0",
118-
"symplify/phpstan-rules": "^14.5",
118+
"symplify/phpstan-rules": "^14.8",
119119
"tomasvotruba/class-leak": "^2.0",
120120
"tomasvotruba/type-coverage": "^2.0",
121121
"yamadashy/phpstan-friendly-formatter": "^1.2"
@@ -232,6 +232,8 @@
232232
"mark-start": "printf '\\n!\\n!\\t\\033[0;36m%s\\033[0m\\n!\\n\\n' \"Started\"",
233233
"md-fix": "@md-lint --fix",
234234
"md-lint": "lint-md --config .lintmdrc ./*.md ./.github/ ./docs/ ./src/*/*.md",
235+
"normalized": "@composer normalize --diff --ansi -v",
236+
"normalized-dry-run": "@normalized --dry-run",
235237
"peck": "/opt/homebrew/opt/php@8.3/bin/php ./vendor/bin/peck check --path=src/ --config=peck.json --ansi -v",
236238
"peck-init": "@peck --init",
237239
"pest": "@php ./vendor/bin/pest --coverage",
@@ -267,11 +269,17 @@
267269
"@putenv PHP83=/opt/homebrew/opt/php@8.3/bin/php",
268270
"@putenv PHP84=/opt/homebrew/opt/php@8.4/bin/php"
269271
],
270-
"rector": "@php ./vendor/bin/rector --clear-cache --ansi -v",
272+
"rector": "@php ./vendor/bin/rector --ansi",
273+
"rector-clear-cache": "@rector --clear-cache",
274+
"rector-clear-cache-dry-run": "@rector-clear-cache --dry-run",
271275
"rector-custom-rule": "@rector custom-rule",
276+
"rector-debug": "@rector-clear-cache --config=rector-debug.php --debug",
277+
"rector-debug-dry-run": "@rector-debug --dry-run",
272278
"rector-detect-node": "@rector detect-node --loop",
273279
"rector-dry-run": "@rector --dry-run",
274280
"rector-list-rules": "@rector list-rules",
281+
"rector-only": "@rector-clear-cache --only=Guanguans\\MonorepoBuilderWorker\\Support\\Rectors\\RenameToPsrNameRector",
282+
"rector-only-dry-run": "@rector-only --dry-run",
275283
"rector-php82": "@rector --config=rector-php82.php",
276284
"rector-php82-dry-run": "@rector-php82 --dry-run",
277285
"rector-setup-ci": "@rector setup-ci",
@@ -304,6 +312,12 @@
304312
"scripts-aliases": {
305313
"lint": [
306314
"php-lint"
315+
],
316+
"normalized": [
317+
"composer-normalize"
318+
],
319+
"normalized-dry-run": [
320+
"composer-normalize-dry-run"
307321
]
308322
},
309323
"$schema": "https://getcomposer.org/schema.json"

0 commit comments

Comments
 (0)