PHP 8.4: Implicitly nullable parameter declarations deprecated

This commit is contained in:
the-djmaze 2024-09-17 15:58:37 +02:00
parent 0263f8fe09
commit 4e3a7a6de2
24 changed files with 44 additions and 44 deletions

View file

@ -472,7 +472,7 @@ class Client implements ClientInterface, IteratorAggregate
* *
* @return Pipeline|array * @return Pipeline|array
*/ */
protected function createPipeline(array $options = null, $callable = null) protected function createPipeline(?array $options = null, $callable = null)
{ {
if (isset($options['atomic']) && $options['atomic']) { if (isset($options['atomic']) && $options['atomic']) {
$class = Atomic::class; $class = Atomic::class;
@ -525,7 +525,7 @@ class Client implements ClientInterface, IteratorAggregate
* *
* @return MultiExecTransaction|array * @return MultiExecTransaction|array
*/ */
protected function createTransaction(array $options = null, $callable = null) protected function createTransaction(?array $options = null, $callable = null)
{ {
$transaction = new MultiExecTransaction($this, $options); $transaction = new MultiExecTransaction($this, $options);
@ -557,7 +557,7 @@ class Client implements ClientInterface, IteratorAggregate
* *
* @return PubSubConsumer|null * @return PubSubConsumer|null
*/ */
protected function createPubSub(array $options = null, $callable = null) protected function createPubSub(?array $options = null, $callable = null)
{ {
if ($this->connection instanceof RelayConnection) { if ($this->connection instanceof RelayConnection) {
$pubsub = new RelayPubSubConsumer($this, $options); $pubsub = new RelayPubSubConsumer($this, $options);

View file

@ -30,7 +30,7 @@ class Consumer extends AbstractConsumer
* @param ClientInterface $client Client instance used by the consumer. * @param ClientInterface $client Client instance used by the consumer.
* @param array $options Options for the consumer initialization. * @param array $options Options for the consumer initialization.
*/ */
public function __construct(ClientInterface $client, array $options = null) public function __construct(ClientInterface $client, ?array $options = null)
{ {
$this->checkCapabilities($client); $this->checkCapabilities($client);

View file

@ -51,7 +51,7 @@ class MultiExec implements ClientContextInterface
* @param ClientInterface $client Client instance used by the transaction. * @param ClientInterface $client Client instance used by the transaction.
* @param array $options Initialization options. * @param array $options Initialization options.
*/ */
public function __construct(ClientInterface $client, array $options = null) public function __construct(ClientInterface $client, ?array $options = null)
{ {
$this->assertClient($client); $this->assertClient($client);

View file

@ -401,7 +401,7 @@ class Client
* @param int $form_content_type HTTP form content type to use * @param int $form_content_type HTTP form content type to use
* @return array * @return array
*/ */
private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART) private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, ?array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
{ {
$curl_options = array( $curl_options = array(
CURLOPT_RETURNTRANSFER => true, CURLOPT_RETURNTRANSFER => true,

View file

@ -64,14 +64,14 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
return $callable($this->getArrayCopy(), ...$arguments); return $callable($this->getArrayCopy(), ...$arguments);
} }
*/ */
public function Slice(int $offset, int $length = null, bool $preserve_keys = false) public function Slice(int $offset, ?int $length = null, bool $preserve_keys = false)
{ {
return new static( return new static(
\array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys) \array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)
); );
} }
public function Crop(int $length = null, int $offset = 0, bool $preserve_keys = false) public function Crop(?int $length = null, int $offset = 0, bool $preserve_keys = false)
{ {
$this->exchangeArray( $this->exchangeArray(
\array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys) \array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)

View file

@ -109,7 +109,7 @@ class Binary
* @return resource|bool * @return resource|bool
*/ */
public static function CreateStream($rStream, public static function CreateStream($rStream,
string $sUtilsDecodeOrEncodeFunctionName = null, string $sFromEncoding = null, string $sToEncoding = null) ?string $sUtilsDecodeOrEncodeFunctionName = null, ?string $sFromEncoding = null, ?string $sToEncoding = null)
{ {
if (null === $sUtilsDecodeOrEncodeFunctionName || !\strlen($sUtilsDecodeOrEncodeFunctionName)) { if (null === $sUtilsDecodeOrEncodeFunctionName || !\strlen($sUtilsDecodeOrEncodeFunctionName)) {
$sUtilsDecodeOrEncodeFunctionName = 'InlineNullDecode'; $sUtilsDecodeOrEncodeFunctionName = 'InlineNullDecode';

View file

@ -285,7 +285,7 @@ trait Folders
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function FolderExpunge(SequenceSet $oUidRange = null) : void public function FolderExpunge(?SequenceSet $oUidRange = null) : void
{ {
$sCmd = 'EXPUNGE'; $sCmd = 'EXPUNGE';
$aArguments = array(); $aArguments = array();

View file

@ -163,7 +163,7 @@ trait Messages
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function MessageAppendStream(string $sFolderName, $rMessageStream, int $iStreamSize, array $aFlagsList = null, int $iDateTime = 0) : ?int public function MessageAppendStream(string $sFolderName, $rMessageStream, int $iStreamSize, ?array $aFlagsList = null, int $iDateTime = 0) : ?int
{ {
if (!\is_resource($rMessageStream)) { if (!\is_resource($rMessageStream)) {
throw new \InvalidArgumentException('$rMessageStream must be a resource'); throw new \InvalidArgumentException('$rMessageStream must be a resource');
@ -225,7 +225,7 @@ trait Messages
/** /**
* RFC 3502 MULTIAPPEND * RFC 3502 MULTIAPPEND
public function MessageAppendStreams(string $sFolderName, $rMessageAppendStream, int $iStreamSize, array $aFlagsList = null, int &$iUid = null, int $iDateTime = 0) : ?int public function MessageAppendStreams(string $sFolderName, $rMessageAppendStream, int $iStreamSize, ?array $aFlagsList = null, ?int &$iUid = null, int $iDateTime = 0) : ?int
*/ */
/** /**
@ -311,7 +311,7 @@ trait Messages
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function MessageReplaceStream(string $sFolderName, int $iUid, $rMessageStream, int $iStreamSize, array $aFlagsList = null, int $iDateTime = 0) : ?int public function MessageReplaceStream(string $sFolderName, int $iUid, $rMessageStream, int $iStreamSize, ?array $aFlagsList = null, int $iDateTime = 0) : ?int
{ {
if (1 > $iUid || !$this->hasCapability('REPLACE')) { if (1 > $iUid || !$this->hasCapability('REPLACE')) {
$this->FolderSelect($sFolderName); $this->FolderSelect($sFolderName);
@ -412,7 +412,7 @@ trait Messages
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function MessageESearch(string $sSearchCriterias, array $aSearchReturn = null, bool $bReturnUid = true, string $sLimit = '') : array public function MessageESearch(string $sSearchCriterias, ?array $aSearchReturn = null, bool $bReturnUid = true, string $sLimit = '') : array
{ {
$oESearch = new \MailSo\Imap\Requests\ESEARCH($this); $oESearch = new \MailSo\Imap\Requests\ESEARCH($this);
$oESearch->sCriterias = $sSearchCriterias ?: 'ALL'; $oESearch->sCriterias = $sSearchCriterias ?: 'ALL';

View file

@ -36,7 +36,7 @@ class Folder implements \JsonSerializable
/** /**
* @throws \ValueError * @throws \ValueError
*/ */
function __construct(string $sFullName, string $sDelimiter = null, array $aAttributes = array()) function __construct(string $sFullName, ?string $sDelimiter = null, array $aAttributes = array())
{ {
if (!\strlen($sFullName)) { if (!\strlen($sFullName)) {
throw new \ValueError; throw new \ValueError;

View file

@ -466,7 +466,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
protected function streamResponse(string $sEndTag = null) : void protected function streamResponse(?string $sEndTag = null) : void
{ {
try { try {
if (\is_resource($this->ConnectionResource())) { if (\is_resource($this->ConnectionResource())) {
@ -488,7 +488,7 @@ class ImapClient extends \MailSo\Net\NetClient
} }
} }
protected function getResponse(string $sEndTag = null) : ResponseCollection protected function getResponse(?string $sEndTag = null) : ResponseCollection
{ {
try { try {
$oResult = new ResponseCollection; $oResult = new ResponseCollection;

View file

@ -279,7 +279,7 @@ class MailClient
return ($aFetchResponse && 1 === \count($aFetchResponse)); return ($aFetchResponse && 1 === \count($aFetchResponse));
} }
public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, array $aAppendFlags = null) : int public function MessageAppendFile(string $sMessageFileName, string $sFolderToSave, ?array $aAppendFlags = null) : int
{ {
if (!\is_file($sMessageFileName) || !\is_readable($sMessageFileName)) { if (!\is_file($sMessageFileName) || !\is_readable($sMessageFileName)) {
throw new \ValueError; throw new \ValueError;
@ -349,7 +349,7 @@ class MailClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, ?SequenceSet $oRange = null) : array
{ {
if ($oRange) { if ($oRange) {
// $aInfo = $this->oImapClient->FolderExamine($sFolderName)->jsonSerialize(); // $aInfo = $this->oImapClient->FolderExamine($sFolderName)->jsonSerialize();

View file

@ -401,7 +401,7 @@ class Client
* @param int $form_content_type HTTP form content type to use * @param int $form_content_type HTTP form content type to use
* @return array * @return array
*/ */
private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART) private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, ?array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
{ {
$curl_options = array( $curl_options = array(
CURLOPT_RETURNTRANSFER => true, CURLOPT_RETURNTRANSFER => true,

View file

@ -439,7 +439,7 @@ trait UserAuth
/** /**
* @throws \RainLoop\Exceptions\ClientException * @throws \RainLoop\Exceptions\ClientException
*/ */
protected function imapConnect(Account $oAccount, bool $bAuthLog = false, \MailSo\Imap\ImapClient $oImapClient = null): void protected function imapConnect(Account $oAccount, bool $bAuthLog = false, ?\MailSo\Imap\ImapClient $oImapClient = null): void
{ {
try { try {
if (!$oImapClient) { if (!$oImapClient) {

View file

@ -35,7 +35,7 @@ abstract class Api
return $oConfig; return $oConfig;
} }
public static function getCSP(string $sScriptNonce = null) : \SnappyMail\HTTP\CSP public static function getCSP(?string $sScriptNonce = null) : \SnappyMail\HTTP\CSP
{ {
$oConfig = static::Config(); $oConfig = static::Config();
$CSP = new \SnappyMail\HTTP\CSP(\trim($oConfig->Get('security', 'content_security_policy', ''))); $CSP = new \SnappyMail\HTTP\CSP(\trim($oConfig->Get('security', 'content_security_policy', '')));

View file

@ -55,7 +55,7 @@ class Domain extends AbstractProvider
return $this->oDriver->GetList($bIncludeAliases); return $this->oDriver->GetList($bIncludeAliases);
} }
public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, string $sNameForTest = null) : ?\RainLoop\Model\Domain public function LoadOrCreateNewFromAction(\RainLoop\Actions $oActions, ?string $sNameForTest = null) : ?\RainLoop\Model\Domain
{ {
$sName = \mb_strtolower((string) $oActions->GetActionParam('name', '')); $sName = \mb_strtolower((string) $oActions->GetActionParam('name', ''));
if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*')) { if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*')) {

View file

@ -251,7 +251,7 @@ abstract class Service
return true; return true;
} }
private static function setCSP(string $sScriptNonce = null) : void private static function setCSP(?string $sScriptNonce = null) : void
{ {
Api::getCSP($sScriptNonce)->setHeaders(); Api::getCSP($sScriptNonce)->setHeaders();
} }

View file

@ -60,7 +60,7 @@ abstract class Crypt
public static function Decrypt(array $data, public static function Decrypt(array $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : mixed */ ) /* : mixed */
{ {
if (3 === \count($data) && isset($data[0], $data[1], $data[2]) && \strlen($data[0])) { if (3 === \count($data) && isset($data[0], $data[1], $data[2]) && \strlen($data[0])) {
@ -85,7 +85,7 @@ abstract class Crypt
public static function DecryptFromJSON(string $data, public static function DecryptFromJSON(string $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : mixed */ ) /* : mixed */
{ {
$data = static::jsonDecode($data); $data = static::jsonDecode($data);
@ -98,7 +98,7 @@ abstract class Crypt
public static function DecryptUrlSafe(string $data, public static function DecryptUrlSafe(string $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : mixed */ ) /* : mixed */
{ {
$data = \explode('.', $data); $data = \explode('.', $data);
@ -113,7 +113,7 @@ abstract class Crypt
#[\SensitiveParameter] #[\SensitiveParameter]
$data, $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : array ) : array
{ {
$data = \json_encode($data); $data = \json_encode($data);
@ -151,7 +151,7 @@ abstract class Crypt
#[\SensitiveParameter] #[\SensitiveParameter]
$data, $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : string ) : string
{ {
return \json_encode(\array_map('base64_encode', static::Encrypt($data, $key))); return \json_encode(\array_map('base64_encode', static::Encrypt($data, $key)));
@ -161,7 +161,7 @@ abstract class Crypt
#[\SensitiveParameter] #[\SensitiveParameter]
$data, $data,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : string ) : string
{ {
return \implode('.', \array_map('MailSo\\Base\\Utils::UrlSafeBase64Encode', static::Encrypt($data, $key))); return \implode('.', \array_map('MailSo\\Base\\Utils::UrlSafeBase64Encode', static::Encrypt($data, $key)));
@ -169,7 +169,7 @@ abstract class Crypt
public static function SodiumDecrypt(string $data, string $nonce, public static function SodiumDecrypt(string $data, string $nonce,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : string|false */ ) /* : string|false */
{ {
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) { if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
@ -188,7 +188,7 @@ abstract class Crypt
string $data, string $data,
string $nonce, string $nonce,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : string ) : string
{ {
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) { if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
@ -208,7 +208,7 @@ abstract class Crypt
public static function OpenSSLDecrypt(string $data, string $iv, public static function OpenSSLDecrypt(string $data, string $iv,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : string|false */ ) /* : string|false */
{ {
if (!$data || !$iv) { if (!$data || !$iv) {
@ -235,7 +235,7 @@ abstract class Crypt
string $data, string $data,
string $iv, string $iv,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : string ) : string
{ {
if (!$data || !$iv) { if (!$data || !$iv) {
@ -263,7 +263,7 @@ abstract class Crypt
public static function XxteaDecrypt(string $data, string $salt, public static function XxteaDecrypt(string $data, string $salt,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) /* : mixed */ ) /* : mixed */
{ {
if (!$data || !$salt) { if (!$data || !$salt) {
@ -280,7 +280,7 @@ abstract class Crypt
string $data, string $data,
string $salt, string $salt,
#[\SensitiveParameter] #[\SensitiveParameter]
string $key = null ?string $key = null
) : string ) : string
{ {
if (!$data || !$salt) { if (!$data || !$salt) {

View file

@ -63,7 +63,7 @@ class Client
* *
* If the specified url is relative, it will be expanded based on the base url. * If the specified url is relative, it will be expanded based on the base url.
*/ */
public function request(string $method, string $url = '', string $body = null, array $headers = array()) : \SnappyMail\HTTP\Response public function request(string $method, string $url = '', ?string $body = null, array $headers = array()) : \SnappyMail\HTTP\Response
{ {
if (!\preg_match('@^(https?:)?//@', $url)) { if (!\preg_match('@^(https?:)?//@', $url)) {
// If the url starts with a slash, we must calculate the url based off // If the url starts with a slash, we must calculate the url based off

View file

@ -66,7 +66,7 @@ class Exception extends \Exception
511 => 'Network Authentication Required', 511 => 'Network Authentication Required',
); );
function __construct(string $message = "", int $code = 0, Response $response = null) function __construct(string $message = "", int $code = 0, ?Response $response = null)
{ {
if ($response) { if ($response) {
if (\in_array($code, array(301, 302, 303, 307))) { if (\in_array($code, array(301, 302, 303, 307))) {

View file

@ -12,7 +12,7 @@ class Response
$headers = array(), # The headers returned from the final_uri $headers = array(), # The headers returned from the final_uri
$body; # The body returned from the final_uri $body; # The body returned from the final_uri
function __construct(string $request_uri, int $status = 0, array $headers = null, $body = null) function __construct(string $request_uri, int $status = 0, ?array $headers = null, $body = null)
{ {
if ($headers) { if ($headers) {
$name = null; $name = null;

View file

@ -16,7 +16,7 @@ class Exif
ORIENTATION_RIGHTBOTTOM = 7, ORIENTATION_RIGHTBOTTOM = 7,
ORIENTATION_LEFTBOTTOM = 8; ORIENTATION_LEFTBOTTOM = 8;
*/ */
public static function getImageOrientation(string &$data, array $image_info = null) : int public static function getImageOrientation(string &$data, ?array $image_info = null) : int
{ {
$image_info = empty($image_info['mime']) ? \getimagesizefromstring($data) : $image_info; $image_info = empty($image_info['mime']) ? \getimagesizefromstring($data) : $image_info;
if (!empty($image_info['mime']) && \IMG_JPG == $image_info[2] && \is_callable('exif_read_data')) { if (!empty($image_info['mime']) && \IMG_JPG == $image_info[2] && \is_callable('exif_read_data')) {

View file

@ -26,7 +26,7 @@ abstract class JWT
* @param int $timestamp Allow the current timestamp to be specified. default time() * @param int $timestamp Allow the current timestamp to be specified. default time()
* @param int $leeway When checking nbf (Not Before) Claim, iat (Issued At) Claim or expiration times, we want to provide some extra leeway time to account for clock skew. * @param int $leeway When checking nbf (Not Before) Claim, iat (Issued At) Claim or expiration times, we want to provide some extra leeway time to account for clock skew.
*/ */
public static function decode(string $jwt, $key, int $timestamp = null, int $leeway = 0) : object public static function decode(string $jwt, $key, ?int $timestamp = null, int $leeway = 0) : object
{ {
$timestamp = $timestamp ?: \time(); $timestamp = $timestamp ?: \time();

View file

@ -81,7 +81,7 @@ class TAR
} }
} }
public function addFile($fileinfo, string $name = null) : bool public function addFile($fileinfo, ?string $name = null) : bool
{ {
if (!($fileinfo instanceof \SplFileInfo)) { if (!($fileinfo instanceof \SplFileInfo)) {
$fileinfo = new \SplFileInfo($fileinfo); $fileinfo = new \SplFileInfo($fileinfo);
@ -174,7 +174,7 @@ class TAR
return true; return true;
} }
public function addDir(string $dirname, \SplFileInfo $fileinfo = null) : void public function addDir(string $dirname, ?\SplFileInfo $fileinfo = null) : void
{ {
$this->writeEntryHeader( $this->writeEntryHeader(
\rtrim(\strtr($dirname, '\\', '/'), '/') . '/', \rtrim(\strtr($dirname, '\\', '/'), '/') . '/',

View file

@ -102,7 +102,7 @@ class ZIP
} }
} }
public function addFile($file, string $name = null) : bool public function addFile($file, ?string $name = null) : bool
{ {
if (\is_file($file) && $fp = new \SplFileObject($file, 'rb')) { if (\is_file($file) && $fp = new \SplFileObject($file, 'rb')) {
return $this->addFromStream($fp, $name ?: \basename($file)); return $this->addFromStream($fp, $name ?: \basename($file));