nur-sery/nur_src/b/coll/TAutoconstsStatic.php

38 lines
1.4 KiB
PHP

<?php
namespace nur\b\coll;
use nur\A;
use nur\php\Autogen;
trait TAutoconstsStatic {
static function _AUTOGEN_CONSTS(?array $params=null): array {
$setters = A::get($params, "setters", true);
$deleters = A::get($params, "deleters", false);
$ci = A::get($params, "ci", false);
$schema = static::SCHEMA;
$autogenConsts = [
"_AUTOGEN_LITERALS" => [
[$schema, "self::SCHEMA"],
[Autogen::class, "\\nur\\php\\Autogen::class"],
],
];
if (A::get($params, "properties", true)) {
$autogenConsts["_AUTO_GETTERS"] = Autogen::auto_getters($schema);
if ($setters) $autogenConsts["_AUTO_SETTERS"] = Autogen::auto_setters($schema);
if ($deleters) $autogenConsts["_AUTO_DELETERS"] = Autogen::auto_deleters($schema);
if ($ci) {
$autogenConsts["_AUTO_CI_GETTERS"] = Autogen::auto_ci_getters($schema);
if ($setters) $autogenConsts["_AUTO_CI_SETTERS"] = Autogen::auto_ci_setters($schema);
}
}
if (A::get($params, "methods", true)) {
$autogenMethods = [];
$autogenMethods[] = [Autogen::class, "auto_getters_methods", $schema];
if ($setters) $autogenMethods[] = [Autogen::class, "auto_setters_methods", $schema];
if ($deleters) $autogenMethods[] = [Autogen::class, "auto_deleters_methods", $schema];
$autogenConsts["_AUTOGEN_METHODS"] = $autogenMethods;
}
return $autogenConsts;
}
}