From 0269b0554b5c952757f3a2ad43b5e58a7100c655 Mon Sep 17 00:00:00 2001 From: Alexander Schnitzler <git@alexanderschnitzler.de> Date: Mon, 11 May 2020 17:33:41 +0200 Subject: [PATCH] [TASK] Fix phpstan checkFunctionArgumentTypes errors in ext:core Http This patch fixes incompatible type usage in function arguments and is preparatory work for introducing native type hints and strict mode in all core files. Releases: master, 10.4 Resolves: #92270 Change-Id: I5e0ec227a6dd382d13fa69b06515621d8efc596a Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65669 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> --- typo3/sysext/core/Classes/Http/NormalizedParams.php | 4 ++-- typo3/sysext/core/Classes/Http/Response.php | 2 +- typo3/sysext/core/Classes/Http/ServerRequestFactory.php | 2 +- typo3/sysext/core/Classes/Http/UploadedFile.php | 2 +- typo3/sysext/core/Classes/Http/Uri.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/typo3/sysext/core/Classes/Http/NormalizedParams.php b/typo3/sysext/core/Classes/Http/NormalizedParams.php index f2911395aa8f..6cfd5ea7822c 100644 --- a/typo3/sysext/core/Classes/Http/NormalizedParams.php +++ b/typo3/sysext/core/Classes/Http/NormalizedParams.php @@ -720,9 +720,9 @@ class NormalizedParams // Choose which IP in list to use $configuredReverseProxyHeaderMultiValue = trim($configuration['reverseProxyHeaderMultiValue'] ?? ''); if (!empty($ip) && $configuredReverseProxyHeaderMultiValue === 'last') { - $ip = array_pop($ip); + $ip = (string)array_pop($ip); } elseif (!empty($ip) && $configuredReverseProxyHeaderMultiValue === 'first') { - $ip = array_shift($ip); + $ip = (string)array_shift($ip); } else { $ip = ''; } diff --git a/typo3/sysext/core/Classes/Http/Response.php b/typo3/sysext/core/Classes/Http/Response.php index f75e78552ee8..bc15bc2d708a 100644 --- a/typo3/sysext/core/Classes/Http/Response.php +++ b/typo3/sysext/core/Classes/Http/Response.php @@ -119,7 +119,7 @@ class Response extends Message implements ResponseInterface /** * Constructor for generating new responses * - * @param StreamInterface|string $body + * @param StreamInterface|string|null $body * @param int $statusCode * @param array $headers * @param string $reasonPhrase diff --git a/typo3/sysext/core/Classes/Http/ServerRequestFactory.php b/typo3/sysext/core/Classes/Http/ServerRequestFactory.php index 8e4daf213d14..80d70c61bbcc 100644 --- a/typo3/sysext/core/Classes/Http/ServerRequestFactory.php +++ b/typo3/sysext/core/Classes/Http/ServerRequestFactory.php @@ -82,7 +82,7 @@ class ServerRequestFactory implements ServerRequestFactoryInterface } $parsedBody = GeneralUtility::_POST(); if (empty($parsedBody) && in_array($method, ['PUT', 'PATCH', 'DELETE'])) { - parse_str(file_get_contents('php://input'), $parsedBody); + parse_str((string)file_get_contents('php://input'), $parsedBody); } if (!empty($parsedBody)) { $request = $request->withParsedBody($parsedBody); diff --git a/typo3/sysext/core/Classes/Http/UploadedFile.php b/typo3/sysext/core/Classes/Http/UploadedFile.php index cc076497f26b..8579fc5ce0e3 100644 --- a/typo3/sysext/core/Classes/Http/UploadedFile.php +++ b/typo3/sysext/core/Classes/Http/UploadedFile.php @@ -134,7 +134,7 @@ class UploadedFile implements UploadedFileInterface return $this->stream; } - $this->stream = new Stream($this->file); + $this->stream = new Stream((string)$this->file); return $this->stream; } diff --git a/typo3/sysext/core/Classes/Http/Uri.php b/typo3/sysext/core/Classes/Http/Uri.php index 9e89965c910a..16e6fd6cfe52 100644 --- a/typo3/sysext/core/Classes/Http/Uri.php +++ b/typo3/sysext/core/Classes/Http/Uri.php @@ -606,7 +606,7 @@ class Uri implements UriInterface * * @param string $scheme * @param string $host - * @param int $port + * @param int|null $port * @return bool */ protected function isNonStandardPort($scheme, $host, $port) -- GitLab