1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: William Desportes <williamdes@wdes.fr>
Date: Fri, 11 Apr 2025 16:08:22 +0200
Subject: Fix trim() null param is deprecated
4 tests triggered 1 PHP deprecation:
1) php-spyc/Spyc.php:353
trim(): Passing null to parameter #1 ($string) of type string is deprecated
Triggered by:
* DumpTest::testDump
php-spyc/tests/DumpTest.php:17
* DumpTest::testDumpWithQuotes
php-spyc/tests/DumpTest.php:26
* DumpTest::testNull
php-spyc/tests/DumpTest.php:43
* RoundTripTest::testNull
php-spyc/tests/RoundTripTest.php:11
---
Spyc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Spyc.php b/Spyc.php
index 3fe0f62..24be0a3 100644
--- a/Spyc.php
+++ b/Spyc.php
@@ -350,7 +350,7 @@ class Spyc {
if (self::isTranslationWord($value)) {
$value = $this->_doLiteralBlock($value, $indent);
}
- if (trim ($value) != $value)
+ if ($value !== null && trim ($value) != $value)
$value = $this->_doLiteralBlock($value,$indent);
if (is_bool($value)) {
|