diff --git a/src/Control/CLIRequestBuilder.php b/src/Control/CLIRequestBuilder.php
index a5ec492e9ec..a51bb08ee35 100644
--- a/src/Control/CLIRequestBuilder.php
+++ b/src/Control/CLIRequestBuilder.php
@@ -48,11 +48,11 @@ public static function cleanEnvironment(array $variables)
if (isset($variables['_SERVER']['argv'][2])) {
$args = array_slice($variables['_SERVER']['argv'], 2);
foreach ($args as $arg) {
- if (strpos($arg, '=') == false) {
+ if (strpos((string) $arg, '=') == false) {
$variables['_GET']['args'][] = $arg;
} else {
$newItems = [];
- parse_str((substr($arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
+ parse_str((substr((string) $arg, 0, 2) == '--') ? substr($arg, 2) : $arg, $newItems);
$variables['_GET'] = array_merge($variables['_GET'], $newItems);
}
}
@@ -79,7 +79,7 @@ public static function createFromVariables(array $variables, $input, $url = null
{
$request = parent::createFromVariables($variables, $input, $url);
// unset scheme so that SS_BASE_URL can provide `is_https` information if required
- $scheme = parse_url(Environment::getEnv('SS_BASE_URL'), PHP_URL_SCHEME);
+ $scheme = parse_url((string) Environment::getEnv('SS_BASE_URL'), PHP_URL_SCHEME);
if ($scheme) {
$request->setScheme($scheme);
}
diff --git a/src/Control/ContentNegotiator.php b/src/Control/ContentNegotiator.php
index fa8c8ff5a51..bf51514db07 100644
--- a/src/Control/ContentNegotiator.php
+++ b/src/Control/ContentNegotiator.php
@@ -79,8 +79,8 @@ public static function enabled_for($response)
// Disable content negotiation for other content types
if ($contentType
- && substr($contentType, 0, 9) != 'text/html'
- && substr($contentType, 0, 21) != 'application/xhtml+xml'
+ && substr((string) $contentType, 0, 9) != 'text/html'
+ && substr((string) $contentType, 0, 21) != 'application/xhtml+xml'
) {
return false;
}
@@ -88,7 +88,7 @@ public static function enabled_for($response)
if (ContentNegotiator::getEnabled()) {
return true;
} else {
- return (substr($response->getBody(), 0, 5) == '<' . '?xml');
+ return (substr((string) $response->getBody(), 0, 5) == '<' . '?xml');
}
}
@@ -140,8 +140,8 @@ public static function process(HTTPResponse $response)
$chosenFormat = "xhtml";
} else {
foreach ($mimes as $format => $mime) {
- $regExp = '/' . str_replace(['+', '/'], ['\+', '\/'], $mime) . '(;q=(\d+\.\d+))?/i';
- if (isset($_SERVER['HTTP_ACCEPT']) && preg_match($regExp, $_SERVER['HTTP_ACCEPT'], $matches)) {
+ $regExp = '/' . str_replace(['+', '/'], ['\+', '\/'], $mime ?: '') . '(;q=(\d+\.\d+))?/i';
+ if (isset($_SERVER['HTTP_ACCEPT']) && preg_match((string) $regExp, $_SERVER['HTTP_ACCEPT'], $matches)) {
$preference = isset($matches[2]) ? $matches[2] : 1;
if (!isset($q[$preference])) {
$q[$preference] = $format;
@@ -189,17 +189,17 @@ public function xhtml(HTTPResponse $response)
$content = preg_replace(
'//',
'',
- $content
+ $content ?: ''
);
- $content = str_replace(' ', ' ', $content);
- $content = str_replace('
', '
', $content);
- $content = str_replace('
', '
', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace('#(]*[^/>])>#i', '\\1/>', $content);
- $content = preg_replace("#(\