Skip to content
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

feat: Add PHP 8.4 support #415

Merged
merged 3 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 ]
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 ]
composer:
- name: lowest
arg: "--prefer-lowest --prefer-stable"
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Auth/AuthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AuthHandler
/** @var Token */
private $token;

public function __construct(callable $nextHandler, callable $tokenGenerator, Token $token = null)
public function __construct(callable $nextHandler, callable $tokenGenerator, ?Token $token = null)
{
$this->nextHandler = $nextHandler;
$this->tokenGenerator = $tokenGenerator;
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Error/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Builder
*/
private $client;

public function __construct(ClientInterface $client = null)
public function __construct(?ClientInterface $client = null)
{
$this->client = $client ?: new Client();
}
Expand Down Expand Up @@ -164,7 +164,7 @@ private function getStatusCodeMessage(int $statusCode): string
* @param mixed $userValue The incorrect value the user actually provided
* @param string|null $furtherLink a link to further information if necessary (optional)
*/
public function userInputError(string $expectedType, $userValue, string $furtherLink = null): UserInputError
public function userInputError(string $expectedType, $userValue, ?string $furtherLink = null): UserInputError
{
$message = $this->header('User Input Error');

Expand Down
2 changes: 1 addition & 1 deletion src/Common/HydratorStrategyTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function hydrate(array $data, array $aliases = [])
}
}

public function set(string $key, $property, array $data, callable $fn = null)
public function set(string $key, $property, array $data, ?callable $fn = null)
{
if (isset($data[$key]) && property_exists($this, $property)) {
$value = $fn ? call_user_func($fn, $data[$key]) : $data[$key];
Expand Down
2 changes: 1 addition & 1 deletion src/Common/JsonSchema/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Schema
/** @var Validator */
private $validator;

public function __construct($body, Validator $validator = null)
public function __construct($body, ?Validator $validator = null)
{
$this->body = (object) $body;
$this->validator = $validator ?: new Validator();
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Resource/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Alias
* @param string|null $className A class name for the property value
* @param bool $list Whether value of the property should be treated as a list or not
*/
public function __construct(string $propertyName, string $className = null, bool $list = false)
public function __construct(string $propertyName, ?string $className = null, bool $list = false)
{
$this->isList = $list;
$this->propertyName = $propertyName;
Expand Down
8 changes: 4 additions & 4 deletions src/Common/Resource/Listable.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ interface Listable
* of the marker will depend on the last element returned in the previous response. If a limit is
* provided, the loop will continue up until that point.
*
* @param array $def The operation definition
* @param array $userVals The user values
* @param callable $mapFn an optional callback that will be executed on every resource iteration
* @param array $def The operation definition
* @param array $userVals The user values
* @param callable|null $mapFn an optional callback that will be executed on every resource iteration
*
* @returns \Generator<mixed, static>
*/
public function enumerate(array $def, array $userVals = [], callable $mapFn = null);
public function enumerate(array $def, array $userVals = [], ?callable $mapFn = null);
}
4 changes: 2 additions & 2 deletions src/Common/Resource/OperatorResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function getResourcesKey(): string
*
* @returns \Generator<mixed, static>
*/
public function enumerate(array $def, array $userVals = [], callable $mapFn = null): \Generator
public function enumerate(array $def, array $userVals = [], ?callable $mapFn = null): \Generator
{
$operation = $this->getOperation($def);

Expand Down Expand Up @@ -105,7 +105,7 @@ public function enumerate(array $def, array $userVals = [], callable $mapFn = nu
*
* @return array<self>
*/
public function extractMultipleInstances(ResponseInterface $response, string $key = null): array
public function extractMultipleInstances(ResponseInterface $response, ?string $key = null): array
{
$key = $key ?: $this->getResourcesKey();
$resourcesData = Utils::jsonDecode($response)[$key];
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Service/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function stockAuthHandler(array &$options): void
}
}

private function httpClient(string $baseUrl, HandlerStack $stack, string $serviceType = null, string $microVersion = null): ClientInterface
private function httpClient(string $baseUrl, HandlerStack $stack, ?string $serviceType = null, ?string $microVersion = null): ClientInterface
{
$clientOptions = [
'base_uri' => Utils::normalizeUrl($baseUrl),
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Transport/HandlerStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HandlerStack
/**
* @deprecated use \OpenStack\Common\Transport\HandlerStackFactory::createWithOptions instead
*/
public static function create(callable $handler = null): \GuzzleHttp\HandlerStack
public static function create(?callable $handler = null): \GuzzleHttp\HandlerStack
{
return HandlerStackFactory::create($handler);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Transport/HandlerStackFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HandlerStackFactory
/**
* @deprecated use \OpenStack\Common\Transport\HandlerStackFactory::createWithOptions instead
*/
public static function create(callable $handler = null): HandlerStack
public static function create(?callable $handler = null): HandlerStack
{
$stack = new HandlerStack($handler ?: Utils::chooseHandler());
$stack->push(Middleware::httpErrors(), 'http_errors');
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Transport/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function (ResponseInterface $response) use ($request, $verbosity) {
};
}

public static function authHandler(callable $tokenGenerator, Token $token = null): callable
public static function authHandler(callable $tokenGenerator, ?Token $token = null): callable
{
return function (callable $handler) use ($tokenGenerator, $token) {
return new AuthHandler($handler, $tokenGenerator, $token);
Expand All @@ -49,7 +49,7 @@ public static function history(array &$container): callable
/**
* @codeCoverageIgnore
*/
public static function retry(callable $decider, callable $delay = null): callable
public static function retry(callable $decider, ?callable $delay = null): callable
{
return GuzzleMiddleware::retry($decider, $delay);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Transport/RequestSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RequestSerializer
{
private $jsonSerializer;

public function __construct(JsonSerializer $jsonSerializer = null)
public function __construct(?JsonSerializer $jsonSerializer = null)
{
$this->jsonSerializer = $jsonSerializer ?: new JsonSerializer();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Transport/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function jsonDecode(ResponseInterface $response, bool $assoc = tru
*
* @return array
*/
public static function flattenJson($data, string $key = null)
public static function flattenJson($data, ?string $key = null)
{
return (!empty($data) && $key && isset($data[$key])) ? $data[$key] : $data;
}
Expand Down
40 changes: 20 additions & 20 deletions src/Compute/v2/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function createServer(array $options): Server
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Server>
*/
public function listServers(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator
public function listServers(bool $detailed = false, array $options = [], ?callable $mapFn = null): \Generator
{
$def = (true === $detailed) ? $this->api->getServersDetail() : $this->api->getServers();

Expand Down Expand Up @@ -72,13 +72,13 @@ public function getServer(array $options = []): Server
/**
* List flavors.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors}
* @param callable $mapFn a callable function that will be invoked on every iteration of the list
* @param bool $detailed set to true to fetch flavors' details
* @param array $options {@see \OpenStack\Compute\v2\Api::getFlavors}
* @param callable|null $mapFn a callable function that will be invoked on every iteration of the list
* @param bool $detailed set to true to fetch flavors' details
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Flavor>
*/
public function listFlavors(array $options = [], callable $mapFn = null, bool $detailed = false): \Generator
public function listFlavors(array $options = [], ?callable $mapFn = null, bool $detailed = false): \Generator
{
$def = true === $detailed ? $this->api->getFlavorsDetail() : $this->api->getFlavors();

Expand Down Expand Up @@ -119,7 +119,7 @@ public function createFlavor(array $options = []): Flavor
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Image>
*/
public function listImages(array $options = [], callable $mapFn = null): \Generator
public function listImages(array $options = [], ?callable $mapFn = null): \Generator
{
return $this->model(Image::class)->enumerate($this->api->getImages(), $options, $mapFn);
}
Expand All @@ -143,12 +143,12 @@ public function getImage(array $options = []): Image
/**
* List key pairs.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs}
* @param callable $mapFn a callable function that will be invoked on every iteration of the list
* @param array $options {@see \OpenStack\Compute\v2\Api::getKeyPairs}
* @param callable|null $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Keypair>
*/
public function listKeypairs(array $options = [], callable $mapFn = null): \Generator
public function listKeypairs(array $options = [], ?callable $mapFn = null): \Generator
{
return $this->model(Keypair::class)->enumerate($this->api->getKeypairs(), $options, $mapFn);
}
Expand Down Expand Up @@ -197,14 +197,14 @@ public function getHypervisorStatistics(): HypervisorStatistic
/**
* List hypervisors.
*
* @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only
* the ID, name and links attributes are returned, saving bandwidth.
* @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors}
* @param callable $mapFn a callable function that will be invoked on every iteration of the list
* @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only
* the ID, name and links attributes are returned, saving bandwidth.
* @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors}
* @param callable|null $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Hypervisor>
*/
public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator
public function listHypervisors(bool $detailed = false, array $options = [], ?callable $mapFn = null): \Generator
{
$def = (true === $detailed) ? $this->api->getHypervisorsDetail() : $this->api->getHypervisors();

Expand All @@ -224,12 +224,12 @@ public function getHypervisor(array $options = []): Hypervisor
/**
* List hosts.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getHosts}
* @param callable $mapFn a callable function that will be invoked on every iteration of the list
* @param array $options {@see \OpenStack\Compute\v2\Api::getHosts}
* @param callable|null $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\Host>
*/
public function listHosts(array $options = [], callable $mapFn = null): \Generator
public function listHosts(array $options = [], ?callable $mapFn = null): \Generator
{
return $this->model(Host::class)->enumerate($this->api->getHosts(), $options, $mapFn);
}
Expand All @@ -255,12 +255,12 @@ public function getHost(array $options = []): Host
/**
* List AZs.
*
* @param array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones}
* @param callable $mapFn a callable function that will be invoked on every iteration of the list
* @param array $options {@see \OpenStack\Compute\v2\Api::getAvailabilityZones}
* @param callable|null $mapFn a callable function that will be invoked on every iteration of the list
*
* @return \Generator<mixed, \OpenStack\Compute\v2\Models\AvailabilityZone>
*/
public function listAvailabilityZones(array $options = [], callable $mapFn = null): \Generator
public function listAvailabilityZones(array $options = [], ?callable $mapFn = null): \Generator
{
return $this->model(AvailabilityZone::class)->enumerate($this->api->getAvailabilityZones(), $options, $mapFn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Images/v2/Models/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Schema extends \OpenStack\Common\JsonSchema\Schema
{
public function __construct($data, Validator $validator = null)
public function __construct($data, ?Validator $validator = null)
{
if (!isset($data->type)) {
$data->type = 'object';
Expand Down
2 changes: 1 addition & 1 deletion src/ObjectStore/v1/Models/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function populateFromResponse(ResponseInterface $response): self
*
* @return \Generator<mixed, \OpenStack\ObjectStore\v1\Models\StorageObject>
*/
public function listObjects(array $options = [], callable $mapFn = null): \Generator
public function listObjects(array $options = [], ?callable $mapFn = null): \Generator
{
$options = array_merge($options, ['name' => $this->name, 'format' => 'json']);

Expand Down
6 changes: 3 additions & 3 deletions src/ObjectStore/v1/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getAccount(): Account
*
* @return \Generator<mixed, \OpenStack\ObjectStore\v1\Models\Container>
*/
public function listContainers(array $options = [], callable $mapFn = null): \Generator
public function listContainers(array $options = [], ?callable $mapFn = null): \Generator
{
$options = array_merge($options, ['format' => 'json']);

Expand All @@ -41,9 +41,9 @@ public function listContainers(array $options = [], callable $mapFn = null): \Ge
* Retrieves a Container object and populates its name according to the value provided. Please note that the
* remote API is not contacted.
*
* @param string $name The unique name of the container
* @param string|null $name The unique name of the container
*/
public function getContainer(string $name = null): Container
public function getContainer(?string $name = null): Container
{
return $this->model(Container::class, ['name' => $name]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class OpenStack
* ['requestOptions'] = (array) Guzzle Http request options [OPTIONAL]
* ['cachedToken'] = (array) Cached token credential [OPTIONAL]
*/
public function __construct(array $options = [], Builder $builder = null)
public function __construct(array $options = [], ?Builder $builder = null)
{
$defaults = ['errorVerbosity' => 2];
$options = array_merge($defaults, $options);
Expand Down
Loading