Skip to content

Commit 1446798

Browse files
authored
Fix deprecation on stropos() usage on sfDebug::shortenFilePath (#299)
Fix PHP v8.x deprecation on strpos() usage with `null` as first parameter
1 parent 5837057 commit 1446798

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/debug/sfDebug.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ public static function removeObjects($values)
235235
*/
236236
public static function shortenFilePath($file)
237237
{
238+
if (!$file) {
239+
return $file;
240+
}
241+
238242
foreach (array('sf_root_dir', 'sf_symfony_lib_dir') as $key) {
239243
if (0 === strpos($file, $value = sfConfig::get($key))) {
240244
$file = str_replace($value, strtoupper($key), $file);

test/unit/debug/sfDebugTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010

1111
require_once __DIR__.'/../../bootstrap/unit.php';
1212

13-
$t = new lime_test(1);
13+
$t = new lime_test(2);
1414

1515
// ::removeObjects()
1616
$t->diag('::removeObjects()');
1717
$objectArray = array('foo', 42, new sfDebug(), array('bar', 23, new lime_test(null)));
1818
$cleanedArray = array('foo', 42, 'sfDebug Object()', array('bar', 23, 'lime_test Object()'));
1919
$t->is_deeply(sfDebug::removeObjects($objectArray), $cleanedArray, '::removeObjects() converts objects to String representations using the class name');
20+
21+
$t->diag('::shortenFilePath()');
22+
$t->is(sfDebug::shortenFilePath(null), null, '->shortenFilePath() handles a null value');

0 commit comments

Comments
 (0)