Fix phpstan doleditor content cannot be nullable

This commit is contained in:
VESSILLER 2024-12-30 13:59:28 +01:00
parent c4889d3a09
commit 4d82beb46a

View file

@ -210,7 +210,7 @@ class DolEditor
$found = 0;
$out = '';
$this->content = ($this->content ?? ''); // to avoid htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
$content = (string) $this->content; // to avoid htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
if (in_array($this->tool, array('textarea', 'ckeditor'))) {
$found = 1;
@ -223,7 +223,7 @@ class DolEditor
$out .= (preg_match('/%/', $this->cols) ? ' style="margin-top: 5px; width: '.$this->cols.'"' : ' cols="'.$this->cols.'"');
$out .= ' '.($moreparam ? $moreparam : '');
$out .= ' class="flat '.$morecss.'">';
$out .= htmlspecialchars($this->content);
$out .= htmlspecialchars($content);
$out .= '</textarea>';
if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && isModEnabled('fckeditor')) {
@ -390,12 +390,12 @@ class DolEditor
$out .= ($this->height ? ' height: '.$this->height.'px; ' : '');
//$out.=" min-height: 100px;";
$out .= '">';
$out .= htmlspecialchars($this->content);
$out .= htmlspecialchars($content);
$out .= '</pre>';
$out .= '<input type="hidden" id="'.$this->htmlname.'_x" name="'.$this->htmlname.'_x">';
$out .= '<input type="hidden" id="'.$this->htmlname.'_y" name="'.$this->htmlname.'_y">';
$out .= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">';
$out .= htmlspecialchars($this->content);
$out .= htmlspecialchars($content);
$out .= '</textarea>';
$out .= '<script nonce="'.getNonce().'" type="text/javascript">'."\n";