Skip to content

Commit 029b0e7

Browse files
TybazethePanz
authored andcommitted
PHP 8.0 & 8.1 > Deprecated of null to non-nullable internal function parameters
Mainly ensure use of string instead of null / false by casting the variable into (string) Also fix method/function arguments with default value must be at the end. Thanks to @teymour cba71a4
1 parent 6401fcc commit 029b0e7

File tree

15 files changed

+21
-20
lines changed

15 files changed

+21
-20
lines changed

lib/helper/DateHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @version SVN: $Id$
1818
*/
1919

20-
function format_daterange($start_date, $end_date, $format = 'd', $full_text, $start_text, $end_text, $culture = null, $charset = null)
20+
function format_daterange($start_date, $end_date, $format = 'd', $full_text = '', $start_text = '', $end_text = '', $culture = null, $charset = null)
2121
{
2222
if ($start_date != '' && $end_date != '')
2323
{

lib/helper/I18NHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* This file is part of the symfony package.
55
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6-
*
6+
*
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
@@ -60,7 +60,7 @@ function __($text, $args = array(), $catalogue = 'messages')
6060
*
6161
* @return string Result of the translation
6262
*/
63-
function format_number_choice($text, $args = array(), $number, $catalogue = 'messages')
63+
function format_number_choice($text, $args = array(), $number = null, $catalogue = 'messages')
6464
{
6565
$translated = __($text, $args, $catalogue);
6666

lib/i18n/sfDateFormat.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,10 @@ public function format($time, $pattern = 'F', $inputPattern = null, $charset = '
239239
}
240240
else
241241
{
242-
$function = ucfirst($this->getFunctionName($pattern));
242+
$function = $this->getFunctionName($pattern);
243243
if ($function != null)
244244
{
245+
$function = ucfirst($function);
245246
$fName = 'get'.$function;
246247
if (in_array($fName, $this->methods))
247248
{

lib/plugins/sfDoctrinePlugin/lib/database/sfDoctrineConnectionProfiler.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static public function fixParams($params)
200200

201201
foreach ($params as $key => $param)
202202
{
203-
if (strlen($param) >= 255)
203+
if ($param && strlen($param) >= 255)
204204
{
205205
$params[$key] = '['.number_format(strlen($param) / 1024, 2).'Kb]';
206206
}

lib/plugins/sfDoctrinePlugin/lib/debug/sfWebDebugPanelDoctrine.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static public function listenToAddPanelEvent(sfEvent $event)
6868

6969
/**
7070
* Returns an array of Doctrine query events.
71-
*
71+
*
7272
* @return array
7373
*/
7474
protected function getDoctrineEvents()
@@ -116,7 +116,7 @@ protected function getSqlLogs()
116116
// interpolate parameters
117117
foreach ($params as $param)
118118
{
119-
$param = htmlspecialchars($param, ENT_QUOTES, sfConfig::get('sf_charset'));
119+
$param = htmlspecialchars((string) $param, ENT_QUOTES, sfConfig::get('sf_charset'));
120120
$query = join(var_export(is_scalar($param) ? $param : (string) $param, true), explode('?', $query, 2));
121121
}
122122

lib/routing/sfRoute.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ protected function generateWithTokens($parameters)
285285
switch ($token[0])
286286
{
287287
case 'variable':
288-
if (!$optional || !isset($this->defaults[$token[3]]) || $parameters[$token[3]] != $this->defaults[$token[3]])
288+
if (!$optional || !isset($this->defaults[$token[3]]) || (isset($parameters[$token[3]]) && $parameters[$token[3]] != $this->defaults[$token[3]]))
289289
{
290290
$url[] = urlencode($parameters[$token[3]]);
291291
$optional = false;
@@ -791,7 +791,7 @@ protected function fixDefaults()
791791
}
792792
else
793793
{
794-
$this->defaults[$key] = urldecode($value);
794+
$this->defaults[$key] = urldecode((string) $value);
795795
}
796796
}
797797
}

lib/util/sfBrowserBase.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ public function doClickElement(DOMElement $item, $arguments = array(), $options
908908
}
909909
else
910910
{
911-
$queryString = http_build_query($arguments, null, '&');
911+
$queryString = (is_array($arguments)) ? http_build_query($arguments, null, '&') : '';
912912
$sep = false === strpos($url, '?') ? '?' : '&';
913913

914914
return array($url.($queryString ? $sep.$queryString : ''), 'get', array());

lib/util/sfInflector.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class sfInflector
2828
public static function camelize($lower_case_and_underscored_word)
2929
{
3030

31-
return strtr(ucwords(strtr($lower_case_and_underscored_word, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
31+
return strtr(ucwords(strtr((string) $lower_case_and_underscored_word, array('/' => ':: ', '_' => ' ', '-' => ' '))), array(' ' => ''));
3232
}
3333

3434
/**
@@ -40,7 +40,7 @@ public static function camelize($lower_case_and_underscored_word)
4040
*/
4141
public static function underscore($camel_cased_word)
4242
{
43-
$tmp = $camel_cased_word;
43+
$tmp = (string) $camel_cased_word;
4444
$tmp = str_replace('::', '/', $tmp);
4545
$tmp = sfToolkit::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\\1_\\2',
4646
'/([a-z\d])([A-Z])/' => '\\1_\\2'));

lib/util/sfToolkit.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public static function replaceConstants($value)
366366
*/
367367
public static function pregtr($search, $replacePairs)
368368
{
369-
return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search);
369+
return preg_replace(array_keys($replacePairs), array_values($replacePairs), (string) $search);
370370
}
371371

372372
/**

lib/vendor/lime/lime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ protected function find_caller($traces)
564564
return array($traces[$last]['file'], $traces[$last]['line']);
565565
}
566566

567-
public function handle_error($code, $message, $file, $line, $context)
567+
public function handle_error($code, $message, $file, $line, $context = null)
568568
{
569569
if (!$this->options['error_reporting'] || ($code & error_reporting()) == 0)
570570
{

0 commit comments

Comments
 (0)