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

Update dependencies and fix BC accordingly #216

Merged
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"php": ">=7.2",
"ext-json": "*",
"devizzent/cebe-php-openapi": "^1.0",
"league/uri": "^6.3",
"league/uri": "^6.3 || ^7.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/http-server-middleware": "^1.0",
"respect/validation": "^1.1.3 || ^2.0",
"riverline/multipart-parser": "^2.0.3",
Expand All @@ -35,8 +35,8 @@
},
"require-dev": {
"doctrine/coding-standard": "^8.0",
"guzzlehttp/psr7": "^1.5",
"hansott/psr7-cookies": "^3.0.2",
"guzzlehttp/psr7": "^2.0",
"hansott/psr7-cookies": "^3.0.2 || ^4.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1",
"phpstan/phpstan-phpunit": "^1",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ parameters:
- src
- tests
treatPhpDocTypesAsCertain: false
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Call to an undefined static method Respect\\Validation\\Validator::numeric\(\).#'
2 changes: 2 additions & 0 deletions src/Schema/TypeFormats/StringURI.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class StringURI
public function __invoke(string $value): bool
{
try {
// namespace 'League\Uri' is provided by multiple packages, but PHPStan does not support merging them
// @phpstan-ignore-next-line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one could be reported to phpstan. really strange

UriString::parse($value);

return true;
Expand Down
5 changes: 2 additions & 3 deletions tests/FromCommunity/EmptyObjectValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;

final class EmptyObjectValidationTest extends TestCase
{
/**
Expand Down Expand Up @@ -40,7 +39,7 @@ public function testIssue57000(): void

$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/v1/products.create'))
->withHeader('Content-Type', 'application/json')
->withBody(stream_for('{}'));
->withBody(Utils::streamFor('{}'));

$validator->validate($psrRequest);

Expand Down
4 changes: 2 additions & 2 deletions tests/FromCommunity/Issue12Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class Issue12Test extends TestCase
Expand Down Expand Up @@ -61,7 +61,7 @@ public function testIssue12(?array $example): void

$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/v1/products.create'))
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode(['test' => $example])));
->withBody(Utils::streamFor(json_encode(['test' => $example])));

$validator->validate($psrRequest);

Expand Down
4 changes: 2 additions & 2 deletions tests/FromCommunity/Issue32Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\ValidationFailed;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class Issue32Test extends TestCase
Expand Down Expand Up @@ -51,7 +51,7 @@ enum:

$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/test/create'))
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode($data)));
->withBody(Utils::streamFor(json_encode($data)));

$serverRequestValidator = (new ValidatorBuilder())->fromYaml($yaml)->getServerRequestValidator();

Expand Down
4 changes: 2 additions & 2 deletions tests/FromCommunity/Issue3Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class Issue3Test extends TestCase
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testIssue3(): void

$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/v1/products.create'))
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode(['test' => 20])));
->withBody(Utils::streamFor(json_encode(['test' => 20])));

$validator->validate($psrRequest);

Expand Down
4 changes: 2 additions & 2 deletions tests/FromCommunity/Issue50Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidBody;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use League\OpenAPIValidation\Schema\Exception\KeywordMismatch;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class Issue50Test extends TestCase
Expand Down Expand Up @@ -54,7 +54,7 @@ public function testIssue50(): void
$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/v1/products.create'))
->withHeader('Content-Type', 'application/json')
->withBody(
stream_for(
Utils::streamFor(
json_encode(
[
'body' =>
Expand Down
4 changes: 2 additions & 2 deletions tests/FromCommunity/Issue57Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace League\OpenAPIValidation\Tests\FromCommunity;

use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class Issue57Test extends TestCase
Expand Down Expand Up @@ -60,7 +60,7 @@ public function testIssue57(): void

$psrRequest = (new ServerRequest('post', 'http://localhost:8000/api/v1/products.create'))
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode(['test' => (object) ['some_property_here' => (object) []]])));
->withBody(Utils::streamFor(json_encode(['test' => (object) ['some_property_here' => (object) []]])));

$validator->validate($psrRequest);

Expand Down
8 changes: 4 additions & 4 deletions tests/PSR7/BaseValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Uri;
use GuzzleHttp\Psr7\Utils;
use HansOtt\PSR7Cookies\SetCookie;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;
use function sprintf;

Expand All @@ -33,7 +33,7 @@ protected function makeGoodResponse(string $path, string $method): ResponseInter
return (new Response())
->withHeader('Content-Type', 'application/json')
->withHeader('Header-B', 'good value')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

case 'post /cookies':
$response = (new Response())
Expand Down Expand Up @@ -72,7 +72,7 @@ protected function makeGoodServerRequest(string $path, string $method): ServerRe

return $request
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

default:
throw new InvalidArgumentException(sprintf("unexpected operation '%s %s''", $method, $path));
Expand Down Expand Up @@ -104,7 +104,7 @@ protected function makeGoodRequest(string $path, string $method): RequestInterfa

return $request
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

default:
throw new InvalidArgumentException(sprintf("unexpected operation '%s %s''", $method, $path));
Expand Down
6 changes: 3 additions & 3 deletions tests/PSR7/CompleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\OperationAddress;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

use const PHP_INT_MAX;
Expand Down Expand Up @@ -56,13 +56,13 @@ protected function buildGoodRequest(): ServerRequestInterface
->withCookieParams(['session_id' => 100])
->withHeader('X-RequestId', 'abcd')
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode(['propB' => 'good value'])));
->withBody(Utils::streamFor(json_encode(['propB' => 'good value'])));
}

protected function buildGoodResponse(): ResponseInterface
{
return (new Response())
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode(['propA' => PHP_INT_MAX])));
->withBody(Utils::streamFor(json_encode(['propA' => PHP_INT_MAX])));
}
}
6 changes: 3 additions & 3 deletions tests/PSR7/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace League\OpenAPIValidation\Tests\PSR7;

use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidBody;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidHeaders;
use League\OpenAPIValidation\PSR7\OperationAddress;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class RequestTest extends BaseValidatorTest
Expand All @@ -27,7 +27,7 @@ public function testItValidatesBodyGreen(): void
{
$body = ['name' => 'Alex'];
$request = $this->makeGoodRequest('/request-body', 'post')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$validator = (new ValidatorBuilder())->fromYamlFile($this->apiSpecFile)->getRequestValidator();
$validator->validate($request);
Expand All @@ -39,7 +39,7 @@ public function testItValidatesBodyHasInvalidPayloadRed(): void
$addr = new OperationAddress('/request-body', 'post');
$body = ['name' => 1000];
$request = $this->makeGoodRequest($addr->path(), $addr->method())
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$this->expectException(InvalidBody::class);
$this->expectExceptionMessage(
Expand Down
6 changes: 3 additions & 3 deletions tests/PSR7/RoutedServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace League\OpenAPIValidation\Tests\PSR7;

use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidBody;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidHeaders;
use League\OpenAPIValidation\PSR7\OperationAddress;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class RoutedServerRequestTest extends BaseValidatorTest
Expand All @@ -27,7 +27,7 @@ public function testItValidatesBodyGreen(): void
{
$body = ['name' => 'Alex'];
$request = $this->makeGoodServerRequest('/request-body', 'post')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$validator = (new ValidatorBuilder())->fromYamlFile($this->apiSpecFile)->getRoutedRequestValidator();
$validator->validate(new OperationAddress('/request-body', 'post'), $request);
Expand All @@ -39,7 +39,7 @@ public function testItValidatesBodyHasInvalidPayloadRed(): void
$addr = new OperationAddress('/request-body', 'post');
$body = ['name' => 1000];
$request = $this->makeGoodServerRequest($addr->path(), $addr->method())
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$this->expectException(InvalidBody::class);
$this->expectExceptionMessage(
Expand Down
6 changes: 3 additions & 3 deletions tests/PSR7/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace League\OpenAPIValidation\Tests\PSR7;

use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidBody;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidHeaders;
use League\OpenAPIValidation\PSR7\OperationAddress;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class ServerRequestTest extends BaseValidatorTest
Expand All @@ -27,7 +27,7 @@ public function testItValidatesBodyGreen(): void
{
$body = ['name' => 'Alex'];
$request = $this->makeGoodServerRequest('/request-body', 'post')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$validator = (new ValidatorBuilder())->fromYamlFile($this->apiSpecFile)->getServerRequestValidator();
$validator->validate($request);
Expand All @@ -39,7 +39,7 @@ public function testItValidatesBodyHasInvalidPayloadRed(): void
$addr = new OperationAddress('/request-body', 'post');
$body = ['name' => 1000];
$request = $this->makeGoodServerRequest($addr->path(), $addr->method())
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$this->expectException(InvalidBody::class);
$this->expectExceptionMessage(
Expand Down
8 changes: 4 additions & 4 deletions tests/PSR7/ValidateResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace League\OpenAPIValidation\Tests\PSR7;

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidBody;
use League\OpenAPIValidation\PSR7\Exception\Validation\InvalidHeaders;
use League\OpenAPIValidation\PSR7\OperationAddress;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;

use function GuzzleHttp\Psr7\stream_for;
use function json_encode;

final class ValidateResponseTest extends BaseValidatorTest
Expand All @@ -32,7 +32,7 @@ public function testItValidatesMessageWithReferencesGreen(): void
];
$response = (new Response())
->withHeader('Content-Type', 'application/json')
->withBody(stream_for(json_encode($body)));
->withBody(Utils::streamFor(json_encode($body)));

$validator = (new ValidatorBuilder())->fromYamlFile($this->apiSpecFile)->getResponseValidator();
$validator->validate(new OperationAddress('/ref', 'post'), $response);
Expand All @@ -43,7 +43,7 @@ public function testItValidatesBinaryResponseGreen(): void
{
$response = $this->makeGoodResponse('/path1', 'get')
->withHeader('Content-Type', 'image/jpeg')
->withBody(stream_for(__DIR__ . '/../stubs/image.jpg'));
->withBody(Utils::streamFor(__DIR__ . '/../stubs/image.jpg'));

$validator = (new ValidatorBuilder())->fromYamlFile($this->apiSpecFile)->getResponseValidator();
$validator->validate(new OperationAddress('/path1', 'get'), $response);
Expand All @@ -54,7 +54,7 @@ public function testItValidatesMessageWrongBodyValueRed(): void
{
$addr = new OperationAddress('/path1', 'get');
$body = [];
$response = $this->makeGoodResponse('/path1', 'get')->withBody(stream_for(json_encode($body)));
$response = $this->makeGoodResponse('/path1', 'get')->withBody(Utils::streamFor(json_encode($body)));

$this->expectException(InvalidBody::class);
$this->expectExceptionMessage(
Expand Down
Loading
Loading