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

63 lines
2.3 KiB
PHP

<?php
namespace nur\b\coll;
use nur\A;
use nur\php\Autogen;
trait TAutoconstsDynamic {
static function _AUTOGEN_SCHEMA(): array {
return static::SCHEMA;
}
static function _AUTOGEN_GETTERS(): array {
return Autogen::auto_getters(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_SETTERS(): array {
return Autogen::auto_setters(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_DELETERS(): array {
return Autogen::auto_deleters(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_CI_GETTERS(): array {
return Autogen::auto_ci_getters(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_CI_SETTERS(): array {
return Autogen::auto_ci_setters(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_GETTERS_METHODS(): array {
return Autogen::auto_getters_methods(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_SETTERS_METHODS(): array {
return Autogen::auto_setters_methods(static::_AUTOGEN_SCHEMA());
}
static function _AUTOGEN_DELETERS_METHODS(): array {
return Autogen::auto_deleters_methods(static::_AUTOGEN_SCHEMA());
}
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);
$autogenConsts = [
"_AUTOGEN_LITERALS" => [
[static::class, "self::class"],
],
];
if (A::get($params, "properties", true)) {
$autogenConsts["_AUTO_GETTERS"] = [static::class, "_AUTOGEN_GETTERS"];
if ($setters) $autogenConsts["_AUTO_SETTERS"] = [static::class, "_AUTOGEN_SETTERS"];
if ($deleters) $autogenConsts["_AUTO_DELETERS"] = [static::class, "_AUTOGEN_DELETERS"];
if ($ci) {
$autogenConsts["_AUTO_CI_GETTERS"] = [static::class, "_AUTOGEN_CI_GETTERS"];
if ($setters) $autogenConsts["_AUTO_CI_SETTERS"] = [static::class, "_AUTOGEN_CI_SETTERS"];
}
}
if (A::get($params, "methods", true)) {
$autogenMethods = [];
$autogenMethods[] = [static::class, "_AUTOGEN_GETTERS_METHODS"];
if ($setters) $autogenMethods[] = [static::class, "_AUTOGEN_SETTERS_METHODS"];
if ($deleters) $autogenMethods[] = [static::class, "_AUTOGEN_DELETERS_METHODS"];
$autogenConsts["_AUTOGEN_METHODS"] = $autogenMethods;
}
return $autogenConsts;
}
}