From 5490c7845898e9e5139ac5933c63a72c99b8eb27 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 20 Jun 2024 03:20:18 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/db/CapacitorChannel.php | 30 +++++++++++++++--------------- src/db/CapacitorStorage.php | 16 ++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/db/CapacitorChannel.php b/src/db/CapacitorChannel.php index a68ed44..4a6fe4c 100644 --- a/src/db/CapacitorChannel.php +++ b/src/db/CapacitorChannel.php @@ -189,8 +189,8 @@ class CapacitorChannel { * * cette méthode doit être utilisée dans {@link self::onUpdate()} */ - function wasRowModified(array $rowValues): bool { - return array_key_exists("modified_", $rowValues); + function wasRowModified(array $values): bool { + return array_key_exists("modified_", $values); } final function serialize($item): ?string { @@ -224,10 +224,10 @@ class CapacitorChannel { return array_combine($sumCols, [$serial, $sum]); } - function wasSumModified(string $key, $value, array $prowValues): bool { + function wasSumModified(string $key, $value, array $pvalues): bool { $sumCol = $this->getSumCols($key)[1]; $sum = $this->sum(null, $value); - $psum = $prowValues[$sumCol] ?? $this->sum(null, $prowValues[$key] ?? null); + $psum = $pvalues[$sumCol] ?? $this->sum(null, $pvalues[$key] ?? null); return $sum !== $psum; } @@ -243,10 +243,10 @@ class CapacitorChannel { * créer un nouvel élément * * @param mixed $item l'élément à charger - * @param array $rowValues la ligne à créer, calculée à partir de $item et des + * @param array $values la ligne à créer, calculée à partir de $item et des * valeurs retournées par {@link getItemValues()} - * @return ?array le cas échéant, un tableau non null à merger dans $rowValues - * et utilisé pour provisionner la ligne nouvellement créée + * @return ?array le cas échéant, un tableau non null à merger dans $values et + * utilisé pour provisionner la ligne nouvellement créée * * Si $item est modifié dans cette méthode, il est possible de le retourner * avec la clé "item" pour mettre à jour la ligne correspondante. @@ -256,7 +256,7 @@ class CapacitorChannel { * peut techniquement retourner de nouvelles valeurs pour la clé primaire, ça * risque de créer des doublons */ - function onCreate($item, array $rowValues, ?array $alwaysNull): ?array { + function onCreate($item, array $values, ?array $alwaysNull): ?array { return null; } @@ -265,9 +265,9 @@ class CapacitorChannel { * mettre à jour un élément existant * * @param mixed $item l'élément à charger - * @param array $rowValues la nouvelle ligne, calculée à partir de $item et + * @param array $values la nouvelle ligne, calculée à partir de $item et * des valeurs retournées par {@link getItemValues()} - * @param array $prowValues la précédente ligne, chargée depuis la base de + * @param array $pvalues la précédente ligne, chargée depuis la base de * données * @return ?array null s'il ne faut pas mettre à jour la ligne. sinon, ce * tableau est mergé dans $values puis utilisé pour mettre à jour la ligne @@ -277,7 +277,7 @@ class CapacitorChannel { * - La clé primaire (il s'agit généralement de "id_") ne peut pas être * modifiée. si elle est retournée, elle est ignorée */ - function onUpdate($item, array $rowValues, array $prowValues): ?array { + function onUpdate($item, array $values, array $pvalues): ?array { return null; } @@ -286,7 +286,7 @@ class CapacitorChannel { * {@link Capacitor::each()} * * @param mixed $item l'élément courant - * @param ?array $rowValues la ligne courante + * @param ?array $values la ligne courante * @return ?array le cas échéant, un tableau non null utilisé pour mettre à * jour la ligne courante * @@ -294,7 +294,7 @@ class CapacitorChannel { * - La clé primaire (il s'agit généralement de "id_") ne peut pas être * modifiée. si elle est retournée, elle est ignorée */ - function onEach($item, array $rowValues): ?array { + function onEach($item, array $values): ?array { return null; } @@ -303,10 +303,10 @@ class CapacitorChannel { * {@link Capacitor::delete()} * * @param mixed $item l'élément courant - * @param ?array $rowValues la ligne courante + * @param ?array $values la ligne courante * @return bool true s'il faut supprimer la ligne, false sinon */ - function onDelete($item, array $rowValues): bool { + function onDelete($item, array $values): bool { return true; } } diff --git a/src/db/CapacitorStorage.php b/src/db/CapacitorStorage.php index 4635e3e..85a0d39 100644 --- a/src/db/CapacitorStorage.php +++ b/src/db/CapacitorStorage.php @@ -209,11 +209,11 @@ EOT; $initFunc = [$channel, "getItemValues"]; $initArgs = $args; func::ensure_func($initFunc, null, $initArgs); - $itemValues = func::call($initFunc, $item, ...$initArgs); + $values = func::call($initFunc, $item, ...$initArgs); $row = cl::merge( $channel->getSum("item", $item), - $this->serialize($channel, $itemValues)); + $this->serialize($channel, $values)); $prow = null; $rowIds = $this->getRowIds($channel, $row, $primaryKeys); if ($rowIds !== null) { @@ -412,9 +412,9 @@ EOT; } try { $args ??= []; - foreach ($this->_all($channel, $filter) as $rowValues) { - $rowIds = $this->getRowIds($channel, $rowValues); - $updates = func::_call($onEach, [$rowValues["item"], $rowValues, ...$args]); + foreach ($this->_all($channel, $filter) as $values) { + $rowIds = $this->getRowIds($channel, $values); + $updates = func::_call($onEach, [$values["item"], $values, ...$args]); if (is_array($updates) && $updates) { if (!array_key_exists("modified_", $updates)) { $updates["modified_"] = date("Y-m-d H:i:s"); @@ -478,9 +478,9 @@ EOT; } try { $args ??= []; - foreach ($this->_all($channel, $filter) as $rowValues) { - $rowIds = $this->getRowIds($channel, $rowValues); - $delete = boolval(func::_call($onEach, [$rowValues["item"], $rowValues, ...$args])); + foreach ($this->_all($channel, $filter) as $values) { + $rowIds = $this->getRowIds($channel, $values); + $delete = boolval(func::_call($onEach, [$values["item"], $values, ...$args])); if ($delete) { $db->exec([ "delete",