Skip to content
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
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: true
matrix:
laravel: ['10.*', '11.*', '12.*']
laravel: ['10.*', '11.*', '12.*', '13.*']
php: [8.1, 8.2, 8.3, 8.4]
phpunit: [ '10.*', '11.*']
include:
Expand All @@ -25,6 +25,8 @@ jobs:
testbench: 9.*
- laravel: 12.*
testbench: 10.*
- laravel: 13.*
testbench: 11.*
exclude:
- laravel: 10.*
phpunit: 11.*
Expand All @@ -36,6 +38,12 @@ jobs:
php: 8.1
- laravel: 12.*
phpunit: 10.*
- laravel: 13.*
php: 8.1
- laravel: 13.*
php: 8.2
- laravel: 13.*
phpunit: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - PU${{ matrix.phpunit }}

Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ on:
pull_request:
branches: [ master ]

permissions:
contents: write

jobs:
lint:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: "laravel-pint"
uses: aglipanci/laravel-pint-action@2.3.1
Expand All @@ -21,4 +26,4 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: PHP Linting (Pint)
skip_fetch: true
skip_fetch: false
4 changes: 3 additions & 1 deletion _ide_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
/** @noinspection PhpUnusedAliasInspection */

namespace Illuminate\Testing {
use Spectator\Assertions;

/**
* @see \Spectator\Assertions
* @see Assertions
*
* @method $this assertValidRequest()
* @method $this assertInvalidRequest()
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"php": "^8.1",
"ext-json": "*",
"devizzent/cebe-php-openapi": "^1.0",
"laravel/framework": "^10.0 | ^11.0 | ^12.0",
"laravel/framework": ">=10.0",
"opis/json-schema": "^2.3"
},
"require-dev": {
"larastan/larastan": "^2.8|^3.0",
"larastan/larastan": ">=2.8",
"laravel/pint": "^1.13",
"nunomaduro/collision": "^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0 | ^10.0",
"phpunit/phpunit": "^10.0|^11.0"
"nunomaduro/collision": ">=7.0",
"orchestra/testbench": ">=8.0",
"phpunit/phpunit": ">=10.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion src/Assertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use cebe\openapi\exceptions\UnresolvableReferenceException;
use Closure;
use Illuminate\Support\Str;
use Illuminate\Testing\TestResponse;
use PHPUnit\Framework\Assert as PHPUnit;
use PHPUnit\Framework\ExpectationFailedException;
use Spectator\Concerns\HasExpectations;
Expand All @@ -16,7 +17,7 @@
use Spectator\Exceptions\ResponseValidationException;

/**
* @mixin \Illuminate\Testing\TestResponse
* @mixin TestResponse
*/
class Assertions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function handle(Request $request, Closure $next): mixed
}

try {
/** @var \Illuminate\Routing\Route $route */
/** @var Route $route */
$route = $request->route();
[$specPath, $pathItem] = $this->pathItem($route, $request->method(), $request->path());
} catch (InvalidPathException|MalformedSpecException|MissingSpecException|TypeErrorException|UnresolvableReferenceException $exception) {
Expand Down
11 changes: 7 additions & 4 deletions src/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Spectator;

use cebe\openapi\exceptions\IOException;
use cebe\openapi\exceptions\TypeErrorException;
use cebe\openapi\exceptions\UnresolvableReferenceException;
use cebe\openapi\json\InvalidJsonPointerSyntaxException;
use cebe\openapi\Reader;
use cebe\openapi\spec\OpenApi;
use Illuminate\Support\Arr;
Expand All @@ -24,7 +27,7 @@ class RequestFactory

protected ?string $pathPrefix = null;

/** @var array<string, \cebe\openapi\spec\OpenApi> */
/** @var array<string, OpenApi> */
private static array $cachedSpecs = [];

/**
Expand Down Expand Up @@ -78,9 +81,9 @@ public function reset(): void
* Resolve and parse the spec.
*
*
* @throws \cebe\openapi\exceptions\IOException
* @throws \cebe\openapi\exceptions\UnresolvableReferenceException
* @throws \cebe\openapi\json\InvalidJsonPointerSyntaxException
* @throws IOException
* @throws UnresolvableReferenceException
* @throws InvalidJsonPointerSyntaxException
* @throws MalformedSpecException
* @throws MissingSpecException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Spectator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @method static \stdClass resolve() Resolve the spec into an object.
* @method bool shouldValidateRequest() Indicate if request should be validated.
*
* @see \Spectator\RequestFactory
* @see RequestFactory
*/
class Spectator extends Facade
{
Expand Down
7 changes: 4 additions & 3 deletions src/Validation/RequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Routing\Route;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Opis\JsonSchema\Validator;
Expand Down Expand Up @@ -55,7 +56,7 @@ protected function handle(): void
*/
protected function validateParameters(): void
{
/** @var \Illuminate\Routing\Route $route */
/** @var Route $route */
$route = $this->request->route();

$parameters = array_merge(
Expand Down Expand Up @@ -125,7 +126,7 @@ protected function validateParameters(): void

protected function translateParameterName(string $parameter): string
{
/** @var \Illuminate\Routing\Route $route */
/** @var Route $route */
$route = $this->request->route();

$route->wheres = [];
Expand Down Expand Up @@ -234,7 +235,7 @@ private function castParameterValue(mixed $parameterValue, ?stdClass $expectedSc
}

/**
* @return ($data is array<string, mixed> ? \stdClass : ($data is array<int, mixed> ? array<int, mixed> : mixed))
* @return ($data is array<string, mixed> ? stdClass : ($data is array<int, mixed> ? array<int, mixed> : mixed))
*/
private function toObject(mixed $data): mixed
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public function test_handles_invalid_spec(): void

Route::get('/', fn () => 'ok')->middleware(Middleware::class);

$this->expectException(\ErrorException::class);
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('The spec file is invalid. Please lint it using spectral (https://github.com/stoplightio/spectral) before trying again.');

$this->getJson('/')
Expand Down