aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/ModelArray.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Minz/ModelArray.php')
-rw-r--r--lib/Minz/ModelArray.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Minz/ModelArray.php b/lib/Minz/ModelArray.php
index 72de35f35..0d8b71f91 100644
--- a/lib/Minz/ModelArray.php
+++ b/lib/Minz/ModelArray.php
@@ -10,6 +10,7 @@
class Minz_ModelArray {
/**
* $filename est le nom du fichier
+ * @var string
*/
protected $filename;
@@ -22,7 +23,8 @@ class Minz_ModelArray {
$this->filename = $filename;
}
- protected function loadArray() {
+ /** @return array<string,mixed> */
+ protected function loadArray(): array {
if (!file_exists($this->filename)) {
throw new Minz_FileNotExistException($this->filename, Minz_Exception::WARNING);
} elseif (($handle = $this->getLock()) === false) {
@@ -42,8 +44,9 @@ class Minz_ModelArray {
/**
* Sauve le tableau $array dans le fichier $filename
- **/
- protected function writeArray($array) {
+ * @param array<string,mixed> $array
+ */
+ protected function writeArray(array $array): bool {
if (file_put_contents($this->filename, "<?php\n return " . var_export($array, true) . ';', LOCK_EX) === false) {
throw new Minz_PermissionDeniedException($this->filename);
}
@@ -53,6 +56,7 @@ class Minz_ModelArray {
return true;
}
+ /** @return resource|false */
private function getLock() {
$handle = fopen($this->filename, 'r');
if ($handle === false) {
@@ -73,7 +77,8 @@ class Minz_ModelArray {
}
}
- private function releaseLock($handle) {
+ /** @param resource $handle */
+ private function releaseLock($handle): void {
flock($handle, LOCK_UN);
fclose($handle);
}