[PHP] Enhance Symfony generator (#12532)

* Enhance Symfony generator

  - Add missing typehints
  - Add missing use statements
  - Simplify model ctor
  - Change fallthrough Exception to Throwable
  - prevent storing result of void methods
  - fix validate method
  - add default null values to model properties
  - simplify API interface return values
  - fix/rework default value implementation
  - fix optional params deprecation warnings
  - ..

For more details check out the PR: https://github.com/OpenAPITools/openapi-generator/pull/12532

* Enhance Symfony generator Tests

  - Skip risky tests
  - Fix type hint error
  - Fix class exists tests
  - Fix broken doc block
  - Enhance annotations
  - Update phpunit.xml.dist
  - Fix test config resource location
This commit is contained in:
Daniel Metzner
2022-06-25 14:53:21 +02:00
committed by GitHub
parent 286a31c019
commit 3b15bb8a4e
56 changed files with 862 additions and 558 deletions

View File

@@ -57,7 +57,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#addPet
*/
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -119,7 +119,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#deletePet
*/
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders): void
public function deletePet(int $petId, ?string $apiKey, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -182,7 +182,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#findPetsByStatus
*/
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders): iterable
public function findPetsByStatus(array $status, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -244,7 +244,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#findPetsByTags
*/
public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders): iterable
public function findPetsByTags(array $tags, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -306,7 +306,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#getPetById
*/
public function getPetById($petId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function getPetById(int $petId, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -368,7 +368,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#updatePet
*/
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet
public function updatePet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -430,7 +430,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#updatePetWithForm
*/
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders): void
public function updatePetWithForm(int $petId, ?string $name, ?string $status, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -494,7 +494,7 @@ class PetApi implements PetApiInterface
/**
* Implementation of PetApiInterface#uploadFile
*/
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\ApiResponse
public function uploadFile(int $petId, ?string $additionalMetadata, ?UploadedFile $file, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}

View File

@@ -45,7 +45,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#deleteOrder
*/
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders): void
public function deleteOrder(string $orderId, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -107,7 +107,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#getInventory
*/
public function getInventory(, &$responseCode, array &$responseHeaders): array|\int
public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -158,7 +158,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#getOrderById
*/
public function getOrderById($orderId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order
public function getOrderById(int $orderId, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -212,7 +212,7 @@ class StoreApi implements StoreApiInterface
/**
* Implementation of StoreApiInterface#placeOrder
*/
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order
public function placeOrder(Order $order, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}

View File

@@ -57,7 +57,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUser
*/
public function createUser(User $user, &$responseCode, array &$responseHeaders): void
public function createUser(User $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -119,7 +119,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUsersWithArrayInput
*/
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders): void
public function createUsersWithArrayInput(array $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -181,7 +181,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#createUsersWithListInput
*/
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders): void
public function createUsersWithListInput(array $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -243,7 +243,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#deleteUser
*/
public function deleteUser($username, &$responseCode, array &$responseHeaders): void
public function deleteUser(string $username, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -297,7 +297,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#getUserByName
*/
public function getUserByName($username, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\User
public function getUserByName(string $username, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -351,7 +351,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#loginUser
*/
public function loginUser($username, $password, &$responseCode, array &$responseHeaders): array|\string
public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null
{
// Implement the operation ...
}
@@ -414,7 +414,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#logoutUser
*/
public function logoutUser(, &$responseCode, array &$responseHeaders): void
public function logoutUser(int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}
@@ -473,7 +473,7 @@ class UserApi implements UserApiInterface
/**
* Implementation of UserApiInterface#updateUser
*/
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders): void
public function updateUser(string $username, User $user, int &$responseCode, array &$responseHeaders): void
{
// Implement the operation ...
}