From f2ec9dad150ca4fad72616c3a0a076bc79281f37 Mon Sep 17 00:00:00 2001
From: nicod_ <nicod@lerebooteux.fr>
Date: Fri, 10 Nov 2023 21:30:42 +0100
Subject: [PATCH] fix: Ajout de typage

---
 blocks_fonctions.php | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/blocks_fonctions.php b/blocks_fonctions.php
index 9f36d1e..c4d8c8c 100644
--- a/blocks_fonctions.php
+++ b/blocks_fonctions.php
@@ -27,10 +27,11 @@ function blocks_serialize($data) {
  * Désérialisation de données (saisies ou valeurs)
  *
  * @param $data
- * @return mixed
+ * @return array|null
  */
 function blocks_deserialize($data) {
-	return json_decode($data ?? '', true);
+	$retour = json_decode($data ?? '', true);
+	return is_array($retour) ? $retour : null;
 }
 
 /**
@@ -69,11 +70,11 @@ function balise_GENERER_BLOCK_dist($p) {
 /**
  * Fonction interne à la balise GENERER_BLOCK
  *
- * @param $id_block
- * @return array|string
+ * @param int $id_block
+ * @return string
  */
-function _block_charger_block($id_block) {
-	$retour = '';
+function _block_charger_block(int $id_block): string {
+	$html = '';
 	$where = ['b.id_block = ' . (int)$id_block];
 	if (!test_espace_prive()) {
 		$where[] = 'b.statut = ' . sql_quote('publie');
@@ -90,7 +91,7 @@ function _block_charger_block($id_block) {
 		$retour = recuperer_fond('inclure/block', $contexte);
 	}
 
-	return $retour;
+	return $html;
 }
 
 /**
@@ -133,11 +134,11 @@ function balise_GENERER_BLOCKS_dist($p) {
 /**
  * Fonction interne à la balise GENERER_BLOCKS
  *
- * @param $objet
- * @param $id_objet
+ * @param string $objet
+ * @param int    $id_objet
  * @return string
  */
-function _block_charger_blocks($objet, $id_objet): string {
+function _block_charger_blocks(string $objet, int $id_objet): string {
 	$retour = '';
 	$where = [
 		'objet = ' . sql_quote($objet),
-- 
GitLab