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
3 changes: 1 addition & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
- package-ecosystem: "composer" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

8 changes: 5 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
- "highest"
- "locked"
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
operating-system:
- "ubuntu-latest"
- "windows-latest"
Expand Down Expand Up @@ -57,9 +58,10 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
- "8.5"
operating-system:
- "ubuntu-latest"

Expand Down Expand Up @@ -92,7 +94,7 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.3"
- "8.4"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "8.3"
php-version: "8.4"
ini-values: memory_limit=-1

- name: "Install dependencies"
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
}
],
"require": {
"php": "^8.1.0",
"php": "^8.2.0",
"league/openapi-psr7-validator": "0.*",
"devizzent/cebe-php-openapi": "^1.0",
"psr/http-message": "^1.0",
"psr/http-message": "^2.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/log": "^1.0|^2.0|^3.0",
"fakerphp/faker": "^1.20"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.11",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.0 || ^12.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class InvalidOpenApiDefinitionException extends InvalidArgumentException
{
public function __construct(Throwable $previous)
{
parent::__construct(sprintf(
parent::__construct(\sprintf(
"The given OpenApi definition can't be loaded:\n%s -> %s",
$previous::class,
$previous->getMessage()
Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/LeagueOpenAPIValidation/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public function __construct(
private readonly ValidatorBuilder $validator,
ValidationExceptionMapper $mapper = null

Check failure on line 17 in src/Bridge/LeagueOpenAPIValidation/Factory.php

View workflow job for this annotation

GitHub Actions / Static Analysis by PHPStan (locked, 8.4, ubuntu-latest)

Deprecated in PHP 8.4: Parameter #2 $mapper (CHStudio\Raven\Bridge\LeagueOpenAPIValidation\Exception\ValidationExceptionMapper) is implicitly nullable via default value null.

Check failure on line 17 in src/Bridge/LeagueOpenAPIValidation/Factory.php

View workflow job for this annotation

GitHub Actions / Static Analysis by PHPStan (locked, 8.5, ubuntu-latest)

Deprecated in PHP 8.4: Parameter #2 $mapper (CHStudio\Raven\Bridge\LeagueOpenAPIValidation\Exception\ValidationExceptionMapper) is implicitly nullable via default value null.
) {
$this->mapper = $mapper ?? new ValidationExceptionMapper();
}
Expand All @@ -23,7 +23,7 @@
{
if (!is_readable($path)) {
throw new InvalidArgumentException(
sprintf('Filename given isn\'t readable: %s', $path)
\sprintf('Filename given isn\'t readable: %s', $path)
);
}

Expand All @@ -36,7 +36,7 @@
{
if (!is_readable($path)) {
throw new InvalidArgumentException(
sprintf('Filename given isn\'t readable: %s', $path)
\sprintf('Filename given isn\'t readable: %s', $path)
);
}

Expand Down
15 changes: 13 additions & 2 deletions src/Http/Factory/Headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ public function __construct(mixed $headers = [])
}

foreach ($headers as $name => $values) {
$this->set($name, $values);
if (\is_string($values)) {
$this->set($name, $values);
} elseif (\is_array($values)) {
foreach ($values as $value) {
if (!\is_string($value)) {
throw new InvalidArgumentException('Header values must be string[]|string.');
}
$this->set($name, $value);
}
} else {
throw new InvalidArgumentException('Header values must be string[]|string.');
}
}
}

Expand All @@ -40,7 +51,7 @@ public function __toString(): string
foreach ($this->headers as $name => $values) {
$name = ucwords($name, '-');
foreach ($values as $value) {
$asString .= sprintf('%s: %s', $name, $value).PHP_EOL;
$asString .= \sprintf('%s: %s', $name, $value).PHP_EOL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Factory/Resolver/FakerValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function resolveFakerValue(array $matches): mixed
);
} catch (InvalidArgumentException) {
} catch (JsonException $error) {
$message = sprintf(
$message = \sprintf(
"Can't extract the arguments to call method %s: [%s]",
$matches[1],
$matches[2]
Expand Down
32 changes: 28 additions & 4 deletions src/Http/Factory/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,42 @@ class Uri implements Stringable
public function __construct(mixed $value)
{
if (\is_array($value)) {
if (!isset($value['base'])) {
if (!\is_string($value['base'])) {
throw new InvalidArgumentException(
'If you want to build an URI from an array, use the schema: [ base => string, ?parameters => [string => mixed]'
);
}

// Check if parameters is a valid string[]
$parameters = $value['parameters'] ?? [];
$value = str_replace(array_keys($parameters), $parameters, (string) $value['base']);
} elseif (!\is_string($value)) {
if (!\is_array($parameters)) {
throw new InvalidArgumentException('value parameters must be an array.');
}

$search = [];
$replace = [];
foreach ($parameters as $name => $parameter) {
if (!\is_string($name) || !\is_string($parameter)) {
throw new InvalidArgumentException(\sprintf(
'Invalid parameter given {name: %s, parameter: %s}',
var_export($name, true),
var_export($parameter, true)
));
}
$search[] = $name;
$replace[] = $parameter;
}

$this->uri = str_replace(
$search,
$replace,
(string) $value['base']
);
} elseif (\is_string($value)) {
$this->uri = $value;
} else {
throw new InvalidArgumentException('$value must be a string or an array.');
}
$this->uri = $value;
}

public function __toString(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Exception/ApiSchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ApiSchemaException extends RuntimeException implements ValidationException
public function __construct(
Throwable $previous
) {
$message = sprintf(
$message = \sprintf(
'Something went wrong with the API schema: %s.',
$previous->getMessage()
);
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Exception/DataSchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
public readonly string $path,
Throwable $previous
) {
$message = sprintf(
$message = \sprintf(
"Data validation failed for property \"%s\", invalid value: %s\n\n> %s",
$path,
var_export($value, true),
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Exception/GenericException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GenericException extends RuntimeException implements ValidationException
public function __construct(
Throwable $previous
) {
$message = sprintf(
$message = \sprintf(
'Something went wrong: %s.',
$previous->getMessage()
);
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Exception/OperationNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{
public function __construct(
public readonly RequestInterface $request,
Throwable $previous = null

Check failure on line 13 in src/Validator/Exception/OperationNotFoundException.php

View workflow job for this annotation

GitHub Actions / Static Analysis by PHPStan (locked, 8.4, ubuntu-latest)

Deprecated in PHP 8.4: Parameter #2 $previous (Throwable) is implicitly nullable via default value null.

Check failure on line 13 in src/Validator/Exception/OperationNotFoundException.php

View workflow job for this annotation

GitHub Actions / Static Analysis by PHPStan (locked, 8.5, ubuntu-latest)

Deprecated in PHP 8.4: Parameter #2 $previous (Throwable) is implicitly nullable via default value null.
) {
$message = sprintf(
$message = \sprintf(
'API operation for request [%s] %s hasn\'t been found.',
$request->getMethod(),
$request->getUri()
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Exception/ResponseNotExpectedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
public readonly ResponseInterface $response,
Throwable $previous
) {
$message = sprintf(
$message = \sprintf(
'API response with status code %d isn\'t defined in the spec for request [%s] %s.',
$response->getStatusCode(),
$request->getMethod(),
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Expectation/ExpectationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
}

/**
* @return ArrayIterator<int, ResponseExpectationInterface>
* @return ArrayIterator<int|string, ResponseExpectationInterface>
*/
public function getIterator(): ArrayIterator
{
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/Expectation/StatusCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function verify(ResponseInterface $message): ?ExpectationFailedException
return $message->getStatusCode() === $this->statusCode
? null
: new ExpectationFailedException(
sprintf('Unexpected status code %s, expected %s', $message->getStatusCode(), $this->statusCode),
\sprintf('Unexpected status code %s, expected %s', $message->getStatusCode(), $this->statusCode),
$this
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Validator/LoggedRequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public function __construct(

public function validate(RequestInterface $request): void
{
$this->logger->debug(sprintf(
$this->logger->debug(\sprintf(
"Start testing Request: [%s] %s",
$request->getMethod(),
$request->getUri()
));
$this->decorated->validate($request);
$this->logger->debug(sprintf(
$this->logger->debug(\sprintf(
'Finish testing Request: [%s] %s',
$request->getMethod(),
$request->getUri()
Expand Down
4 changes: 2 additions & 2 deletions src/Validator/LoggedResponseValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public function __construct(

public function validate(ResponseInterface $response, RequestInterface $request): void
{
$this->logger->debug(sprintf(
$this->logger->debug(\sprintf(
'Start testing Response: [%d] %s',
$response->getStatusCode(),
$response->getReasonPhrase()
));

$this->decorated->validate($response, $request);

$this->logger->debug(sprintf(
$this->logger->debug(\sprintf(
'Finish testing Response: [%d] %s',
$response->getStatusCode(),
$response->getReasonPhrase()
Expand Down
Loading