fix: phpstan level=6

This commit is contained in:
origami11@yandex.ru 2025-10-06 12:49:36 +03:00
parent acbf2c847d
commit 48269bd424
41 changed files with 324 additions and 347 deletions

View file

@ -5,47 +5,47 @@ use ctiso\File,
Exception;
class Registry {
public $namespace = [];
public array $namespace = [];
public $data;
function importFile($namespace, $filePath = null) {
function importFile(string $namespace, ?string $filePath = null) {
$data = json_decode(File::getContents($filePath), true);
$data['_file'] = $filePath;
$this->namespace[$namespace] = [
'path' => $filePath,
'data' => $data
];
];
}
function importArray($namespace, $data = []) {
function importArray(string $namespace, array $data = []) {
if (isset($this->namespace[$namespace])) {
$data = array_merge($this->namespace[$namespace]['data'], $data);
}
}
$this->namespace[$namespace] = [
'path' => null,
'data' => $data
];
];
}
public function get($ns, $key) {
public function get(string $ns, string $key) {
if (isset($this->namespace[$ns]['data'][$key])) {
return $this->namespace[$ns]['data'][$key];
}
throw new Exception('Unknown key ' . $ns . '::' . $key);
}
public function getOpt($ns, $key) {
public function getOpt(string $ns, string $key) {
if (isset($this->namespace[$ns]['data'][$key])) {
return $this->namespace[$ns]['data'][$key];
}
return null;
}
public function has($ns, $key) {
public function has(string $ns, string $key): bool {
return isset($this->namespace[$ns]['data'][$key]);
}
function set($ns, $key, $value) {
function set(string $ns, string $key, mixed $value): void {
$this->namespace[$ns]['data'][$key] = $value;
}
}