Copilot fixes

This commit is contained in:
slawkens
2026-02-15 01:57:26 +01:00
parent 4bc3923996
commit ad1d069b1f
8 changed files with 38 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ use MyAAC\Cache\Cache;
class Groups
{
private static array $groups;
private static array $groups = [];
public function __construct() {
self::$groups = Cache::remember('groups', 10 * 60, function () {

View File

@@ -6,7 +6,7 @@ use Devium\Toml\Toml;
class Groups
{
private array $groups;
private array $groups = [];
public function load(): void
{
@@ -14,7 +14,7 @@ class Groups
if(!@file_exists($file)) {
error('Error: Cannot load groups.toml. More info in system/logs/error.log file.');
log_append('error.log', '[OTS_Groups_List.php] Fatal error: Cannot load groups.toml (' . $file . '). It doesnt exist.');
log_append('error.log', "[OTS_Groups_List.php] Fatal error: Cannot load groups.toml ($file). It doesn't exist.");
return;
}

View File

@@ -33,7 +33,20 @@ class Items
return !in_array($key, ['id', 'article', 'name', 'plural']);
}, ARRAY_FILTER_USE_KEY);
$items[$item['id']] = ['article' => $item['article'], 'name' => $item['name'], 'plural' => $item['plural'] ?? '', 'attributes' => $attributes];
$id = $item['id'] ?? null;
if ($id === null) {
continue;
}
$article = $item['article'] ?? '';
$name = $item['name'] ?? '';
$plural = $item['plural'] ?? '';
$items[$id] = [
'article' => $article,
'name' => $name,
'plural' => $plural,
'attributes' => $attributes,
];
}
$cache_php = new CachePHP(config('cache_prefix'), CACHE . 'persistent/');

View File

@@ -6,14 +6,14 @@ use Devium\Toml\Toml;
class Vocations
{
private array $vocations;
private array $vocationsFrom;
private array $vocations = [];
private array $vocationsFrom = [];
public function load(): void
{
$tomlVocations = glob(config('data_path') . 'vocations/*.toml');
if (count($tomlVocations) <= 0) {
throw new \RuntimeException('ERROR: Cannot load any <i>.toml</i> vocation in the data/vocations folder.');
throw new \RuntimeException('ERROR: Cannot load any .toml vocation from the data/vocations folder.');
}
foreach ($tomlVocations as $file) {

View File

@@ -6,8 +6,8 @@ use MyAAC\Cache\Cache;
class Vocations
{
private static array $vocations;
private static array $vocationsFrom;
private static array $vocations = [];
private static array $vocationsFrom = [];
public function __construct() {
$cached = Cache::remember('vocations', 10 * 60, function () {

View File

@@ -4,7 +4,7 @@ namespace MyAAC\Server\XML;
class Groups
{
private array $groups;
private array $groups = [];
public function load(): void
{
@@ -12,7 +12,7 @@ class Groups
if(!@file_exists($file)) {
error('Error: Cannot load groups.xml. More info in system/logs/error.log file.');
log_append('error.log', '[OTS_Groups_List.php] Fatal error: Cannot load groups.xml (' . $file . '). It doesnt exist.');
log_append('error.log', "[OTS_Groups_List.php] Fatal error: Cannot load groups.xml ($file). It doesn't exist.");
return;
}

View File

@@ -4,8 +4,8 @@ namespace MyAAC\Server\XML;
class Vocations
{
private array $vocations;
private array $vocationsFrom;
private array $vocations = [];
private array $vocationsFrom = [];
public function load(): void
{