Skip to content

Commit 9bba8c5

Browse files
authored
Merge pull request #272 from vemaeg/feature/more-php-8.1-fixes
Fix(php) Fix a few more php 8 issues
2 parents 7ad07e0 + 8b81a56 commit 9bba8c5

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

lib/config/sfViewConfigHandler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected function addHtmlHead($viewName = '')
223223

224224
foreach ($this->mergeConfigValue('metas', $viewName) as $name => $content)
225225
{
226-
$data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&(?=\w+;)/', '&', htmlspecialchars($content, ENT_QUOTES, sfConfig::get('sf_charset')))));
226+
$data[] = sprintf(" \$response->addMeta('%s', '%s', false, false);", $name, str_replace('\'', '\\\'', preg_replace('/&(?=\w+;)/', '&', htmlspecialchars((string) $content, ENT_QUOTES, sfConfig::get('sf_charset')))));
227227
}
228228

229229
return implode("\n", $data)."\n";

lib/controller/sfController.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ protected function getController($moduleName, $controllerName, $extension)
299299
$classSuffix = ucfirst(strtolower($extension));
300300
if (!isset($this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix]))
301301
{
302-
$this->controllerExists($moduleName, $controllerName, $extension, true);
302+
if (!$this->controllerExists($moduleName, $controllerName, $extension, true))
303+
{
304+
return null;
305+
}
303306
}
304307

305308
$class = $this->controllerClasses[$moduleName.'_'.$controllerName.'_'.$classSuffix];

lib/escaper/sfOutputEscaperArrayDecorator.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ public function offsetExists($offset)
124124
#[\ReturnTypeWillChange]
125125
public function offsetGet($offset)
126126
{
127-
return sfOutputEscaper::escape($this->escapingMethod, $this->value[$offset]);
127+
$value = isset($this->value[$offset]) ? $this->value[$offset] : null;
128+
return sfOutputEscaper::escape($this->escapingMethod, $value);
128129
}
129130

130131
/**

lib/request/sfWebRequest.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function getContentType($trim = true)
192192
{
193193
$contentType = $this->getHttpHeader('Content-Type', null);
194194

195-
if ($trim && false !== $pos = strpos($contentType, ';'))
195+
if ($trim && false !== $pos = strpos((string) $contentType, ';'))
196196
{
197197
$contentType = substr($contentType, 0, $pos);
198198
}

lib/response/sfWebResponse.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ public function sendHttpHeaders()
365365
// cookies
366366
foreach ($this->cookies as $cookie)
367367
{
368-
setrawcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']);
368+
$expire = isset($cookie['expire']) ? $cookie['expire'] : 0;
369+
setrawcookie($cookie['name'], $cookie['value'], $expire, $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']);
369370

370371
if ($this->options['logging'])
371372
{

0 commit comments

Comments
 (0)