Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow phpstan/phpdoc-parser 2 (which in turns allow PHPstan 2, Larastan 3) for api-platform/laravel #6900

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Laravel/Eloquent/Filter/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public function getSchema(Parameter $parameter): array
return ['type' => 'date'];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
/**
* @return OpenApiParameter[]
*/
public function getOpenApiParameters(Parameter $parameter): array
{
$in = $parameter instanceof QueryParameter ? 'query' : 'header';
$key = $parameter->getKey();
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Eloquent/Filter/OrFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getSchema(Parameter $parameter): array
return ['type' => 'array', 'items' => $schema];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
public function getOpenApiParameters(Parameter $parameter): OpenApiParameter
{
return new OpenApiParameter(name: $parameter->getKey().'[]', in: 'query', style: 'deepObject', explode: true);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Laravel/Eloquent/Filter/OrderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public function getSchema(Parameter $parameter): array
return ['type' => 'string', 'enum' => ['asc', 'desc']];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
/**
* @return OpenApiParameter[]|null
*/
public function getOpenApiParameters(Parameter $parameter): ?array
{
if (str_contains($parameter->getKey(), ':property')) {
$parameters = [];
Expand Down
5 changes: 4 additions & 1 deletion src/Laravel/Eloquent/Filter/RangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public function getSchema(Parameter $parameter): array
return ['type' => 'number'];
}

public function getOpenApiParameters(Parameter $parameter): OpenApiParameter|array|null
/**
* @return OpenApiParameter[]
*/
public function getOpenApiParameters(Parameter $parameter): array
{
$in = $parameter instanceof QueryParameter ? 'query' : 'header';
$key = $parameter->getKey();
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Eloquent/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(

public function count(): int
{
return $this->paginator->count();
return $this->paginator->count(); // @phpstan-ignore-line
}

public function getLastPage(): float
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Eloquent/PartialPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(

public function count(): int
{
return $this->paginator->count();
return $this->paginator->count(); // @phpstan-ignore-line
}

public function getCurrentPage(): float
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Routing/IriConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function generateRoute(object|string $resource, int $referenceType = Url
if (\is_object($resource)) {
try {
$identifiers = $this->identifiersExtractor->getIdentifiersFromItem($resource, $identifiersExtractorOperation, $context);
} catch (InvalidArgumentException|RuntimeException $e) {
} catch (RuntimeException $e) {
// We can try using context uri variables if any
if (!$identifiers) {
throw new InvalidArgumentException(\sprintf('Unable to generate an IRI for the item of type "%s"', $operation->getClass()), $e->getCode(), $e);
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Routing/SkolemIriConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getResourceFromIri(string $iri, array $context = [], ?Operation
/**
* {@inheritdoc}
*/
public function getIriFromResource(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = []): ?string
public function getIriFromResource(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, ?Operation $operation = null, array $context = []): string
{
$referenceType = $operation ? ($operation->getUrlGenerationStrategy() ?? $referenceType) : $referenceType;
if (($isObject = \is_object($resource)) && $this->objectHashMap->contains($resource)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MakeStateProcessorCommandTest extends TestCase
/** @var string */
private const CHOSEN_CLASS_NAME = 'Choose a class name for your state processor (e.g. <fg=yellow>AwesomeStateProcessor</>)';

private ?Filesystem $filesystem;
private Filesystem $filesystem;
private PathResolver $pathResolver;
private AppServiceFileGenerator $appServiceFileGenerator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MakeStateProviderCommandTest extends TestCase
/** @var string */
private const STATE_PROVIDER_CLASS_NAME = 'Choose a class name for your state provider (e.g. <fg=yellow>AwesomeStateProvider</>)';

private ?Filesystem $filesystem;
private Filesystem $filesystem;
private PathResolver $pathResolver;
private AppServiceFileGenerator $appServiceFileGenerator;

Expand Down
4 changes: 2 additions & 2 deletions src/Laravel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
"illuminate/container": "^11.0",
"symfony/web-link": "^6.4 || ^7.1",
"willdurand/negotiation": "^3.1",
"phpstan/phpdoc-parser": "^1.29",
"phpstan/phpdoc-parser": "^1.29 || ^2.0",
"phpdocumentor/reflection-docblock": "^5.1"
},
"require-dev": {
"doctrine/dbal": "^4.0",
"larastan/larastan": "^2.0",
"larastan/larastan": "^2.0 || ^3.0",
"orchestra/testbench": "^9.1",
"phpunit/phpunit": "^11.2",
"api-platform/graphql": "^4.0",
Expand Down
Loading