Skip to content

Commit 3bd8709

Browse files
committed
chore: Use StructArmed on QA
1 parent 0f478fb commit 3bd8709

165 files changed

Lines changed: 436 additions & 331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ phpunit.xml export-ignore
1919
phpunit.xml.dist export-ignore
2020
README.md export-ignore
2121
rector.php export-ignore
22+
structarmed.php export-ignore
2223
cliff.toml export-ignore
2324
.commitlintrc.json export-ignore
2425

‎.github/workflows/coding-conventions.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
phpstan-result-cache-
6666
6767
- name: Run PHPStan
68-
run: vendor/bin/phpstan --error-format=github -vv
68+
run: vendor/bin/phpstan --error-format=github -vv
6969

7070
- name: Save PHPStan result cache
7171
uses: actions/cache/save@v4
@@ -92,3 +92,22 @@ jobs:
9292
#
9393
# - name: Run Rector
9494
# run: vendor/bin/rector process --no-ansi --dry-run --no-progress-bar
95+
96+
97+
structarmed:
98+
name: "Run static analysis: StructArmed"
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: Setup PHP
104+
uses: shivammathur/setup-php@v2
105+
with:
106+
php-version: 8.5
107+
coverage: none
108+
109+
- name: Install composer dependencies
110+
uses: ramsey/composer-install@v3
111+
112+
- name: Run StructArmed
113+
run: vendor/bin/structarmed analyze

‎composer.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
"thenetworg/oauth2-azure": "^2.2",
9393
"twig/twig": "^3.16",
9494
"vertisan/oauth2-twitch-helix": "^2.0",
95-
"wohali/oauth2-discord-new": "^1.2"
95+
"wohali/oauth2-discord-new": "^1.2",
96+
"boundwize/structarmed": "^0.17.9"
9697
},
9798
"replace": {
9899
"tempest/auth": "self.version",

‎packages/auth/src/AccessControl/PolicyBasedAccessControl.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function findPoliciesForResourceAction(object|string $resource, UnitEnum
8686
$actionBeingEvaluated = Str\parse($action);
8787

8888
return new ImmutableArray($this->authConfig->policies[$resource] ?? [])
89-
->filter(fn ($_, string $action) => $action === $actionBeingEvaluated)
89+
->filter(static fn ($_, string $action) => $action === $actionBeingEvaluated)
9090
->flatten();
9191
}
9292

@@ -97,13 +97,13 @@ private function evaluatePolicy(MethodReflector $policy, ?object $resource, ?obj
9797
$this->ensureParameterAcceptsInput(
9898
reflector: $policy->getParameter(key: 0),
9999
input: $resource,
100-
throw: fn (string $expected) => throw PolicyMethodWasInvalid::resourceParameterIsInvalid($policyName, $expected),
100+
throw: static fn (string $expected) => throw PolicyMethodWasInvalid::resourceParameterIsInvalid($policyName, $expected),
101101
);
102102

103103
$this->ensureParameterAcceptsInput(
104104
reflector: $policy->getParameter(key: 1),
105105
input: $subject,
106-
throw: fn (string $expected) => throw PolicyMethodWasInvalid::subjectParameterIsInvalid($policyName, $expected),
106+
throw: static fn (string $expected) => throw PolicyMethodWasInvalid::subjectParameterIsInvalid($policyName, $expected),
107107
);
108108

109109
$decision = $policy->invokeArgs(

‎packages/auth/src/OAuth/Testing/TestingOAuthClient.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function assertAuthorizationUrlGenerated(?array $scopes = null, ?array $o
245245
public function assertUserFetched(string $code): void
246246
{
247247
Assert::assertNotEmpty(
248-
actual: array_filter($this->users, fn (array $user) => $user['code'] === $code),
248+
actual: array_filter($this->users, static fn (array $user) => $user['code'] === $code),
249249
message: sprintf('User with code "%s" was not handled.', $code),
250250
);
251251
}
@@ -259,7 +259,7 @@ public function assertAccessTokenRetrieved(?string $code = null): void
259259

260260
if ($code !== null) {
261261
Assert::assertNotEmpty(
262-
actual: array_filter($this->accessTokens, fn (array $token) => $token['code'] === $code),
262+
actual: array_filter($this->accessTokens, static fn (array $token) => $token['code'] === $code),
263263
message: sprintf('No access token was retrieved for code "%s".', $code),
264264
);
265265
}
@@ -275,7 +275,7 @@ public function assertAccessTokenRefreshed(?string $refreshToken = null): void
275275
if ($refreshToken !== null) {
276276
// @mago-expect lint:no-insecure-comparison
277277
Assert::assertNotEmpty(
278-
actual: array_filter($this->refreshedTokens, fn (array $token) => $token['refresh_token'] === $refreshToken),
278+
actual: array_filter($this->refreshedTokens, static fn (array $token) => $token['refresh_token'] === $refreshToken),
279279
message: sprintf('No access token was refreshed for refresh token "%s".', $refreshToken),
280280
);
281281
}

‎packages/cache/src/Commands/CacheClearCommand.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ private function clearUserCaches(?string $tag = null, bool $all = false): void
9393
/** @var GenericContainer $container */
9494
$container = $this->container;
9595
$cacheTags = arr($container->getSingletons(CacheConfig::class))
96-
->map(fn ($_, string $key) => $key === CacheConfig::class ? self::DEFAULT_CACHE : Str\after_last($key, '#'))
97-
->filter(fn (string $value) => $tag === null || $value === $tag)
96+
->map(static fn ($_, string $key) => $key === CacheConfig::class ? self::DEFAULT_CACHE : Str\after_last($key, '#'))
97+
->filter(static fn (string $value) => $tag === null || $value === $tag)
9898
->values();
9999

100100
if ($all === false && count($cacheTags) > 1) {

‎packages/cache/src/GenericCache.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getMany(iterable $key): array
134134
if (! $this->enabled) {
135135
return Arr\map_with_keys(
136136
array: $key,
137-
map: fn (string|Stringable $key) => yield (string) $key => null,
137+
map: static fn (string|Stringable $key) => yield (string) $key => null,
138138
);
139139
}
140140

‎packages/command-bus/src/AsyncCommandRepositories/FileCommandRepository.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function markAsFailed(string $uuid): void
5252
public function getPendingCommands(): array
5353
{
5454
return arr(glob(__DIR__ . '/../stored-commands/*.pending.txt'))
55-
->mapWithKeys(function (string $path) {
55+
->mapWithKeys(static function (string $path) {
5656
if (! Filesystem\is_file($path)) {
5757
return;
5858
}

‎packages/command-bus/src/MonitorAsyncCommands.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __invoke(): void
7171
}
7272

7373
$availableCommands = arr($this->repository->getPendingCommands())
74-
->filter(fn (object $_, string $uuid) => ! array_key_exists($uuid, $processes));
74+
->filter(static fn (object $_, string $uuid) => ! array_key_exists($uuid, $processes));
7575

7676
if (count($processes) === 5) {
7777
$this->sleep(0.5);

‎packages/console/src/Actions/RenderConsoleCommand.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function renderArgument(ConsoleArgumentDefinition $argument): string
7575
private function renderEnumArgument(ConsoleArgumentDefinition $argument): string
7676
{
7777
$parts = array_map(
78-
callback: fn (BackedEnum $case) => $case->value,
78+
callback: static fn (BackedEnum $case) => $case->value,
7979
array: $argument->type::cases(),
8080
);
8181

0 commit comments

Comments
 (0)