fix: phpstan. Удаление State
This commit is contained in:
parent
4ac027b8ee
commit
1638d558c5
6 changed files with 22 additions and 97 deletions
|
|
@ -6,14 +6,10 @@ use Exception,
|
|||
ctiso\Url,
|
||||
ctiso\Model\Factory,
|
||||
ctiso\HttpRequest,
|
||||
ctiso\Functions,
|
||||
ctiso\Settings,
|
||||
ctiso\Registry,
|
||||
ctiso\Role\User,
|
||||
ctiso\View\Composite,
|
||||
ctiso\Filter\ActionAccess,
|
||||
ctiso\View\View,
|
||||
ctiso\Controller\State;
|
||||
App\Controller\State;
|
||||
/**
|
||||
* Контроллер страниц
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
namespace ctiso\Controller;
|
||||
use ctiso\Path,
|
||||
ctiso\Model\BaseMapper,
|
||||
ctiso\File,
|
||||
ctiso\Registry,
|
||||
ctiso\Database\PDOStatement;
|
||||
|
|
@ -40,8 +41,8 @@ class Service
|
|||
|
||||
/**
|
||||
* Создает модель
|
||||
* @param string $name
|
||||
* @return Model
|
||||
* @param string $name
|
||||
* @return BaseMapper
|
||||
*/
|
||||
public function getModel($name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace ctiso\Controller;
|
||||
use ctiso\Controller\Action,
|
||||
ctiso\Url;
|
||||
|
||||
class State
|
||||
{
|
||||
public $action = '';
|
||||
public $states = array();
|
||||
public $titles = array();
|
||||
|
||||
public function __construct($action)
|
||||
{
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
static function make($action)
|
||||
{
|
||||
return new State($action);
|
||||
}
|
||||
|
||||
public function addTitle($name, $url = array())
|
||||
{
|
||||
$this->titles [] = array($name, $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addState(State $state)
|
||||
{
|
||||
$this->states [$state->getAction()] = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
function checkAction($action, &$list)
|
||||
{
|
||||
if ($this->action == $action) {
|
||||
array_push($list, $this);
|
||||
return true;
|
||||
} else {
|
||||
foreach ($this->states as $state) {
|
||||
if ($state->checkAction($action, $list)) {
|
||||
array_push($list, $this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function makeTitle(Action $module)
|
||||
{
|
||||
foreach ($this->titles as $item) {
|
||||
$module->path->addMenuItem($module->nUrl($this->action, $item[1]), $item[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function getPath($module, $action)
|
||||
{
|
||||
$list = array();
|
||||
if ($this->checkAction($action, $list)) {
|
||||
foreach (array_reverse($list) as $item) {
|
||||
$item->makeTitle($module);
|
||||
}
|
||||
} else {
|
||||
$this->makeTitle($module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ class Database/*<Database_PDOStatement>*/ extends PDO
|
|||
$connection = null;
|
||||
if ($dsn['phptype'] == 'pgsql' || $dsn['phptype'] == 'mysql') {
|
||||
$port = (isset($dsn['port'])) ? "port={$dsn['port']};" : "";
|
||||
$connection/*: Database*/ = new static("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']);
|
||||
$connection/*: Database*/ = new self("{$dsn['phptype']}:host={$dsn['hostspec']}; $port dbname={$dsn['database']}", $dsn['username'], $dsn['password']);
|
||||
if ($dsn['phptype'] == 'pgsql') {
|
||||
$connection->query('SET client_encoding="UTF-8"');
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ class Database/*<Database_PDOStatement>*/ extends PDO
|
|||
}
|
||||
}
|
||||
if ($dsn['phptype'] == 'sqlite') {
|
||||
$connection/*: Database*/ = new static("{$dsn['phptype']}:{$dsn['database']}");
|
||||
$connection/*: Database*/ = new self("{$dsn['phptype']}:{$dsn['database']}");
|
||||
$connection->setAttribute(PDO::ATTR_TIMEOUT, 5);
|
||||
$mode = defined('SQLITE_JOURNAL_MODE') ? SQLITE_JOURNAL_MODE : 'WAL';
|
||||
$connection->query("PRAGMA journal_mode=$mode");
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ class Field
|
|||
public $_title = array();
|
||||
public $description = "";
|
||||
public $alias = array();
|
||||
|
||||
|
||||
/** @phpstan-ignore-next-line */
|
||||
public function __construct ($input = array(), $factory = null)
|
||||
{
|
||||
|
||||
{
|
||||
$this->default = null;
|
||||
if (isset($input['validate'])) {
|
||||
$this->require = strpos($input['validate'], 'require') !== false;
|
||||
|
|
|
|||
|
|
@ -47,21 +47,23 @@ class Primitive {
|
|||
{
|
||||
$result = 0;
|
||||
$tmp = explode("/", $value ?? '', 3);
|
||||
if (!empty($tmp)) {
|
||||
if (count($tmp) != 3) return $result;
|
||||
|
||||
if (count($tmp) != 3) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$year = (int)$tmp[2];
|
||||
$month = (int)$tmp[1];
|
||||
$day = (int)$tmp[0];
|
||||
$year = (int)$tmp[2];
|
||||
$month = (int)$tmp[1];
|
||||
$day = (int)$tmp[0];
|
||||
|
||||
if ($month != 0 && $day != 0 && $year != 0) {
|
||||
if (checkdate($month, $day, $year)) {
|
||||
return mktime(0, 0, 0, $month, $day, $year);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if ($month != 0 && $day != 0 && $year != 0) {
|
||||
if (checkdate($month, $day, $year)) {
|
||||
return mktime(0, 0, 0, $month, $day, $year);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue