Skip to content

fix: php-cs-fixer keep nullable return annotations #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
'operators' => ['=>' => null],
],
'multiline_whitespace_before_semicolons' => false,
'phpdoc_trim' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
8 changes: 8 additions & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ rm -f ./src/Model/*

java -jar ./bin/swagger-codegen-cli.jar generate -t ./template -l php -i ./res/fingerprint-server-api.yaml -o ./ -c config.json

if [ ! -f .php-cs-fixer.php ]; then
echo ".php-cs-fixer.php configuration file not found!"
exit 1
fi

echo "Using .php-cs-fixer.php configuration:"
cat .php-cs-fixer.php

docker run --rm -v $(pwd):/code ghcr.io/php-cs-fixer/php-cs-fixer:${FIXER_VERSION:-3-php8.3} fix --config=/code/.php-cs-fixer.php /code/src

# fix invalid code generated for structure with additionalProperties
Expand Down
4 changes: 2 additions & 2 deletions src/Api/FingerprintApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function ($e) {
*
* @param string $request_id The unique [identifier](https://dev.fingerprint.com/docs/js-agent#requestid) of each identification request. (required)
*
* @return array{ null|\Fingerprint\ServerAPI\Model\EventResponse, \Psr\Http\Message\ResponseInterface }
* @return array{ \Fingerprint\ServerAPI\Model\EventResponse|null, \Psr\Http\Message\ResponseInterface }
*
* @throws \InvalidArgumentException
* @throws SerializationException
Expand Down Expand Up @@ -435,7 +435,7 @@ function ($e) {
* @param string $pagination_key Use `paginationKey` to get the next page of results. When more results are available (e.g., you requested 200 results using `limit` parameter, but a total of 600 results are available), the `paginationKey` top-level attribute is added to the response. The key corresponds to the `requestId` of the last returned event. In the following request, use that value in the `paginationKey` parameter to get the next page of results: 1. First request, returning most recent 200 events: `GET api-base-url/visitors/:visitorId?limit=200` 2. Use `response.paginationKey` to get the next page of results: `GET api-base-url/visitors/:visitorId?limit=200&paginationKey=1683900801733.Ogvu1j` Pagination happens during scanning and before filtering, so you can get less visits than the `limit` you specified with more available on the next page. When there are no more results available for scanning, the `paginationKey` attribute is not returned. (optional)
* @param int $before ⚠️ Deprecated pagination method, please use `paginationKey` instead. Timestamp (in milliseconds since epoch) used to paginate results. (optional)
*
* @return array{ null|\Fingerprint\ServerAPI\Model\Response, \Psr\Http\Message\ResponseInterface }
* @return array{ \Fingerprint\ServerAPI\Model\Response|null, \Psr\Http\Message\ResponseInterface }
*
* @throws \InvalidArgumentException
* @throws SerializationException
Expand Down
9 changes: 7 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function setApiKey(string $apiKeyIdentifier, string $key): self
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
*
* @return null|string API key or token
* @return string|null API key or token
*/
public function getApiKey(string $apiKeyIdentifier): ?string
{
Expand All @@ -150,6 +150,7 @@ public function setApiKeyPrefix(string $apiKeyIdentifier, string $prefix): self
* Gets API key prefix.
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
*
*/
public function getApiKeyPrefix(string $apiKeyIdentifier): ?string
{
Expand Down Expand Up @@ -329,6 +330,7 @@ public function setDebug(bool $debug): self

/**
* Gets the debug flag.
*
*/
public function getDebug(): bool
{
Expand All @@ -351,6 +353,7 @@ public function setDebugFile(string $debugFile): self

/**
* Gets the debug file.
*
*/
public function getDebugFile(): string
{
Expand Down Expand Up @@ -383,6 +386,7 @@ public function getTempFolderPath(): string

/**
* Gets the default configuration instance, with apiKey and host params.
*
*/
public static function getDefaultConfiguration(?string $api_key = null, ?string $region = self::REGION_GLOBAL): self
{
Expand All @@ -400,6 +404,7 @@ public static function getDefaultConfiguration(?string $api_key = null, ?string
* Sets the detault configuration instance.
*
* @param Configuration $config An instance of the Configuration Object
*
*/
public static function setDefaultConfiguration(Configuration $config): void
{
Expand Down Expand Up @@ -428,7 +433,7 @@ public static function toDebugReport(): string
*
* @param string $apiKeyIdentifier name of apikey
*
* @return null|string API key with the prefix
* @return string|null API key with the prefix
*/
public function getApiKeyWithPrefix(string $apiKeyIdentifier): ?string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/ASN.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ASN implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'ASN';

Expand Down Expand Up @@ -118,6 +119,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -256,6 +258,8 @@ public function setNetwork(string $network): self

/**
* Gets name.
*
* @return ?string
*/
public function getName(): ?string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/BotdDetectionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class BotdDetectionResult implements ModelInterface, \ArrayAccess

/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'BotdDetectionResult';

Expand Down Expand Up @@ -118,6 +119,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -260,6 +262,8 @@ public function setResult(string $result): self

/**
* Gets type.
*
* @return ?string
*/
public function getType(): ?string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/BotdResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class BotdResult implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'BotdResult';

Expand Down Expand Up @@ -144,6 +145,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -360,6 +362,8 @@ public function setRequestId(string $request_id): self

/**
* Gets linked_id.
*
* @return ?string
*/
public function getLinkedId(): ?string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/BrowserDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class BrowserDetails implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'BrowserDetails';

Expand Down Expand Up @@ -148,6 +149,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -411,6 +413,8 @@ public function setUserAgent(string $user_agent): self

/**
* Gets bot_probability.
*
* @return ?int
*/
public function getBotProbability(): ?int
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/ClonedAppResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ClonedAppResult implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'ClonedAppResult';

Expand Down Expand Up @@ -106,6 +107,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Common403ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Common403ErrorResponse implements ModelInterface, \ArrayAccess

/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'Common403ErrorResponse';

Expand Down Expand Up @@ -118,6 +119,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/Confidence.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Confidence implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'Confidence';

Expand Down Expand Up @@ -112,6 +113,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -225,6 +227,8 @@ public function setScore(float $score): self

/**
* Gets revision.
*
* @return ?string
*/
public function getRevision(): ?string
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/DataCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DataCenter implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'DataCenter';

Expand Down Expand Up @@ -112,6 +113,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -225,6 +227,8 @@ public function setResult(bool $result): self

/**
* Gets name.
*
* @return ?string
*/
public function getName(): ?string
{
Expand Down
14 changes: 14 additions & 0 deletions src/Model/DeprecatedIPLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class DeprecatedIPLocation implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'DeprecatedIPLocation';

Expand Down Expand Up @@ -156,6 +157,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -241,6 +243,8 @@ public function valid(): bool

/**
* Gets accuracy_radius.
*
* @return ?int
*/
public function getAccuracyRadius(): ?int
{
Expand Down Expand Up @@ -311,6 +315,8 @@ public function setLongitude(?float $longitude): self

/**
* Gets postal_code.
*
* @return ?string
*/
public function getPostalCode(): ?string
{
Expand All @@ -333,6 +339,8 @@ public function setPostalCode(?string $postal_code): self

/**
* Gets timezone.
*
* @return ?string
*/
public function getTimezone(): ?string
{
Expand All @@ -355,6 +363,8 @@ public function setTimezone(?string $timezone): self

/**
* Gets city.
*
* @return ?\Fingerprint\ServerAPI\Model\DeprecatedIPLocationCity
*/
public function getCity(): ?DeprecatedIPLocationCity
{
Expand All @@ -377,6 +387,8 @@ public function setCity(?DeprecatedIPLocationCity $city): self

/**
* Gets country.
*
* @return ?\Fingerprint\ServerAPI\Model\Location
*/
public function getCountry(): ?Location
{
Expand All @@ -399,6 +411,8 @@ public function setCountry(?Location $country): self

/**
* Gets continent.
*
* @return ?\Fingerprint\ServerAPI\Model\Location
*/
public function getContinent(): ?Location
{
Expand Down
4 changes: 4 additions & 0 deletions src/Model/DeprecatedIPLocationCity.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DeprecatedIPLocationCity implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'DeprecatedIPLocationCity';

Expand Down Expand Up @@ -106,6 +107,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down Expand Up @@ -191,6 +193,8 @@ public function valid(): bool

/**
* Gets name.
*
* @return ?string
*/
public function getName(): ?string
{
Expand Down
2 changes: 2 additions & 0 deletions src/Model/DeveloperToolsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DeveloperToolsResult implements ModelInterface, \ArrayAccess
{
/**
* The original name of the model.
*
*/
protected static string $swaggerModelName = 'DeveloperToolsResult';

Expand Down Expand Up @@ -106,6 +107,7 @@ public function __construct(?array $data = null)

/**
* Gets the string presentation of the object.
*
*/
public function __toString(): string
{
Expand Down
Loading
Loading