diff --git a/system/MagiQL/Api/Factory.php b/system/MagiQL/Api/Factory.php new file mode 100644 index 0000000..80da2eb --- /dev/null +++ b/system/MagiQL/Api/Factory.php @@ -0,0 +1,21 @@ +class = \Phacil\Framework\MagiQL::class; + } +} \ No newline at end of file diff --git a/system/MagiQL/MagiQL.php b/system/MagiQL/MagiQL.php index 8a7da72..336e84b 100644 --- a/system/MagiQL/MagiQL.php +++ b/system/MagiQL/MagiQL.php @@ -65,26 +65,26 @@ class MagiQL extends AbstractBuilder { * @throws \Phacil\Framework\Exception */ public function isTableExists($tableName) { - if($this->db->getDBTypeId() == DatabaseDriverInterface::LIST_DB_TYPE_ID['MYSQL']){ + if($this->db->getDBTypeId() === DatabaseDriverInterface::LIST_DB_TYPE_ID['MYSQL']){ $sql = 'SELECT (1) AS tbl_exists FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = :v1 AND TABLE_SCHEMA = :v2'; $result = $this->db->execute($sql, [ ':v1' => $tableName, ':v2' => \Phacil\Framework\Config::DB_DATABASE() ]); } - if($this->db->getDBTypeId() == DatabaseDriverInterface::LIST_DB_TYPE_ID['MSSQL']){ + if($this->db->getDBTypeId() === DatabaseDriverInterface::LIST_DB_TYPE_ID['MSSQL']){ $sql = "SELECT OBJECT_ID(:v1, 'U') AS table_id"; $result = $this->db->execute($sql, [ ':v1' => $tableName ]); } - if($this->db->getDBTypeId() == DatabaseDriverInterface::LIST_DB_TYPE_ID['POSTGRE']){ + if($this->db->getDBTypeId() === DatabaseDriverInterface::LIST_DB_TYPE_ID['POSTGRE']){ $sql = "SELECT 1 FROM information_schema.tables WHERE table_name = :v1"; $result = $this->db->execute($sql, [ ':v1' => $tableName ]); } - if($this->db->getDBTypeId() == DatabaseDriverInterface::LIST_DB_TYPE_ID['SQLLITE3']){ + if($this->db->getDBTypeId() === DatabaseDriverInterface::LIST_DB_TYPE_ID['SQLLITE3']){ $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name=:v1"; $result = $this->db->execute($sql, [ ':v1' => $tableName diff --git a/system/engine/api/log.php b/system/engine/api/log.php index e1fe6ab..71882ce 100644 --- a/system/engine/api/log.php +++ b/system/engine/api/log.php @@ -69,6 +69,24 @@ interface Log */ public function getFileName(); + /** + * @param string $logformat + * @return $this + */ + public function setLogformat($logformat); + + /** + * @param bool $remove + * @return $this + */ + public function setRemoveUsedContextFields($remove = false); + + /** + * @param bool $allow + * @return $this + */ + public function setAllowInlineLineBreaks($allow = true); + /** * Return the log file path * @@ -103,9 +121,9 @@ interface Log * System is unusable. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function emergency($message, array $context = array()); @@ -116,9 +134,9 @@ interface Log * trigger the SMS alerts and wake you up. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function alert($message, array $context = array()); @@ -128,9 +146,9 @@ interface Log * Example: Application component unavailable, unexpected exception. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function critical($message, array $context = array()); @@ -139,9 +157,9 @@ interface Log * be logged and monitored. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function error($message, array $context = array()); @@ -152,9 +170,9 @@ interface Log * that are not necessarily wrong. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function warning($message, array $context = array()); @@ -162,9 +180,9 @@ interface Log * Normal but significant events. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function notice($message, array $context = array()); @@ -174,9 +192,9 @@ interface Log * Example: User logs in, SQL logs. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function info($message, array $context = array()); @@ -184,22 +202,22 @@ interface Log * Detailed debug information. * * @param string $message - * @param mixed[] $context + * @param array $context * - * @return void + * @return int|false */ public function debug($message, array $context = array()); /** * Logs with an arbitrary level. * - * @param string $level * @param string $message + * @param string $level (Optional) * @param array $context (Optional) * * @return int|false * * @throws \Phacil\Framework\Exception\InvalidArgumentException */ - public function log($level, $message, array $context = array()); + public function log($message, $level = self::INFO, array $context = array()); } \ No newline at end of file diff --git a/system/engine/log.php b/system/engine/log.php index c4230b5..39adf93 100644 --- a/system/engine/log.php +++ b/system/engine/log.php @@ -38,7 +38,6 @@ class Log implements \Phacil\Framework\Api\Log { private $filepath; /** - * * @var \Phacil\Framework\Api\Log[] */ private $extraLoggers = []; @@ -46,6 +45,9 @@ class Log implements \Phacil\Framework\Api\Log { /** @var bool */ protected $removeUsedContextFields = false; + /** + * @var bool + */ protected $allowInlineLineBreaks = true; /** @@ -55,8 +57,7 @@ class Log implements \Phacil\Framework\Api\Log { protected $format = "[%datetime%] %channel%.%level_name%: %message% %context% %extra% | %route%"; /** - * @param string $filename (optional) The name of log file. The path is automatic defined in the DIR_LOGS constant in config file. Isn't not possible to change the path. The default name is error.log. - * @return void + * {@inheritdoc} */ public function __construct($filename = \Phacil\Framework\Api\Log::DEFAULT_FILE_NAME) { if(!defined(self::CONFIGURATION_LOGS_CONST)){ @@ -95,11 +96,7 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * Write the error message in the log file - * - * @param string $message - * @return int|false - * @since 1.0.0 + * {@inheritdoc} */ public function write($message) { return $this->writeToFile('[' . $this->getDateTime() . '] - ' . print_r($message, true)." | ".$_SERVER['REQUEST_URI'] . " | " . \Phacil\Framework\startEngineExacTI::getRoute()); @@ -144,10 +141,7 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * Return the log file name - * - * @since 2.0.0 - * @return string + * {@inheritdoc} */ public function getFileName() { @@ -155,10 +149,7 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * Return the log file path - * - * @since 2.0.0 - * @return string + * {@inheritdoc} */ public function getFilePath() { @@ -166,13 +157,31 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * Return last lines of log archive - * - * @param string|null $filepath (optional) Path of file. Default is the log file. - * @param int $lines (optional) Lines to be readed. Default value is 10. - * @param bool $adaptive (optional) Default value is true. - * @return false|string - * @since 2.0.0 + * @inheritdoc + */ + public function setLogformat($logformat) { + $this->format = $logformat; + return $this; + } + + /** + * @inheritdoc + */ + public function setRemoveUsedContextFields($remove = false) { + $this->removeUsedContextFields = $remove; + return $this; + } + + /** + * @inheritdoc + */ + public function setAllowInlineLineBreaks($allow = true){ + $this->allowInlineLineBreaks = $allow; + return $this; + } + + /** + * @inheritdoc */ public function tail($filepath = null, $lines = 10, $adaptive = true) { @@ -231,13 +240,7 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * Return first lines of log archive - * - * @param string|null $filepath (optional) Path of file. Default is the log file. - * @param int $lines (optional) Lines to be readed. Default value is 10. - * @param bool $adaptive (optional) Default value is true. - * @return false|string - * @since 2.0.0 + * @inheritdoc */ public function head($filepath = null, $lines = 10, $adaptive = true) { @@ -266,124 +269,73 @@ class Log implements \Phacil\Framework\Api\Log { } /** - * System is unusable. - * - * @param string $message - * @param array $context - * - * @return void + * {@inheritdoc} */ public function emergency($message, array $context = array()) { - $this->log(self::EMERGENCY, $message, $context); + return $this->log($message, self::EMERGENCY, $context); } /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return void + * {@inheritdoc} */ public function alert($message, array $context = array()) { - $this->log(self::ALERT, $message, $context); + return $this->log($message, self::ALERT, $context); } /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return void + * {@inheritdoc} */ public function critical($message, array $context = array()) { - $this->log(self::CRITICAL, $message, $context); + return $this->log($message, self::CRITICAL, $context); } /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return void + * {@inheritdoc} */ public function error($message, array $context = array()) { - $this->log(self::ERROR, $message, $context); + return $this->log($message, self::ERROR, $context); } /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return void + * @inheritdoc */ public function warning($message, array $context = array()) { - $this->log(self::WARNING, $message, $context); + return $this->log($message, self::WARNING, $context); } /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return void + * @inheritdoc */ public function notice($message, array $context = array()) { - $this->log(self::NOTICE, $message, $context); + return $this->log($message, self::NOTICE, $context); } /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return void + * @inheritdoc */ public function info($message, array $context = array()) { - $this->log(self::INFO, $message, $context); + return $this->log($message, self::INFO, $context); } /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return void + * @inheritdoc */ public function debug($message, array $context = array()) { - $this->log(self::DEBUG, $message, $context); + return $this->log($message, self::DEBUG, $context); } /** * {@inheritdoc} */ - public function log($level = self::INFO, $message = null, array $context = array()) { + public function log($message = null, $level = self::INFO, array $context = array()) { $record = [ 'message' => $message, 'context' => $context, @@ -508,6 +460,12 @@ class Log implements \Phacil\Framework\Api\Log { return $this->replaceNewlines($this->convertToString($value)); } + /** + * @param mixed $format + * @param mixed $record + * @return string + * @throws \RuntimeException + */ protected function interpolate($format, $record) { $replace = []; diff --git a/system/etc/preferences.json b/system/etc/preferences.json index 4c4e4dc..e210572 100644 --- a/system/etc/preferences.json +++ b/system/etc/preferences.json @@ -10,6 +10,8 @@ "Phacil\\Framework\\Mail\\Api\\MailInterface": "Phacil\\Framework\\Mail", "Phacil\\Framework\\Api\\Document": "Phacil\\Framework\\Document", "Phacil\\Framework\\Api\\Log": "Phacil\\Framework\\Log", - "Phacil\\Framework\\Databases\\Api\\LogInterface": "Phacil\\Framework\\Log" + "Phacil\\Framework\\Databases\\Api\\LogInterface": "Phacil\\Framework\\Log", + "Phacil\\Framework\\Interfaces\\Serializer": "Phacil\\Framework\\Json", + "Phacil\\Framework\\MagiQL\\Api\\Factory": "Phacil\\Framework\\MagiQL\\Factory" } } \ No newline at end of file diff --git a/system/library/encryption.php b/system/library/encryption.php index 1aa46c4..c2e5391 100644 --- a/system/library/encryption.php +++ b/system/library/encryption.php @@ -7,4 +7,4 @@ */ -class_alias('\Phacil\Framework\Encryption', 'Encryption'); \ No newline at end of file +class_alias(\Phacil\Framework\Encryption::class, 'Encryption'); \ No newline at end of file