Skip to content

Commit

Permalink
chore: fix larastan 3 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jan 10, 2025
1 parent 9f585ea commit 0e27625
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 10 deletions.
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

0 comments on commit 0e27625

Please sign in to comment.