aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/ModelArray.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-05 23:26:38 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-05 23:26:38 +0200
commit2118448133e327294ad2b69ed8736bc29879103d (patch)
tree00c003056dedbd8e3554801d6493a25641a260a5 /lib/Minz/ModelArray.php
parent4f078958b5603900592e14f9f3189bbebfc81bab (diff)
PHPStan level 6 for more files (#5264)
7 more files passing (see phpstan-next.txt)
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);
}