Skip to content

Commit f87af02

Browse files
shishstaabm
authored andcommitted
Bring lib/ up to php8.4 standards
(Breaking the diff against shish/safe into smaller parts for easier reviewing)
1 parent 097c8e5 commit f87af02

File tree

7 files changed

+8
-13
lines changed

7 files changed

+8
-13
lines changed

lib/Exceptions/CurlException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Safe\Exceptions;
54

65
class CurlException extends \Exception implements SafeExceptionInterface

lib/Exceptions/JsonException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Safe\Exceptions;
54

65
class JsonException extends \JsonException implements SafeExceptionInterface

lib/Exceptions/OpensslException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Safe\Exceptions;
54

65
class OpensslException extends \Exception implements SafeExceptionInterface

lib/Exceptions/PcreException.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace Safe\Exceptions;
54

65
class PcreException extends \Exception implements SafeExceptionInterface
@@ -15,7 +14,7 @@ public static function createFromPhpError(): self
1514
PREG_BAD_UTF8_OFFSET_ERROR => 'PREG_BAD_UTF8_OFFSET_ERROR',
1615
PREG_JIT_STACKLIMIT_ERROR => 'PREG_JIT_STACKLIMIT_ERROR',
1716
];
18-
$errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: '.preg_last_error();
17+
$errMsg = $errorMap[preg_last_error()] ?? 'Unknown PCRE error: ' . preg_last_error();
1918
return new self($errMsg, \preg_last_error());
2019
}
2120
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?php
22

3-
43
namespace Safe\Exceptions;
54

65
interface SafeExceptionInterface extends \Throwable
76
{
8-
97
}

lib/Exceptions/SimplexmlException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Safe\Exceptions;
34

45
class SimplexmlException extends \ErrorException implements SafeExceptionInterface

lib/special_cases.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file contains all the functions that could not be dealt with automatically using the code generator.
45
* If you add a function in this list, do not forget to add it in the generator/config/specialCasesFunctions.php
@@ -7,9 +8,6 @@
78

89
namespace Safe;
910

10-
use Safe\Exceptions\FilesystemException;
11-
use const PREG_NO_ERROR;
12-
1311
use Safe\Exceptions\MiscException;
1412
use Safe\Exceptions\PosixException;
1513
use Safe\Exceptions\SocketsException;
@@ -19,6 +17,9 @@
1917
use Safe\Exceptions\OpensslException;
2018
use Safe\Exceptions\PcreException;
2119
use Safe\Exceptions\SimplexmlException;
20+
use Safe\Exceptions\FilesystemException;
21+
22+
use const PREG_NO_ERROR;
2223

2324
/**
2425
* Wrapper for json_decode that throws when an error occurs.
@@ -157,7 +158,7 @@ function apcu_fetch($key)
157158
* @throws PcreException
158159
*
159160
*/
160-
function preg_replace($pattern, $replacement, $subject, int $limit = -1, int &$count = null)
161+
function preg_replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null)
161162
{
162163
error_clear_last();
163164
$result = \preg_replace($pattern, $replacement, $subject, $limit, $count);
@@ -394,7 +395,6 @@ function fputcsv($stream, array $fields, string $separator = ",", string $enclos
394395
{
395396
error_clear_last();
396397
if (PHP_VERSION_ID >= 80100) {
397-
/** @phpstan-ignore-next-line */
398398
$result = \fputcsv($stream, $fields, $separator, $enclosure, $escape, $eol);
399399
} else {
400400
$result = \fputcsv($stream, $fields, $separator, $enclosure, $escape);
@@ -431,7 +431,7 @@ function fputcsv($stream, array $fields, string $separator = ",", string $enclos
431431
* @throws FilesystemException
432432
*
433433
*/
434-
function fgetcsv($stream, int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
434+
function fgetcsv($stream, ?int $length = null, string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
435435
{
436436
error_clear_last();
437437
$safeResult = \fgetcsv($stream, $length, $separator, $enclosure, $escape);

0 commit comments

Comments
 (0)