Skip to content

Commit ae6ff68

Browse files
fix(phpdoc): array shape
1 parent 9e382e0 commit ae6ff68

11 files changed

+78
-27
lines changed

docs/adr/0006-filtering-system-and-parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ During the `Provider` phase (`RequestEvent::REQUEST`), we could use a `Parameter
193193
interface ParameterProviderInterface
194194
{
195195
/**
196-
* @param array<string, mixed> $parameters
197-
* @param array<string, mixed>|array{request?: Request, resource_class?: string, operation: HttpOperation} $context
196+
* @param array<string, mixed> $parameters
197+
* @param array<string, mixed> $context
198198
*/
199199
public function provide(Parameter $parameter, array $parameters = [], array $context = []): ?HttpOperation;
200200
}

src/GraphQl/Type/ContextAwareTypeBuilderInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ interface ContextAwareTypeBuilderInterface
3131
/**
3232
* Gets the object type of the given resource.
3333
*
34-
* @param array<string, mixed>&array{input?: bool, wrapped?: bool, depth?: int} $context
34+
* @param array<string, mixed> $context
35+
*
36+
* @phpstan-param array<string, mixed> $context
37+
*
38+
* @psalm-param array{input?: bool, wrapped?: bool, depth?: int, ...<string, mixed>} $context
3539
*
3640
* @return GraphQLType the object type, possibly wrapped by NonNull
3741
*/

src/Laravel/Eloquent/Metadata/ModelMetadata.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ private function getCastsWithDates(Model $model): Collection
256256
/**
257257
* Gets the default value for the given column.
258258
*
259-
* @param array<string, mixed>&array{name: string, default: string} $column
259+
* @param array<string, mixed> $column
260+
*
261+
* @phpstan-param array<string, mixed> $column
262+
*
263+
* @psalm-param array{name: string, default: string, ...<string, mixed>} $column
260264
*/
261265
private function getColumnDefault(array $column, Model $model): mixed
262266
{

src/Laravel/Routing/Router.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public function getRouteCollection(): RouteCollection
7272
/**
7373
* {@inheritdoc}
7474
*
75-
* @return array<string, mixed>|array{_api_resource_class?: class-string|string, _api_operation_name?: string, uri_variables?: array<string, mixed>}
75+
* @return array<string, mixed>
76+
*
77+
* @phpstan-return array<string, mixed>
78+
*
79+
* @psalm-return array{_api_resource_class?: class-string|string, _api_operation_name?: string, uri_variables?: array<string, mixed>, ...<string, mixed>}
7680
*/
7781
public function match(string $pathInfo): array
7882
{

src/Metadata/IriConverterInterface.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use ApiPlatform\Metadata\Exception\ItemNotFoundException;
1818
use ApiPlatform\Metadata\Exception\OperationNotFoundException;
1919
use ApiPlatform\Metadata\Exception\RuntimeException;
20+
use Symfony\Component\HttpFoundation\Request;
2021

2122
/**
2223
* Converts item and resources to IRI and vice versa.
@@ -28,7 +29,11 @@ interface IriConverterInterface
2829
/**
2930
* Retrieves an item from its IRI.
3031
*
31-
* @param array<string, mixed>|array{request?: Request, resource_class?: string|class-string} $context
32+
* @param array<string, mixed> $context
33+
*
34+
* @phpstan-param array<string, mixed> $context
35+
*
36+
* @psalm-param array{request?: Request, resource_class?: string|class-string, ...<string, mixed>} $context
3237
*
3338
* @throws InvalidArgumentException
3439
* @throws ItemNotFoundException
@@ -38,8 +43,12 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation
3843
/**
3944
* Gets the IRI associated with the given item.
4045
*
41-
* @param object|class-string $resource
42-
* @param array<string, mixed>|array{force_resource_class?: string|class-string, item_uri_template?: string, uri_variables?: array<string, string>} $context
46+
* @param object|class-string $resource
47+
* @param array<string, mixed> $context
48+
*
49+
* @phpstan-param array<string, mixed> $context
50+
*
51+
* @psalm-param array{force_resource_class?: string|class-string, item_uri_template?: string, uri_variables?: array<string, string>, ...<string, mixed>} $context
4352
*
4453
* @throws OperationNotFoundException
4554
* @throws InvalidArgumentException

src/Metadata/Parameter.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@
2424
abstract class Parameter
2525
{
2626
/**
27-
* @param (array<string, mixed>&array{type?: string, default?: string})|null $schema
28-
* @param array<string, mixed> $extraProperties
29-
* @param ParameterProviderInterface|callable|string|null $provider
30-
* @param list<string> $properties a list of properties this parameter applies to (works with the :property placeholder)
31-
* @param FilterInterface|string|null $filter
32-
* @param mixed $constraints an array of Symfony constraints, or an array of Laravel rules
33-
* @param Type $nativeType the PHP native type, we cast values to an array if its a CollectionType, if not and it's an array with a single value we use it (eg: HTTP Header)
34-
* @param ?bool $castToNativeType whether API Platform should cast your parameter to the nativeType declared
35-
* @param ?callable(mixed): mixed $castFn the closure used to cast your parameter, this gets called only when $castToNativeType is set
27+
* @param array<string, mixed>|null $schema
28+
* @param array<string, mixed> $extraProperties
29+
* @param ParameterProviderInterface|callable|string|null $provider
30+
* @param list<string> $properties a list of properties this parameter applies to (works with the :property placeholder)
31+
* @param FilterInterface|string|null $filter
32+
* @param mixed $constraints an array of Symfony constraints, or an array of Laravel rules
33+
* @param Type $nativeType the PHP native type, we cast values to an array if its a CollectionType, if not and it's an array with a single value we use it (eg: HTTP Header)
34+
* @param ?bool $castToNativeType whether API Platform should cast your parameter to the nativeType declared
35+
* @param ?callable(mixed): mixed $castFn the closure used to cast your parameter, this gets called only when $castToNativeType is set
36+
*
37+
* @phpstan-param array<string, mixed>|null $schema
38+
*
39+
* @psalm-param array{type?: string, default?: string, ...<string, mixed>}|null $schema
3640
*/
3741
public function __construct(
3842
protected ?string $key = null,
@@ -64,7 +68,11 @@ public function getKey(): ?string
6468
}
6569

6670
/**
67-
* @return (array<string, mixed>&array{type?: string, default?: string})|null $schema
71+
* @return array<string, mixed>|null
72+
*
73+
* @phpstan-return array<string, mixed>|null
74+
*
75+
* @psalm-return array{type?: string, default?: string, ...<string, mixed>}|null
6876
*/
6977
public function getSchema(): ?array
7078
{

src/Serializer/TagCollectorInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ interface TagCollectorInterface
2323
/**
2424
* Collect cache tags for cache invalidation.
2525
*
26-
* @param array<string, mixed>&array{iri?: string, data?: mixed, object?: mixed, property_metadata?: \ApiPlatform\Metadata\ApiProperty, api_attribute?: string, resources?: array<string, string>, format?: string, operation?: \ApiPlatform\Metadata\Operation} $context
26+
* @param array<string, mixed> $context
27+
*
28+
* @phpstan-param array<string, mixed> $context
29+
*
30+
* @psalm-param array{iri?: string, data?: mixed, object?: mixed, property_metadata?: \ApiPlatform\Metadata\ApiProperty, api_attribute?: string, resources?: array<string, string>, format?: string, operation?: \ApiPlatform\Metadata\Operation, ...<string, mixed>} $context
2731
*/
2832
public function collect(array $context = []): void;
2933
}

src/State/ParameterProviderInterface.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use ApiPlatform\Metadata\Operation;
1717
use ApiPlatform\Metadata\Parameter;
18+
use Symfony\Component\HttpFoundation\Request;
1819

1920
/**
2021
* Optionnaly transforms request parameters and provides modification to the current Operation.
@@ -24,8 +25,12 @@
2425
interface ParameterProviderInterface
2526
{
2627
/**
27-
* @param array<string, mixed> $parameters
28-
* @param array<string, mixed>|array{request?: Request, resource_class?: string, operation: Operation} $context
28+
* @param array<string, mixed> $parameters
29+
* @param array<string, mixed> $context
30+
*
31+
* @phpstan-param array<string, mixed> $context
32+
*
33+
* @psalm-param array{request?: Request, resource_class?: string, operation: Operation, ...<string, mixed>} $context
2934
*/
3035
public function provide(Parameter $parameter, array $parameters = [], array $context = []): ?Operation;
3136
}

src/State/ProcessorInterface.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ interface ProcessorInterface
2929
/**
3030
* Handles the state.
3131
*
32-
* @param T1 $data
33-
* @param array<string, mixed> $uriVariables
34-
* @param array<string, mixed>&array{request?: Request, previous_data?: mixed, resource_class?: string|null, original_data?: mixed} $context
32+
* @param T1 $data
33+
* @param array<string, mixed> $uriVariables
34+
* @param array<string, mixed> $context
35+
*
36+
* @phpstan-param array<string, mixed> $context
37+
*
38+
* @psalm-param array{request?: Request, previous_data?: mixed, resource_class?: string|null, original_data?: mixed, ...<string, mixed>} $context
3539
*
3640
* @return T2
3741
*/

src/State/ProviderInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ interface ProviderInterface
2929
/**
3030
* Provides data.
3131
*
32-
* @param array<string, mixed> $uriVariables
33-
* @param array<string, mixed>|array{request?: Request, resource_class?: string} $context
32+
* @param array<string, mixed> $uriVariables
33+
* @param array<string, mixed> $context
34+
*
35+
* @phpstan-param array<string, mixed> $context
36+
*
37+
* @psalm-param array{request?: Request, resource_class?: string, ...<string, mixed>} $context
3438
*
3539
* @return T|PartialPaginatorInterface<T>|iterable<T>|null
3640
*/

0 commit comments

Comments
 (0)