Skip to content

Commit 0e09b05

Browse files
chore: update mago and improve static analysis issues
1 parent dce5cd8 commit 0e09b05

12 files changed

Lines changed: 71 additions & 70 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"require-dev": {
4141
"phpunit/phpunit": "^11.5.15",
42-
"carthage-software/mago": "1.0.0-beta.24"
42+
"carthage-software/mago": "1.0.0-rc.1"
4343
},
4444
"minimum-stability": "dev",
4545
"config": {

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mago.toml

Lines changed: 0 additions & 42 deletions
This file was deleted.

mago.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Welcome to Mago!
2+
# yaml-language-server: $schema=./mago.schema.json
3+
# For full documentation, see https://mago.carthage.software/tools/overview
4+
php-version: "8.4.0"
5+
6+
source:
7+
paths:
8+
- "src/"
9+
- "tests/"
10+
includes:
11+
- "vendor"
12+
excludes:
13+
- "./vendor/symfony/cache/Traits/ValueWrapper.php"
14+
- "./vendor/composer"
15+
- "./tests"
16+
17+
formatter:
18+
print-width: 120
19+
tab-width: 4
20+
use-tabs: false
21+
null-type-hint: "Question"
22+
23+
linter:
24+
integrations:
25+
- "phpunit"
26+
27+
linter.rules:
28+
yoda-conditions:
29+
enabled: false
30+
ambiguous-function-call:
31+
enabled: false
32+
literal-named-argument:
33+
enabled: false
34+
halstead:
35+
effort-threshold: 7000
36+
interface-name:
37+
enabled: false
38+
trait-name:
39+
enabled: false
40+
return-type:
41+
ignore-arrow-function: true
42+
parameter-type:
43+
ignore-closure: true
44+
ignore-arrow-function: true
45+
46+
analyzer:
47+
excludes:
48+
- "./tests"
49+
find-unused-definitions: true
50+
find-unused-expressions: false
51+
analyze-dead-code: false
52+
check-throws: true
53+
allow-possibly-undefined-array-keys: true
54+
perform-heuristic-checks: false

src/Concerns/IsMergeableProp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
trait IsMergeableProp
1111
{
12-
public function merge(): self
12+
public function merge(): static
1313
{
1414
$this->shouldMerge = true;
1515

src/Contracts/MergeableProp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ interface MergeableProp
1010
get;
1111
}
1212

13-
public function merge(): self;
13+
public function merge(): static;
1414
}

src/Http/InertiaResponse.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ private static function resolvePartialProps(Request $request, string $component,
120120
string: $headers->get(Header::PARTIAL_EXCEPT) ?? '',
121121
));
122122

123-
/** @var mixed[] */
124123
$filtered = $only ? array_intersect_key($props, array_flip($only)) : $props;
125124

126125
return array_filter($filtered, static fn($key) => !in_array($key, $except, strict: true), ARRAY_FILTER_USE_KEY);
@@ -152,8 +151,8 @@ private static function resolvePropKeysThatShouldMerge(array $props, Request $re
152151
));
153152

154153
$propKeysToMerge = arr($props)
155-
->filter(fn($prop) => $prop instanceof MergeableProp && $prop->shouldMerge)
156-
->filter(fn($_, $key) => !$resetProps->contains($key))
154+
->filter(static fn($prop) => $prop instanceof MergeableProp && $prop->shouldMerge)
155+
->filter(static fn($_, $key) => !$resetProps->contains($key))
157156
->keys();
158157

159158
return $propKeysToMerge->isEmpty() ? null : $propKeysToMerge->toArray();

src/Http/Middleware.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function __construct(
2727
#[Override]
2828
public function __invoke(Request $request, HttpMiddlewareCallable $next): Response
2929
{
30-
/** @var Response $response */
3130
$response = $next($request);
3231

3332
$response = $response->addHeader(

src/Inertia.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,8 @@ public function render(string $component, array $props = []): InertiaResponse
8181
props: array_merge($this->config->sharedProps, $props),
8282
rootView: $this->config->rootView,
8383
version: $this->version,
84-
clearHistory: $this->session->get(
85-
key: 'inertia.clear_history',
86-
default: false,
87-
),
88-
encryptHistory: $this->session->get(
89-
key: 'inertia.encrypt_history',
90-
default: false,
91-
),
84+
clearHistory: $this->session->get(key: 'inertia.clear_history') === true,
85+
encryptHistory: $this->session->get(key: 'inertia.encrypt_history') === true,
9286
);
9387
}
9488

@@ -114,7 +108,6 @@ public function clearHistory(): self
114108

115109
public function location(string|Redirect $url): Response
116110
{
117-
/** @var bool */
118111
$isInertiaRequest = $this->container->get(Request::class)?->headers?->has(Header::INERTIA) ?? false;
119112

120113
if ($isInertiaRequest) {

src/Installer/InertiaInstaller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function installReact(string $clientPath, string $pagesPath): void
8989
$this->publish(
9090
source: __DIR__ . '/React/main.tsx',
9191
destination: (string) path($clientPath, 'main.entrypoint.tsx'),
92-
callback: function (string $_, string $target) use ($pagesPath): void {
92+
callback: static function (string $_, string $target) use ($pagesPath): void {
9393
$content = read_file($target);
9494

9595
write_file($target, replace(
@@ -145,7 +145,7 @@ private function installVue(string $clientPath, string $pagesPath): void
145145
$this->publish(
146146
source: __DIR__ . '/Vue/main.ts',
147147
destination: (string) path($clientPath, 'main.entrypoint.ts'),
148-
callback: function (string $_, string $target) use ($pagesPath): void {
148+
callback: static function (string $_, string $target) use ($pagesPath): void {
149149
$content = read_file($target);
150150

151151
write_file($target, replace(

0 commit comments

Comments
 (0)