mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°7645 - PHP 8.1: Fix usage of strpos() & str_replace() with null value when compiling empty dictionary (#600)
* fix(compiler): provide empty string instead of null value * Apply review suggestions
This commit is contained in:
@@ -1165,6 +1165,7 @@ EOF
|
||||
*/
|
||||
protected function QuoteForPHP($sStr, $bSimpleQuotes = false)
|
||||
{
|
||||
$sStr = $sStr ?? '';
|
||||
if ($bSimpleQuotes)
|
||||
{
|
||||
$sEscaped = str_replace(array('\\', "'"), array('\\\\', "\\'"), $sStr);
|
||||
@@ -3229,10 +3230,11 @@ EOF;
|
||||
|
||||
$aEntriesPHP = array();
|
||||
$oEntries = $oDictionaryNode->GetUniqueElement('entries');
|
||||
/** @var MFElement $oEntry */
|
||||
foreach ($oEntries->getElementsByTagName('entry') as $oEntry)
|
||||
{
|
||||
$sStringCode = $oEntry->getAttribute('id');
|
||||
$sValue = $oEntry->GetText();
|
||||
$sValue = $oEntry->GetText('');
|
||||
$aEntriesPHP[] = "\t'$sStringCode' => ".self::QuoteForPHP(self::FilterDictString($sValue), true).",";
|
||||
}
|
||||
$sEntriesPHP = implode("\n", $aEntriesPHP);
|
||||
@@ -3267,7 +3269,7 @@ EOF;
|
||||
file_put_contents($sLanguagesFile, $sLanguagesFileContent);
|
||||
}
|
||||
|
||||
protected static function FilterDictString($s)
|
||||
protected static function FilterDictString(string $s): string
|
||||
{
|
||||
if (strpos($s, '~') !== false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user