Skip to content

Commit

Permalink
Fixes for PHP 8.4 deprecation (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Mar 31, 2024
1 parent 45b30f9 commit 0423dd4
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
->setRules([
'@PHP71Migration:risky' => true,
'@PHPUnit75Migration:risky' => true,
'@PSR12:risky' => true,
'@Symfony' => true,
'global_namespace_import' => false,
'no_superfluous_phpdoc_tags' => [
Expand Down
2 changes: 1 addition & 1 deletion src/CachingStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class CachingStream implements StreamInterface
*/
public function __construct(
StreamInterface $stream,
StreamInterface $target = null
?StreamInterface $target = null
) {
$this->remoteStream = $stream;
$this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
Expand Down
6 changes: 3 additions & 3 deletions src/HttpFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInter
{
public function createUploadedFile(
StreamInterface $stream,
int $size = null,
?int $size = null,
int $error = \UPLOAD_ERR_OK,
string $clientFilename = null,
string $clientMediaType = null
?string $clientFilename = null,
?string $clientMediaType = null
): UploadedFileInterface {
if ($size === null) {
$size = $stream->getSize();
Expand Down
2 changes: 1 addition & 1 deletion src/MultipartStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class MultipartStream implements StreamInterface
*
* @throws \InvalidArgumentException
*/
public function __construct(array $elements = [], string $boundary = null)
public function __construct(array $elements = [], ?string $boundary = null)
{
$this->boundary = $boundary ?: bin2hex(random_bytes(20));
$this->stream = $this->createStream($elements);
Expand Down
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct(
array $headers = [],
$body = null,
string $version = '1.1',
string $reason = null
?string $reason = null
) {
$this->assertStatusCodeRange($status);

Expand Down
2 changes: 1 addition & 1 deletion src/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function register(): void
}
}

public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path = null): bool
{
$options = stream_context_get_options($this->context);

Expand Down
4 changes: 2 additions & 2 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function __construct(
$streamOrFile,
?int $size,
int $errorStatus,
string $clientFilename = null,
string $clientMediaType = null
?string $clientFilename = null,
?string $clientMediaType = null
) {
$this->setError($errorStatus);
$this->size = $size;
Expand Down
2 changes: 1 addition & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public static function isRelativePathReference(UriInterface $uri): bool
*
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
*/
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool
public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool
{
if ($base !== null) {
$uri = UriResolver::resolve($base, $uri);
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public static function modifyRequest(RequestInterface $request, array $changes):
* @param StreamInterface $stream Stream to read from
* @param int|null $maxLength Maximum buffer length
*/
public static function readLine(StreamInterface $stream, int $maxLength = null): string
public static function readLine(StreamInterface $stream, ?int $maxLength = null): string
{
$buffer = '';
$size = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

require dirname(__DIR__, 2).'/vendor/autoload.php';

$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals();
$request = GuzzleHttp\Psr7\ServerRequest::fromGlobals();

$output = [
'method' => $request->getMethod(),
Expand Down
2 changes: 1 addition & 1 deletion tests/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testStopsCopyToSteamWhenWriteFailsWithMaxLen(): void
public function testCopyToStreamReadsInChunksInsteadOfAllInMemory(): void
{
$sizes = [];
$s1 = new Psr7\FnStream([
$s1 = new FnStream([
'eof' => function () {
return false;
},
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": "^7.4 || ^8.0",
"friendsofphp/php-cs-fixer": "3.40.2"
"friendsofphp/php-cs-fixer": "3.52.1"
},
"config": {
"preferred-install": "dist"
Expand Down

0 comments on commit 0423dd4

Please sign in to comment.