diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index c070d3d1fb889ec374018174c2c8c35b42fd4430..57d3b6e4c92831b52bcb392efd5b2d935be1a9b7 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -909,7 +909,10 @@ function corriger_caracteres($texte) { * @return string * Texte encodé pour XML */ -function texte_backend($texte) { +function texte_backend(string $texte) : string { + if ($texte === '') { + return ''; + } static $apostrophe = ['’', "'"]; # n'allouer qu'une fois @@ -960,7 +963,7 @@ function texte_backend($texte) { * @return string * Texte encodé et quote pour XML */ -function texte_backendq($texte) { +function texte_backendq(string $texte) : string { return addslashes(texte_backend($texte)); } @@ -1327,7 +1330,7 @@ function taille_en_octets($taille) { * @return string * Texte prêt pour être utilisé en attribut HTML **/ -function attribut_html($texte, $textebrut = true) { +function attribut_html(string $texte, $textebrut = true) : string { $u = $GLOBALS['meta']['pcre_u']; if ($textebrut) { $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte)); @@ -2040,7 +2043,7 @@ function extraire_attribut($balise, $attribut, $complet = false) { * @return string * Code html modifié **/ -function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) { +function inserer_attribut(string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false) : string { // preparer l'attribut // supprimer les etc mais pas les balises html // qui ont un sens dans un attribut value d'un input @@ -2050,7 +2053,7 @@ function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = f // echapper les ' pour eviter tout bug $val = str_replace("'", ''', $val); - if ($vider and strlen($val) == 0) { + if ($vider and strlen($val) === 0) { $insert = ''; } else { $insert = " $attribut='$val'"; @@ -2088,7 +2091,7 @@ function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = f * @param string $attribut Nom de l'attribut à enlever * @return string Code HTML sans l'attribut **/ -function vider_attribut($balise, $attribut) { +function vider_attribut(string $balise, string $attribut) : string { return inserer_attribut($balise, $attribut, '', false, true); } diff --git a/ecrire/inc/filtres_images_lib_mini.php b/ecrire/inc/filtres_images_lib_mini.php index 60d8f7822896255bd5502924fab9f217a30cb62b..a92560c4a017bb6b3cb2e2a572be6bbefd80373f 100644 --- a/ecrire/inc/filtres_images_lib_mini.php +++ b/ecrire/inc/filtres_images_lib_mini.php @@ -1264,7 +1264,7 @@ function _image_tag_changer_taille($tag, $width, $height, $style = false) { $tag = inserer_attribut($tag, 'hspace', ''); } - $tag = inserer_attribut($tag, 'style', $style, true, $style ? false : true); + $tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true); return $tag; } diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 76e124c313d683b2c73c3cfce328d06a6900c489..77b129876530474b51573850cf573aed3ea308f5 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -1305,7 +1305,7 @@ function http_script($script, $src = '', $noscript = '') { * @return string * Texte échappé **/ -function texte_script($texte) { +function texte_script(string $texte) : string { return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); } diff --git a/ecrire/public/composer.php b/ecrire/public/composer.php index 7801cd1f1952411458ba503f6ded7057cff4e300..2330f6cb1f4251ced0299a2c0c94ec5ad46ad4e4 100644 --- a/ecrire/public/composer.php +++ b/ecrire/public/composer.php @@ -352,7 +352,7 @@ function argumenter_squelette($v) { if (is_object($v)) { return var_export($v, true); } elseif (!is_array($v)) { - return "'" . texte_script($v) . "'"; + return "'" . texte_script((string) $v) . "'"; } else { $out = []; foreach ($v as $k => $val) {