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

Bring lib/ up to php8.4 standards #466

Merged
merged 1 commit into from
Nov 28, 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
1 change: 0 additions & 1 deletion lib/Exceptions/CurlException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Safe\Exceptions;

class CurlException extends \Exception implements SafeExceptionInterface
Expand Down
1 change: 0 additions & 1 deletion lib/Exceptions/JsonException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Safe\Exceptions;

class JsonException extends \JsonException implements SafeExceptionInterface
Expand Down
1 change: 0 additions & 1 deletion lib/Exceptions/OpensslException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Safe\Exceptions;

class OpensslException extends \Exception implements SafeExceptionInterface
Expand Down
3 changes: 1 addition & 2 deletions lib/Exceptions/PcreException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Safe\Exceptions;

class PcreException extends \Exception implements SafeExceptionInterface
Expand All @@ -15,7 +14,7 @@ public static function createFromPhpError(): self
PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR',
];
$errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: '.preg_last_error();
$errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: ' . preg_last_error();
return new self($errMsg, \preg_last_error());
}
}
2 changes: 0 additions & 2 deletions lib/Exceptions/SafeExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace Safe\Exceptions;

interface SafeExceptionInterface extends \Throwable
{

}
1 change: 1 addition & 0 deletions lib/Exceptions/SimplexmlException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Safe\Exceptions;

class SimplexmlException extends \ErrorException implements SafeExceptionInterface
Expand Down
12 changes: 6 additions & 6 deletions lib/special_cases.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file contains all the functions that could not be dealt with automatically using the code generator.
* If you add a function in this list, do not forget to add it in the generator/config/specialCasesFunctions.php
Expand All @@ -7,9 +8,6 @@

namespace Safe;

use Safe\Exceptions\FilesystemException;
use const PREG_NO_ERROR;

use Safe\Exceptions\MiscException;
use Safe\Exceptions\PosixException;
use Safe\Exceptions\SocketsException;
Expand All @@ -19,6 +17,9 @@
use Safe\Exceptions\OpensslException;
use Safe\Exceptions\PcreException;
use Safe\Exceptions\SimplexmlException;
use Safe\Exceptions\FilesystemException;

use const PREG_NO_ERROR;

/**
* Wrapper for json_decode that throws when an error occurs.
Expand Down Expand Up @@ -157,7 +158,7 @@ function apcu_fetch($key)
* @throws PcreException
*
*/
function preg_replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null)
function preg_replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null)
{
error_clear_last();
$result = \preg_replace($pattern, $replacement, $subject, $limit, $count);
Expand Down Expand Up @@ -394,7 +395,6 @@ function fputcsv($stream, array $fields, string $separator = ",", string $enclos
{
error_clear_last();
if (PHP_VERSION_ID >= 80100) {
/** @phpstan-ignore-next-line */
$result = \fputcsv($stream, $fields, $separator, $enclosure, $escape, $eol);
} else {
$result = \fputcsv($stream, $fields, $separator, $enclosure, $escape);
Expand Down Expand Up @@ -431,7 +431,7 @@ function fputcsv($stream, array $fields, string $separator = ",", string $enclos
* @throws FilesystemException
*
*/
function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
function fgetcsv($stream, ?int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
{
error_clear_last();
$safeResult = \fgetcsv($stream, $length, $separator, $enclosure, $escape);
Expand Down
Loading