Skip to content

Commit 24b016e

Browse files
claudef3l1x
authored andcommitted
Fix PHPStan type hints and code style
- Add type hints for enum arrays in RequestParameter and EndpointParameter - Add type hints for groups array in SymfonyValidator - Fix return type in ArrayEntity::getData() - Fix EntityAdapter spacing issue
1 parent 94f7f76 commit 24b016e

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

src/Core/Annotation/Controller/RequestParameter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ class RequestParameter
3131

3232
private bool $allowEmpty;
3333

34+
/** @var list<string|int>|null */
3435
private ?array $enum;
3536

37+
/**
38+
* @param list<string|int>|null $enum
39+
*/
3640
public function __construct(
3741
string $name,
3842
string $type,
@@ -101,6 +105,9 @@ public function isAllowEmpty(): bool
101105
return $this->allowEmpty;
102106
}
103107

108+
/**
109+
* @return list<string|int>|null
110+
*/
104111
public function getEnum(): ?array
105112
{
106113
return $this->enum;

src/Core/Mapping/Validator/SymfonyValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class SymfonyValidator implements IEntityValidator
2121

2222
private ?string $translationDomain = null;
2323

24+
/** @var list<string>|null */
2425
private ?array $groups = null;
2526

2627
public function __construct(?Reader $reader = null)
@@ -44,6 +45,9 @@ public function setTranslationDomain(string $translationDomain): void
4445
$this->translationDomain = $translationDomain;
4546
}
4647

48+
/**
49+
* @param list<string> $groups
50+
*/
4751
public function setGroups(array $groups): void
4852
{
4953
$this->groups = $groups;

src/Core/Schema/EndpointParameter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class EndpointParameter
4747

4848
private bool $allowEmpty = false;
4949

50+
/** @var list<string|int>|null */
5051
private ?array $enum = null;
5152

5253
public function __construct(string $name, string $type = self::TYPE_STRING)
@@ -134,11 +135,17 @@ public function setAllowEmpty(bool $allowEmpty): void
134135
$this->allowEmpty = $allowEmpty;
135136
}
136137

138+
/**
139+
* @return list<string|int>|null
140+
*/
137141
public function getEnum(): ?array
138142
{
139143
return $this->enum;
140144
}
141145

146+
/**
147+
* @param list<string|int>|null $enum
148+
*/
142149
public function setEnum(?array $enum): void
143150
{
144151
$this->enum = $enum;

src/Negotiation/Http/ArrayEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public function __construct(array $data)
2323

2424
/**
2525
* @param mixed[] $data
26-
* @return static
26+
* @phpstan-return static<int|string>
2727
*/
28-
public static function from(array $data): self
28+
public static function from(array $data): static
2929
{
3030
return new static($data);
3131
}

src/OpenApi/SchemaDefinition/Entity/EntityAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ protected function getProperties(string $type): array
147147
if ($propertyType === $type) {
148148
$propertyType = 'object';
149149
}
150+
150151
if (str_ends_with($propertyType, '[]')) {
151152
$subType = Strings::replace($propertyType, '#\\[\\]#', '');
152153

0 commit comments

Comments
 (0)