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
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions ISSUE_TEMPLATE.md → .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<!-- Provide a general summary of the issue in the Title above -->

> **Warning**
> Are you sure your issue is caused by this package? Almost all reported issues come from a misunderstanding of the [OpenAPI specification](https://swagger.io/specification/). Please make sure that your answer isn't there before posting.

## Detailed description

Provide a detailed description of the change or addition you are proposing.
Expand Down
File renamed without changes.
21 changes: 12 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ on:

jobs:

phpcs:
name: PHP_CodeSniffer
style:
name: Style
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
tools: cs2pr, phpcs

- name: Run PHP_CodeSniffer
uses: chekalsky/phpcs-action@v1
- name: Run phpcs
run: phpcs -q --report=checkstyle | cs2pr

phpunit:
name: PHPUnit
tests:
name: Tests
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"require": {
"php": "^7.3|^8.0",
"php": "^8.0",
"ext-json": "*",
"league/openapi-psr7-validator": "^0.19",
"nyholm/psr7": "^1.0",
Expand All @@ -33,6 +33,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"rector/rector": "^0.17.1",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload": {
Expand All @@ -47,8 +48,8 @@
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs src tests",
"fix-style": "phpcbf src tests"
"fix": "phpcbf src tests",
"refactor": "rector process"
},
"extra": {
"branch-alias": {
Expand Down
14 changes: 14 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);

$rectorConfig->sets([LevelSetList::UP_TO_PHP_80]);
};
2 changes: 1 addition & 1 deletion src/Adapters/HttpFoundationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function convert(object $message): MessageInterface
return $psrHttpFactory->createRequest($message);
}

throw new InvalidArgumentException(sprintf('Unsupported %s object received', get_class($message)));
throw new InvalidArgumentException(sprintf('Unsupported %s object received', $message::class));
}
}
1 change: 0 additions & 1 deletion src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ValidationException extends Exception
/**
* Build a new exception from a ValidationFailed exception.
*
* @param ValidationFailed $exception
* @return ValidationException
*/
public static function fromValidationFailed(ValidationFailed $exception): ValidationException
Expand Down
32 changes: 3 additions & 29 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,11 @@

final class Validator implements ValidatorInterface
{
/**
* @var RoutedServerRequestValidator
*/
private $requestValidator;

/**
* @var ResponseValidator
*/
private $responseValidator;

/**
* @var AdapterInterface
*/
private $adapter;

/**
* Constructor.
*
* @param RoutedServerRequestValidator $requestValidator
* @param ResponseValidator $responseValidator
* @param AdapterInterface $adapter
* @return void
*/
public function __construct(
RoutedServerRequestValidator $requestValidator,
ResponseValidator $responseValidator,
AdapterInterface $adapter
private RoutedServerRequestValidator $requestValidator,
private ResponseValidator $responseValidator,
private AdapterInterface $adapter
) {
$this->requestValidator = $requestValidator;
$this->responseValidator = $responseValidator;
$this->adapter = $adapter;
}

/**
Expand Down
19 changes: 2 additions & 17 deletions src/ValidatorBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,10 @@
*/
final class ValidatorBuilder implements ValidatorBuilderInterface
{
/**
* @var string
*/
private $adapter = HttpFoundationAdapter::class;

/**
* @var BaseValidatorBuilder
*/
private $validatorBuilder;
private string $adapter = HttpFoundationAdapter::class;

/**
* Constructor.
*
* @param BaseValidatorBuilder $builder
* @return void
*/
public function __construct(BaseValidatorBuilder $builder)
public function __construct(private BaseValidatorBuilder $validatorBuilder)
{
$this->validatorBuilder = $builder;
}

/**
Expand Down