From 4ef302c0be2047f78b1aa3976eba003a2c280f64 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 12 Jan 2018 14:15:12 +0100 Subject: Request->getHeader() should always return a string PHPDoc (of the public API) says that this method returns string but it also returns null, which is not allowed in some method calls. This fixes that behaviour and returns an empty string and fixes all code paths that explicitly checked for null to be still compliant. Found while enabling the strict_typing for lib/private for the PHP7+ migration. Signed-off-by: Morris Jobke --- core/Controller/ClientFlowLoginController.php | 2 +- core/Controller/CssController.php | 2 +- core/Controller/JsController.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php index 0e7fbf892b6..23bd42a0f18 100644 --- a/core/Controller/ClientFlowLoginController.php +++ b/core/Controller/ClientFlowLoginController.php @@ -115,7 +115,7 @@ class ClientFlowLoginController extends Controller { */ private function getClientName() { $userAgent = $this->request->getHeader('USER_AGENT'); - return $userAgent !== null ? $userAgent : 'unknown'; + return $userAgent !== '' ? $userAgent : 'unknown'; } /** diff --git a/core/Controller/CssController.php b/core/Controller/CssController.php index 95a41f8dd15..43a4f453b0e 100644 --- a/core/Controller/CssController.php +++ b/core/Controller/CssController.php @@ -98,7 +98,7 @@ class CssController extends Controller { private function getFile(ISimpleFolder $folder, $fileName, &$gzip) { $encoding = $this->request->getHeader('Accept-Encoding'); - if ($encoding !== null && strpos($encoding, 'gzip') !== false) { + if (strpos($encoding, 'gzip') !== false) { try { $gzip = true; return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php index f02948e47a0..670ca997257 100644 --- a/core/Controller/JsController.php +++ b/core/Controller/JsController.php @@ -96,7 +96,7 @@ class JsController extends Controller { private function getFile(ISimpleFolder $folder, $fileName, &$gzip) { $encoding = $this->request->getHeader('Accept-Encoding'); - if ($encoding !== null && strpos($encoding, 'gzip') !== false) { + if (strpos($encoding, 'gzip') !== false) { try { $gzip = true; return $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz -- cgit v1.2.3