Skip to content

Commit f7911cc

Browse files
committed
--force
1 parent 85ea00c commit f7911cc

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
".gitignore": true,
1616
"composer.lock": true,
1717
"phpstan-baseline.neon": true,
18-
"phpstan.neon.dist": true
18+
"phpstan.neon.dist": true,
19+
"CHANGELOG.md": true,
20+
"LICENSE.md": true,
21+
"phpunit.xml.dist": true
1922
},
2023
"hide-files.files": [
2124
".vscode",
@@ -25,6 +28,9 @@
2528
".gitignore",
2629
"composer.lock",
2730
"phpstan-baseline.neon",
28-
"phpstan.neon.dist"
31+
"phpstan.neon.dist",
32+
"CHANGELOG.md",
33+
"LICENSE.md",
34+
"phpunit.xml.dist"
2935
]
3036
}

src/Concerns/InteractsWithTheRequest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@
66

77
trait InteractsWithTheRequest
88
{
9-
public function setRequest(Request $request): static
10-
{
11-
$this->request = $request;
12-
13-
return $this;
14-
}
15-
16-
public function request(): Request
9+
public function get(string $key, mixed $default = null): mixed
1710
{
18-
return $this->request;
11+
return $this->request->get($key, $default);
1912
}
2013

2114
public function has(string|array $key): bool
2215
{
2316
return $this->request->has($key);
2417
}
2518

26-
public function hasAny(string|array $keys): bool
27-
{
28-
return $this->request->hasAny($keys);
29-
}
30-
3119
public function hasAll(array $keys): bool
3220
{
3321
foreach ($keys as $key) {
@@ -39,9 +27,28 @@ public function hasAll(array $keys): bool
3927
return true;
4028
}
4129

42-
public function get(string $key, mixed $default = null): mixed
30+
public function hasAny(string|array $keys): bool
4331
{
44-
return $this->request->get($key, $default);
32+
return $this->request->hasAny($keys);
33+
}
34+
35+
public function replace(string|array $key, mixed $value): static
36+
{
37+
$this->set($key, $value, replace: true);
38+
39+
return $this;
40+
}
41+
42+
public function request(): Request
43+
{
44+
return $this->request;
45+
}
46+
47+
public function setRequest(Request $request): static
48+
{
49+
$this->request = $request;
50+
51+
return $this;
4552
}
4653

4754
public function set(string|array $key, mixed $value = null, bool $replace = false): static
@@ -89,11 +96,4 @@ public function setIfMissing(string|array $key, mixed $value): static
8996

9097
return $this;
9198
}
92-
93-
public function replace(string|array $key, mixed $value): static
94-
{
95-
$this->set($key, $value, replace: true);
96-
97-
return $this;
98-
}
9999
}

src/Concerns/SupportsPublicPropetyMappingFeatures.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ public function attemptToMapValidatedDataToPublicProperties(): static
4141

4242
$propertyName = $inspector->getPropertyName($property);
4343

44-
if(!array_key_exists($propertyName, $validated)) {
44+
if (! array_key_exists($propertyName, $validated)) {
4545
continue;
4646
}
4747

4848
$value = $validated[$propertyName];
49-
49+
5050
if (! $inspector->propertyHasTypehints($property)) {
5151
$inspector->setPropertyValue($property, $value);
52-
52+
5353
continue;
5454
}
55-
55+
5656
$valueType = $this->getNormalizedType($value);
5757
$propertyTypes = $inspector->getPropertyTypeHints($property);
5858

@@ -62,10 +62,10 @@ public function attemptToMapValidatedDataToPublicProperties(): static
6262
$inspector->setPropertyValue($property, $value);
6363
}
6464
} else {
65-
if($valueType === $propertyTypes[0]) {
65+
if ($valueType === $propertyTypes[0]) {
6666
$inspector->setPropertyValue($property, $value);
6767
}
68-
}
68+
}
6969

7070
}
7171

@@ -76,11 +76,11 @@ protected function getNormalizedType($value): string
7676
{
7777
$type = gettype($value);
7878

79-
if($type === 'object') {
79+
if ($type === 'object') {
8080
$type = get_class($value);
8181
}
8282

83-
if($type === 'integer') {
83+
if ($type === 'integer') {
8484
$type = 'int';
8585
}
8686

src/Inspector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function getPropertyTypeHints(ReflectionProperty $property): array
7373
$types[] = $type->getName();
7474
}
7575

76-
7776
return array_values(array_unique($types));
7877
}
7978

tests/FormActionPublicPropertyMappingFeaturesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ public function validated(string|array|int $key = null, mixed $default = null):
106106

107107
expect(isset($action->model))->toBeTrue();
108108
expect($action->model)->toBeInstanceOf(TestModel::class);
109-
});
109+
});

0 commit comments

Comments
 (0)