fix: Доп. проверки значений

This commit is contained in:
origami11@yandex.ru 2025-11-12 19:41:24 +03:00
parent 33565c9f7e
commit b20ea0e7dc
8 changed files with 45 additions and 39 deletions

View file

@ -16,35 +16,7 @@ use ctiso\Controller\SiteInterface;
use ctiso\Database\PDOStatement; use ctiso\Database\PDOStatement;
use PHPTAL; use PHPTAL;
use PHPTAL_PreFilter_Normalize; use PHPTAL_PreFilter_Normalize;
use ctiso\View\FakeTemplate;
class FakeTemplate {
/** @var array */
public $_data = [];
/** @var string */
public $_name = '';
/**
* @param string $name
*/
function __construct($name) {
$this->_name = $name;
}
/**
* @param string $key
* @param mixed $value
*/
function __set($key, $value): void {
$this->_data[$key] = $value;
}
/**
* @return string
*/
function execute() {
return json_encode($this->_data);
}
}
/** /**
* Класс компонента * Класс компонента

View file

@ -15,7 +15,8 @@ class Session
function set(string|array $key, mixed $value): void function set(string|array $key, mixed $value): void
{ {
if (is_array($key)) { if (is_array($key)) {
$_SESSION[strtolower(get_class($key[0]))][$key[1]] = $value; $className = get_class($key[0]);
$_SESSION[strtolower($className)][$key[1]] = $value;
} else { } else {
$_SESSION[$key] = $value; $_SESSION[$key] = $value;
} }

View file

@ -184,7 +184,7 @@ class Settings
/** /**
* Запись настроек в файл (Может переименовать в store) * Запись настроек в файл (Может переименовать в store)
* *
* @param File $file * @param string $file
* @return void * @return void
*/ */
public function write($file = null) public function write($file = null)
@ -199,7 +199,7 @@ class Settings
$result = var_export($this->data, true); $result = var_export($this->data, true);
$result = "<?php\nreturn ".$result.";\n?>"; $result = "<?php\nreturn ".$result.";\n?>";
} }
file_put_contents (($file) ? $file : $this->file, $result); file_put_contents(($file) ? $file : $this->file, $result);
} }
/** /**

View file

@ -66,8 +66,8 @@ class SQLStatementExtractor
/** /**
* Extract SQL statements from array of lines. * Extract SQL statements from array of lines.
* *
* @param list<string> $lines Lines of the read-in file. * @param string[] $lines Lines of the read-in file.
* @return list<string> * @return string[] SQL statements
*/ */
protected static function extractStatements($lines) protected static function extractStatements($lines)
{ {
@ -177,6 +177,6 @@ class SQLStatementExtractor
protected static function getLines(string $buffer): array protected static function getLines(string $buffer): array
{ {
$lines = preg_split("/\r?\n|\r/", $buffer); $lines = preg_split("/\r?\n|\r/", $buffer);
return $lines; return $lines === false ? [] : $lines;
} }
} }

View file

@ -15,6 +15,6 @@ class PregMatch extends AbstractRule
public function isValid(Collection $container, $status = null): bool public function isValid(Collection $container, $status = null): bool
{ {
return preg_match($this->pattern, $container->get($this->field)); return preg_match($this->pattern, $container->get($this->field)) !== false;
} }
} }

View file

@ -1,8 +1,9 @@
<?php <?php
namespace ctiso\View; namespace ctiso\View;
use ctiso\View\View,
PHPTAL; use ctiso\View\View;
use PHPTAL;
use PHPTAL_TranslationService; use PHPTAL_TranslationService;
class Composite extends View class Composite extends View

32
src/View/FakeTemplate.php Normal file
View file

@ -0,0 +1,32 @@
<?php
namespace ctiso\View;
class FakeTemplate extends \stdClass {
/** @var array */
public $_data = [];
/** @var string */
public $_name = '';
/**
* @param string $name
*/
function __construct($name) {
$this->_name = $name;
}
/**
* @param string $key
* @param mixed $value
*/
function __set($key, $value): void {
$this->_data[$key] = $value;
}
/**
* @return string
*/
function execute() {
return json_encode($this->_data);
}
}

View file

@ -71,6 +71,6 @@ class Plain extends \stdClass
include ($document); include ($document);
$content = ob_get_contents (); $content = ob_get_contents ();
ob_clean (); ob_clean ();
return $content; return $content === false ? '' : $content;
} }
} }