Skip to content

Commit 9c99715

Browse files
chore: update dependencies
1 parent 12091a3 commit 9c99715

14 files changed

+94
-128
lines changed

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": "^0.26.1"
42+
"carthage-software/mago": "1.0.0-beta.7"
4343
},
4444
"minimum-stability": "dev",
4545
"config": {

composer.lock

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

mago.toml

Lines changed: 30 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,37 @@
1-
# Mago configuration file
2-
# For more information, see https://mago.carthage.software/#/getting-started/configuration
3-
php_version = "8.4.0"
1+
# Welcome to Mago!
2+
# For full documentation, see https://mago.carthage.software/tools/overview
3+
php-version = "8.4.0"
44

55
[source]
66
paths = ["src/", "tests/"]
77
includes = ["vendor"]
8-
excludes = [
9-
"./vendor/symfony/cache/Traits/ValueWrapper.php",
10-
"./vendor/composer",
11-
]
8+
excludes = []
129

13-
[format]
14-
print_width = 120
15-
tab_width = 4
16-
use_tabs = false
17-
null_type_hint = "Question"
10+
[formatter]
11+
print-width = 120
12+
tab-width = 4
13+
use-tabs = false
14+
null-type-hint = "question"
1815

1916
[linter]
20-
default_plugins = true
21-
plugins = ["php-unit"]
22-
23-
# NAMING
24-
[[linter.rules]]
25-
name = "naming/interface"
26-
psr = false
27-
28-
[[linter.rules]]
29-
name = "naming/trait"
30-
psr = false
31-
32-
[[linter.rules]]
33-
name = "naming/class"
34-
psr = false
35-
36-
# STRICTNESS
37-
38-
[[linter.rules]]
39-
name = "strictness/require-parameter-type"
40-
ignore_arrow_function = true
41-
ignore_closure = true
42-
43-
[[linter.rules]]
44-
name = "strictness/require-return-type"
45-
ignore_arrow_function = true
46-
ignore_closure = true
47-
48-
[[linter.rules]]
49-
name = "analysis/override-attribute"
50-
level = "off"
51-
52-
[[linter.rules]]
53-
name = "maintainability/halstead"
54-
level = "off"
55-
56-
[[linter.rules]]
57-
name = "maintainability/too-many-methods"
58-
level = "off"
59-
60-
[[linter.rules]]
61-
name = "maintainability/kan-defect"
62-
level = "off"
63-
64-
[[linter.rules]]
65-
name = "maintainability/cyclomatic-complexity"
66-
level = "off"
17+
integrations = ["phpunit"]
18+
19+
[linter.rules]
20+
ambiguous-function-call = { enabled = false }
21+
literal-named-argument = { enabled = false }
22+
halstead = { effort-threshold = 7000 }
23+
parameter-type = { ignore-closure = true, ignore-arrow-function = true }
24+
return-type = { ignore-arrow-function = true }
25+
too-many-methods = { enabled = false }
26+
trait-name = { enabled = false}
27+
class-name = { enabled = false}
28+
interface-name = { enabled = false}
29+
cyclomatic-complexity = { threshold = 18 }
30+
31+
[analyzer]
32+
find-unused-definitions = true
33+
find-unused-expressions = false
34+
analyze-dead-code = false
35+
check-throws = true
36+
allow-possibly-undefined-array-keys = true
37+
perform-heuristic-checks = true

src/Http/InertiaResponse.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class InertiaResponse implements Response
2525
{
2626
use IsResponse;
2727

28-
// @mago-expect maintainability/excessive-parameter-list
28+
// @mago-expect lint:excessive-parameter-list
2929
public function __construct(
3030
readonly Request $request,
3131
readonly string $component,
@@ -158,26 +158,25 @@ private static function resolvePropKeysThatShouldMerge(array $props, Request $re
158158
* Evaluates props recursively.
159159
* @pure
160160
*/
161-
private static function evaluateProps(array $props, Request $request, bool $unpackDotProps = true): array // @mago-expect best-practices/no-boolean-flag-parameter
161+
// @mago-expect lint:no-boolean-flag-parameter
162+
private static function evaluateProps(array $props, Request $request, bool $unpackDotProps = true): array
162163
{
163-
return arr($props)
164-
->map(function ($value, string|int $key) use ($request): array {
165-
$evaluated = ($value instanceof Closure) ? invoke($value) : $value;
166-
$evaluated = ($evaluated instanceof CallableProp) ? $evaluated() : $evaluated;
167-
$evaluated = ($evaluated instanceof ArrayInterface) ? $evaluated->toArray() : $evaluated;
168-
$evaluated = is_array($evaluated)
169-
? self::evaluateProps($evaluated, $request, unpackDotProps: false)
170-
: $evaluated;
171-
172-
return [$key, $evaluated];
173-
})
174-
->reduce(function (array $acc, array $item) use ($unpackDotProps): array {
175-
[$key, $value] = $item;
176-
if ($unpackDotProps && is_string($key) && str_contains($key, needle: '.')) {
177-
return arr($acc)->set($key, $value)->toArray();
178-
}
179-
$acc[$key] = $value;
180-
return $acc;
181-
}, []);
164+
return arr($props)->map(function ($value, string|int $key) use ($request): array {
165+
$evaluated = $value instanceof Closure ? invoke($value) : $value;
166+
$evaluated = $evaluated instanceof CallableProp ? $evaluated() : $evaluated;
167+
$evaluated = $evaluated instanceof ArrayInterface ? $evaluated->toArray() : $evaluated;
168+
$evaluated = is_array($evaluated)
169+
? self::evaluateProps($evaluated, $request, unpackDotProps: false)
170+
: $evaluated;
171+
172+
return [$key, $evaluated];
173+
})->reduce(function (array $acc, array $item) use ($unpackDotProps): array {
174+
[$key, $value] = $item;
175+
if ($unpackDotProps && is_string($key) && str_contains($key, needle: '.')) {
176+
return arr($acc)->set($key, $value)->toArray();
177+
}
178+
$acc[$key] = $value;
179+
return $acc;
180+
}, []);
182181
}
183182
}

src/Http/Middleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function __invoke(Request $request, HttpMiddlewareCallable $next): Respon
4646
}
4747

4848
if (
49-
$response->status === Status::FOUND &&
50-
in_array($request->method, [Method::POST, Method::PUT, Method::PATCH], strict: true)
49+
$response->status === Status::FOUND
50+
&& in_array($request->method, [Method::POST, Method::PUT, Method::PATCH], strict: true)
5151
) {
5252
$response->setStatus(Status::SEE_OTHER);
5353
}

src/Inertia.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ public function clearHistory(): self
9090

9191
public function location(string|Redirect $url): Response
9292
{
93-
$isInertiaRequest = $this
94-
->container->get(Request::class)
95-
->headers->has(Header::INERTIA);
93+
$isInertiaRequest = $this->container->get(Request::class)->headers->has(Header::INERTIA);
9694

9795
if ($isInertiaRequest) {
9896
if ($url instanceof Redirect) {
@@ -108,6 +106,6 @@ public function location(string|Redirect $url): Response
108106
);
109107
}
110108

111-
return ($url instanceof Redirect) ? $url : new Redirect($url);
109+
return $url instanceof Redirect ? $url : new Redirect($url);
112110
}
113111
}

src/ManifestVersionResolver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
{
1414
public function __construct(
1515
public ?string $manifestPath = null,
16-
) {}
16+
) {
17+
}
1718

1819
public function resolve(Container $container): string
1920
{

src/PageData.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
namespace NeoIsRecursive\Inertia;
66

77
use JsonSerializable;
8-
use Tempest\Support\Html\HtmlString;
98

109
final readonly class PageData implements JsonSerializable
1110
{
12-
// @mago-expect maintainability/excessive-parameter-list
11+
// @mago-expect lint:excessive-parameter-list
1312
public function __construct(
1413
public string $component,
1514
public array $props,
@@ -19,7 +18,8 @@ public function __construct(
1918
public bool $encryptHistory,
2019
public ?array $propKeysToDefer = null,
2120
public ?array $propsKeysToMerge = null,
22-
) {}
21+
) {
22+
}
2323

2424
public function toArray(): array
2525
{

tests/Integration/AlwaysPropTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class AlwaysPropTest extends TestCase
1212
{
1313
public function test_can_invoke(): void
1414
{
15-
$alwaysProp = new AlwaysProp(function () {
15+
$alwaysProp = new AlwaysProp(function (): string {
1616
return 'An always value';
1717
});
1818

@@ -53,9 +53,7 @@ public function __invoke(): string
5353

5454
public function test_can_resolve_bindings_when_invoked(): void
5555
{
56-
$alwaysProp = new AlwaysProp(function (Request $request) {
57-
return $request;
58-
});
56+
$alwaysProp = new AlwaysProp(fn(Request $request) => $request);
5957

6058
static::assertInstanceOf(Request::class, $alwaysProp());
6159
}

tests/Integration/DeferPropsTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class DeferPropsTest extends TestCase
1212
{
1313
public function test_can_invoke(): void
1414
{
15-
$deferProp = new DeferProp(function () {
15+
$deferProp = new DeferProp(function (): string {
1616
return 'A defered value';
1717
});
1818

@@ -34,9 +34,7 @@ public function test_can_accept_scalar_values(): void
3434

3535
public function test_can_resolve_bindings_when_invoked(): void
3636
{
37-
$deferProp = new DeferProp(function (Request $request) {
38-
return $request;
39-
});
37+
$deferProp = new DeferProp(fn(Request $request) => $request);
4038

4139
static::assertInstanceOf(Request::class, $deferProp());
4240
}

0 commit comments

Comments
 (0)