From 3d41a142e8e194f8e1db07e408f200f2a1fd9c17 Mon Sep 17 00:00:00 2001 From: Vitor de Souza Date: Wed, 13 Dec 2023 13:40:38 -0300 Subject: [PATCH] cs fixer --- .php-cs-fixer.php | 12 +- .php-cs-fixer.php.dist | 69 +++++++ README.md | 2 +- .../PetStoreApiConsumer.php | 2 + .../PetStoreClient/src/Request/CookieJar.php | 6 +- .../src/Request/DeleteOrderRequest.php | 2 +- .../src/Request/DeletePetRequest.php | 6 +- .../src/Request/DeleteUserRequest.php | 2 +- .../src/Request/FindPetsByStatusRequest.php | 4 +- .../src/Request/FindPetsByTagsRequest.php | 4 +- .../src/Request/GetOrderByIdRequest.php | 2 +- .../src/Request/GetPetByIdRequest.php | 2 +- .../src/Request/GetUserByNameRequest.php | 2 +- .../src/Request/LoginUserRequest.php | 4 +- .../src/Request/UpdatePetWithFormRequest.php | 6 +- .../src/Request/UpdateUserRequest.php | 2 +- .../src/Response/ResponseHandler.php | 2 +- .../src/Schema/Mapper/PetMapper.php | 6 +- .../src/Schema/PetCollection.php | 4 +- .../src/Schema/TagCollection.php | 4 +- .../src/Schema/UserCollection.php | 4 +- .../src/Serializer/BodySerializer.php | 6 +- .../AbstractJsonContentTypeSerializer.php | 10 +- .../FormUrlencodedContentTypeSerializer.php | 4 +- .../ContentType/XmlContentTypeSerializer.php | 70 +++---- .../src/Serializer/QuerySerializer.php | 2 +- example/PetStoreMock/PetStoreMock.php | 12 +- example/test-example.php | 2 +- src/Application.php | 3 +- src/Ast/Builder/CodeBuilder.php | 4 +- src/Ast/ParameterNode.php | 2 +- src/Ast/PhpVersion.php | 5 + .../Visitor/NamespaceSubstituteVisitor.php | 2 +- src/Command/GenerateCommand.php | 2 +- src/Entity/FieldType.php | 14 ++ src/Entity/OperationCollection.php | 3 +- src/Entity/Request.php | 8 + src/Entity/RequestFieldRegistry.php | 5 + src/Generator/ClientGenerator.php | 10 +- src/Generator/FreeFormSchemaGenerator.php | 2 +- .../ContainerImplementationStrategy.php | 4 +- .../HttpMessage/HttpMessageAbstract.php | 4 +- .../HttpMessageImplementationStrategy.php | 7 +- src/Generator/RequestGenerator.php | 1 + src/Generator/RequestMapperGenerator.php | 3 +- src/Generator/SchemaCollectionGenerator.php | 6 +- src/Generator/SchemaGenerator.php | 2 + src/Generator/SchemaMapperGenerator.php | 5 +- .../BasicAuthenticationSecurityStrategy.php | 1 + .../BearerAuthenticationSecurityStrategy.php | 2 + src/Generator/ServiceProviderGenerator.php | 6 +- src/Input/Configuration.php | 21 ++- src/Input/Factory/FieldFactory.php | 2 +- src/Input/Factory/OperationFactory.php | 2 +- src/Input/Factory/ResponseFactory.php | 2 + src/Input/FileReader.php | 6 +- src/Meta/Template/TwigExtension.php | 7 - src/Naming/ClientNaming.php | 3 +- .../AbstractJsonContentTypeSerializer.php | 1 + .../ContentType/XmlContentTypeSerializer.php | 64 ++----- .../Copy/Serializer/QuerySerializer.php | 1 + src/ServiceProvider.php | 20 +- test/suite/acceptance/PetStore3Test.php | 7 +- .../suite/functional/ConfigurationBuilder.php | 13 +- .../Generator/AbstractGeneratorTest.php | 6 + .../Generator/FreeFormSchemaGeneratorTest.php | 2 +- .../Request/GetResourcesRequest74.php | 6 +- .../Request/GetResourcesRequest80.php | 6 +- .../Request/GetSubResourcesRequest74.php | 6 +- .../Request/GetSubResourcesRequest80.php | 6 +- .../Request/PatchResourceRequest74.php | 4 +- .../Request/PatchResourceRequest80.php | 4 +- .../Request/PutResourceByIdRequest74.php | 16 +- .../Request/PutResourceByIdRequest80.php | 16 +- .../Generator/RequestGeneratorTest.php | 12 +- .../functional/Generator/Schema/ItemPhp70.php | 56 +++--- .../functional/Generator/Schema/ItemPhp72.php | 56 +++--- .../functional/Generator/Schema/ItemPhp74.php | 56 +++--- .../functional/Generator/Schema/ItemPhp80.php | 56 +++--- .../SchemaCollection/ItemCollectionPhp70.php | 4 +- .../SchemaCollection/ItemCollectionPhp72.php | 4 +- .../SchemaCollection/ItemCollectionPhp74.php | 4 +- .../SchemaCollection/ItemCollectionPhp80.php | 4 +- .../Generator/SchemaGeneratorTest.php | 2 +- .../Generator/SchemaMapper/ItemMapper74.php | 8 +- .../Generator/SchemaMapper/ItemMapper80.php | 8 +- .../SchemaMapper/ResourceMapper74.php | 4 +- .../SchemaMapper/ResourceMapper80.php | 4 +- .../Generator/SchemaMapperGeneratorTest.php | 12 +- .../suite/functional/Input/FileReaderTest.php | 2 +- test/suite/functional/Input/ParserTest.php | 96 +++++----- .../functional/Input/SpecificationTest.php | 22 +-- .../functional/Meta/AbstractTemplateTest.php | 2 + .../Meta/ComposerJsonTemplateTest.php | 8 +- .../functional/Meta/ReadmeMdTemplateTest.php | 2 +- .../functional/Naming/SchemaNamingTest.php | 1 + .../Copy/Serializer/BodySerializerTest.php | 6 +- .../unit/Ast/Builder/CodeBuilderTest.php | 10 +- .../NamespaceSubstituteVisitorTest.php | 4 +- test/suite/unit/Entity/OperationTest.php | 5 + .../suite/unit/Input/PhpNameValidatorTest.php | 6 - test/suite/unit/Naming/CaseCasterTest.php | 176 +++++++++--------- .../Output/Copy/Request/CookieJarTest.php | 14 +- .../FormEncodedContentTypeSerializerTest.php | 12 +- .../JsonContentTypeSerializerTest.php | 28 +-- .../VdnApiJsonContentTypeSerializerTest.php | 26 +-- .../XmlContentTypeSerializerTest.php | 54 +++--- .../Copy/Serializer/QuerySerializerTest.php | 16 +- .../unit/Output/DirectoryPrinterTest.php | 1 + .../unit/Output/Meta/MetaFilePrinterTest.php | 1 + test/suite/unit/Output/Php/PhpFileTest.php | 4 +- test/suite/unit/Output/Php/PhpPrinterTest.php | 3 + 112 files changed, 740 insertions(+), 624 deletions(-) create mode 100644 .php-cs-fixer.php.dist diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index acd3e54..3b5f129 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -2,12 +2,6 @@ use PhpCsFixer\Config; -$header = <<<'EOT' -This file was generated by docler-labs/api-client-generator. - -Do not edit it manually. -EOT; - $rules = [ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], @@ -16,7 +10,7 @@ 'echo_tag_syntax' => ['format' => 'long'], 'no_unused_imports' => true, 'blank_line_after_opening_tag' => true, - 'not_operator_with_successor_space' => true, + 'not_operator_with_successor_space' => false, 'no_useless_else' => true, 'ordered_imports' => ['sort_algorithm' => 'alpha'], 'class_attributes_separation' => [ @@ -50,14 +44,12 @@ 'no_leading_import_slash' => true, 'declare_strict_types' => true, 'single_line_after_imports' => true, - 'header_comment' => ['header' => $header], 'not_operator_with_space' => false, 'no_spaces_inside_parenthesis' => true, 'unary_operator_spaces' => true, 'return_type_declaration' => ['space_before' => 'none'], - 'native_function_invocation' => ['include' => ['@all']], 'braces' => ['allow_single_line_closure' => true], - 'binary_operator_spaces' => ['default' => 'align_single_space_minimal'], + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal']], 'no_superfluous_phpdoc_tags' => true, 'no_empty_phpdoc' => true, 'no_extra_blank_lines' => true, diff --git a/.php-cs-fixer.php.dist b/.php-cs-fixer.php.dist new file mode 100644 index 0000000..7965c77 --- /dev/null +++ b/.php-cs-fixer.php.dist @@ -0,0 +1,69 @@ + true, + 'array_syntax' => ['syntax' => 'short'], + 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], + 'no_blank_lines_after_class_opening' => true, + 'echo_tag_syntax' => ['format' => 'long'], + 'no_unused_imports' => true, + 'blank_line_after_opening_tag' => true, + 'not_operator_with_successor_space' => false, + 'no_useless_else' => true, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'class_attributes_separation' => [ + 'elements' => [ + 'const' => 'one', + 'method' => 'one', + 'property' => 'one', + ], + ], + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'return', 'try'], + ], + 'no_alternative_syntax' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_align' => ['align' => 'vertical'], + 'phpdoc_indent' => true, + 'phpdoc_no_package' => true, + 'phpdoc_order' => true, + 'phpdoc_separation' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_trim' => true, + 'phpdoc_var_without_name' => true, + 'phpdoc_to_comment' => true, + 'phpdoc_scalar' => [ + 'types' => ['boolean', 'double', 'integer', 'real', 'str'], + ], + 'single_quote' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'trim_array_spaces' => true, + 'no_leading_import_slash' => true, + 'declare_strict_types' => true, + 'single_line_after_imports' => true, + 'header_comment' => ['header' => $header], + 'not_operator_with_space' => false, + 'no_spaces_inside_parenthesis' => true, + 'unary_operator_spaces' => true, + 'return_type_declaration' => ['space_before' => 'none'], + 'braces' => ['allow_single_line_closure' => true], + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal', '=' => 'align_single_space_minimal']], + 'no_superfluous_phpdoc_tags' => true, + 'no_empty_phpdoc' => true, + 'no_extra_blank_lines' => true, +]; + +return (new Config()) + ->setRiskyAllowed(true) + ->setRules($rules) + ->setIndent(' ') + ->setUsingCache(false); diff --git a/README.md b/README.md index 0c4518d..0e46629 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ The following environment variables are available: | `PACKAGE` | yes | | | group/some-api-client | | `OPENAPI ` | yes | | | /api/openapi.yaml | | `OUTPUT_DIR` | yes | | | /client | -| `CODE_STYLE` | no | {path-to-repository}/.php-cs-fixer.php | | /client/myCodeStyle.php | +| `CODE_STYLE` | no | {path-to-repository}/.php-cs-fixer.php.dist | | /client/myCodeStyle.php | | `SOURCE_DIR` | no | src | | src | | `CLIENT_PHP_VERSION` | no | 7.4 | 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 | 7.4 | | `COMPOSER_JSON_TEMPLATE_DIR` | no | {path-to-repository}/template/composer.json.twig | | /path/composer.json.twig | diff --git a/example/PetStoreApiConsumer/PetStoreApiConsumer.php b/example/PetStoreApiConsumer/PetStoreApiConsumer.php index b8cb07e..381cc25 100644 --- a/example/PetStoreApiConsumer/PetStoreApiConsumer.php +++ b/example/PetStoreApiConsumer/PetStoreApiConsumer.php @@ -1,5 +1,7 @@ $value) { - if (\preg_match('/[\\x00-\\x20\\x22\\x28-\\x29\\x2c\\x2f\\x3a-\\x40\\x5c\\x7b\\x7d\\x7f]/', $name)) { + if (preg_match('/[\\x00-\\x20\\x22\\x28-\\x29\\x2c\\x2f\\x3a-\\x40\\x5c\\x7b\\x7d\\x7f]/', $name)) { throw new InvalidArgumentException('Cookie name must not contain invalid characters: ASCII ' . 'Control characters (0-31;127), space, tab and the following characters: ()<>@,;:\\"/?={}'); } // Value must not be empty, but can be 0 - if (empty($value) && ! \is_numeric($value)) { + if (empty($value) && !is_numeric($value)) { throw new InvalidArgumentException('The cookie value must not be empty'); } } @@ -34,6 +34,6 @@ public function __construct(array $cookies = []) public function withCookieHeader(RequestInterface $request): RequestInterface { - return empty($this->cookies) ? $request : $request->withHeader('Cookie', \http_build_query($this->cookies, '', '; ')); + return empty($this->cookies) ? $request : $request->withHeader('Cookie', http_build_query($this->cookies, '', '; ')); } } diff --git a/example/PetStoreClient/src/Request/DeleteOrderRequest.php b/example/PetStoreClient/src/Request/DeleteOrderRequest.php index 95e7030..71b16b2 100644 --- a/example/PetStoreClient/src/Request/DeleteOrderRequest.php +++ b/example/PetStoreClient/src/Request/DeleteOrderRequest.php @@ -33,7 +33,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('store/order/{orderId}', ['{orderId}' => $this->orderId]); + return strtr('store/order/{orderId}', ['{orderId}' => $this->orderId]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Request/DeletePetRequest.php b/example/PetStoreClient/src/Request/DeletePetRequest.php index df96468..c8a4935 100644 --- a/example/PetStoreClient/src/Request/DeletePetRequest.php +++ b/example/PetStoreClient/src/Request/DeletePetRequest.php @@ -44,7 +44,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('pet/{petId}', ['{petId}' => $this->petId]); + return strtr('pet/{petId}', ['{petId}' => $this->petId]); } public function getQueryParameters(): array @@ -64,9 +64,9 @@ public function getCookies(): array public function getHeaders(): array { - return \array_merge([], \array_map(static function ($value) { + return array_merge([], array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['api_key' => $this->apiKey], static function ($value) { + }, array_filter(['api_key' => $this->apiKey], static function ($value) { return null !== $value; }))); } diff --git a/example/PetStoreClient/src/Request/DeleteUserRequest.php b/example/PetStoreClient/src/Request/DeleteUserRequest.php index e5b3706..4334bcb 100644 --- a/example/PetStoreClient/src/Request/DeleteUserRequest.php +++ b/example/PetStoreClient/src/Request/DeleteUserRequest.php @@ -33,7 +33,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('user/{username}', ['{username}' => $this->username]); + return strtr('user/{username}', ['{username}' => $this->username]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Request/FindPetsByStatusRequest.php b/example/PetStoreClient/src/Request/FindPetsByStatusRequest.php index 444e8cb..d85a328 100644 --- a/example/PetStoreClient/src/Request/FindPetsByStatusRequest.php +++ b/example/PetStoreClient/src/Request/FindPetsByStatusRequest.php @@ -48,9 +48,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['status' => $this->status], static function ($value) { + }, array_filter(['status' => $this->status], static function ($value) { return null !== $value; })); } diff --git a/example/PetStoreClient/src/Request/FindPetsByTagsRequest.php b/example/PetStoreClient/src/Request/FindPetsByTagsRequest.php index 8a6ebc1..4a05a34 100644 --- a/example/PetStoreClient/src/Request/FindPetsByTagsRequest.php +++ b/example/PetStoreClient/src/Request/FindPetsByTagsRequest.php @@ -45,9 +45,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['tags' => $this->tags], static function ($value) { + }, array_filter(['tags' => $this->tags], static function ($value) { return null !== $value; })); } diff --git a/example/PetStoreClient/src/Request/GetOrderByIdRequest.php b/example/PetStoreClient/src/Request/GetOrderByIdRequest.php index 8cac13e..d82f9b0 100644 --- a/example/PetStoreClient/src/Request/GetOrderByIdRequest.php +++ b/example/PetStoreClient/src/Request/GetOrderByIdRequest.php @@ -33,7 +33,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('store/order/{orderId}', ['{orderId}' => $this->orderId]); + return strtr('store/order/{orderId}', ['{orderId}' => $this->orderId]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Request/GetPetByIdRequest.php b/example/PetStoreClient/src/Request/GetPetByIdRequest.php index 939e9dd..66a0e59 100644 --- a/example/PetStoreClient/src/Request/GetPetByIdRequest.php +++ b/example/PetStoreClient/src/Request/GetPetByIdRequest.php @@ -33,7 +33,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('pet/{petId}', ['{petId}' => $this->petId]); + return strtr('pet/{petId}', ['{petId}' => $this->petId]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Request/GetUserByNameRequest.php b/example/PetStoreClient/src/Request/GetUserByNameRequest.php index 49e6036..f0f24a6 100644 --- a/example/PetStoreClient/src/Request/GetUserByNameRequest.php +++ b/example/PetStoreClient/src/Request/GetUserByNameRequest.php @@ -33,7 +33,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('user/{username}', ['{username}' => $this->username]); + return strtr('user/{username}', ['{username}' => $this->username]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Request/LoginUserRequest.php b/example/PetStoreClient/src/Request/LoginUserRequest.php index 1ac3ac4..4ebf07d 100644 --- a/example/PetStoreClient/src/Request/LoginUserRequest.php +++ b/example/PetStoreClient/src/Request/LoginUserRequest.php @@ -51,9 +51,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['username' => $this->username, 'password' => $this->password], static function ($value) { + }, array_filter(['username' => $this->username, 'password' => $this->password], static function ($value) { return null !== $value; })); } diff --git a/example/PetStoreClient/src/Request/UpdatePetWithFormRequest.php b/example/PetStoreClient/src/Request/UpdatePetWithFormRequest.php index d9392b4..92ab3a8 100644 --- a/example/PetStoreClient/src/Request/UpdatePetWithFormRequest.php +++ b/example/PetStoreClient/src/Request/UpdatePetWithFormRequest.php @@ -53,14 +53,14 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('pet/{petId}', ['{petId}' => $this->petId]); + return strtr('pet/{petId}', ['{petId}' => $this->petId]); } public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['name' => $this->name, 'status' => $this->status], static function ($value) { + }, array_filter(['name' => $this->name, 'status' => $this->status], static function ($value) { return null !== $value; })); } diff --git a/example/PetStoreClient/src/Request/UpdateUserRequest.php b/example/PetStoreClient/src/Request/UpdateUserRequest.php index ef4cc52..0a6cc78 100644 --- a/example/PetStoreClient/src/Request/UpdateUserRequest.php +++ b/example/PetStoreClient/src/Request/UpdateUserRequest.php @@ -39,7 +39,7 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('user/{username}', ['{username}' => $this->username]); + return strtr('user/{username}', ['{username}' => $this->username]); } public function getQueryParameters(): array diff --git a/example/PetStoreClient/src/Response/ResponseHandler.php b/example/PetStoreClient/src/Response/ResponseHandler.php index 515d5f7..96f6b1f 100644 --- a/example/PetStoreClient/src/Response/ResponseHandler.php +++ b/example/PetStoreClient/src/Response/ResponseHandler.php @@ -38,6 +38,6 @@ public function handle(ResponseInterface $response): array if ($statusCode >= 200 && $statusCode < 300) { return $this->bodySerializer->unserializeResponse($response); } - throw $this->responseExceptionFactory->create(\sprintf('Server replied with a non-200 status code: %s', $response->getStatusCode()), $response); + throw $this->responseExceptionFactory->create(sprintf('Server replied with a non-200 status code: %s', $response->getStatusCode()), $response); } } diff --git a/example/PetStoreClient/src/Schema/Mapper/PetMapper.php b/example/PetStoreClient/src/Schema/Mapper/PetMapper.php index 0d5963b..6a97d8e 100644 --- a/example/PetStoreClient/src/Schema/Mapper/PetMapper.php +++ b/example/PetStoreClient/src/Schema/Mapper/PetMapper.php @@ -30,8 +30,8 @@ public function __construct(CategoryMapper $categoryMapper, TagCollectionMapper */ public function toSchema(array $payload): Pet { - $missingFields = \implode(', ', \array_diff(['name', 'photoUrls'], \array_keys($payload))); - if (! empty($missingFields)) { + $missingFields = implode(', ', array_diff(['name', 'photoUrls'], array_keys($payload))); + if (!empty($missingFields)) { throw new UnexpectedResponseBodyException('Required attributes for `Pet` missing in the response body: ' . $missingFields); } $schema = new Pet($payload['name'], $payload['photoUrls']); @@ -47,7 +47,7 @@ public function toSchema(array $payload): Pet if (isset($payload['status'])) { $schema->setStatus($payload['status']); } - if (\array_key_exists('chipped', $payload)) { + if (array_key_exists('chipped', $payload)) { $schema->setChipped($payload['chipped']); } diff --git a/example/PetStoreClient/src/Schema/PetCollection.php b/example/PetStoreClient/src/Schema/PetCollection.php index 8c62e8f..a3f76d9 100644 --- a/example/PetStoreClient/src/Schema/PetCollection.php +++ b/example/PetStoreClient/src/Schema/PetCollection.php @@ -52,12 +52,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?Pet { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/example/PetStoreClient/src/Schema/TagCollection.php b/example/PetStoreClient/src/Schema/TagCollection.php index 7e950ef..89e6854 100644 --- a/example/PetStoreClient/src/Schema/TagCollection.php +++ b/example/PetStoreClient/src/Schema/TagCollection.php @@ -52,12 +52,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?Tag { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/example/PetStoreClient/src/Schema/UserCollection.php b/example/PetStoreClient/src/Schema/UserCollection.php index ac0115e..2f76ae9 100644 --- a/example/PetStoreClient/src/Schema/UserCollection.php +++ b/example/PetStoreClient/src/Schema/UserCollection.php @@ -52,12 +52,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?User { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/example/PetStoreClient/src/Serializer/BodySerializer.php b/example/PetStoreClient/src/Serializer/BodySerializer.php index 9161461..b038a0f 100644 --- a/example/PetStoreClient/src/Serializer/BodySerializer.php +++ b/example/PetStoreClient/src/Serializer/BodySerializer.php @@ -66,9 +66,9 @@ public function unserializeResponse(ResponseInterface $response): array private function getContentTypeSerializer(string $contentType): ContentTypeSerializerInterface { - $contentType = \strtolower(\trim(\explode(';', $contentType)[0])); - if (! isset($this->contentTypeSerializers[$contentType])) { - throw new InvalidArgumentException(\sprintf('Serializer for `%s` is not found. Supported: %s', $contentType, \json_encode(\array_keys($this->contentTypeSerializers)))); + $contentType = strtolower(trim(explode(';', $contentType)[0])); + if (!isset($this->contentTypeSerializers[$contentType])) { + throw new InvalidArgumentException(sprintf('Serializer for `%s` is not found. Supported: %s', $contentType, json_encode(array_keys($this->contentTypeSerializers)))); } return $this->contentTypeSerializers[$contentType]; diff --git a/example/PetStoreClient/src/Serializer/ContentType/AbstractJsonContentTypeSerializer.php b/example/PetStoreClient/src/Serializer/ContentType/AbstractJsonContentTypeSerializer.php index 7eb40c0..f6c6110 100644 --- a/example/PetStoreClient/src/Serializer/ContentType/AbstractJsonContentTypeSerializer.php +++ b/example/PetStoreClient/src/Serializer/ContentType/AbstractJsonContentTypeSerializer.php @@ -24,8 +24,8 @@ abstract class AbstractJsonContentTypeSerializer implements ContentTypeSerialize */ public function encode(SerializableInterface $body): string { - $encodedData = \json_encode($body->toArray(), self::JSON_OPTIONS); - $lastErrorCode = \json_last_error(); + $encodedData = json_encode($body->toArray(), self::JSON_OPTIONS); + $lastErrorCode = json_last_error(); if ($lastErrorCode === JSON_ERROR_NONE && $encodedData !== false) { return $encodedData; } @@ -40,10 +40,10 @@ public function decode(StreamInterface $body): array $body->rewind(); // According to RFC7159 a JSON value MUST be an object, array, number, string, // or one of the following three literal names: false, null, true. - $result = \json_decode($body->getContents(), true, self::JSON_DEPTH, self::JSON_OPTIONS); - $lastErrorCode = \json_last_error(); + $result = json_decode($body->getContents(), true, self::JSON_DEPTH, self::JSON_OPTIONS); + $lastErrorCode = json_last_error(); if ($lastErrorCode === JSON_ERROR_NONE) { - if (! \is_array($result)) { + if (!is_array($result)) { $result = [ContentTypeSerializerInterface::LITERAL_VALUE_KEY => $result]; } diff --git a/example/PetStoreClient/src/Serializer/ContentType/FormUrlencodedContentTypeSerializer.php b/example/PetStoreClient/src/Serializer/ContentType/FormUrlencodedContentTypeSerializer.php index 727a9ef..59cc96c 100644 --- a/example/PetStoreClient/src/Serializer/ContentType/FormUrlencodedContentTypeSerializer.php +++ b/example/PetStoreClient/src/Serializer/ContentType/FormUrlencodedContentTypeSerializer.php @@ -19,13 +19,13 @@ class FormUrlencodedContentTypeSerializer implements ContentTypeSerializerInterf public function encode(SerializableInterface $body): string { - return \http_build_query($body->toArray()); + return http_build_query($body->toArray()); } public function decode(StreamInterface $body): array { $body->rewind(); - \parse_str($body->getContents(), $decoded); + parse_str($body->getContents(), $decoded); return $decoded; } diff --git a/example/PetStoreClient/src/Serializer/ContentType/XmlContentTypeSerializer.php b/example/PetStoreClient/src/Serializer/ContentType/XmlContentTypeSerializer.php index c5f6bc5..772604f 100644 --- a/example/PetStoreClient/src/Serializer/ContentType/XmlContentTypeSerializer.php +++ b/example/PetStoreClient/src/Serializer/ContentType/XmlContentTypeSerializer.php @@ -51,15 +51,15 @@ public function decode(StreamInterface $body): array $childNodeName = $child->nodeName; $this->items[$childNodeName] = $childValue; // Add namespacing information to the root node - if (! empty($this->namespaces) && $this->config['namespacesOnRoot']) { - if (! isset($this->items[$childNodeName][$this->config['attributesKey']])) { + if (!empty($this->namespaces) && $this->config['namespacesOnRoot']) { + if (!isset($this->items[$childNodeName][$this->config['attributesKey']])) { $this->items[$childNodeName][$this->config['attributesKey']] = []; } foreach ($this->namespaces as $uri => $prefix) { - if (! \is_string($prefix)) { + if (!is_string($prefix)) { continue; } - $prefix = \sprintf('%s%s%s', self::ATTRIBUTE_NAMESPACE, self::ATTRIBUTE_NAMESPACE_SEPARATOR, $prefix); + $prefix = sprintf('%s%s%s', self::ATTRIBUTE_NAMESPACE, self::ATTRIBUTE_NAMESPACE_SEPARATOR, $prefix); $this->items[$childNodeName][$this->config['attributesKey']][$prefix] = $uri; } } @@ -70,10 +70,10 @@ public function decode(StreamInterface $body): array public function encode(SerializableInterface $body): string { $this->xml = new DOMDocument($this->config['version'], $this->config['encoding']); - if (\strrpos(\get_class($body), '\\') === false) { - $rootKey = \get_class($body); + if (strrpos(get_class($body), '\\') === false) { + $rootKey = get_class($body); } else { - $rootKey = \substr(\get_class($body), \strrpos(\get_class($body), '\\') + 1); + $rootKey = substr(get_class($body), strrpos(get_class($body), '\\') + 1); } $this->xml->appendChild($this->buildNode($rootKey, $body->toArray())); $result = $this->xml->saveXML(); @@ -136,8 +136,8 @@ private function parseChildNodes(DOMNode $node, $output) { foreach ($node->childNodes as $child) { if ($child->nodeType === XML_CDATA_SECTION_NODE) { - if (! \is_array($output)) { - if (! empty($output)) { + if (!is_array($output)) { + if (!empty($output)) { $output = [$this->config['valueKey'] => $output]; } else { $output = []; @@ -148,7 +148,7 @@ private function parseChildNodes(DOMNode $node, $output) $value = $this->parseNode($child); if ($child->nodeType === XML_TEXT_NODE) { if ($value !== '') { - if (! empty($output)) { + if (!empty($output)) { $output[$this->config['valueKey']] = $value; } else { $output = $value; @@ -156,7 +156,7 @@ private function parseChildNodes(DOMNode $node, $output) } } elseif ($child->nodeType !== XML_COMMENT_NODE) { $nodeName = $child->nodeName; - if (! isset($output[$nodeName])) { + if (!isset($output[$nodeName])) { $output[$nodeName] = []; } $output[$nodeName][] = $value; @@ -174,17 +174,17 @@ private function parseChildNodes(DOMNode $node, $output) */ private function normalizeTextContent($textContent): string { - $normalized = \preg_replace(['/\\n+\\s+/', '/\\r+\\s+/', '/\\n+\\t+/', '/\\r+\\t+/'], ' ', $textContent); - if (! \is_string($normalized)) { - throw new SerializeException(\sprintf('Normalization of %s failed', \json_encode($textContent))); + $normalized = preg_replace(['/\\n+\\s+/', '/\\r+\\s+/', '/\\n+\\t+/', '/\\r+\\t+/'], ' ', $textContent); + if (!is_string($normalized)) { + throw new SerializeException(sprintf('Normalization of %s failed', json_encode($textContent))); } - return \trim($normalized); + return trim($normalized); } private function normalizeNodeValues($values) { - if (! \is_array($values)) { + if (!is_array($values)) { return $values; } if (empty($values)) { @@ -192,9 +192,9 @@ private function normalizeNodeValues($values) } // if there is only one node of its kind, assign it directly instead of array($value); foreach ($values as $key => $value) { - if (\is_array($value) && \count($value) === 1) { - $keyName = \array_keys($value)[0]; - if (\is_numeric($keyName)) { + if (is_array($value) && count($value) === 1) { + $keyName = array_keys($value)[0]; + if (is_numeric($keyName)) { $values[$key] = $value[$keyName]; } } @@ -205,7 +205,7 @@ private function normalizeNodeValues($values) private function collectAttributes(DOMNode $node, $output) { - if ($node->attributes === null || ! $node->attributes->length) { + if ($node->attributes === null || !$node->attributes->length) { return $output; } $attributes = []; @@ -218,14 +218,14 @@ private function collectAttributes(DOMNode $node, $output) } } // if it is a leaf node, store the value in @value - if (! \is_array($output)) { - if (! empty($output)) { + if (!is_array($output)) { + if (!empty($output)) { $output = [$this->config['valueKey'] => $output]; } else { $output = []; } } - foreach (\array_merge($attributes, $namespaces) as $key => $value) { + foreach (array_merge($attributes, $namespaces) as $key => $value) { $output[$this->config['attributesKey']][$key] = $value; } @@ -235,7 +235,7 @@ private function collectAttributes(DOMNode $node, $output) private function collectNodeNamespaces(DOMNode $node, array $output): array { $namespaces = $this->collectNamespaces($node); - if (! empty($namespaces)) { + if (!empty($namespaces)) { $output[$this->config['attributesKey']] = $namespaces; } @@ -248,9 +248,9 @@ private function collectNamespaces(DOMNode $node): array if ($node->namespaceURI) { $nsUri = $node->namespaceURI; $nsPrefix = $node->lookupPrefix($nsUri); - if (! \array_key_exists($nsUri, $this->namespaces)) { + if (!array_key_exists($nsUri, $this->namespaces)) { $this->namespaces[$nsUri] = $nsPrefix; - if (! $this->config['namespacesOnRoot']) { + if (!$this->config['namespacesOnRoot']) { if ($nsPrefix) { $nsPrefix = self::ATTRIBUTE_NAMESPACE_SEPARATOR . $nsPrefix; } @@ -267,14 +267,14 @@ private function collectNamespaces(DOMNode $node): array */ private function buildNode(string $nodeName, $data): DOMElement { - if (! $this->isValidTagName($nodeName)) { + if (!$this->isValidTagName($nodeName)) { throw new SerializeException('Invalid character in the tag name being generated: ' . $nodeName); } $node = $this->xml->createElement($nodeName); if ($data === false) { throw new SerializeException('Failed to create a node for: ' . $nodeName); } - if (\is_array($data)) { + if (is_array($data)) { $this->parseArray($node, $data); } else { $node->appendChild($this->xml->createTextNode($this->normalizeValues($data))); @@ -298,10 +298,10 @@ private function parseArray(DOMElement $node, array $array) $array = $this->parseCdata($node, $array); // recurse to build child nodes for this node foreach ($array as $key => $value) { - if (! $this->isValidTagName($key)) { + if (!$this->isValidTagName($key)) { throw new SerializeException('Invalid character in the tag name being generated: ' . $key); } - if (\is_array($value) && \is_numeric(\key($value))) { + if (is_array($value) && is_numeric(key($value))) { // MORE THAN ONE NODE OF ITS KIND // if the new array is numeric index, means it is array of nodes of the same kind // it should follow the parent key name @@ -322,9 +322,9 @@ private function parseArray(DOMElement $node, array $array) private function parseAttributes(DOMElement $node, array $array): array { $attributesKey = $this->config['attributesKey']; - if (\array_key_exists($attributesKey, $array) && \is_array($array[$attributesKey])) { + if (array_key_exists($attributesKey, $array) && is_array($array[$attributesKey])) { foreach ($array[$attributesKey] as $key => $value) { - if (! $this->isValidTagName($key)) { + if (!$this->isValidTagName($key)) { throw new SerializeException('Invalid character in the attribute name being generated: ' . $key); } $node->setAttribute($key, $this->normalizeValues($value)); @@ -338,7 +338,7 @@ private function parseAttributes(DOMElement $node, array $array): array private function parseValue(DOMElement $node, array $array): array { $valueKey = $this->config['valueKey']; - if (\array_key_exists($valueKey, $array)) { + if (array_key_exists($valueKey, $array)) { $node->appendChild($this->xml->createTextNode($this->normalizeValues($array[$valueKey]))); unset($array[$valueKey]); } @@ -349,7 +349,7 @@ private function parseValue(DOMElement $node, array $array): array private function parseCdata(DOMElement $node, array $array): array { $cdataKey = $this->config['cdataKey']; - if (\array_key_exists($cdataKey, $array)) { + if (array_key_exists($cdataKey, $array)) { $node->appendChild($this->xml->createCDATASection($this->normalizeValues($array[$cdataKey]))); unset($array[$cdataKey]); } @@ -370,6 +370,6 @@ private function isValidTagName(string $tag): bool { $pattern = '/^[a-zA-Z_][\\w\\:\\-\\.]*$/'; - return \preg_match($pattern, $tag, $matches) && $matches[0] === $tag && $tag[\strlen($tag) - 1] !== ':'; + return preg_match($pattern, $tag, $matches) && $matches[0] === $tag && $tag[strlen($tag) - 1] !== ':'; } } diff --git a/example/PetStoreClient/src/Serializer/QuerySerializer.php b/example/PetStoreClient/src/Serializer/QuerySerializer.php index 1e7565c..cd45a8c 100644 --- a/example/PetStoreClient/src/Serializer/QuerySerializer.php +++ b/example/PetStoreClient/src/Serializer/QuerySerializer.php @@ -34,6 +34,6 @@ public function serializeRequest(RequestInterface $request): string $queryParameters[$name] = $value; } - return \http_build_query($queryParameters, '', '&', PHP_QUERY_RFC3986); + return http_build_query($queryParameters, '', '&', PHP_QUERY_RFC3986); } } diff --git a/example/PetStoreMock/PetStoreMock.php b/example/PetStoreMock/PetStoreMock.php index ecbfeeb..78e4452 100644 --- a/example/PetStoreMock/PetStoreMock.php +++ b/example/PetStoreMock/PetStoreMock.php @@ -1,5 +1,7 @@ 2972962088, - 'category' => [ + 'id' => 2972962088, + 'category' => [ 'id' => 1085449728, 'name' => 'dog', ], @@ -17,12 +19,12 @@ class PetStoreMock 'http://foo.bar.com/1', 'http://foo.bar.com/2', ], - 'tags' => [ + 'tags' => [ [ 'id' => 2291630681, ], ], - 'status' => 'sold', + 'status' => 'sold', ]; private Client $wiremockClient; @@ -82,7 +84,7 @@ private function mock( [ 'body' => json_encode( [ - 'request' => array_filter( + 'request' => array_filter( [ 'method' => $requestMethod, 'urlPathPattern' => $urlMatcher, diff --git a/example/test-example.php b/example/test-example.php index 579e4b3..5224401 100644 --- a/example/test-example.php +++ b/example/test-example.php @@ -9,7 +9,7 @@ use OpenApi\PetStoreClient\Serializer\ContentType\XmlContentTypeSerializer; use OpenApi\PetStoreMock\PetStoreMock; -$mock = new PetStoreMock(); +$mock = new PetStoreMock(); $consumer = new PetStoreApiConsumer(); $mock->mockFindPetsByStatus(); diff --git a/src/Application.php b/src/Application.php index 9a236ff..c416371 100644 --- a/src/Application.php +++ b/src/Application.php @@ -10,7 +10,8 @@ class Application extends BaseApplication { - protected const NAME = 'OpenApi client generator'; + protected const NAME = 'OpenApi client generator'; + protected const VERSION = '1.0.0'; public function __construct() diff --git a/src/Ast/Builder/CodeBuilder.php b/src/Ast/Builder/CodeBuilder.php index 12c7287..46ca77a 100644 --- a/src/Ast/Builder/CodeBuilder.php +++ b/src/Ast/Builder/CodeBuilder.php @@ -373,7 +373,7 @@ public function className(string $string): Name public function compare(Expr $left, string $operator, Expr $right): BinaryOp { - return match($operator) { + return match ($operator) { '>' => new Greater($left, $right), '>=' => new GreaterOrEqual($left, $right), '<' => new Smaller($left, $right), @@ -384,7 +384,7 @@ public function compare(Expr $left, string $operator, Expr $right): BinaryOp public function operation(Expr $left, string $operator, Expr $right): BinaryOp { - return match($operator) { + return match ($operator) { '-' => new Minus($left, $right), '+' => new Plus($left, $right), '*' => new Mul($left, $right), diff --git a/src/Ast/ParameterNode.php b/src/Ast/ParameterNode.php index 8ed1199..6a6dc39 100644 --- a/src/Ast/ParameterNode.php +++ b/src/Ast/ParameterNode.php @@ -31,7 +31,7 @@ public function getDocBlockType(): string } if ($this->type instanceof UnionType) { - return implode("|", $this->type->getAttribute('types')); + return implode('|', $this->type->getAttribute('types')); } if ($this->type instanceof NullableType) { diff --git a/src/Ast/PhpVersion.php b/src/Ast/PhpVersion.php index dd8f5eb..8076474 100644 --- a/src/Ast/PhpVersion.php +++ b/src/Ast/PhpVersion.php @@ -9,10 +9,15 @@ class PhpVersion { public const VERSION_PHP70 = 7.0; + public const VERSION_PHP71 = 7.1; + public const VERSION_PHP72 = 7.2; + public const VERSION_PHP73 = 7.3; + public const VERSION_PHP74 = 7.4; + public const VERSION_PHP80 = 8.0; private const SUPPORTED_VERSIONS = [ diff --git a/src/Ast/Visitor/NamespaceSubstituteVisitor.php b/src/Ast/Visitor/NamespaceSubstituteVisitor.php index 39c2774..6e83548 100644 --- a/src/Ast/Visitor/NamespaceSubstituteVisitor.php +++ b/src/Ast/Visitor/NamespaceSubstituteVisitor.php @@ -34,7 +34,7 @@ public function leaveNode(Node $node) private function renameNode($namespacedStatement): void { if ($namespacedStatement->name !== null) { - $newName = str_replace($this->original, $this->substitute, $namespacedStatement->name->toString()); + $newName = str_replace($this->original, $this->substitute, $namespacedStatement->name->toString()); $namespacedStatement->name = new Name($newName); } } diff --git a/src/Command/GenerateCommand.php b/src/Command/GenerateCommand.php index b132c53..cc1da43 100644 --- a/src/Command/GenerateCommand.php +++ b/src/Command/GenerateCommand.php @@ -57,7 +57,7 @@ public function configure(): void $this->setName('generate'); $this->setDescription('Generate an api client based on a given OpenApi specification'); $this->addUsage( - 'OPENAPI={path}/swagger.yaml NAMESPACE=Group\SomeApiClient PACKAGE=dh-group/some-api-client OUTPUT_DIR={path}/generated CODE_STYLE={path}/.php-cs-fixer.php ./bin/api-client-generator generate' + 'OPENAPI={path}/swagger.yaml NAMESPACE=Group\SomeApiClient PACKAGE=dh-group/some-api-client OUTPUT_DIR={path}/generated CODE_STYLE={path}/.php-cs-fixer.php.dist ./bin/api-client-generator generate' ); } diff --git a/src/Entity/FieldType.php b/src/Entity/FieldType.php index a6f130f..9588ba3 100644 --- a/src/Entity/FieldType.php +++ b/src/Entity/FieldType.php @@ -10,18 +10,31 @@ class FieldType { public const SPEC_TYPE_STRING = 'string'; + public const SPEC_TYPE_FLOAT = 'number'; + public const SPEC_TYPE_INTEGER = 'integer'; + public const SPEC_TYPE_ARRAY = 'array'; + public const SPEC_TYPE_BOOLEAN = 'boolean'; + public const SPEC_TYPE_OBJECT = 'object'; + public const PHP_TYPE_STRING = 'string'; + public const PHP_TYPE_FLOAT = 'float'; + public const PHP_TYPE_INTEGER = 'int'; + public const PHP_TYPE_ARRAY = 'array'; + public const PHP_TYPE_BOOLEAN = 'bool'; + public const PHP_TYPE_OBJECT = 'object'; + public const PHP_TYPE_MIXED = 'mixed'; + private const SPEC_TYPES = [ self::SPEC_TYPE_STRING, self::SPEC_TYPE_FLOAT, @@ -30,6 +43,7 @@ class FieldType self::SPEC_TYPE_BOOLEAN, self::SPEC_TYPE_OBJECT, ]; + private const SPEC_TO_PHP_TYPE_MAP = [ self::SPEC_TYPE_STRING => self::PHP_TYPE_STRING, self::SPEC_TYPE_FLOAT => self::PHP_TYPE_FLOAT, diff --git a/src/Entity/OperationCollection.php b/src/Entity/OperationCollection.php index 90fa5fc..d2cff20 100644 --- a/src/Entity/OperationCollection.php +++ b/src/Entity/OperationCollection.php @@ -11,6 +11,7 @@ class OperationCollection implements IteratorAggregate { protected array $items = []; + protected array $operationNames = []; public function add(Operation $item): self @@ -19,7 +20,7 @@ public function add(Operation $item): self throw new InvalidSpecificationException('Duplicated operationId found: ' . $item->name); } - $this->items[] = $item; + $this->items[] = $item; $this->operationNames[$item->name] = true; return $this; diff --git a/src/Entity/Request.php b/src/Entity/Request.php index bb45274..cc4afcb 100644 --- a/src/Entity/Request.php +++ b/src/Entity/Request.php @@ -13,12 +13,19 @@ class Request { public const GET = 'GET'; + public const POST = 'POST'; + public const PUT = 'PUT'; + public const PATCH = 'PATCH'; + public const OPTIONS = 'OPTIONS'; + public const DELETE = 'DELETE'; + public const HEAD = 'HEAD'; + public const ALLOWED_METHODS = [ self::GET, self::POST, @@ -28,6 +35,7 @@ class Request self::DELETE, self::HEAD, ]; + private const ALLOWED_CONTENT_TYPES = [ JsonContentTypeSerializer::MIME_TYPE, FormUrlencodedContentTypeSerializer::MIME_TYPE, diff --git a/src/Entity/RequestFieldRegistry.php b/src/Entity/RequestFieldRegistry.php index a09cf14..e51720b 100644 --- a/src/Entity/RequestFieldRegistry.php +++ b/src/Entity/RequestFieldRegistry.php @@ -12,10 +12,15 @@ class RequestFieldRegistry implements IteratorAggregate { public const ORIGIN_QUERY = 'query'; + public const ORIGIN_PATH = 'path'; + public const ORIGIN_HEADER = 'header'; + public const ORIGIN_COOKIE = 'cookie'; + public const ORIGIN_BODY = 'body'; + private const ALLOWED_ORIGINS = [ self::ORIGIN_QUERY, self::ORIGIN_PATH, diff --git a/src/Generator/ClientGenerator.php b/src/Generator/ClientGenerator.php index 519c149..8f28981 100644 --- a/src/Generator/ClientGenerator.php +++ b/src/Generator/ClientGenerator.php @@ -137,7 +137,7 @@ protected function generateConstructor(): ClassMethod ->addImport(CopiedNamespace::getImport($this->baseNamespace, RequestInterface::class)); /** @var ParameterBuilder[] $parameters */ - $parameters = []; + $parameters = []; $parameters[] = $this->builder->param('client')->setType('ClientInterface'); $parameters[] = $this->builder->param('container')->setType('ContainerInterface'); @@ -180,7 +180,7 @@ private function generateHandleResponse(): ClassMethod ->param('response') ->setType('ResponseInterface') ->getNode(); - $response = $this->builder->var('response'); + $response = $this->builder->var('response'); $handleResponseStatement = $this->builder->return( $this->builder->methodCall( @@ -271,7 +271,7 @@ private function singleBodyAction( $handleResponseStmt = $this->builder->localMethodCall('handleResponse', $this->builder->args([$sendRequestStmt])); $stmts = [ $this->builder->assign($responseVar, $handleResponseStmt), - $this->builder->return($this->processResponse($responseVar, $responseBody)) + $this->builder->return($this->processResponse($responseVar, $responseBody)), ]; return $this @@ -316,7 +316,7 @@ private function multiBodyAction( } } else { $returnTypeHints[$responseBody->getPhpTypeHint()] = true; - $isNullable = $isNullable || $responseBody->isNullable(); + $isNullable = $isNullable || $responseBody->isNullable(); $phpClassName = $responseBody->getPhpClassName(); @@ -332,7 +332,7 @@ private function multiBodyAction( } } - $cases = []; + $cases = []; $matchArms = []; foreach ($nullableCases as $statusCode => $nullableCase) { if ($this->phpVersion->isMatchSupported()) { diff --git a/src/Generator/FreeFormSchemaGenerator.php b/src/Generator/FreeFormSchemaGenerator.php index 602fc61..efc05af 100644 --- a/src/Generator/FreeFormSchemaGenerator.php +++ b/src/Generator/FreeFormSchemaGenerator.php @@ -85,7 +85,7 @@ private function generateFreeFormField(): Field private function generateToArray(): ClassMethod { - $return = $this->builder->return( + $return = $this->builder->return( $this->builder->castToArray( $this->builder->localPropertyFetch(self::FREE_FORM_SCHEMA_VARIABLE) ) diff --git a/src/Generator/Implementation/ContainerImplementationStrategy.php b/src/Generator/Implementation/ContainerImplementationStrategy.php index 525f2d1..469a598 100644 --- a/src/Generator/Implementation/ContainerImplementationStrategy.php +++ b/src/Generator/Implementation/ContainerImplementationStrategy.php @@ -14,10 +14,12 @@ class ContainerImplementationStrategy implements ContainerImplementationInterface { - public const CONTAINER_PIMPLE = 'pimple'; + public const CONTAINER_PIMPLE = 'pimple'; + public const CONTAINER_IMPLEMENTATIONS = [ self::CONTAINER_PIMPLE => PimpleContainer::class, ]; + private ContainerImplementationInterface $containerImplementation; public function __construct(string $container, string $baseNamespace, CodeBuilder $builder) diff --git a/src/Generator/Implementation/HttpMessage/HttpMessageAbstract.php b/src/Generator/Implementation/HttpMessage/HttpMessageAbstract.php index 3e0a306..53f071e 100644 --- a/src/Generator/Implementation/HttpMessage/HttpMessageAbstract.php +++ b/src/Generator/Implementation/HttpMessage/HttpMessageAbstract.php @@ -25,7 +25,7 @@ public function generateRequestMapMethod(): MethodBuilder $bodyVariable = $this->builder->var('body'); - $bodyEncodeMethodCall = $this->builder->methodCall( + $bodyEncodeMethodCall = $this->builder->methodCall( $this->builder->localPropertyFetch('bodySerializer'), 'serializeRequest', [ @@ -66,7 +66,7 @@ public function generateRequestMapMethod(): MethodBuilder $this->builder->methodCall($psr7RequestVariable, 'getUri'), 'withQuery', [$query] - ) + ), ] ) ); diff --git a/src/Generator/Implementation/HttpMessageImplementationStrategy.php b/src/Generator/Implementation/HttpMessageImplementationStrategy.php index c2bb348..22b84a9 100644 --- a/src/Generator/Implementation/HttpMessageImplementationStrategy.php +++ b/src/Generator/Implementation/HttpMessageImplementationStrategy.php @@ -12,12 +12,15 @@ class HttpMessageImplementationStrategy implements HttpMessageImplementationInterface { - public const HTTP_MESSAGE_GUZZLE = 'guzzle'; - public const HTTP_MESSAGE_NYHOLM = 'nyholm'; + public const HTTP_MESSAGE_GUZZLE = 'guzzle'; + + public const HTTP_MESSAGE_NYHOLM = 'nyholm'; + public const HTTP_MESSAGE_IMPLEMENTATIONS = [ self::HTTP_MESSAGE_GUZZLE => GuzzleHttpMessage::class, self::HTTP_MESSAGE_NYHOLM => NyholmHttpMessage::class, ]; + private HttpMessageImplementationInterface $httpMessageImplementation; public function __construct(string $httpMessage, CodeBuilder $builder) diff --git a/src/Generator/RequestGenerator.php b/src/Generator/RequestGenerator.php index e96be07..eb2e689 100644 --- a/src/Generator/RequestGenerator.php +++ b/src/Generator/RequestGenerator.php @@ -24,6 +24,7 @@ class RequestGenerator extends MutatorAccessorClassGeneratorAbstract { public const NAMESPACE_SUBPATH = '\\Request'; + public const SUBDIRECTORY = 'Request/'; /** @var SecurityStrategyAbstract[] */ diff --git a/src/Generator/RequestMapperGenerator.php b/src/Generator/RequestMapperGenerator.php index c99b6c2..3fb3551 100644 --- a/src/Generator/RequestMapperGenerator.php +++ b/src/Generator/RequestMapperGenerator.php @@ -22,6 +22,7 @@ class RequestMapperGenerator extends MutatorAccessorClassGeneratorAbstract { public const NAMESPACE_SUBPATH = '\\Request\\Mapper'; + public const SUBDIRECTORY = 'Request/Mapper/'; public function __construct( @@ -60,7 +61,7 @@ public function generate(Specification $specification, PhpFileCollection $fileRe ); /** @var ParameterBuilder[] $parameters */ - $parameters = []; + $parameters = []; $parameters[] = $this->builder->param($bodySerializerPropertyName)->setType('BodySerializer'); $parameters[] = $this->builder->param($querySerializerPropertyName)->setType('QuerySerializer'); diff --git a/src/Generator/SchemaCollectionGenerator.php b/src/Generator/SchemaCollectionGenerator.php index b5c17c6..ceee4e5 100644 --- a/src/Generator/SchemaCollectionGenerator.php +++ b/src/Generator/SchemaCollectionGenerator.php @@ -17,8 +17,10 @@ class SchemaCollectionGenerator extends GeneratorAbstract { - public const SUBDIRECTORY = 'Schema/'; - public const NAMESPACE_SUBPATH = '\\Schema'; + public const SUBDIRECTORY = 'Schema/'; + + public const NAMESPACE_SUBPATH = '\\Schema'; + private const INTERNAL_ARRAY_NAME = 'items'; public function generate(Specification $specification, PhpFileCollection $fileRegistry): void diff --git a/src/Generator/SchemaGenerator.php b/src/Generator/SchemaGenerator.php index df65774..67a37cb 100644 --- a/src/Generator/SchemaGenerator.php +++ b/src/Generator/SchemaGenerator.php @@ -19,7 +19,9 @@ class SchemaGenerator extends MutatorAccessorClassGeneratorAbstract { public const SUBDIRECTORY = 'Schema/'; + public const NAMESPACE_SUBPATH = '\\Schema'; + private const OPTIONAL_CHANGED_FIELDS_PROPERTY_NAME = 'optionalPropertyChanged'; public function generate(Specification $specification, PhpFileCollection $fileRegistry): void diff --git a/src/Generator/SchemaMapperGenerator.php b/src/Generator/SchemaMapperGenerator.php index 773f4ee..75dc6a5 100644 --- a/src/Generator/SchemaMapperGenerator.php +++ b/src/Generator/SchemaMapperGenerator.php @@ -19,6 +19,7 @@ class SchemaMapperGenerator extends MutatorAccessorClassGeneratorAbstract { public const NAMESPACE_SUBPATH = '\\Schema\\Mapper'; + public const SUBDIRECTORY = 'Schema/Mapper/'; private array $mapMethodThrownExceptions; @@ -99,7 +100,7 @@ protected function generateConstructor(Field $root): ?ClassMethod ->param($propertyName) ->setType($childClassName); - $paramInits[] = $this->builder->assign( + $paramInits[] = $this->builder->assign( $this->builder->localPropertyFetch($propertyName), $this->builder->var($propertyName) ); @@ -267,7 +268,7 @@ protected function generateMapStatementsForObject(Field $root, Variable $payload 'array_diff', [$this->builder->array($requiredItemsNames), $missingFieldsArrayKeys] ); - $missingFieldsImplode = $this->builder->funcCall( + $missingFieldsImplode = $this->builder->funcCall( 'implode', [$this->builder->val(', '), $missingFieldsArrayDiff] ); diff --git a/src/Generator/Security/BasicAuthenticationSecurityStrategy.php b/src/Generator/Security/BasicAuthenticationSecurityStrategy.php index eae2071..4166101 100644 --- a/src/Generator/Security/BasicAuthenticationSecurityStrategy.php +++ b/src/Generator/Security/BasicAuthenticationSecurityStrategy.php @@ -16,6 +16,7 @@ class BasicAuthenticationSecurityStrategy extends SecurityStrategyAbstract public const SCHEME = 'basic'; private const PROPERTY_CREDENTIALS = 'credentials'; + private const TYPE = 'http'; public function getImports(string $baseNamespace): ImportCollection diff --git a/src/Generator/Security/BearerAuthenticationSecurityStrategy.php b/src/Generator/Security/BearerAuthenticationSecurityStrategy.php index e25e0cc..a8e1f10 100644 --- a/src/Generator/Security/BearerAuthenticationSecurityStrategy.php +++ b/src/Generator/Security/BearerAuthenticationSecurityStrategy.php @@ -11,7 +11,9 @@ class BearerAuthenticationSecurityStrategy extends SecurityStrategyAbstract { private const PROPERTY_NAME = 'bearerToken'; + private const SCHEME = 'bearer'; + private const TYPE = 'http'; public function getProperties(Operation $operation, Specification $specification): array diff --git a/src/Generator/ServiceProviderGenerator.php b/src/Generator/ServiceProviderGenerator.php index fe9c305..5b2d44a 100644 --- a/src/Generator/ServiceProviderGenerator.php +++ b/src/Generator/ServiceProviderGenerator.php @@ -179,7 +179,7 @@ private function generateQuerySerializerClosure(): Closure { return $this->builder->closure( [ - $this->builder->return($this->builder->new('QuerySerializer')) + $this->builder->return($this->builder->new('QuerySerializer')), ], [], [], @@ -274,7 +274,7 @@ private function buildMapperDependencies(Field $field, Variable $containerVariab $alreadyInjected = []; foreach ($field->getObjectProperties() as $subfield) { if ($subfield->isComposite() && !isset($alreadyInjected[$subfield->getPhpClassName()])) { - $getMethodArg = $this->builder->classConstFetch( + $getMethodArg = $this->builder->classConstFetch( SchemaMapperNaming::getClassName($subfield), 'class' ); @@ -284,7 +284,7 @@ private function buildMapperDependencies(Field $field, Variable $containerVariab } } } elseif ($field->isArrayOfObjects()) { - $getMethodArg = $this->builder->classConstFetch( + $getMethodArg = $this->builder->classConstFetch( SchemaMapperNaming::getClassName($field->getArrayItem()), 'class' ); diff --git a/src/Input/Configuration.php b/src/Input/Configuration.php index 50e3c40..6a89eff 100644 --- a/src/Input/Configuration.php +++ b/src/Input/Configuration.php @@ -11,14 +11,21 @@ class Configuration { - public const DEFAULT_CODE_STYLE_CONFIG = __DIR__ . '/../../.php-cs-fixer.php'; - public const DEFAULT_TEMPLATE_DIRECTORY = __DIR__ . '/../../template'; - public const DEFAULT_PHP_VERSION = PhpVersion::VERSION_PHP74; - public const DEFAULT_SOURCE_DIRECTORY = 'src'; - public const DEFAULT_HTTP_MESSAGE = HttpMessageImplementationStrategy::HTTP_MESSAGE_GUZZLE; - public const DEFAULT_CONTAINER = ContainerImplementationStrategy::CONTAINER_PIMPLE; + public const DEFAULT_CODE_STYLE_CONFIG = __DIR__ . '/../../.php-cs-fixer.php.dist'; + + public const DEFAULT_TEMPLATE_DIRECTORY = __DIR__ . '/../../template'; + + public const DEFAULT_PHP_VERSION = PhpVersion::VERSION_PHP74; + + public const DEFAULT_SOURCE_DIRECTORY = 'src'; + + public const DEFAULT_HTTP_MESSAGE = HttpMessageImplementationStrategy::HTTP_MESSAGE_GUZZLE; + + public const DEFAULT_CONTAINER = ContainerImplementationStrategy::CONTAINER_PIMPLE; + public const STATIC_PHP_FILE_BASE_NAMESPACE = 'DoclerLabs\\ApiClientGenerator\\Output\\Copy'; - public const STATIC_PHP_FILE_DIRECTORY = __DIR__ . '/../Output/Copy'; + + public const STATIC_PHP_FILE_DIRECTORY = __DIR__ . '/../Output/Copy'; public function __construct( public readonly string $specificationFilePath, diff --git a/src/Input/Factory/FieldFactory.php b/src/Input/Factory/FieldFactory.php index 29385ac..4d158be 100644 --- a/src/Input/Factory/FieldFactory.php +++ b/src/Input/Factory/FieldFactory.php @@ -64,7 +64,7 @@ public function create( } $objectProperties = $this->mergeAllOfProperties($operationName, $schema); - $schema = $this->mergeAllOfAttributes($schema); + $schema = $this->mergeAllOfAttributes($schema); } elseif (FieldType::isSpecificationTypeArray($type)) { $itemReferenceName = ''; if ($schema->items === null) { diff --git a/src/Input/Factory/OperationFactory.php b/src/Input/Factory/OperationFactory.php index 7e178ab..a999f39 100644 --- a/src/Input/Factory/OperationFactory.php +++ b/src/Input/Factory/OperationFactory.php @@ -39,7 +39,7 @@ public function create( trigger_error($warningMessage, E_USER_WARNING); } - $parameters = array_merge($commonParameters, $operation->parameters ?? []); + $parameters = array_merge($commonParameters, $operation->parameters ?? []); $requestBody = $operation->requestBody; if ($requestBody instanceof Reference) { $requestBody = $requestBody->resolve(); diff --git a/src/Input/Factory/ResponseFactory.php b/src/Input/Factory/ResponseFactory.php index 1a15dc9..a3efa7f 100644 --- a/src/Input/Factory/ResponseFactory.php +++ b/src/Input/Factory/ResponseFactory.php @@ -28,12 +28,14 @@ public function createSuccessfulResponses(string $operationName, array $openApiR if ($code === 204) { $responses[] = new Response(204, null); + continue; } if (200 <= $code && $code < 300) { if (empty($response->content) || current($response->content) === false) { $responses[] = new Response((int)$code, null); + continue; } diff --git a/src/Input/FileReader.php b/src/Input/FileReader.php index 6fbd2cd..807d300 100644 --- a/src/Input/FileReader.php +++ b/src/Input/FileReader.php @@ -20,10 +20,10 @@ public function read(string $fileName): array throw new InvalidSpecificationException('Specification file is empty.'); } - return match($ext) { + return match ($ext) { 'yaml', 'yml' => Yaml::parse($contents), - 'json' => json_decode($contents, true, 512, JSON_THROW_ON_ERROR), - default => throw new InvalidSpecificationException(sprintf('Unknown specification file extension: %s. Supported: yaml, yml, json', $ext)), + 'json' => json_decode($contents, true, 512, JSON_THROW_ON_ERROR), + default => throw new InvalidSpecificationException(sprintf('Unknown specification file extension: %s. Supported: yaml, yml, json', $ext)), }; } } diff --git a/src/Meta/Template/TwigExtension.php b/src/Meta/Template/TwigExtension.php index 232646a..fca9c2e 100644 --- a/src/Meta/Template/TwigExtension.php +++ b/src/Meta/Template/TwigExtension.php @@ -18,13 +18,6 @@ public function getFunctions(): array ]; } - /** - * @param string $class - * @param string $method - * @param mixed ...$arguments - * - * @return mixed - */ public function staticCall(string $class, string $method, ...$arguments) { if (!class_exists($class)) { diff --git a/src/Naming/ClientNaming.php b/src/Naming/ClientNaming.php index 9b1825f..7dd20af 100644 --- a/src/Naming/ClientNaming.php +++ b/src/Naming/ClientNaming.php @@ -8,7 +8,8 @@ class ClientNaming { - private const CLIENT_SUFFIX = 'Client'; + private const CLIENT_SUFFIX = 'Client'; + private const FACTORY_SUFFIX = 'ClientFactory'; public static function getClassName(Specification $specification): string diff --git a/src/Output/Copy/Serializer/ContentType/AbstractJsonContentTypeSerializer.php b/src/Output/Copy/Serializer/ContentType/AbstractJsonContentTypeSerializer.php index 3d4d7c3..e2a8112 100644 --- a/src/Output/Copy/Serializer/ContentType/AbstractJsonContentTypeSerializer.php +++ b/src/Output/Copy/Serializer/ContentType/AbstractJsonContentTypeSerializer.php @@ -10,6 +10,7 @@ abstract class AbstractJsonContentTypeSerializer implements ContentTypeSerializerInterface { private const JSON_DEPTH = 512; + private const JSON_OPTIONS = JSON_BIGINT_AS_STRING | JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_UNICODE; /** diff --git a/src/Output/Copy/Serializer/ContentType/XmlContentTypeSerializer.php b/src/Output/Copy/Serializer/ContentType/XmlContentTypeSerializer.php index 39d400b..510d47f 100644 --- a/src/Output/Copy/Serializer/ContentType/XmlContentTypeSerializer.php +++ b/src/Output/Copy/Serializer/ContentType/XmlContentTypeSerializer.php @@ -13,7 +13,9 @@ class XmlContentTypeSerializer implements ContentTypeSerializerInterface { const MIME_TYPE = 'application/xml'; + const ATTRIBUTE_NAMESPACE = 'xmlns'; + const ATTRIBUTE_NAMESPACE_SEPARATOR = ':'; /** @var array */ @@ -23,10 +25,9 @@ class XmlContentTypeSerializer implements ContentTypeSerializerInterface 'attributesKey' => '@attributes', 'cdataKey' => '@cdata', 'valueKey' => '@value', - 'namespacesOnRoot' => true + 'namespacesOnRoot' => true, ]; - /** @var mixed */ private $xml; /** @var array */ @@ -102,9 +103,9 @@ public function getMimeType(): string } /** - * @param string $inputXml - * @return void * @throws SerializeException + * + * @return void */ private function loadXml(string $inputXml) { @@ -118,8 +119,6 @@ private function loadXml(string $inputXml) } /** - * @param DOMNode $node - * @return mixed * @throws SerializeException */ private function parseNode(DOMNode $node) @@ -129,16 +128,19 @@ private function parseNode(DOMNode $node) switch ($node->nodeType) { case XML_CDATA_SECTION_NODE: $output[$this->config['cdataKey']] = $this->normalizeTextContent($node->textContent); + break; case XML_TEXT_NODE: $output = $this->normalizeTextContent($node->textContent); + break; case XML_ELEMENT_NODE: $output = $this->parseChildNodes($node, $output); $output = $this->normalizeNodeValues($output); $output = $this->collectAttributes($node, $output); + break; } @@ -146,9 +148,6 @@ private function parseNode(DOMNode $node) } /** - * @param DOMNode $node - * @param mixed $output - * @return mixed * @throws SerializeException */ private function parseChildNodes(DOMNode $node, $output) @@ -192,7 +191,7 @@ private function parseChildNodes(DOMNode $node, $output) /** * @param string|string[] $textContent - * @return string + * * @throws SerializeException */ private function normalizeTextContent($textContent): string @@ -202,7 +201,7 @@ private function normalizeTextContent($textContent): string '/\n+\s+/', '/\r+\s+/', '/\n+\t+/', - '/\r+\t+/' + '/\r+\t+/', ], ' ', $textContent @@ -214,10 +213,6 @@ private function normalizeTextContent($textContent): string return trim($normalized); } - /** - * @param mixed $values - * @return mixed - */ private function normalizeNodeValues($values) { if (!is_array($values)) { @@ -241,11 +236,6 @@ private function normalizeNodeValues($values) return $values; } - /** - * @param DOMNode $node - * @param mixed $output - * @return mixed - */ private function collectAttributes(DOMNode $node, $output) { if ($node->attributes === null || !$node->attributes->length) { @@ -280,11 +270,6 @@ private function collectAttributes(DOMNode $node, $output) return $output; } - /** - * @param DOMNode $node - * @param array $output - * @return array - */ private function collectNodeNamespaces(DOMNode $node, array $output): array { $namespaces = $this->collectNamespaces($node); @@ -296,10 +281,6 @@ private function collectNodeNamespaces(DOMNode $node, array $output): array return $output; } - /** - * @param DOMNode $node - * @return array - */ private function collectNamespaces(DOMNode $node): array { $namespaces = []; @@ -325,9 +306,6 @@ private function collectNamespaces(DOMNode $node): array } /** - * @param string $nodeName - * @param mixed $data - * @return DOMElement * @throws SerializeException */ private function buildNode(string $nodeName, $data): DOMElement @@ -352,10 +330,9 @@ private function buildNode(string $nodeName, $data): DOMElement } /** - * @param DOMElement $node - * @param array $array - * @return void * @throws SerializeException + * + * @return void */ private function parseArray(DOMElement $node, array $array) { @@ -391,9 +368,6 @@ private function parseArray(DOMElement $node, array $array) } /** - * @param DOMElement $node - * @param array $array - * @return array * @throws SerializeException */ private function parseAttributes(DOMElement $node, array $array): array @@ -415,11 +389,6 @@ private function parseAttributes(DOMElement $node, array $array): array return $array; } - /** - * @param DOMElement $node - * @param array $array - * @return array - */ private function parseValue(DOMElement $node, array $array): array { $valueKey = $this->config['valueKey']; @@ -433,11 +402,6 @@ private function parseValue(DOMElement $node, array $array): array return $array; } - /** - * @param DOMElement $node - * @param array $array - * @return array - */ private function parseCdata(DOMElement $node, array $array): array { $cdataKey = $this->config['cdataKey']; @@ -451,10 +415,6 @@ private function parseCdata(DOMElement $node, array $array): array return $array; } - /** - * @param mixed $value - * @return string - */ private function normalizeValues($value): string { $value = $value === true ? 'true' : $value; diff --git a/src/Output/Copy/Serializer/QuerySerializer.php b/src/Output/Copy/Serializer/QuerySerializer.php index 99f6c80..3af611a 100644 --- a/src/Output/Copy/Serializer/QuerySerializer.php +++ b/src/Output/Copy/Serializer/QuerySerializer.php @@ -1,4 +1,5 @@ new HttpMessageImplementationStrategy( - $container[Configuration::class]->httpMessage, - $container[CodeBuilder::class] - ); + $pimple[HttpMessageImplementationStrategy::class] = static fn (Container $container) => new HttpMessageImplementationStrategy( + $container[Configuration::class]->httpMessage, + $container[CodeBuilder::class] + ); - $pimple[ContainerImplementationStrategy::class] = - static fn (Container $container) => new ContainerImplementationStrategy( - $container[Configuration::class]->container, - $container[Configuration::class]->baseNamespace, - $container[CodeBuilder::class] - ); + $pimple[ContainerImplementationStrategy::class] = static fn (Container $container) => new ContainerImplementationStrategy( + $container[Configuration::class]->container, + $container[Configuration::class]->baseNamespace, + $container[CodeBuilder::class] + ); $pimple[PhpFilePrinter::class] = static fn (Container $container) => new PhpFilePrinter( new Standard(), diff --git a/test/suite/acceptance/PetStore3Test.php b/test/suite/acceptance/PetStore3Test.php index 70b51e5..38890b9 100644 --- a/test/suite/acceptance/PetStore3Test.php +++ b/test/suite/acceptance/PetStore3Test.php @@ -1,5 +1,7 @@ 'install', '--working-dir' => self::EXAMPLE_DIR, - '--no-cache' => true + '--no-cache' => true, ] ), new BufferedOutput() diff --git a/test/suite/functional/ConfigurationBuilder.php b/test/suite/functional/ConfigurationBuilder.php index aa71111..69c7be3 100644 --- a/test/suite/functional/ConfigurationBuilder.php +++ b/test/suite/functional/ConfigurationBuilder.php @@ -9,16 +9,27 @@ class ConfigurationBuilder { private string $specificationFilePath; + private string $baseNamespace; + private string $outputDirectory; + private string $sourceDirectory; + private string $codeStyleConfig; + private string $packageName; + private float $phpVersion; + private string $generatorVersion; + private string $composerJsonTemplateDir; + private string $readmeMdTemplateDir; + private string $httpMessage; + private string $container; private function __construct() @@ -27,7 +38,7 @@ private function __construct() $this->baseNamespace = 'Test'; $this->outputDirectory = '/dir/output'; $this->sourceDirectory = Configuration::DEFAULT_SOURCE_DIRECTORY; - $this->codeStyleConfig = __DIR__ . '/../../../.php-cs-fixer.php'; + $this->codeStyleConfig = __DIR__ . '/../../../.php-cs-fixer.php.dist'; $this->packageName = 'test/test-api-client'; $this->phpVersion = Configuration::DEFAULT_PHP_VERSION; $this->generatorVersion = '5.6.0'; diff --git a/test/suite/functional/Generator/AbstractGeneratorTest.php b/test/suite/functional/Generator/AbstractGeneratorTest.php index 1998338..b5cfbb1 100644 --- a/test/suite/functional/Generator/AbstractGeneratorTest.php +++ b/test/suite/functional/Generator/AbstractGeneratorTest.php @@ -1,4 +1,5 @@ toArray() : $value; - }, \array_filter(['filterById' => $this->filterById, 'filterByName' => $this->filterByName, 'filterByIds' => $this->filterByIds, 'filter' => $this->filter], static function ($value) { + }, array_filter(['filterById' => $this->filterById, 'filterByName' => $this->filterByName, 'filterByIds' => $this->filterByIds, 'filter' => $this->filter], static function ($value) { return null !== $value; })); } @@ -99,7 +99,7 @@ public function getCookies(): array public function getHeaders(): array { - return ['Authorization' => \sprintf('Basic %s', \base64_encode(\sprintf('%s:%s', $this->credentials->getUsername(), $this->credentials->getPassword())))]; + return ['Authorization' => sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->credentials->getUsername(), $this->credentials->getPassword())))]; } public function getBody() diff --git a/test/suite/functional/Generator/Request/GetResourcesRequest80.php b/test/suite/functional/Generator/Request/GetResourcesRequest80.php index 81773c7..5c3c805 100644 --- a/test/suite/functional/Generator/Request/GetResourcesRequest80.php +++ b/test/suite/functional/Generator/Request/GetResourcesRequest80.php @@ -77,9 +77,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['filterById' => $this->filterById, 'filterByName' => $this->filterByName, 'filterByIds' => $this->filterByIds, 'filter' => $this->filter], static function ($value) { + }, array_filter(['filterById' => $this->filterById, 'filterByName' => $this->filterByName, 'filterByIds' => $this->filterByIds, 'filter' => $this->filter], static function ($value) { return null !== $value; })); } @@ -96,7 +96,7 @@ public function getCookies(): array public function getHeaders(): array { - return ['Authorization' => \sprintf('Basic %s', \base64_encode(\sprintf('%s:%s', $this->credentials->getUsername(), $this->credentials->getPassword())))]; + return ['Authorization' => sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->credentials->getUsername(), $this->credentials->getPassword())))]; } public function getBody() diff --git a/test/suite/functional/Generator/Request/GetSubResourcesRequest74.php b/test/suite/functional/Generator/Request/GetSubResourcesRequest74.php index fa7a472..c5957aa 100644 --- a/test/suite/functional/Generator/Request/GetSubResourcesRequest74.php +++ b/test/suite/functional/Generator/Request/GetSubResourcesRequest74.php @@ -50,9 +50,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['filter' => $this->filter], static function ($value) { + }, array_filter(['filter' => $this->filter], static function ($value) { return null !== $value; })); } @@ -69,7 +69,7 @@ public function getCookies(): array public function getHeaders(): array { - return ['Authorization' => \sprintf('Bearer %s', $this->bearerToken)]; + return ['Authorization' => sprintf('Bearer %s', $this->bearerToken)]; } public function getBody() diff --git a/test/suite/functional/Generator/Request/GetSubResourcesRequest80.php b/test/suite/functional/Generator/Request/GetSubResourcesRequest80.php index 4df715c..b29df76 100644 --- a/test/suite/functional/Generator/Request/GetSubResourcesRequest80.php +++ b/test/suite/functional/Generator/Request/GetSubResourcesRequest80.php @@ -47,9 +47,9 @@ public function getRoute(): string public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['filter' => $this->filter], static function ($value) { + }, array_filter(['filter' => $this->filter], static function ($value) { return null !== $value; })); } @@ -66,7 +66,7 @@ public function getCookies(): array public function getHeaders(): array { - return ['Authorization' => \sprintf('Bearer %s', $this->bearerToken)]; + return ['Authorization' => sprintf('Bearer %s', $this->bearerToken)]; } public function getBody() diff --git a/test/suite/functional/Generator/Request/PatchResourceRequest74.php b/test/suite/functional/Generator/Request/PatchResourceRequest74.php index f8a454b..8251652 100644 --- a/test/suite/functional/Generator/Request/PatchResourceRequest74.php +++ b/test/suite/functional/Generator/Request/PatchResourceRequest74.php @@ -63,9 +63,9 @@ public function getCookies(): array public function getHeaders(): array { - return \array_merge(['Content-Type' => $this->contentType], \array_map(static function ($value) { + return array_merge(['Content-Type' => $this->contentType], array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['Accept' => $this->accept], static function ($value) { + }, array_filter(['Accept' => $this->accept], static function ($value) { return null !== $value; }))); } diff --git a/test/suite/functional/Generator/Request/PatchResourceRequest80.php b/test/suite/functional/Generator/Request/PatchResourceRequest80.php index 6c694b4..656a684 100644 --- a/test/suite/functional/Generator/Request/PatchResourceRequest80.php +++ b/test/suite/functional/Generator/Request/PatchResourceRequest80.php @@ -57,9 +57,9 @@ public function getCookies(): array public function getHeaders(): array { - return \array_merge(['Content-Type' => $this->contentType], \array_map(static function ($value) { + return array_merge(['Content-Type' => $this->contentType], array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['Accept' => $this->accept], static function ($value) { + }, array_filter(['Accept' => $this->accept], static function ($value) { return null !== $value; }))); } diff --git a/test/suite/functional/Generator/Request/PutResourceByIdRequest74.php b/test/suite/functional/Generator/Request/PutResourceByIdRequest74.php index ed5042f..27b33ab 100644 --- a/test/suite/functional/Generator/Request/PutResourceByIdRequest74.php +++ b/test/suite/functional/Generator/Request/PutResourceByIdRequest74.php @@ -75,7 +75,7 @@ class PutResourceByIdRequest implements RequestInterface public function __construct(int $resourceId, int $mandatoryIntegerParameter, string $mandatoryStringParameter, string $mandatoryEnumParameter, DateTimeInterface $mandatoryDateParameter, float $mandatoryFloatParameter, bool $mandatoryBooleanParameter, array $mandatoryArrayParameter, EmbeddedObject $mandatoryObjectParameter, string $xRequestId, PutResourceByIdRequestBody $putResourceByIdRequestBody) { if ($resourceId < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'resourceId', $resourceId)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'resourceId', $resourceId)); } $this->resourceId = $resourceId; $this->mandatoryIntegerParameter = $mandatoryIntegerParameter; @@ -168,14 +168,14 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('v1/resources/{resourceId}', ['{resourceId}' => $this->resourceId]); + return strtr('v1/resources/{resourceId}', ['{resourceId}' => $this->resourceId]); } public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['integerParameter' => $this->integerParameter, 'stringParameter' => $this->stringParameter, 'enumParameter' => $this->enumParameter, 'dateParameter' => $this->dateParameter, 'floatParameter' => $this->floatParameter, 'booleanParameter' => $this->booleanParameter, 'arrayParameter' => $this->arrayParameter, 'objectParameter' => $this->objectParameter, 'mandatoryIntegerParameter' => $this->mandatoryIntegerParameter, 'mandatoryStringParameter' => $this->mandatoryStringParameter, 'mandatoryEnumParameter' => $this->mandatoryEnumParameter, 'mandatoryDateParameter' => $this->mandatoryDateParameter, 'mandatoryFloatParameter' => $this->mandatoryFloatParameter, 'mandatoryBooleanParameter' => $this->mandatoryBooleanParameter, 'mandatoryArrayParameter' => $this->mandatoryArrayParameter, 'mandatoryObjectParameter' => $this->mandatoryObjectParameter], static function ($value) { + }, array_filter(['integerParameter' => $this->integerParameter, 'stringParameter' => $this->stringParameter, 'enumParameter' => $this->enumParameter, 'dateParameter' => $this->dateParameter, 'floatParameter' => $this->floatParameter, 'booleanParameter' => $this->booleanParameter, 'arrayParameter' => $this->arrayParameter, 'objectParameter' => $this->objectParameter, 'mandatoryIntegerParameter' => $this->mandatoryIntegerParameter, 'mandatoryStringParameter' => $this->mandatoryStringParameter, 'mandatoryEnumParameter' => $this->mandatoryEnumParameter, 'mandatoryDateParameter' => $this->mandatoryDateParameter, 'mandatoryFloatParameter' => $this->mandatoryFloatParameter, 'mandatoryBooleanParameter' => $this->mandatoryBooleanParameter, 'mandatoryArrayParameter' => $this->mandatoryArrayParameter, 'mandatoryObjectParameter' => $this->mandatoryObjectParameter], static function ($value) { return null !== $value; })); } @@ -187,18 +187,18 @@ public function getRawQueryParameters(): array public function getCookies(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['csrf_token' => $this->csrfToken], static function ($value) { + }, array_filter(['csrf_token' => $this->csrfToken], static function ($value) { return null !== $value; })); } public function getHeaders(): array { - return \array_merge(['Content-Type' => $this->contentType], \array_map(static function ($value) { + return array_merge(['Content-Type' => $this->contentType], array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['X-Request-ID' => $this->xRequestId], static function ($value) { + }, array_filter(['X-Request-ID' => $this->xRequestId], static function ($value) { return null !== $value; }))); } diff --git a/test/suite/functional/Generator/Request/PutResourceByIdRequest80.php b/test/suite/functional/Generator/Request/PutResourceByIdRequest80.php index 8ca4374..213b452 100644 --- a/test/suite/functional/Generator/Request/PutResourceByIdRequest80.php +++ b/test/suite/functional/Generator/Request/PutResourceByIdRequest80.php @@ -53,7 +53,7 @@ class PutResourceByIdRequest implements RequestInterface public function __construct(private int $resourceId, private int $mandatoryIntegerParameter, private string $mandatoryStringParameter, private string $mandatoryEnumParameter, private DateTimeInterface $mandatoryDateParameter, private float $mandatoryFloatParameter, private bool $mandatoryBooleanParameter, private array $mandatoryArrayParameter, private EmbeddedObject $mandatoryObjectParameter, private string $xRequestId, private PutResourceByIdRequestBody $putResourceByIdRequestBody) { if ($resourceId < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'resourceId', $resourceId)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'resourceId', $resourceId)); } } @@ -135,14 +135,14 @@ public function getMethod(): string public function getRoute(): string { - return \strtr('v1/resources/{resourceId}', ['{resourceId}' => $this->resourceId]); + return strtr('v1/resources/{resourceId}', ['{resourceId}' => $this->resourceId]); } public function getQueryParameters(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['integerParameter' => $this->integerParameter, 'stringParameter' => $this->stringParameter, 'enumParameter' => $this->enumParameter, 'dateParameter' => $this->dateParameter, 'floatParameter' => $this->floatParameter, 'booleanParameter' => $this->booleanParameter, 'arrayParameter' => $this->arrayParameter, 'objectParameter' => $this->objectParameter, 'mandatoryIntegerParameter' => $this->mandatoryIntegerParameter, 'mandatoryStringParameter' => $this->mandatoryStringParameter, 'mandatoryEnumParameter' => $this->mandatoryEnumParameter, 'mandatoryDateParameter' => $this->mandatoryDateParameter, 'mandatoryFloatParameter' => $this->mandatoryFloatParameter, 'mandatoryBooleanParameter' => $this->mandatoryBooleanParameter, 'mandatoryArrayParameter' => $this->mandatoryArrayParameter, 'mandatoryObjectParameter' => $this->mandatoryObjectParameter], static function ($value) { + }, array_filter(['integerParameter' => $this->integerParameter, 'stringParameter' => $this->stringParameter, 'enumParameter' => $this->enumParameter, 'dateParameter' => $this->dateParameter, 'floatParameter' => $this->floatParameter, 'booleanParameter' => $this->booleanParameter, 'arrayParameter' => $this->arrayParameter, 'objectParameter' => $this->objectParameter, 'mandatoryIntegerParameter' => $this->mandatoryIntegerParameter, 'mandatoryStringParameter' => $this->mandatoryStringParameter, 'mandatoryEnumParameter' => $this->mandatoryEnumParameter, 'mandatoryDateParameter' => $this->mandatoryDateParameter, 'mandatoryFloatParameter' => $this->mandatoryFloatParameter, 'mandatoryBooleanParameter' => $this->mandatoryBooleanParameter, 'mandatoryArrayParameter' => $this->mandatoryArrayParameter, 'mandatoryObjectParameter' => $this->mandatoryObjectParameter], static function ($value) { return null !== $value; })); } @@ -154,18 +154,18 @@ public function getRawQueryParameters(): array public function getCookies(): array { - return \array_map(static function ($value) { + return array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['csrf_token' => $this->csrfToken], static function ($value) { + }, array_filter(['csrf_token' => $this->csrfToken], static function ($value) { return null !== $value; })); } public function getHeaders(): array { - return \array_merge(['Content-Type' => $this->contentType], \array_map(static function ($value) { + return array_merge(['Content-Type' => $this->contentType], array_map(static function ($value) { return $value instanceof SerializableInterface ? $value->toArray() : $value; - }, \array_filter(['X-Request-ID' => $this->xRequestId], static function ($value) { + }, array_filter(['X-Request-ID' => $this->xRequestId], static function ($value) { return null !== $value; }))); } diff --git a/test/suite/functional/Generator/RequestGeneratorTest.php b/test/suite/functional/Generator/RequestGeneratorTest.php index 13cf19c..78656b5 100644 --- a/test/suite/functional/Generator/RequestGeneratorTest.php +++ b/test/suite/functional/Generator/RequestGeneratorTest.php @@ -16,37 +16,37 @@ class RequestGeneratorTest extends AbstractGeneratorTest public function exampleProvider(): array { return [ - 'Request with body with php 7.4' => [ + 'Request with body with php 7.4' => [ '/Request/patchResource.yaml', '/Request/PatchResourceRequest74.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\PatchResourceRequest', ConfigurationBuilder::fake()->build(), ], - 'Request with body with php 8.0' => [ + 'Request with body with php 8.0' => [ '/Request/patchResource.yaml', '/Request/PatchResourceRequest80.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\PatchResourceRequest', ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(), ], - 'Request with mandatory parameters and body with php 7.4' => [ + 'Request with mandatory parameters and body with php 7.4' => [ '/Request/putResourceById.yaml', '/Request/PutResourceByIdRequest74.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\PutResourceByIdRequest', ConfigurationBuilder::fake()->build(), ], - 'Request with mandatory parameters and body with php 8.0' => [ + 'Request with mandatory parameters and body with php 8.0' => [ '/Request/putResourceById.yaml', '/Request/PutResourceByIdRequest80.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\PutResourceByIdRequest', ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(), ], - 'Request without mandatory parameters and body with php 7.4' => [ + 'Request without mandatory parameters and body with php 7.4' => [ '/Request/getResources.yaml', '/Request/GetResourcesRequest74.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\GetResourcesRequest', ConfigurationBuilder::fake()->build(), ], - 'Request without mandatory parameters and body with php 8.0' => [ + 'Request without mandatory parameters and body with php 8.0' => [ '/Request/getResources.yaml', '/Request/GetResourcesRequest80.php', self::BASE_NAMESPACE . RequestGenerator::NAMESPACE_SUBPATH . '\\GetResourcesRequest', diff --git a/test/suite/functional/Generator/Schema/ItemPhp70.php b/test/suite/functional/Generator/Schema/ItemPhp70.php index 615e0f2..14455bc 100644 --- a/test/suite/functional/Generator/Schema/ItemPhp70.php +++ b/test/suite/functional/Generator/Schema/ItemPhp70.php @@ -141,14 +141,14 @@ class Item implements SerializableInterface, JsonSerializable */ public function __construct(int $mandatoryInteger, string $mandatoryString, string $mandatoryEnum, DateTimeInterface $mandatoryDate, $mandatoryNullableDate, float $mandatoryFloat, bool $mandatoryBoolean, array $mandatoryArray, array $mandatoryArrayWithMinItems, ItemMandatoryObject $mandatoryObject, $mandatoryNullableObjectWithAllOf, $mandatoryMixed, $mandatoryAnyOf, $mandatoryNullableStringWithMinMaxLength) { - if (\count($mandatoryArrayWithMinItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); + if (count($mandatoryArrayWithMinItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } $this->mandatoryInteger = $mandatoryInteger; $this->mandatoryString = $mandatoryString; @@ -284,11 +284,11 @@ public function setOptionalMixedArray(array $optionalMixedArray): self */ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxItems): self { - if (\count($optionalArrayWithMinMaxItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } - if (\count($optionalArrayWithMinMaxItems) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } $this->optionalArrayWithMinMaxItems = $optionalArrayWithMinMaxItems; $this->optionalPropertyChanged['optionalArrayWithMinMaxItems'] = true; @@ -301,11 +301,11 @@ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxIt */ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinMaxLength): self { - if (\grapheme_strlen($optionalStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } - if (\grapheme_strlen($optionalStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } $this->optionalStringWithMinMaxLength = $optionalStringWithMinMaxLength; $this->optionalPropertyChanged['optionalStringWithMinMaxLength'] = true; @@ -318,8 +318,8 @@ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinM */ public function setOptionalStringWithPattern(string $optionalStringWithPattern): self { - if (\preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); + if (preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); } $this->optionalStringWithPattern = $optionalStringWithPattern; $this->optionalPropertyChanged['optionalStringWithPattern'] = true; @@ -333,10 +333,10 @@ public function setOptionalStringWithPattern(string $optionalStringWithPattern): public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenIncluded): self { if ($optionalIntegerBetweenIncluded < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } if ($optionalIntegerBetweenIncluded > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } $this->optionalIntegerBetweenIncluded = $optionalIntegerBetweenIncluded; $this->optionalPropertyChanged['optionalIntegerBetweenIncluded'] = true; @@ -350,10 +350,10 @@ public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenInc public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExcluded): self { if ($optionalIntegerBetweenExcluded <= 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } if ($optionalIntegerBetweenExcluded >= 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } $this->optionalIntegerBetweenExcluded = $optionalIntegerBetweenExcluded; $this->optionalPropertyChanged['optionalIntegerBetweenExcluded'] = true; @@ -367,10 +367,10 @@ public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExc public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenIncluded): self { if ($optionalNumberBetweenIncluded < 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } if ($optionalNumberBetweenIncluded > 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } $this->optionalNumberBetweenIncluded = $optionalNumberBetweenIncluded; $this->optionalPropertyChanged['optionalNumberBetweenIncluded'] = true; @@ -384,10 +384,10 @@ public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenInc public function setOptionalNumberBetweenExcluded(float $optionalNumberBetweenExcluded): self { if ($optionalNumberBetweenExcluded <= 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } if ($optionalNumberBetweenExcluded >= 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } $this->optionalNumberBetweenExcluded = $optionalNumberBetweenExcluded; $this->optionalPropertyChanged['optionalNumberBetweenExcluded'] = true; @@ -410,11 +410,11 @@ public function setOptionalObject(EmbeddedObject $optionalObject): self */ public function setOptionalNullableStringWithMinMaxLength($optionalNullableStringWithMinMaxLength): self { - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } $this->optionalNullableStringWithMinMaxLength = $optionalNullableStringWithMinMaxLength; $this->optionalPropertyChanged['optionalNullableStringWithMinMaxLength'] = true; diff --git a/test/suite/functional/Generator/Schema/ItemPhp72.php b/test/suite/functional/Generator/Schema/ItemPhp72.php index 7d5be9a..8d993e0 100644 --- a/test/suite/functional/Generator/Schema/ItemPhp72.php +++ b/test/suite/functional/Generator/Schema/ItemPhp72.php @@ -138,14 +138,14 @@ class Item implements SerializableInterface, JsonSerializable */ public function __construct(int $mandatoryInteger, string $mandatoryString, string $mandatoryEnum, DateTimeInterface $mandatoryDate, ?DateTimeInterface $mandatoryNullableDate, float $mandatoryFloat, bool $mandatoryBoolean, array $mandatoryArray, array $mandatoryArrayWithMinItems, ItemMandatoryObject $mandatoryObject, ?MandatoryNullableObjectWithAllOf $mandatoryNullableObjectWithAllOf, $mandatoryMixed, $mandatoryAnyOf, ?string $mandatoryNullableStringWithMinMaxLength) { - if (\count($mandatoryArrayWithMinItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); + if (count($mandatoryArrayWithMinItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } $this->mandatoryInteger = $mandatoryInteger; $this->mandatoryString = $mandatoryString; @@ -275,11 +275,11 @@ public function setOptionalMixedArray(array $optionalMixedArray): self */ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxItems): self { - if (\count($optionalArrayWithMinMaxItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } - if (\count($optionalArrayWithMinMaxItems) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } $this->optionalArrayWithMinMaxItems = $optionalArrayWithMinMaxItems; $this->optionalPropertyChanged['optionalArrayWithMinMaxItems'] = true; @@ -292,11 +292,11 @@ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxIt */ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinMaxLength): self { - if (\grapheme_strlen($optionalStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } - if (\grapheme_strlen($optionalStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } $this->optionalStringWithMinMaxLength = $optionalStringWithMinMaxLength; $this->optionalPropertyChanged['optionalStringWithMinMaxLength'] = true; @@ -309,8 +309,8 @@ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinM */ public function setOptionalStringWithPattern(string $optionalStringWithPattern): self { - if (\preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); + if (preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); } $this->optionalStringWithPattern = $optionalStringWithPattern; $this->optionalPropertyChanged['optionalStringWithPattern'] = true; @@ -324,10 +324,10 @@ public function setOptionalStringWithPattern(string $optionalStringWithPattern): public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenIncluded): self { if ($optionalIntegerBetweenIncluded < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } if ($optionalIntegerBetweenIncluded > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } $this->optionalIntegerBetweenIncluded = $optionalIntegerBetweenIncluded; $this->optionalPropertyChanged['optionalIntegerBetweenIncluded'] = true; @@ -341,10 +341,10 @@ public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenInc public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExcluded): self { if ($optionalIntegerBetweenExcluded <= 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } if ($optionalIntegerBetweenExcluded >= 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } $this->optionalIntegerBetweenExcluded = $optionalIntegerBetweenExcluded; $this->optionalPropertyChanged['optionalIntegerBetweenExcluded'] = true; @@ -358,10 +358,10 @@ public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExc public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenIncluded): self { if ($optionalNumberBetweenIncluded < 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } if ($optionalNumberBetweenIncluded > 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } $this->optionalNumberBetweenIncluded = $optionalNumberBetweenIncluded; $this->optionalPropertyChanged['optionalNumberBetweenIncluded'] = true; @@ -375,10 +375,10 @@ public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenInc public function setOptionalNumberBetweenExcluded(float $optionalNumberBetweenExcluded): self { if ($optionalNumberBetweenExcluded <= 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } if ($optionalNumberBetweenExcluded >= 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } $this->optionalNumberBetweenExcluded = $optionalNumberBetweenExcluded; $this->optionalPropertyChanged['optionalNumberBetweenExcluded'] = true; @@ -399,11 +399,11 @@ public function setOptionalObject(EmbeddedObject $optionalObject): self */ public function setOptionalNullableStringWithMinMaxLength(?string $optionalNullableStringWithMinMaxLength): self { - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } $this->optionalNullableStringWithMinMaxLength = $optionalNullableStringWithMinMaxLength; $this->optionalPropertyChanged['optionalNullableStringWithMinMaxLength'] = true; diff --git a/test/suite/functional/Generator/Schema/ItemPhp74.php b/test/suite/functional/Generator/Schema/ItemPhp74.php index 65eef9c..b8c8392 100644 --- a/test/suite/functional/Generator/Schema/ItemPhp74.php +++ b/test/suite/functional/Generator/Schema/ItemPhp74.php @@ -104,14 +104,14 @@ class Item implements SerializableInterface, JsonSerializable */ public function __construct(int $mandatoryInteger, string $mandatoryString, string $mandatoryEnum, DateTimeInterface $mandatoryDate, ?DateTimeInterface $mandatoryNullableDate, float $mandatoryFloat, bool $mandatoryBoolean, array $mandatoryArray, array $mandatoryArrayWithMinItems, ItemMandatoryObject $mandatoryObject, ?MandatoryNullableObjectWithAllOf $mandatoryNullableObjectWithAllOf, $mandatoryMixed, $mandatoryAnyOf, ?string $mandatoryNullableStringWithMinMaxLength) { - if (\count($mandatoryArrayWithMinItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); + if (count($mandatoryArrayWithMinItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } $this->mandatoryInteger = $mandatoryInteger; $this->mandatoryString = $mandatoryString; @@ -241,11 +241,11 @@ public function setOptionalMixedArray(array $optionalMixedArray): self */ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxItems): self { - if (\count($optionalArrayWithMinMaxItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } - if (\count($optionalArrayWithMinMaxItems) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } $this->optionalArrayWithMinMaxItems = $optionalArrayWithMinMaxItems; $this->optionalPropertyChanged['optionalArrayWithMinMaxItems'] = true; @@ -258,11 +258,11 @@ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxIt */ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinMaxLength): self { - if (\grapheme_strlen($optionalStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } - if (\grapheme_strlen($optionalStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } $this->optionalStringWithMinMaxLength = $optionalStringWithMinMaxLength; $this->optionalPropertyChanged['optionalStringWithMinMaxLength'] = true; @@ -275,8 +275,8 @@ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinM */ public function setOptionalStringWithPattern(string $optionalStringWithPattern): self { - if (\preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); + if (preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); } $this->optionalStringWithPattern = $optionalStringWithPattern; $this->optionalPropertyChanged['optionalStringWithPattern'] = true; @@ -290,10 +290,10 @@ public function setOptionalStringWithPattern(string $optionalStringWithPattern): public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenIncluded): self { if ($optionalIntegerBetweenIncluded < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } if ($optionalIntegerBetweenIncluded > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } $this->optionalIntegerBetweenIncluded = $optionalIntegerBetweenIncluded; $this->optionalPropertyChanged['optionalIntegerBetweenIncluded'] = true; @@ -307,10 +307,10 @@ public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenInc public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExcluded): self { if ($optionalIntegerBetweenExcluded <= 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } if ($optionalIntegerBetweenExcluded >= 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } $this->optionalIntegerBetweenExcluded = $optionalIntegerBetweenExcluded; $this->optionalPropertyChanged['optionalIntegerBetweenExcluded'] = true; @@ -324,10 +324,10 @@ public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExc public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenIncluded): self { if ($optionalNumberBetweenIncluded < 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } if ($optionalNumberBetweenIncluded > 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } $this->optionalNumberBetweenIncluded = $optionalNumberBetweenIncluded; $this->optionalPropertyChanged['optionalNumberBetweenIncluded'] = true; @@ -341,10 +341,10 @@ public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenInc public function setOptionalNumberBetweenExcluded(float $optionalNumberBetweenExcluded): self { if ($optionalNumberBetweenExcluded <= 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } if ($optionalNumberBetweenExcluded >= 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } $this->optionalNumberBetweenExcluded = $optionalNumberBetweenExcluded; $this->optionalPropertyChanged['optionalNumberBetweenExcluded'] = true; @@ -365,11 +365,11 @@ public function setOptionalObject(EmbeddedObject $optionalObject): self */ public function setOptionalNullableStringWithMinMaxLength(?string $optionalNullableStringWithMinMaxLength): self { - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } $this->optionalNullableStringWithMinMaxLength = $optionalNullableStringWithMinMaxLength; $this->optionalPropertyChanged['optionalNullableStringWithMinMaxLength'] = true; diff --git a/test/suite/functional/Generator/Schema/ItemPhp80.php b/test/suite/functional/Generator/Schema/ItemPhp80.php index cb17728..c07098e 100644 --- a/test/suite/functional/Generator/Schema/ItemPhp80.php +++ b/test/suite/functional/Generator/Schema/ItemPhp80.php @@ -76,14 +76,14 @@ class Item implements SerializableInterface, JsonSerializable */ public function __construct(private int $mandatoryInteger, private string $mandatoryString, private string $mandatoryEnum, private DateTimeInterface $mandatoryDate, private ?DateTimeInterface $mandatoryNullableDate, private float $mandatoryFloat, private bool $mandatoryBoolean, private array $mandatoryArray, private array $mandatoryArrayWithMinItems, private ItemMandatoryObject $mandatoryObject, private ?MandatoryNullableObjectWithAllOf $mandatoryNullableObjectWithAllOf, private mixed $mandatoryMixed, private mixed $mandatoryAnyOf, private ?string $mandatoryNullableStringWithMinMaxLength) { - if (\count($mandatoryArrayWithMinItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); + if (count($mandatoryArrayWithMinItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'mandatoryArrayWithMinItems', $mandatoryArrayWithMinItems)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } - if ($mandatoryNullableStringWithMinMaxLength !== null && \grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); + if ($mandatoryNullableStringWithMinMaxLength !== null && grapheme_strlen($mandatoryNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'mandatoryNullableStringWithMinMaxLength', $mandatoryNullableStringWithMinMaxLength)); } } @@ -199,11 +199,11 @@ public function setOptionalMixedArray(array $optionalMixedArray): self */ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxItems): self { - if (\count($optionalArrayWithMinMaxItems) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected min items: `1`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } - if (\count($optionalArrayWithMinMaxItems) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); + if (count($optionalArrayWithMinMaxItems) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Expected max items: `5`.', 'optionalArrayWithMinMaxItems', $optionalArrayWithMinMaxItems)); } $this->optionalArrayWithMinMaxItems = $optionalArrayWithMinMaxItems; $this->optionalPropertyChanged['optionalArrayWithMinMaxItems'] = true; @@ -216,11 +216,11 @@ public function setOptionalArrayWithMinMaxItems(array $optionalArrayWithMinMaxIt */ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinMaxLength): self { - if (\grapheme_strlen($optionalStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } - if (\grapheme_strlen($optionalStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); + if (grapheme_strlen($optionalStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalStringWithMinMaxLength', $optionalStringWithMinMaxLength)); } $this->optionalStringWithMinMaxLength = $optionalStringWithMinMaxLength; $this->optionalPropertyChanged['optionalStringWithMinMaxLength'] = true; @@ -233,8 +233,8 @@ public function setOptionalStringWithMinMaxLength(string $optionalStringWithMinM */ public function setOptionalStringWithPattern(string $optionalStringWithPattern): self { - if (\preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); + if (preg_match('/^\\d{3}-\\d{2}-\\d{4}$/', $optionalStringWithPattern) !== 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Pattern is ^\\d{3}-\\d{2}-\\d{4}$.', 'optionalStringWithPattern', $optionalStringWithPattern)); } $this->optionalStringWithPattern = $optionalStringWithPattern; $this->optionalPropertyChanged['optionalStringWithPattern'] = true; @@ -248,10 +248,10 @@ public function setOptionalStringWithPattern(string $optionalStringWithPattern): public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenIncluded): self { if ($optionalIntegerBetweenIncluded < 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } if ($optionalIntegerBetweenIncluded > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalIntegerBetweenIncluded', $optionalIntegerBetweenIncluded)); } $this->optionalIntegerBetweenIncluded = $optionalIntegerBetweenIncluded; $this->optionalPropertyChanged['optionalIntegerBetweenIncluded'] = true; @@ -265,10 +265,10 @@ public function setOptionalIntegerBetweenIncluded(int $optionalIntegerBetweenInc public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExcluded): self { if ($optionalIntegerBetweenExcluded <= 0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } if ($optionalIntegerBetweenExcluded >= 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalIntegerBetweenExcluded', $optionalIntegerBetweenExcluded)); } $this->optionalIntegerBetweenExcluded = $optionalIntegerBetweenExcluded; $this->optionalPropertyChanged['optionalIntegerBetweenExcluded'] = true; @@ -282,10 +282,10 @@ public function setOptionalIntegerBetweenExcluded(int $optionalIntegerBetweenExc public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenIncluded): self { if ($optionalNumberBetweenIncluded < 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than 0.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } if ($optionalNumberBetweenIncluded > 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than 5.', 'optionalNumberBetweenIncluded', $optionalNumberBetweenIncluded)); } $this->optionalNumberBetweenIncluded = $optionalNumberBetweenIncluded; $this->optionalPropertyChanged['optionalNumberBetweenIncluded'] = true; @@ -299,10 +299,10 @@ public function setOptionalNumberBetweenIncluded(float $optionalNumberBetweenInc public function setOptionalNumberBetweenExcluded(float $optionalNumberBetweenExcluded): self { if ($optionalNumberBetweenExcluded <= 0.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be less than or equal to 0.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } if ($optionalNumberBetweenExcluded >= 5.0) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Cannot be greater than or equal to 5.', 'optionalNumberBetweenExcluded', $optionalNumberBetweenExcluded)); } $this->optionalNumberBetweenExcluded = $optionalNumberBetweenExcluded; $this->optionalPropertyChanged['optionalNumberBetweenExcluded'] = true; @@ -323,11 +323,11 @@ public function setOptionalObject(EmbeddedObject $optionalObject): self */ public function setOptionalNullableStringWithMinMaxLength(?string $optionalNullableStringWithMinMaxLength): self { - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) < 1) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be greater than 1.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } - if ($optionalNullableStringWithMinMaxLength !== null && \grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { - throw new RequestValidationException(\sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); + if ($optionalNullableStringWithMinMaxLength !== null && grapheme_strlen($optionalNullableStringWithMinMaxLength) > 5) { + throw new RequestValidationException(sprintf('Invalid %s value. Given: `%s`. Length should be less than 5.', 'optionalNullableStringWithMinMaxLength', $optionalNullableStringWithMinMaxLength)); } $this->optionalNullableStringWithMinMaxLength = $optionalNullableStringWithMinMaxLength; $this->optionalPropertyChanged['optionalNullableStringWithMinMaxLength'] = true; diff --git a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp70.php b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp70.php index 0428c22..008fae2 100644 --- a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp70.php +++ b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp70.php @@ -53,7 +53,7 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } /** @@ -61,7 +61,7 @@ public function count(): int */ public function first() { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp72.php b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp72.php index e538767..8e687c0 100644 --- a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp72.php +++ b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp72.php @@ -53,12 +53,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?Item { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp74.php b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp74.php index d8413db..e0586a0 100644 --- a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp74.php +++ b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp74.php @@ -52,12 +52,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?Item { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp80.php b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp80.php index d8413db..e0586a0 100644 --- a/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp80.php +++ b/test/suite/functional/Generator/SchemaCollection/ItemCollectionPhp80.php @@ -52,12 +52,12 @@ public function getIterator(): ArrayIterator public function count(): int { - return \count($this->items); + return count($this->items); } public function first(): ?Item { - $first = \reset($this->items); + $first = reset($this->items); if ($first === false) { return null; } diff --git a/test/suite/functional/Generator/SchemaGeneratorTest.php b/test/suite/functional/Generator/SchemaGeneratorTest.php index 2e81b77..0e541c0 100644 --- a/test/suite/functional/Generator/SchemaGeneratorTest.php +++ b/test/suite/functional/Generator/SchemaGeneratorTest.php @@ -46,7 +46,7 @@ public function exampleProvider(): array self::BASE_NAMESPACE . SchemaGenerator::NAMESPACE_SUBPATH . '\\ItemMandatoryObject', ConfigurationBuilder::fake()->build(), ], - 'All of' => [ + 'All of' => [ '/Schema/extendedItem.yaml', '/Schema/AllOfItem.php', self::BASE_NAMESPACE . SchemaGenerator::NAMESPACE_SUBPATH . '\\ExtendedItem', diff --git a/test/suite/functional/Generator/SchemaMapper/ItemMapper74.php b/test/suite/functional/Generator/SchemaMapper/ItemMapper74.php index 283b6b1..adc1b85 100644 --- a/test/suite/functional/Generator/SchemaMapper/ItemMapper74.php +++ b/test/suite/functional/Generator/SchemaMapper/ItemMapper74.php @@ -31,8 +31,8 @@ public function __construct(EmbeddedObjectMapper $embeddedObjectMapper, Embedded */ public function toSchema(array $payload): Item { - $missingFields = \implode(', ', \array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate', 'mandatoryNullableDate', 'mandatoryFloat', 'mandatoryBoolean', 'mandatoryArray', 'mandatoryObject', 'mandatoryNullableObject'], \array_keys($payload))); - if (! empty($missingFields)) { + $missingFields = implode(', ', array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate', 'mandatoryNullableDate', 'mandatoryFloat', 'mandatoryBoolean', 'mandatoryArray', 'mandatoryObject', 'mandatoryNullableObject'], array_keys($payload))); + if (!empty($missingFields)) { throw new UnexpectedResponseBodyException('Required attributes for `Item` missing in the response body: ' . $missingFields); } $schema = new Item($payload['mandatoryInteger'], $payload['mandatoryString'], $payload['mandatoryEnum'], new DateTimeImmutable($payload['mandatoryDate']), $payload['mandatoryNullableDate'] !== null ? new DateTimeImmutable($payload['mandatoryNullableDate']) : null, $payload['mandatoryFloat'], $payload['mandatoryBoolean'], $payload['mandatoryArray'], $this->embeddedObjectMapper->toSchema($payload['mandatoryObject']), $payload['mandatoryNullableObject'] !== null ? $this->embeddedNullableObjectMapper->toSchema($payload['mandatoryNullableObject']) : null); @@ -48,7 +48,7 @@ public function toSchema(array $payload): Item if (isset($payload['optionalDate'])) { $schema->setOptionalDate(new DateTimeImmutable($payload['optionalDate'])); } - if (\array_key_exists('optionalNullableDate', $payload)) { + if (array_key_exists('optionalNullableDate', $payload)) { $schema->setOptionalNullableDate($payload['optionalNullableDate'] !== null ? new DateTimeImmutable($payload['optionalNullableDate']) : null); } if (isset($payload['optionalFloat'])) { @@ -63,7 +63,7 @@ public function toSchema(array $payload): Item if (isset($payload['optionalObject'])) { $schema->setOptionalObject($this->embeddedObjectMapper->toSchema($payload['optionalObject'])); } - if (\array_key_exists('optionalNullableObject', $payload)) { + if (array_key_exists('optionalNullableObject', $payload)) { $schema->setOptionalNullableObject($payload['optionalNullableObject'] !== null ? $this->embeddedNullableObjectMapper->toSchema($payload['optionalNullableObject']) : null); } diff --git a/test/suite/functional/Generator/SchemaMapper/ItemMapper80.php b/test/suite/functional/Generator/SchemaMapper/ItemMapper80.php index c155414..1320cec 100644 --- a/test/suite/functional/Generator/SchemaMapper/ItemMapper80.php +++ b/test/suite/functional/Generator/SchemaMapper/ItemMapper80.php @@ -25,8 +25,8 @@ public function __construct(private EmbeddedObjectMapper $embeddedObjectMapper, */ public function toSchema(array $payload): Item { - $missingFields = \implode(', ', \array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate', 'mandatoryNullableDate', 'mandatoryFloat', 'mandatoryBoolean', 'mandatoryArray', 'mandatoryObject', 'mandatoryNullableObject'], \array_keys($payload))); - if (! empty($missingFields)) { + $missingFields = implode(', ', array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate', 'mandatoryNullableDate', 'mandatoryFloat', 'mandatoryBoolean', 'mandatoryArray', 'mandatoryObject', 'mandatoryNullableObject'], array_keys($payload))); + if (!empty($missingFields)) { throw new UnexpectedResponseBodyException('Required attributes for `Item` missing in the response body: ' . $missingFields); } $schema = new Item($payload['mandatoryInteger'], $payload['mandatoryString'], $payload['mandatoryEnum'], new DateTimeImmutable($payload['mandatoryDate']), $payload['mandatoryNullableDate'] !== null ? new DateTimeImmutable($payload['mandatoryNullableDate']) : null, $payload['mandatoryFloat'], $payload['mandatoryBoolean'], $payload['mandatoryArray'], $this->embeddedObjectMapper->toSchema($payload['mandatoryObject']), $payload['mandatoryNullableObject'] !== null ? $this->embeddedNullableObjectMapper->toSchema($payload['mandatoryNullableObject']) : null); @@ -42,7 +42,7 @@ public function toSchema(array $payload): Item if (isset($payload['optionalDate'])) { $schema->setOptionalDate(new DateTimeImmutable($payload['optionalDate'])); } - if (\array_key_exists('optionalNullableDate', $payload)) { + if (array_key_exists('optionalNullableDate', $payload)) { $schema->setOptionalNullableDate($payload['optionalNullableDate'] !== null ? new DateTimeImmutable($payload['optionalNullableDate']) : null); } if (isset($payload['optionalFloat'])) { @@ -57,7 +57,7 @@ public function toSchema(array $payload): Item if (isset($payload['optionalObject'])) { $schema->setOptionalObject($this->embeddedObjectMapper->toSchema($payload['optionalObject'])); } - if (\array_key_exists('optionalNullableObject', $payload)) { + if (array_key_exists('optionalNullableObject', $payload)) { $schema->setOptionalNullableObject($payload['optionalNullableObject'] !== null ? $this->embeddedNullableObjectMapper->toSchema($payload['optionalNullableObject']) : null); } diff --git a/test/suite/functional/Generator/SchemaMapper/ResourceMapper74.php b/test/suite/functional/Generator/SchemaMapper/ResourceMapper74.php index d247ce4..9a00338 100644 --- a/test/suite/functional/Generator/SchemaMapper/ResourceMapper74.php +++ b/test/suite/functional/Generator/SchemaMapper/ResourceMapper74.php @@ -21,8 +21,8 @@ class ResourceMapper implements SchemaMapperInterface */ public function toSchema(array $payload): Resource { - $missingFields = \implode(', ', \array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate'], \array_keys($payload))); - if (! empty($missingFields)) { + $missingFields = implode(', ', array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate'], array_keys($payload))); + if (!empty($missingFields)) { throw new UnexpectedResponseBodyException('Required attributes for `Resource` missing in the response body: ' . $missingFields); } diff --git a/test/suite/functional/Generator/SchemaMapper/ResourceMapper80.php b/test/suite/functional/Generator/SchemaMapper/ResourceMapper80.php index d247ce4..9a00338 100644 --- a/test/suite/functional/Generator/SchemaMapper/ResourceMapper80.php +++ b/test/suite/functional/Generator/SchemaMapper/ResourceMapper80.php @@ -21,8 +21,8 @@ class ResourceMapper implements SchemaMapperInterface */ public function toSchema(array $payload): Resource { - $missingFields = \implode(', ', \array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate'], \array_keys($payload))); - if (! empty($missingFields)) { + $missingFields = implode(', ', array_diff(['mandatoryInteger', 'mandatoryString', 'mandatoryEnum', 'mandatoryDate'], array_keys($payload))); + if (!empty($missingFields)) { throw new UnexpectedResponseBodyException('Required attributes for `Resource` missing in the response body: ' . $missingFields); } diff --git a/test/suite/functional/Generator/SchemaMapperGeneratorTest.php b/test/suite/functional/Generator/SchemaMapperGeneratorTest.php index 84c9d93..a30a459 100644 --- a/test/suite/functional/Generator/SchemaMapperGeneratorTest.php +++ b/test/suite/functional/Generator/SchemaMapperGeneratorTest.php @@ -16,25 +16,25 @@ class SchemaMapperGeneratorTest extends AbstractGeneratorTest public function exampleProvider(): array { return [ - 'Single object response with php 7.4' => [ + 'Single object response with php 7.4' => [ '/SchemaMapper/item.yaml', '/SchemaMapper/ItemMapper74.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\ItemMapper', ConfigurationBuilder::fake()->build(), ], - 'Single object response with php 8.0' => [ + 'Single object response with php 8.0' => [ '/SchemaMapper/item.yaml', '/SchemaMapper/ItemMapper80.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\ItemMapper', ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(), ], - 'Collection response with php 7.4' => [ + 'Collection response with php 7.4' => [ '/SchemaMapper/itemCollection.yaml', '/SchemaMapper/ItemCollectionMapper74.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\ItemCollectionMapper', ConfigurationBuilder::fake()->build(), ], - 'Collection response with php 8.0' => [ + 'Collection response with php 8.0' => [ '/SchemaMapper/itemCollection.yaml', '/SchemaMapper/ItemCollectionMapper80.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\ItemCollectionMapper', @@ -52,13 +52,13 @@ public function exampleProvider(): array self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\ResourceMapper', ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(), ], - 'Free form object response with php 7.4' => [ + 'Free form object response with php 7.4' => [ '/SchemaMapper/freeFormItem.yaml', '/SchemaMapper/FreeFormItemMapper74.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\FreeFormItemMapper', ConfigurationBuilder::fake()->build(), ], - 'Free form object response with php 8.0' => [ + 'Free form object response with php 8.0' => [ '/SchemaMapper/freeFormItem.yaml', '/SchemaMapper/FreeFormItemMapper80.php', self::BASE_NAMESPACE . SchemaMapperGenerator::NAMESPACE_SUBPATH . '\\FreeFormItemMapper', diff --git a/test/suite/functional/Input/FileReaderTest.php b/test/suite/functional/Input/FileReaderTest.php index a62659b..ae30720 100644 --- a/test/suite/functional/Input/FileReaderTest.php +++ b/test/suite/functional/Input/FileReaderTest.php @@ -4,8 +4,8 @@ namespace DoclerLabs\ApiClientGenerator\Test\Functional\Input; -use DoclerLabs\ApiClientGenerator\Input\InvalidSpecificationException; use DoclerLabs\ApiClientGenerator\Input\FileReader; +use DoclerLabs\ApiClientGenerator\Input\InvalidSpecificationException; use DoclerLabs\ApiClientGenerator\Test\Functional\ConfigurationAwareTrait; use DoclerLabs\ApiClientGenerator\Test\Functional\ConfigurationBuilder; use PHPUnit\Framework\TestCase; diff --git a/test/suite/functional/Input/ParserTest.php b/test/suite/functional/Input/ParserTest.php index 850fe06..32e4f8e 100644 --- a/test/suite/functional/Input/ParserTest.php +++ b/test/suite/functional/Input/ParserTest.php @@ -53,7 +53,7 @@ public function validSpecificationProvider() 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -73,23 +73,23 @@ public function validSpecificationProvider() public function invalidSpecificationProvider() { return [ - 'Empty specification file' => [ + 'Empty specification file' => [ [], ], - 'No paths' => [ + 'No paths' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [], + 'paths' => [], ], ], 'Swagger specification version is lower than 3.0' => [ [ - 'swagger' => '2.0', - 'info' => [ + 'swagger' => '2.0', + 'info' => [ 'title' => 'Sample API', 'description' => 'API description.', 'version' => '1.0.0', @@ -100,7 +100,7 @@ public function invalidSpecificationProvider() 'paths' => [], ], ], - 'Paths field is missing' => [ + 'Paths field is missing' => [ [ 'openapi' => '3.0.0', 'info' => [ @@ -109,14 +109,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Responses field is missing' => [ + 'Responses field is missing' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -125,14 +125,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Unsupported operation' => [ + 'Unsupported operation' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'flurp' => [ 'operationId' => 'flurpThem', @@ -146,14 +146,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Response without description' => [ + 'Response without description' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -173,14 +173,14 @@ public function invalidSpecificationProvider() ], ], ], - 'OneOf keyword is not supported' => [ + 'OneOf keyword is not supported' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'responses' => [ @@ -200,14 +200,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Reference to non-existing schema' => [ + 'Reference to non-existing schema' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -231,14 +231,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Array schema without items' => [ + 'Array schema without items' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -259,14 +259,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Invalid field name' => [ + 'Invalid field name' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -292,14 +292,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Invalid reference name' => [ + 'Invalid reference name' => [ [ - 'openapi' => '3.0.0', - 'info' => [ + 'openapi' => '3.0.0', + 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getItems', @@ -323,8 +323,7 @@ public function invalidSpecificationProvider() '7Item' => [ 'type' => 'object', 'properties' => [ - 'name' => - [ + 'name' => [ 'type' => 'string', ], ], @@ -333,14 +332,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Invalid array item reference name' => [ + 'Invalid array item reference name' => [ [ - 'openapi' => '3.0.0', - 'info' => [ + 'openapi' => '3.0.0', + 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getItems', @@ -367,8 +366,7 @@ public function invalidSpecificationProvider() '7Item' => [ 'type' => 'object', 'properties' => [ - 'name' => - [ + 'name' => [ 'type' => 'string', ], ], @@ -377,17 +375,17 @@ public function invalidSpecificationProvider() ], ], ], - 'Incomplete parameter' => [ + 'Incomplete parameter' => [ [ - 'openapi' => '3.0.0', - 'info' => [ + 'openapi' => '3.0.0', + 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ - 'parameters' => [ + 'parameters' => [ ['$ref' => '#/components/parameters/ItemName',], ], 'operationId' => 'getItems', @@ -408,14 +406,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Usage of parameter inside a schema' => [ + 'Usage of parameter inside a schema' => [ [ - 'openapi' => '3.0.0', - 'info' => [ + 'openapi' => '3.0.0', + 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getItems', @@ -450,14 +448,14 @@ public function invalidSpecificationProvider() ], ], ], - 'Duplicated operation id' => [ + 'Duplicated operation id' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'getUsers', @@ -481,17 +479,17 @@ public function invalidSpecificationProvider() ], ], ], - 'Parameter with invalid origin' => [ + 'Parameter with invalid origin' => [ [ - 'openapi' => '3.0.0', - 'info' => [ + 'openapi' => '3.0.0', + 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ - 'parameters' => [ + 'parameters' => [ ['$ref' => '#/components/parameters/ItemName',], ], 'operationId' => 'getItems', diff --git a/test/suite/functional/Input/SpecificationTest.php b/test/suite/functional/Input/SpecificationTest.php index 64be70d..89336ef 100644 --- a/test/suite/functional/Input/SpecificationTest.php +++ b/test/suite/functional/Input/SpecificationTest.php @@ -31,14 +31,14 @@ public function testAllContentTypesArrayPopulatedCorrectly(array $data, array $e public function contentTypesTestProvider(): array { return [ - 'No serializers required' => [ + 'No serializers required' => [ [ 'openapi' => '3.0.0', 'info' => [ 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users/{userId}' => [ 'parameters' => [ [ @@ -50,7 +50,7 @@ public function contentTypesTestProvider(): array ], ], ], - 'delete' => [ + 'delete' => [ 'operationId' => 'deleteUser', 'responses' => [ '204' => [ @@ -70,7 +70,7 @@ public function contentTypesTestProvider(): array 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'post' => [ 'operationId' => 'createUser', @@ -99,7 +99,7 @@ public function contentTypesTestProvider(): array ], ], ], - 'responses' => [ + 'responses' => [ '201' => [ 'description' => 'Created', ], @@ -120,14 +120,14 @@ public function contentTypesTestProvider(): array 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users' => [ 'get' => [ 'operationId' => 'createUser', 'responses' => [ '200' => [ 'description' => 'Array of users', - 'content' => [ + 'content' => [ 'application/json' => [ 'schema' => [ 'type' => 'object', @@ -167,7 +167,7 @@ public function contentTypesTestProvider(): array 'title' => 'Sample API', 'version' => '1.0.0', ], - 'paths' => [ + 'paths' => [ '/users/{userId}' => [ 'parameters' => [ [ @@ -206,10 +206,10 @@ public function contentTypesTestProvider(): array ], ], ], - 'responses' => [ + 'responses' => [ '200' => [ 'description' => 'Modified user', - 'content' => [ + 'content' => [ 'application/json' => [ 'schema' => [ 'type' => 'object', @@ -232,7 +232,7 @@ public function contentTypesTestProvider(): array 'application/x-www-form-urlencoded', 'application/json', ], - ] + ], ]; } diff --git a/test/suite/functional/Meta/AbstractTemplateTest.php b/test/suite/functional/Meta/AbstractTemplateTest.php index 63d2760..164a63e 100644 --- a/test/suite/functional/Meta/AbstractTemplateTest.php +++ b/test/suite/functional/Meta/AbstractTemplateTest.php @@ -18,7 +18,9 @@ abstract class AbstractTemplateTest extends TestCase use ConfigurationAwareTrait; protected FileReader $specificationReader; + protected Parser $specificationParser; + protected MetaFileCollection $fileRegistry; protected function setUp(): void diff --git a/test/suite/functional/Meta/ComposerJsonTemplateTest.php b/test/suite/functional/Meta/ComposerJsonTemplateTest.php index 3dd3544..5d64bff 100644 --- a/test/suite/functional/Meta/ComposerJsonTemplateTest.php +++ b/test/suite/functional/Meta/ComposerJsonTemplateTest.php @@ -25,25 +25,25 @@ class ComposerJsonTemplateTest extends AbstractTemplateTest public function exampleProvider(): array { return [ - 'Default composer.json + PHP 7.4' => [ + 'Default composer.json + PHP 7.4' => [ '/ComposerJson/petstore.yaml', '/ComposerJson/composer_default74.json', 'composer.json', ConfigurationBuilder::fake()->build(), ], - 'Default composer.json + PHP 8.0' => [ + 'Default composer.json + PHP 8.0' => [ '/ComposerJson/petstore.yaml', '/ComposerJson/composer_default80.json', 'composer.json', ConfigurationBuilder::fake()->withPhpVersion(PhpVersion::VERSION_PHP80)->build(), ], - 'composer.json with intl + PHP 7.4' => [ + 'composer.json with intl + PHP 7.4' => [ '/ComposerJson/petstore_with_intl_requirement.yaml', '/ComposerJson/composer_with_intl_requirement74.json', 'composer.json', ConfigurationBuilder::fake()->build(), ], - 'composer.json with intl + PHP 8.0' => [ + 'composer.json with intl + PHP 8.0' => [ '/ComposerJson/petstore_with_intl_requirement.yaml', '/ComposerJson/composer_with_intl_requirement80.json', 'composer.json', diff --git a/test/suite/functional/Meta/ReadmeMdTemplateTest.php b/test/suite/functional/Meta/ReadmeMdTemplateTest.php index e550d0c..5af53e9 100644 --- a/test/suite/functional/Meta/ReadmeMdTemplateTest.php +++ b/test/suite/functional/Meta/ReadmeMdTemplateTest.php @@ -25,7 +25,7 @@ public function exampleProvider(): array '/ReadmeMd/petstore.yaml', '/ReadmeMd/README74.md', 'README.md', - ConfigurationBuilder::fake()->build() + ConfigurationBuilder::fake()->build(), ], 'Basic README.md + PHP 8.0' => [ '/ReadmeMd/petstore.yaml', diff --git a/test/suite/functional/Naming/SchemaNamingTest.php b/test/suite/functional/Naming/SchemaNamingTest.php index 554d196..921051f 100644 --- a/test/suite/functional/Naming/SchemaNamingTest.php +++ b/test/suite/functional/Naming/SchemaNamingTest.php @@ -16,6 +16,7 @@ class SchemaNamingTest extends TestCase use ConfigurationAwareTrait; private FileReader $specificationReader; + private Parser $specificationParser; protected function setUp(): void diff --git a/test/suite/functional/Output/Copy/Serializer/BodySerializerTest.php b/test/suite/functional/Output/Copy/Serializer/BodySerializerTest.php index 2f9c700..8baa82b 100644 --- a/test/suite/functional/Output/Copy/Serializer/BodySerializerTest.php +++ b/test/suite/functional/Output/Copy/Serializer/BodySerializerTest.php @@ -71,16 +71,16 @@ public function testUnserializeJsonResponse(string $contentType): void public function applicationJsonContentTypeStringsProvider(): array { return [ - 'default' => [ + 'default' => [ 'application/json', ], 'with extra symbols' => [ 'application/json; ', ], - 'upper case' => [ + 'upper case' => [ 'applicaTion/JSON', ], - 'with charset' => [ + 'with charset' => [ 'application/json; charset=ISO-8859-4', ], ]; diff --git a/test/suite/unit/Ast/Builder/CodeBuilderTest.php b/test/suite/unit/Ast/Builder/CodeBuilderTest.php index 310bff3..dd0a214 100644 --- a/test/suite/unit/Ast/Builder/CodeBuilderTest.php +++ b/test/suite/unit/Ast/Builder/CodeBuilderTest.php @@ -19,8 +19,10 @@ class CodeBuilderTest extends TestCase { private CodeBuilder $sut; + /** @var PhpVersion|MockObject */ private $phpVersionResolver; + private Standard $printer; protected function setUp(): void @@ -73,10 +75,10 @@ public function testNot(): void public function testTryCatch(): void { - $tryStmts[] = $this->sut->expr($this->sut->assign($this->sut->val(1), $this->sut->val(1))); - $catchStmts[] = $this->sut->expr($this->sut->assign($this->sut->val(2), $this->sut->val(2))); - $exceptionVar = $this->sut->var('exception'); - $catches[] = $this->sut->catch( + $tryStmts[] = $this->sut->expr($this->sut->assign($this->sut->val(1), $this->sut->val(1))); + $catchStmts[] = $this->sut->expr($this->sut->assign($this->sut->val(2), $this->sut->val(2))); + $exceptionVar = $this->sut->var('exception'); + $catches[] = $this->sut->catch( [ $this->sut->className('LogicException'), $this->sut->className('RuntimeException'), diff --git a/test/suite/unit/Ast/Visitor/NamespaceSubstituteVisitorTest.php b/test/suite/unit/Ast/Visitor/NamespaceSubstituteVisitorTest.php index 237784c..2c69a48 100644 --- a/test/suite/unit/Ast/Visitor/NamespaceSubstituteVisitorTest.php +++ b/test/suite/unit/Ast/Visitor/NamespaceSubstituteVisitorTest.php @@ -16,8 +16,10 @@ */ class NamespaceSubstituteVisitorTest extends TestCase { - private const ORIGINAL_NAMESPACE = 'Some\\Original\\Namespace'; + private const ORIGINAL_NAMESPACE = 'Some\\Original\\Namespace'; + private const SUBSTITUTE_NAMESPACE = 'Substitute\\Namespace'; + private NamespaceSubstituteVisitor $sut; protected function setUp(): void diff --git a/test/suite/unit/Entity/OperationTest.php b/test/suite/unit/Entity/OperationTest.php index 3a399f0..6306006 100644 --- a/test/suite/unit/Entity/OperationTest.php +++ b/test/suite/unit/Entity/OperationTest.php @@ -16,13 +16,18 @@ class OperationTest extends TestCase { private const NAME = 'operation'; + private const DESCRIPTION = 'Very important operation'; + private const TAGS = ['one', 'two']; private Operation $sut; + private array $errorResponses; + /** @var Request|MockObject */ private $request; + /** @var Response[]|MockObject[] */ private array $succesfulResponses; diff --git a/test/suite/unit/Input/PhpNameValidatorTest.php b/test/suite/unit/Input/PhpNameValidatorTest.php index c63130a..3254d03 100644 --- a/test/suite/unit/Input/PhpNameValidatorTest.php +++ b/test/suite/unit/Input/PhpNameValidatorTest.php @@ -22,9 +22,6 @@ protected function setUp(): void /** * @dataProvider classNameProvider - * - * @param string $input - * @param bool $expectedResult */ public function testIsValidClassName(string $input, bool $expectedResult): void { @@ -33,9 +30,6 @@ public function testIsValidClassName(string $input, bool $expectedResult): void /** * @dataProvider variableNameProvider - * - * @param string $input - * @param bool $expectedResult */ public function testIsValidVariableName(string $input, bool $expectedResult): void { diff --git a/test/suite/unit/Naming/CaseCasterTest.php b/test/suite/unit/Naming/CaseCasterTest.php index cde82b5..a1db0bc 100644 --- a/test/suite/unit/Naming/CaseCasterTest.php +++ b/test/suite/unit/Naming/CaseCasterTest.php @@ -48,92 +48,92 @@ public function camelCaseDataProvider() { return [ [ - "f", - "f", + 'f', + 'f', ], [ - "1234", - "1234", + '1234', + '1234', ], [ - "FOO", - "foo", + 'FOO', + 'foo', ], [ - "FooBar", - "fooBar", + 'FooBar', + 'fooBar', ], [ - "fooBar", - "fooBar", + 'fooBar', + 'fooBar', ], [ - "foo bar", - "fooBar", + 'foo bar', + 'fooBar', ], [ - "Foo - Bar", - "fooBar", + 'Foo - Bar', + 'fooBar', ], [ - "foo & bar", - "fooBar", + 'foo & bar', + 'fooBar', ], [ - "FooFooBar", - "fooFooBar", + 'FooFooBar', + 'fooFooBar', ], [ - "Foo2Foo2Bar", - "foo2Foo2Bar", + 'Foo2Foo2Bar', + 'foo2Foo2Bar', ], [ - "foo-bar-baz", - "fooBarBaz", + 'foo-bar-baz', + 'fooBarBaz', ], [ - "foo_bar_1_2", - "fooBar12", + 'foo_bar_1_2', + 'fooBar12', ], [ - "_foo_bar_baz_", - "fooBarBaz", + '_foo_bar_baz_', + 'fooBarBaz', ], [ - "--foo-bar--", - "fooBar", + '--foo-bar--', + 'fooBar', ], [ - "FOO_BAR_baz", - "fooBarBaz", + 'FOO_BAR_baz', + 'fooBarBaz', ], [ - "__FOO_BAR__", - "fooBar", + '__FOO_BAR__', + 'fooBar', ], [ "Foo w1th apo's and punc]t", - "fooW1thApoSAndPuncT", + 'fooW1thApoSAndPuncT', ], [ - "getHTTPResponse", - "getHttpResponse", + 'getHTTPResponse', + 'getHttpResponse', ], [ - "currencyISOCode", - "currencyIsoCode", + 'currencyISOCode', + 'currencyIsoCode', ], [ - "get2HTTPResponse", - "get2HttpResponse", + 'get2HTTPResponse', + 'get2HttpResponse', ], [ - "HTTPResponseCode", - "httpResponseCode", + 'HTTPResponseCode', + 'httpResponseCode', ], [ - "HTTPResponseCodeXY", - "httpResponseCodeXy", + 'HTTPResponseCodeXY', + 'httpResponseCodeXy', ], ]; } @@ -142,96 +142,96 @@ public function snakeCaseDataProvider() { return [ [ - "", - "", + '', + '', ], [ - "f", - "f", + 'f', + 'f', ], [ - "1234", - "1234", + '1234', + '1234', ], [ - "FOO", - "foo", + 'FOO', + 'foo', ], [ - "FooBar", - "foo_bar", + 'FooBar', + 'foo_bar', ], [ - "fooBar", - "foo_bar", + 'fooBar', + 'foo_bar', ], [ - "foo bar", - "foo_bar", + 'foo bar', + 'foo_bar', ], [ - "Foo - Bar", - "foo_bar", + 'Foo - Bar', + 'foo_bar', ], [ - "foo & bar", - "foo_bar", + 'foo & bar', + 'foo_bar', ], [ - "FooFooBar", - "foo_foo_bar", + 'FooFooBar', + 'foo_foo_bar', ], [ - "Foo2Foo2Bar", - "foo2_foo2_bar", + 'Foo2Foo2Bar', + 'foo2_foo2_bar', ], [ - "foo-bar-baz", - "foo_bar_baz", + 'foo-bar-baz', + 'foo_bar_baz', ], [ - "foo_bar_1_2", - "foo_bar_1_2", + 'foo_bar_1_2', + 'foo_bar_1_2', ], [ - "_foo_bar_baz_", - "foo_bar_baz", + '_foo_bar_baz_', + 'foo_bar_baz', ], [ - "--foo-bar--", - "foo_bar", + '--foo-bar--', + 'foo_bar', ], [ - "FOO_BAR_baz", - "foo_bar_baz", + 'FOO_BAR_baz', + 'foo_bar_baz', ], [ - "__FOO_BAR__", - "foo_bar", + '__FOO_BAR__', + 'foo_bar', ], [ "Foo w1th apo's and punc]t", - "foo_w1th_apo_s_and_punc_t", + 'foo_w1th_apo_s_and_punc_t', ], [ - "getHTTPResponse", - "get_http_response", + 'getHTTPResponse', + 'get_http_response', ], [ - "currencyISOCode", - "currency_iso_code", + 'currencyISOCode', + 'currency_iso_code', ], [ - "get2HTTPResponse", - "get2_http_response", + 'get2HTTPResponse', + 'get2_http_response', ], [ - "HTTPResponseCode", - "http_response_code", + 'HTTPResponseCode', + 'http_response_code', ], [ - "HTTPResponseCodeXY", - "http_response_code_xy", + 'HTTPResponseCodeXY', + 'http_response_code_xy', ], ]; } diff --git a/test/suite/unit/Output/Copy/Request/CookieJarTest.php b/test/suite/unit/Output/Copy/Request/CookieJarTest.php index ca8c299..49cbd42 100644 --- a/test/suite/unit/Output/Copy/Request/CookieJarTest.php +++ b/test/suite/unit/Output/Copy/Request/CookieJarTest.php @@ -62,17 +62,17 @@ public function testCannotAddCookiesToPsrRequest(array $cookies) public function validCookiesProvider(): array { return [ - 'regular cookie' => [ + 'regular cookie' => [ 'cookies' => ['foo' => 'bar'], - 'serializedCookie' => 'foo=bar' + 'serializedCookie' => 'foo=bar', ], - 'multiple cookies' => [ + 'multiple cookies' => [ 'cookies' => ['foo' => 'bar', 'foobar' => 'barfoo'], - 'serializedCookie' => 'foo=bar; foobar=barfoo' + 'serializedCookie' => 'foo=bar; foobar=barfoo', ], 'with integers as values' => [ 'cookies' => ['foo' => '0', 'bar' => 123, 'foobar' => 0], - 'serializedCookie' => 'foo=0; bar=123; foobar=0' + 'serializedCookie' => 'foo=0; bar=123; foobar=0', ], ]; } @@ -80,13 +80,13 @@ public function validCookiesProvider(): array public function invalidCookiesProvider(): array { return [ - 'with spaces on name' => [ + 'with spaces on name' => [ 'cookies' => ['foo bar' => 'bar'], ], 'with newline on name' => [ 'cookies' => ["foo\n" => 'bar'], ], - 'with empty value' => [ + 'with empty value' => [ 'cookies' => ['foo' => ''], ], ]; diff --git a/test/suite/unit/Output/Copy/Serializer/ContentType/FormEncodedContentTypeSerializerTest.php b/test/suite/unit/Output/Copy/Serializer/ContentType/FormEncodedContentTypeSerializerTest.php index 001d6b1..f48412a 100644 --- a/test/suite/unit/Output/Copy/Serializer/ContentType/FormEncodedContentTypeSerializerTest.php +++ b/test/suite/unit/Output/Copy/Serializer/ContentType/FormEncodedContentTypeSerializerTest.php @@ -1,5 +1,7 @@ 'Shyam', 'email' => 'shyamjaiswal@gmail.com'], ['name' => 'Bob', 'email' => 'bob32@gmail.com'], ['name' => 'Jai', 'email' => 'jai87@gmail.com'], - ] + ], ], - 'employees%5B0%5D%5Bname%5D=Shyam&employees%5B0%5D%5Bemail%5D=shyamjaiswal%40gmail.com&employees%5B1%5D%5Bname%5D=Bob&employees%5B1%5D%5Bemail%5D=bob32%40gmail.com&employees%5B2%5D%5Bname%5D=Jai&employees%5B2%5D%5Bemail%5D=jai87%40gmail.com' + 'employees%5B0%5D%5Bname%5D=Shyam&employees%5B0%5D%5Bemail%5D=shyamjaiswal%40gmail.com&employees%5B1%5D%5Bname%5D=Bob&employees%5B1%5D%5Bemail%5D=bob32%40gmail.com&employees%5B2%5D%5Bname%5D=Jai&employees%5B2%5D%5Bemail%5D=jai87%40gmail.com', ], [ [ @@ -79,9 +81,9 @@ public function validCasesProvider(): array ['value' => 'Save', 'onclick' => 'SaveDoc()'], ], ], - ] + ], ], - 'menu%5Bid%5D=file&menu%5Bvalue%5D=File&menu%5Bpopup%5D%5Bmenuitem%5D%5B0%5D%5Bvalue%5D=New&menu%5Bpopup%5D%5Bmenuitem%5D%5B0%5D%5Bonclick%5D=CreateDoc%28%29&menu%5Bpopup%5D%5Bmenuitem%5D%5B1%5D%5Bvalue%5D=Open&menu%5Bpopup%5D%5Bmenuitem%5D%5B1%5D%5Bonclick%5D=OpenDoc%28%29&menu%5Bpopup%5D%5Bmenuitem%5D%5B2%5D%5Bvalue%5D=Save&menu%5Bpopup%5D%5Bmenuitem%5D%5B2%5D%5Bonclick%5D=SaveDoc%28%29' + 'menu%5Bid%5D=file&menu%5Bvalue%5D=File&menu%5Bpopup%5D%5Bmenuitem%5D%5B0%5D%5Bvalue%5D=New&menu%5Bpopup%5D%5Bmenuitem%5D%5B0%5D%5Bonclick%5D=CreateDoc%28%29&menu%5Bpopup%5D%5Bmenuitem%5D%5B1%5D%5Bvalue%5D=Open&menu%5Bpopup%5D%5Bmenuitem%5D%5B1%5D%5Bonclick%5D=OpenDoc%28%29&menu%5Bpopup%5D%5Bmenuitem%5D%5B2%5D%5Bvalue%5D=Save&menu%5Bpopup%5D%5Bmenuitem%5D%5B2%5D%5Bonclick%5D=SaveDoc%28%29', ], ]; } diff --git a/test/suite/unit/Output/Copy/Serializer/ContentType/JsonContentTypeSerializerTest.php b/test/suite/unit/Output/Copy/Serializer/ContentType/JsonContentTypeSerializerTest.php index 7f4c909..a81ce7e 100644 --- a/test/suite/unit/Output/Copy/Serializer/ContentType/JsonContentTypeSerializerTest.php +++ b/test/suite/unit/Output/Copy/Serializer/ContentType/JsonContentTypeSerializerTest.php @@ -1,5 +1,7 @@ 'Shyam', 'email' => 'shyamjaiswal@gmail.com'], ['name' => 'Bob', 'email' => 'bob32@gmail.com'], ['name' => 'Jai', 'email' => 'jai87@gmail.com'], - ] + ], ], - '{"employees":[{"name":"Shyam","email":"shyamjaiswal@gmail.com"},{"name":"Bob","email":"bob32@gmail.com"},{"name":"Jai","email":"jai87@gmail.com"}]}' + '{"employees":[{"name":"Shyam","email":"shyamjaiswal@gmail.com"},{"name":"Bob","email":"bob32@gmail.com"},{"name":"Jai","email":"jai87@gmail.com"}]}', ], [ [ @@ -76,13 +78,13 @@ public function validCasesProvider(): array ['value' => 'Save', 'onclick' => 'SaveDoc()'], ], ], - ] + ], ], - '{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Save","onclick":"SaveDoc()"}]}}}' + '{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Save","onclick":"SaveDoc()"}]}}}', ], [ [1, 2, 3], - '[1,2,3]' + '[1,2,3]', ], ]; } @@ -92,27 +94,27 @@ public function literalCasesProvider(): array return [ [ [ - '__literalResponseValue' => null + '__literalResponseValue' => null, ], - 'null' + 'null', ], [ [ - '__literalResponseValue' => false + '__literalResponseValue' => false, ], - 'false' + 'false', ], [ [ - '__literalResponseValue' => 0 + '__literalResponseValue' => 0, ], - '0' + '0', ], [ [ - '__literalResponseValue' => 'asd' + '__literalResponseValue' => 'asd', ], - '"asd"' + '"asd"', ], ]; } diff --git a/test/suite/unit/Output/Copy/Serializer/ContentType/VdnApiJsonContentTypeSerializerTest.php b/test/suite/unit/Output/Copy/Serializer/ContentType/VdnApiJsonContentTypeSerializerTest.php index 544a936..79869b6 100644 --- a/test/suite/unit/Output/Copy/Serializer/ContentType/VdnApiJsonContentTypeSerializerTest.php +++ b/test/suite/unit/Output/Copy/Serializer/ContentType/VdnApiJsonContentTypeSerializerTest.php @@ -62,9 +62,9 @@ public function validCasesProvider(): array ['name' => 'Shyam', 'email' => 'shyamjaiswal@gmail.com'], ['name' => 'Bob', 'email' => 'bob32@gmail.com'], ['name' => 'Jai', 'email' => 'jai87@gmail.com'], - ] + ], ], - '{"employees":[{"name":"Shyam","email":"shyamjaiswal@gmail.com"},{"name":"Bob","email":"bob32@gmail.com"},{"name":"Jai","email":"jai87@gmail.com"}]}' + '{"employees":[{"name":"Shyam","email":"shyamjaiswal@gmail.com"},{"name":"Bob","email":"bob32@gmail.com"},{"name":"Jai","email":"jai87@gmail.com"}]}', ], [ [ @@ -78,13 +78,13 @@ public function validCasesProvider(): array ['value' => 'Save', 'onclick' => 'SaveDoc()'], ], ], - ] + ], ], - '{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Save","onclick":"SaveDoc()"}]}}}' + '{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Save","onclick":"SaveDoc()"}]}}}', ], [ [1, 2, 3], - '[1,2,3]' + '[1,2,3]', ], ]; } @@ -94,27 +94,27 @@ public function literalCasesProvider(): array return [ [ [ - '__literalResponseValue' => null + '__literalResponseValue' => null, ], - 'null' + 'null', ], [ [ - '__literalResponseValue' => false + '__literalResponseValue' => false, ], - 'false' + 'false', ], [ [ - '__literalResponseValue' => 0 + '__literalResponseValue' => 0, ], - '0' + '0', ], [ [ - '__literalResponseValue' => 'asd' + '__literalResponseValue' => 'asd', ], - '"asd"' + '"asd"', ], ]; } diff --git a/test/suite/unit/Output/Copy/Serializer/ContentType/XmlContentTypeSerializerTest.php b/test/suite/unit/Output/Copy/Serializer/ContentType/XmlContentTypeSerializerTest.php index 7fe962f..a206107 100644 --- a/test/suite/unit/Output/Copy/Serializer/ContentType/XmlContentTypeSerializerTest.php +++ b/test/suite/unit/Output/Copy/Serializer/ContentType/XmlContentTypeSerializerTest.php @@ -1,5 +1,7 @@ ['value' => [1, 2, 3]]], ' 123 -' +', ], [ [ @@ -69,63 +71,63 @@ public function validCasesProvider(): array ['name' => 'Bob', 'email' => 'bob32@gmail.com'], ['name' => 'Jai', 'email' => 'jai87@gmail.com'], ], - ] + ], ], ' Shyamshyamjaiswal@gmail.comBobbob32@gmail.comJaijai87@gmail.com -' +', ], [ [ 'root_node' => [ - 'tag' => 'Example tag', - 'attribute_tag' => [ + 'tag' => 'Example tag', + 'attribute_tag' => [ '@value' => 'Another tag with attributes', '@attributes' => [ - 'description' => 'This is a tag with attribute' - ] + 'description' => 'This is a tag with attribute', + ], ], - 'cdata_section' => [ - '@cdata' => 'This is CDATA section' + 'cdata_section' => [ + '@cdata' => 'This is CDATA section', ], - 'tag_with_subtag' => [ - 'sub_tag' => ['Sub tag 1', 'Sub tag 2'] + 'tag_with_subtag' => [ + 'sub_tag' => ['Sub tag 1', 'Sub tag 2'], ], - 'mixed_section' => [ + 'mixed_section' => [ '@value' => 'Hello', '@cdata' => 'This is another CDATA section', 'section' => [ [ '@value' => 'Section number 1', '@attributes' => [ - 'id' => 'sec_1' - ] + 'id' => 'sec_1', + ], ], [ '@value' => 'Section number 2', '@attributes' => [ - 'id' => 'sec_2' - ] + 'id' => 'sec_2', + ], ], [ '@value' => 'Section number 3', '@attributes' => [ - 'id' => 'sec_3' - ] - ] - ] + 'id' => 'sec_3', + ], + ], + ], ], 'example:with_namespace' => [ - 'example:sub' => 'Content' + 'example:sub' => 'Content', + ], + '@attributes' => [ + 'xmlns:example' => 'http://example.com', ], - '@attributes' => [ - 'xmlns:example' => 'http://example.com' - ] - ] + ], ], ' Example tagAnother tag with attributesSub tag 1Sub tag 2Hello
Section number 1
Section number 2
Section number 3
Content
-' +', ], ]; } diff --git a/test/suite/unit/Output/Copy/Serializer/QuerySerializerTest.php b/test/suite/unit/Output/Copy/Serializer/QuerySerializerTest.php index 70e1606..4e6e031 100644 --- a/test/suite/unit/Output/Copy/Serializer/QuerySerializerTest.php +++ b/test/suite/unit/Output/Copy/Serializer/QuerySerializerTest.php @@ -55,7 +55,7 @@ public function dataProvider(): array ->willReturn($jsonSerialized = ['bar' => 'foo']); return [ - 'DateTime' => [ + 'DateTime' => [ [ 'dateTime' => $dateTime = new DateTimeImmutable( '2020-11-24 01:02:03', @@ -66,13 +66,13 @@ public function dataProvider(): array 'dateTime' => $dateTime->format(DateTimeInterface::RFC3339), ], ], - 'Nullable' => [ + 'Nullable' => [ [ 'nullable' => null, ], [], ], - 'Integer' => [ + 'Integer' => [ [ 'integer' => $integer = 11, ], @@ -80,7 +80,7 @@ public function dataProvider(): array 'integer' => (string)$integer, ], ], - 'String' => [ + 'String' => [ [ 'string' => $string = 'simple string', ], @@ -88,7 +88,7 @@ public function dataProvider(): array 'string' => $string, ], ], - 'Float' => [ + 'Float' => [ [ 'float' => $float = 42.13, ], @@ -96,9 +96,9 @@ public function dataProvider(): array 'float' => (string)$float, ], ], - 'Boolean' => [ + 'Boolean' => [ [ - 'booleanTrue' => $booleanTrue = true, + 'booleanTrue' => $booleanTrue = true, 'booleanFalse' => $booleanFalse = false, ], [ @@ -106,7 +106,7 @@ public function dataProvider(): array 'booleanFalse' => (string)(int)$booleanFalse, ], ], - 'Serializable interface' => [ + 'Serializable interface' => [ [ 'serializable' => $serializable, ], diff --git a/test/suite/unit/Output/DirectoryPrinterTest.php b/test/suite/unit/Output/DirectoryPrinterTest.php index e939f75..49ff4a5 100644 --- a/test/suite/unit/Output/DirectoryPrinterTest.php +++ b/test/suite/unit/Output/DirectoryPrinterTest.php @@ -15,6 +15,7 @@ class DirectoryPrinterTest extends TestCase { private DirectoryPrinter $sut; + private vfsStreamDirectory $directory; protected function setUp(): void diff --git a/test/suite/unit/Output/Meta/MetaFilePrinterTest.php b/test/suite/unit/Output/Meta/MetaFilePrinterTest.php index b881f1a..d36fb4d 100644 --- a/test/suite/unit/Output/Meta/MetaFilePrinterTest.php +++ b/test/suite/unit/Output/Meta/MetaFilePrinterTest.php @@ -17,6 +17,7 @@ class MetaFilePrinterTest extends TestCase { /** @var MetaFilePrinter */ private $sut; + /** @var TextFilePrinter|MockObject */ private $printer; diff --git a/test/suite/unit/Output/Php/PhpFileTest.php b/test/suite/unit/Output/Php/PhpFileTest.php index 5b1126b..f1a679e 100644 --- a/test/suite/unit/Output/Php/PhpFileTest.php +++ b/test/suite/unit/Output/Php/PhpFileTest.php @@ -12,8 +12,10 @@ */ class PhpFileTest extends TestCase { - private const FILE_NAME = 'test.php'; + private const FILE_NAME = 'test.php'; + private const CLASS_NAME = 'Test\\Test'; + /** @var PhpFile */ private $sut; diff --git a/test/suite/unit/Output/Php/PhpPrinterTest.php b/test/suite/unit/Output/Php/PhpPrinterTest.php index 58ae020..7459d93 100644 --- a/test/suite/unit/Output/Php/PhpPrinterTest.php +++ b/test/suite/unit/Output/Php/PhpPrinterTest.php @@ -19,10 +19,13 @@ class PhpPrinterTest extends TestCase { /** @var PhpFilePrinter */ private $sut; + /** @var PrettyPrinterAbstract|MockObject */ private $marshaler; + /** @var TextFilePrinter|MockObject */ private $printer; + /** @var PhpCodeStyleFixer|MockObject */ private $fixer;