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
34 changes: 16 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@
"canvural/php-openapi-faker": "^2.0",
"cebe/php-openapi": "^1.5",
"fakerphp/faker": "^1.9",
"firebase/php-jwt": "^6.0.0",
"guzzlehttp/promises": "^1.4.0",
"illuminate/collections": "^8.0",
"monolog/monolog": "^1.25.1 || ^2.8.0 || ^3.0.0",
"firebase/php-jwt": "^6.0",
"guzzlehttp/promises": "^1.4.0 || ^2.0",
"illuminate/collections": "^8.99",
"myclabs/deep-copy": "^1.11",
"nesbot/carbon": "^2.48",
"nyholm/psr7": "1.*",
"nyholm/psr7": "^1.0",
"league/openapi-psr7-validator": "^0.18",
"openclassrooms/openapi-psr7-validator": "dev-master",
"opis/json-schema": "^2.3",
Expand All @@ -65,17 +64,17 @@
"phpstan/phpdoc-parser": "^1.2",
"phpunit/phpunit": "^9.5",
"psr/http-client": "^1.0",
"psr/http-message": "1.*",
"symfony/console": "^5.0 || ^6.0",
"symfony/dotenv": "^5.0 || ^6.0",
"symfony/finder": "^5.0 || ^6.0",
"symfony/http-client": "^5.0 || ^6.0",
"symfony/http-kernel": "^5.0 || ^6.0",
"symfony/property-access": "^5.0 || ^6.0 || ^6.0",
"symfony/property-info": "^5.0 || ^6.0",
"symfony/psr-http-message-bridge": "^1.2 || ^2.1.2",
"symfony/serializer": "^5.0 || ^6.0",
"symfony/yaml": "^5.0 || ^6.0"
"psr/http-message": "^1.0 || ^2.0",
"symfony/console": "^5.0 || ^6.0 || ^7.0",
"symfony/dotenv": "^5.0 || ^6.0 || ^7.0",
"symfony/finder": "^5.0 || ^6.0 || ^7.0",
"symfony/http-client": "^5.0 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.0 || ^6.0 || ^7.0",
"symfony/property-access": "^5.0 || ^6.0 || ^7.0",
"symfony/property-info": "^5.0 || ^6.0 || ^7.0",
"symfony/psr-http-message-bridge": "^1.2 || ^2.1.2 || ^6.0 || ^7.0",
"symfony/serializer": "^5.0 || ^6.0 || ^7.0",
"symfony/yaml": "^5.0 || ^6.0 || ^7.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.25",
Expand All @@ -92,9 +91,8 @@
"pyrech/composer-changelogs": "^1.8",
"rector/rector": "^0.15.23",
"roave/security-advisories": "dev-latest",
"dereuromark/composer-versions-check": "^0.1",
"spaze/phpstan-disallowed-calls": "^2.1",
"symfony/var-dumper": "^5.0 || ^6.0",
"symfony/var-dumper": "^5.0 || ^6.0 || ^7.0",
"symplify/easy-coding-standard": "^11.3.0",
"thecodingmachine/phpstan-strict-rules": "^1.0",
"veewee/composer-run-parallel": "^1.1"
Expand Down
2 changes: 2 additions & 0 deletions config/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ parameters:
- '/Language construct empty\(\) should not be used./'
- '/In method "APITester\\Requester\\SymfonyKernelRequester::request", caught "Throwable" must be rethrown.+/'
- '/.+ APITester\\Test\\TestCase\|null is not subtype of type PHPUnit\\Framework\\Test\|null/'
- '/throws checked exception Symfony\\Component\\Serializer\\Exception\\ExceptionInterface/'
- '/APITester\\Command\\ExecutePlanCommand::\$defaultName has no type specified./'
- {paths: [ ../tests ], message: '/Method .+ throws checked exception .+ but it''s missing from the PHPDoc @throws tag./'}
- {paths: [ ../src/Test/TestCase.php, ../src/Test/Plan.php ], message: '/Calling eval\(\) is forbidden, eval is evil, please write more code and do not use eval\(\)/'}
- {paths: [ ../src/Test/TestCase.php, ../src/Test/Plan.php ], message: '/Language construct eval\(\) should not be used./'}
Expand Down
36 changes: 16 additions & 20 deletions src/Util/Normalizer/PsrRequestNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,28 @@

final class PsrRequestNormalizer implements NormalizerInterface
{
/**
* @inerhitDoc
*
* @param mixed $data
* @param mixed|null $format
*/
public function supportsNormalization($data, $format = null): bool
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof Request;
}

/**
* @inerhitDoc
*
* @param mixed $object
* @param mixed|null $format
*
* @return array{'method': string,
* 'url': string,
* 'body': string|array<mixed>,
* 'headers': array<string, string>
* }
*/
public function normalize($object, $format = null, array $context = []): array
public function normalize(mixed $data, ?string $format = null, array $context = []): array
{
/** @var Request $object */
/** @var Request $data */
$result = [
'method' => $object->getMethod(),
'url' => (string) $object->getUri(),
'body' => Json::isJson((string) $object->getBody()) ? Json::decode(
(string) $object->getBody()
) : (string) $object->getBody(),
'headers' => $object->getHeaders(),
'method' => $data->getMethod(),
'url' => (string) $data->getUri(),
'body' => Json::isJson((string) $data->getBody()) ? Json::decode(
(string) $data->getBody()
) : (string) $data->getBody(),
'headers' => $data->getHeaders(),
];

if (isset($context[AbstractNormalizer::IGNORED_ATTRIBUTES])) {
Expand All @@ -61,4 +50,11 @@ public function normalize($object, $format = null, array $context = []): array
*/
return $result;
}

public function getSupportedTypes(?string $format): array
{
return [
Request::class => true,
];
}
}
34 changes: 15 additions & 19 deletions src/Util/Normalizer/PsrResponseNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,27 @@

final class PsrResponseNormalizer implements NormalizerInterface
{
/**
* @inerhitDoc
*
* @param mixed $data
* @param mixed|null $format
*/
public function supportsNormalization($data, $format = null): bool
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof Response;
}

/**
* @inerhitDoc
*
* @param mixed $object
* @param mixed|null $format
*
* @return array{
* 'body': string|array<mixed>,
* 'status': int,
* 'headers': array<string, string>
* }
*/
public function normalize($object, $format = null, array $context = []): array
public function normalize(mixed $data, ?string $format = null, array $context = []): array
{
/** @var Response $object */
/** @var Response $data */
$result = [
'body' => Json::isJson((string) $object->getBody()) ? Json::decode(
(string) $object->getBody()
) : (string) $object->getBody(),
'headers' => $object->getHeaders(),
'status' => $object->getStatusCode(),
'body' => Json::isJson((string) $data->getBody()) ? Json::decode(
(string) $data->getBody()
) : (string) $data->getBody(),
'headers' => $data->getHeaders(),
'status' => $data->getStatusCode(),
];

if (isset($context[AbstractNormalizer::IGNORED_ATTRIBUTES])) {
Expand All @@ -60,4 +49,11 @@ public function normalize($object, $format = null, array $context = []): array
*/
return $result;
}

public function getSupportedTypes(?string $format): array
{
return [
Response::class => true,
];
}
}