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

View file

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

View file

@ -401,7 +401,7 @@ class Client
* @param int $form_content_type HTTP form content type to use
* @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(
CURLOPT_RETURNTRANSFER => true,

View file

@ -64,14 +64,14 @@ abstract class Collection extends \ArrayObject implements \JsonSerializable
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(
\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(
\array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)

View file

@ -109,7 +109,7 @@ class Binary
* @return resource|bool
*/
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)) {
$sUtilsDecodeOrEncodeFunctionName = 'InlineNullDecode';

View file

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

View file

@ -163,7 +163,7 @@ trait Messages
* @throws \MailSo\Net\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)) {
throw new \InvalidArgumentException('$rMessageStream must be a resource');
@ -225,7 +225,7 @@ trait Messages
/**
* 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\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')) {
$this->FolderSelect($sFolderName);
@ -412,7 +412,7 @@ trait Messages
* @throws \MailSo\Net\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->sCriterias = $sSearchCriterias ?: 'ALL';

View file

@ -36,7 +36,7 @@ class Folder implements \JsonSerializable
/**
* @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)) {
throw new \ValueError;

View file

@ -466,7 +466,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\*
*/
protected function streamResponse(string $sEndTag = null) : void
protected function streamResponse(?string $sEndTag = null) : void
{
try {
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 {
$oResult = new ResponseCollection;

View file

@ -279,7 +279,7 @@ class MailClient
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)) {
throw new \ValueError;
@ -349,7 +349,7 @@ class MailClient
* @throws \MailSo\Net\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) {
// $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
* @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(
CURLOPT_RETURNTRANSFER => true,

View file

@ -439,7 +439,7 @@ trait UserAuth
/**
* @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 {
if (!$oImapClient) {

View file

@ -35,7 +35,7 @@ abstract class Api
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();
$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);
}
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', ''));
if (\strlen($sName) && $sNameForTest && !\str_contains($sName, '*')) {

View file

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

View file

@ -60,7 +60,7 @@ abstract class Crypt
public static function Decrypt(array $data,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : mixed */
{
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,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : mixed */
{
$data = static::jsonDecode($data);
@ -98,7 +98,7 @@ abstract class Crypt
public static function DecryptUrlSafe(string $data,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : mixed */
{
$data = \explode('.', $data);
@ -113,7 +113,7 @@ abstract class Crypt
#[\SensitiveParameter]
$data,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : array
{
$data = \json_encode($data);
@ -151,7 +151,7 @@ abstract class Crypt
#[\SensitiveParameter]
$data,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : string
{
return \json_encode(\array_map('base64_encode', static::Encrypt($data, $key)));
@ -161,7 +161,7 @@ abstract class Crypt
#[\SensitiveParameter]
$data,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : string
{
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,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : string|false */
{
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
@ -188,7 +188,7 @@ abstract class Crypt
string $data,
string $nonce,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : string
{
if (!\is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
@ -208,7 +208,7 @@ abstract class Crypt
public static function OpenSSLDecrypt(string $data, string $iv,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : string|false */
{
if (!$data || !$iv) {
@ -235,7 +235,7 @@ abstract class Crypt
string $data,
string $iv,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : string
{
if (!$data || !$iv) {
@ -263,7 +263,7 @@ abstract class Crypt
public static function XxteaDecrypt(string $data, string $salt,
#[\SensitiveParameter]
string $key = null
?string $key = null
) /* : mixed */
{
if (!$data || !$salt) {
@ -280,7 +280,7 @@ abstract class Crypt
string $data,
string $salt,
#[\SensitiveParameter]
string $key = null
?string $key = null
) : string
{
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.
*/
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 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',
);
function __construct(string $message = "", int $code = 0, Response $response = null)
function __construct(string $message = "", int $code = 0, ?Response $response = null)
{
if ($response) {
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
$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) {
$name = null;

View file

@ -16,7 +16,7 @@ class Exif
ORIENTATION_RIGHTBOTTOM = 7,
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;
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 $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();

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)) {
$fileinfo = new \SplFileInfo($fileinfo);
@ -174,7 +174,7 @@ class TAR
return true;
}
public function addDir(string $dirname, \SplFileInfo $fileinfo = null) : void
public function addDir(string $dirname, ?\SplFileInfo $fileinfo = null) : void
{
$this->writeEntryHeader(
\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')) {
return $this->addFromStream($fp, $name ?: \basename($file));