Some PHP improvements and little fixes

This commit is contained in:
Bizarrus committed 2023-11-04 04:00:10 +01:00
1 parent 558ef8a36e
commit c596aabda8
31 files changed
+182 -183

No files matched your search

+11 -11
View File
@@ -12,11 +12,11 @@
$this->info = new ModuleInfo($path);
}
public function isValid() {
public function isValid() : bool {
return (!empty($this->info) && !$this->info->isValid());
}
public function getInfo() {
public function getInfo() : ModuleInfo {
return $this->info;
}
@@ -24,11 +24,11 @@
return $this->instance;
}
public function getPath() {
public function getPath() : string {
return $this->path;
}
public function getSettings($name, $default = NULL) {
public function getSettings(string $name, mixed $default = NULL) : mixed {
$result = Database::single('SELECT * FROM `' . DATABASE_PREFIX . 'modules_settings` WHERE `module`=:module AND `key`=:key LIMIT 1', [
'key' => $name,
'module' => $this->getDirectory()
@@ -43,7 +43,7 @@
return $default;
}
public function setSettings($name, $value = NULL) {
public function setSettings(string $name, mixed $value = NULL) {
if(Database::exists('SELECT `id` FROM `' . DATABASE_PREFIX . 'modules_settings` WHERE `module`=:module AND `key`=:key LIMIT 1', [
'module' => $this->getDirectory(),
'key' => $name
@@ -63,27 +63,27 @@
}
}
public function hasSettingsPath() {
public function hasSettingsPath() : bool {
return file_exists($this->getSettingsPath());
}
public function getSettingsPath() {
public function getSettingsPath() : string {
return sprintf('%s%sadmin.php', $this->path, DS);
}
public function getDirectory() {
public function getDirectory() : string {
return basename($this->path);
}
public function isEnabled() {
public function isEnabled() : bool {
return $this->enabled;
}
public function setEnabled($state) {
public function setEnabled(bool $state) {
$this->enabled = $state;
}
public function init($core) {
public function init(Core $core) : Module {
$script = sprintf('%s%smodule.php', $this->path, DS);
if(!file_exists($script)) {