$env = [];
$env['app'] = [];
$env['app']['cache'] = new FileCache;
$env['app']['render'] = new Render;
$env['app']['router'] = new Router;
# массив
$env['app']['router'];
# обьект
$env->app->cache;
<?php
Class TempFunc
{
public static null|array $func = [];
public static function __callStatic ($name, $arguments)
{
if(is_array(self::$func) && isset(self::$func[$name]))
{
return self::$func[$name](...$arguments);
}
return null;
}
}
// init
TempFunc::$func['sub'] = function ()
{
return 123;
};
TempFunc::$func['main'] = function ()
{
echo TempFunc::sub();
};
// execute
TempFunc::main();
// remove
TempFunc::$func = null;
/**
* debug_backtrace minimal
*/
function __ALL (int $size = 5):array
{
$debug = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $size);
return array_map(function($arr, $k)
{
return implode(' | ', [$k, $arr['file'] ?? '', $arr['line'] ?? '', $arr['function'] ?? '']);
}, $debug, array_keys($debug));
}
Write::logs(..., __ALL());
INSERT INTO availability_other_title
(...)
VALUES
(...)
ON CONFLICT(idBook)
DO UPDATE SET
...