Skip to content
Open
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
4 changes: 1 addition & 3 deletions src/Constraint/BuiltInStringConstraintParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
{
public const REGEX_VERSION_RULE = '([<>=]*)([\d.]*)';

public function __construct(
private readonly VersionParser $versionParser,
) {}
public function __construct(private readonly VersionParser $versionParser) {}

public function parse(string $constraint): Constraint
{
preg_match('/' . self::REGEX_VERSION_RULE . '/', $constraint, $result);

if ($constraint !== $result[0]) {

Check failure on line 21 in src/Constraint/BuiltInStringConstraintParser.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Offset 0 might not exist on array{}|array{string, string, string}.
throw new BadConstraintException("Constraint rule {$constraint} didn't match " . self::REGEX_VERSION_RULE);
}

Expand Down
4 changes: 1 addition & 3 deletions src/RouteVersionMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*
* @mixin Route
*/
class RouteVersionMixin

Check failure on line 22 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Class TenantCloud\APIVersioning\RouteVersionMixin has PHPDoc tag `@method` for method parseAction() return type with no value type specified in iterable type array.
{
public function __construct(
public readonly ConstraintChecker $checker
) {}
public function __construct(public readonly ConstraintChecker $checker) {}

/**
* Fluent variant for "as" option of a resource.
Expand All @@ -36,14 +34,14 @@
*/
return function (string $rule, $action = null) {
if ($action === null) {
$this->action['versions'][$rule] = Arr::only($this->action, ['uses', 'controller']);

Check failure on line 37 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Parameter #1 $array of static method Illuminate\Support\Arr::only() expects array, mixed given.

Check failure on line 37 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset string on mixed.

Check failure on line 37 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset 'versions' on mixed.
} else {
/* @phpstan-ignore-next-line property.protected */
if ((fn () => /** @var Router $this */ $this->actionReferencesController($action))->call($this->router)) {
/** @phpstan-ignore-next-line property.protected */
$action = (fn () => $this->convertToControllerAction($action))->call($this->router);
}
$this->action['versions'][$rule] = Arr::except($this->parseAction($action), ['prefix']);

Check failure on line 44 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset string on mixed.

Check failure on line 44 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset 'versions' on mixed.
}

return $this;
Expand All @@ -56,7 +54,7 @@

return function (Version $version) use ($that) {
/** @var list<string> $constraints */
$constraints = array_keys($this->action['versions']);

Check failure on line 57 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Parameter #1 $array of function array_keys expects array, mixed given.

Check failure on line 57 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset 'versions' on mixed.

$suggestedConstraint = $that->checker->matches($version, $constraints);

Expand All @@ -65,7 +63,7 @@
}

/** @var array{'uses': string} $versionData */
$versionData = Arr::get($this->action['versions'], (string) $suggestedConstraint);

Check failure on line 66 in src/RouteVersionMixin.php

View workflow job for this annotation

GitHub Actions / PHPStan on PHP v8.4 & TestBench ^10.0

Cannot access offset 'versions' on mixed.

return [
$this->container->make(mb_ltrim((string) Str::parseCallback($versionData['uses'])[0], '\\')),
Expand Down
Loading