Skip to content

Commit

Permalink
Apply method_argument_space and nullable_type_declaration_for_default…
Browse files Browse the repository at this point in the history
…_null_value
  • Loading branch information
deviantintegral committed Feb 20, 2024
1 parent 00c07cc commit 2860d7d
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/AuthenticatedClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AuthenticatedClient implements ClientInterface
* @param UserSession $userSession The user associated with this client.
* @param IdInterface $account (optional) The account to use as the account context for requests.
*/
public function __construct(Client $client, UserSession $userSession, IdInterface $account = null)
public function __construct(Client $client, UserSession $userSession, ?IdInterface $account = null)
{
$this->client = $client;
$this->userSession = $userSession;
Expand Down Expand Up @@ -94,7 +94,7 @@ public function getConfig($option = null)
*
* @param int|null $duration The duration in seconds, or null to not use a specific lifetime.
*/
public function setTokenDuration(int $duration = null): void
public function setTokenDuration(?int $duration = null): void
{
$this->duration = $duration;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/Adapter/PHPArray/ArrayCachePool.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ function (string $key) use ($default) {
$item = $this->cache->getItem($key);

return $item->isHit() ? $item->get() : $default;
}
, $keys);
}, $keys);
}

public function setMultiple($values, $ttl = null): bool
Expand Down
2 changes: 1 addition & 1 deletion src/DataService/CachingPhpDocExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CachingPhpDocExtractor implements PropertyDescriptionExtractorInterface, P
* @param string[]|null $accessorPrefixes
* @param string[]|null $arrayMutatorPrefixes
*/
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
public function __construct(?DocBlockFactoryInterface $docBlockFactory = null, ?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null)
{
if (!class_exists(DocBlockFactory::class)) {
throw new \RuntimeException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed.', self::class));
Expand Down
6 changes: 3 additions & 3 deletions src/DataService/DataObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DataObjectFactory
* @param \Lullabot\Mpx\AuthenticatedClient $authenticatedClient A client to make authenticated MPX calls.
* @param CacheItemPoolInterface|null $cacheItemPool (optional) Cache to store API metadata.
*/
public function __construct(DiscoveredDataService $dataService, AuthenticatedClient $authenticatedClient, CacheItemPoolInterface $cacheItemPool = null)
public function __construct(DiscoveredDataService $dataService, AuthenticatedClient $authenticatedClient, ?CacheItemPoolInterface $cacheItemPool = null)
{
$this->authenticatedClient = $authenticatedClient;
$this->dataService = $dataService;
Expand Down Expand Up @@ -201,7 +201,7 @@ public function load(UriInterface $uri, array $options = []): PromiseInterface
*
* @return ObjectListIterator An iterator over the full result set.
*/
public function select(ObjectListQuery $objectListQuery = null, array $options = []): ObjectListIterator
public function select(?ObjectListQuery $objectListQuery = null, array $options = []): ObjectListIterator
{
return new ObjectListIterator($this->selectRequest($objectListQuery, $options));
}
Expand All @@ -217,7 +217,7 @@ public function select(ObjectListQuery $objectListQuery = null, array $options =
*
* @return PromiseInterface A promise to return an ObjectList.
*/
public function selectRequest(ObjectListQuery $objectListQuery = null, array $options = []): PromiseInterface
public function selectRequest(?ObjectListQuery $objectListQuery = null, array $options = []): PromiseInterface
{
if (!$objectListQuery) {
$objectListQuery = new ObjectListQuery();
Expand Down
2 changes: 1 addition & 1 deletion src/DataService/DataServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(private readonly DataServiceDiscovery $discovery)
*
* @return static
*/
public static function basicDiscovery(CustomFieldManager $customFieldManager = null)
public static function basicDiscovery(?CustomFieldManager $customFieldManager = null)
{
if (!$customFieldManager) {
$customFieldManager = CustomFieldManager::basicDiscovery();
Expand Down
2 changes: 1 addition & 1 deletion src/DataService/DateTime/ConcreteDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(private readonly \DateTime $dateTime)
*
* @see http://php.net/manual/en/datetime.construct.php
*/
public static function fromString($time = 'now', \DateTimeZone $timezone = null): self
public static function fromString($time = 'now', ?\DateTimeZone $timezone = null): self
{
return new static(new \DateTime($time, $timezone));
}
Expand Down
2 changes: 1 addition & 1 deletion src/DataService/NotificationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class NotificationListener
* @param string $clientId A string to identify this client in debugging.
* @param CacheItemPoolInterface|null $cacheItemPool (optional) The cache for API metadata.
*/
public function __construct(AuthenticatedClient $session, DiscoveredDataService $service, private readonly string $clientId, CacheItemPoolInterface $cacheItemPool = null)
public function __construct(AuthenticatedClient $session, DiscoveredDataService $service, private readonly string $clientId, ?CacheItemPoolInterface $cacheItemPool = null)
{
$this->authenticatedClient = $session;
$this->service = $service;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClientException extends GuzzleClientException implements MpxExceptionInter
* @param \Exception|null $previous (optional) The previous exception.
* @param array $handlerContext (optional) Custom HTTP handler context, if available.
*/
public function __construct(RequestInterface $request, ResponseInterface $response, \Exception $previous = null, array $handlerContext = [])
public function __construct(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null, array $handlerContext = [])
{
$message = $this->parseResponse($response);
parent::__construct($message, $request, $response, $previous, $handlerContext);
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/MpxExceptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MpxExceptionFactory
public static function create(
RequestInterface $request,
ResponseInterface $response,
\Exception $previous = null,
?\Exception $previous = null,
array $ctx = []
): ClientException|ServerException {
$data = \GuzzleHttp\Utils::jsonDecode($response->getBody(), true);
Expand All @@ -30,7 +30,7 @@ public static function create(
/**
* Create a new MPX API exception from a notification.
*/
public static function createFromNotificationException(RequestInterface $request, ResponseInterface $response, \Exception $previous = null, array $ctx = []): ClientException|ServerException
public static function createFromNotificationException(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null, array $ctx = []): ClientException|ServerException
{
$data = \GuzzleHttp\Utils::jsonDecode($response->getBody(), true);
ServerException::validateNotificationData($data);
Expand All @@ -45,7 +45,7 @@ public static function createFromNotificationException(RequestInterface $request
*/
private static function createException(RequestInterface $request,
ResponseInterface $altered,
\Exception $previous = null,
?\Exception $previous = null,
array $ctx = []
): ClientException|ServerException {
if ($altered->getStatusCode() >= 400 && $altered->getStatusCode() < 500) {
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ServerException extends GuzzleServerException implements MpxExceptionInter
* @param \Exception|null $previous (optional) The previous exception.
* @param array $handlerContext (optional) Custom HTTP handler context, if available.
*/
public function __construct(RequestInterface $request, ResponseInterface $response, \Exception $previous = null, array $handlerContext = [])
public function __construct(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null, array $handlerContext = [])
{
$message = $this->parseResponse($response);
parent::__construct($message, $request, $response, $previous, $handlerContext);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/TokenNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TokenNotFoundException extends \RuntimeException
* @param int $code The exception code.
* @param \Throwable|null $previous The previous exception, if available.
*/
public function __construct(UserSession $userSession, int $code = 0, \Throwable $previous = null)
public function __construct(UserSession $userSession, int $code = 0, ?\Throwable $previous = null)
{
parent::__construct(sprintf('Token not found for %s.', $userSession->getUser()->getMpxUsername()), $code, $previous);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Normalizer/UnixMillisecondNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public function getSupportedTypes(?string $format): array
/**
* @throws InvalidArgumentException
*/
public function normalize(mixed $object, string $format = null, array $context = []): string
public function normalize(mixed $object, ?string $format = null, array $context = []): string
{
return $this->decorated->normalize($object, $format, $context);
}

public function supportsNormalization(mixed $data, string $format = null): bool
public function supportsNormalization(mixed $data, ?string $format = null): bool
{
return $this->decorated->supportsNormalization($data, $format);
}

public function denormalize(mixed $data, string $type, string $format = null, array $context = []): ConcreteDateTime
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): ConcreteDateTime
{
if (!\is_int($data)) {
throw new NotNormalizableValueException('The data is not an integer, you should pass an integer representing the unix time in milliseconds.');
Expand All @@ -80,7 +80,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar
return new ConcreteDateTime($date);
}

public function supportsDenormalization(mixed $data, string $type, string $format = null): bool
public function supportsDenormalization(mixed $data, string $type, ?string $format = null): bool
{
return isset(self::$supportedTypes[$type]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/AccessManagement/ResolveBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class ResolveBase
* @param AuthenticatedClient $authenticatedClient The client used to access mpx.
* @param CacheItemPoolInterface|null $cache (optional) The cache to store responses in. Defaults to an array cache.
*/
public function __construct(AuthenticatedClient $authenticatedClient, CacheItemPoolInterface $cache = null)
public function __construct(AuthenticatedClient $authenticatedClient, ?CacheItemPoolInterface $cache = null)
{
$this->authenticatedClient = $authenticatedClient;

Expand Down
6 changes: 3 additions & 3 deletions src/Service/IdentityManagement/UserSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class UserSession
*
* @see \Psr\Log\NullLogger To disable logging of token requests.
*/
public function __construct(UserInterface $user, Client $client, PersistingStoreInterface $store = null, TokenCachePool $tokenCachePool = null)
public function __construct(UserInterface $user, Client $client, ?PersistingStoreInterface $store = null, ?TokenCachePool $tokenCachePool = null)
{
$this->user = $user;
$this->client = $client;
Expand All @@ -92,7 +92,7 @@ public function __construct(UserInterface $user, Client $client, PersistingStore
*
* @return Token A valid mpx authentication token.
*/
public function acquireToken(int $duration = null, bool $reset = false): Token
public function acquireToken(?int $duration = null, bool $reset = false): Token
{
if ($reset) {
$this->tokenCachePool->deleteToken($this);
Expand Down Expand Up @@ -169,7 +169,7 @@ public function signOut()
*
* @return \Lullabot\Mpx\Token The token.
*/
protected function signInWithLock(int $duration = null): Token
protected function signInWithLock(?int $duration = null): Token
{
if ($this->store) {
$factory = new LockFactory($this->store);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Fixtures/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function getA()
/**
* B.
*/
public function setB(ParentDummy $parent = null)
public function setB(?ParentDummy $parent = null)
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/Unit/DataService/CachingPhpDocExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testParamTagTypeIsOmitted()
/**
* @dataProvider typesWithCustomPrefixesProvider
*/
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
{
$customExtractor = new CachingPhpDocExtractor(null, ['add', 'remove'], ['is', 'can']);

Expand All @@ -46,7 +46,7 @@ public function testExtractTypesWithCustomPrefixes($property, array $type = null
/**
* @dataProvider typesWithNoPrefixesProvider
*/
public function testExtractTypesWithNoPrefixes($property, array $type = null)
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
{
$noPrefixExtractor = new CachingPhpDocExtractor(null, [], [], []);

Expand Down

0 comments on commit 2860d7d

Please sign in to comment.