diff --git a/composer.json b/composer.json index 24403b9..7550172 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ "@solve-lint" ], "lint": [ - "phpcs --encoding=utf-8 -n -s --colors --standard=PSR1,PSR12,PEAR --exclude=PEAR.Commenting.ClassComment,PEAR.Commenting.FileComment,PEAR.Commenting.FunctionComment --ignore=node_modules/*,system/composer/*,public/* ./ " + "phpcs --encoding=utf-8 -n -s --colors --standard=PSR1,PSR12 --ignore=node_modules/*,system/composer/*,public/* ./ " ], "fix-lint": [ - "phpcbf --encoding=utf-8 -n --colors --standard=PSR1,PSR12,PEAR --exclude=PEAR.Commenting.ClassComment,PEAR.Commenting.FileComment --ignore=node_modules/*,system/composer/*,public/* ./" + "phpcbf --encoding=utf-8 -n --colors --standard=PSR1,PSR12 --ignore=node_modules/*,system/composer/*,public/* ./" ] }, "authors": [ diff --git a/src/product/controller/productController.php b/src/product/controller/productController.php index b07aa46..79a2bbe 100644 --- a/src/product/controller/productController.php +++ b/src/product/controller/productController.php @@ -8,7 +8,7 @@ * Default's controller, this shows the demo pages when you run for first time * this project */ -class productController extends Controller +class ProductController extends Controller { /** diff --git a/src/welcome/controller/welcomeController.php b/src/welcome/controller/welcomeController.php index 1189d27..89a6fde 100644 --- a/src/welcome/controller/welcomeController.php +++ b/src/welcome/controller/welcomeController.php @@ -8,7 +8,7 @@ * Default's controller, this shows the demo pages when you run for first time * this project */ -class welcomeController extends Controller +class WelcomeController extends Controller { /** * First sample page, returns welcome template diff --git a/system/bootstrap.php b/system/bootstrap.php index f624164..dda855e 100644 --- a/system/bootstrap.php +++ b/system/bootstrap.php @@ -70,13 +70,13 @@ set_exception_handler(array($logger,"myExceptionHandler")); // XSS, scape characters, SQL Injection -$util->array_walk_recursive_referential($_GET, array($util, "preventXSS")); -$util->array_walk_recursive_referential($_GET, "trim"); -$util->array_walk_recursive_referential($_GET, array($util, "escape")); +$util->arrayWalkRecursiveReferential($_GET, array($util, "preventXSS")); +$util->arrayWalkRecursiveReferential($_GET, "trim"); +$util->arrayWalkRecursiveReferential($_GET, array($util, "escape")); -$util->array_walk_recursive_referential($_POST, array($util, "preventXSS")); -$util->array_walk_recursive_referential($_POST, "trim"); -$util->array_walk_recursive_referential($_POST, array($util, "escape")); +$util->arrayWalkRecursiveReferential($_POST, array($util, "preventXSS")); +$util->arrayWalkRecursiveReferential($_POST, "trim"); +$util->arrayWalkRecursiveReferential($_POST, array($util, "escape")); // Add container entries $container = new Container(); diff --git a/system/library/Database.php b/system/library/Database.php index 8f7fdaa..f33f90c 100644 --- a/system/library/Database.php +++ b/system/library/Database.php @@ -7,20 +7,20 @@ */ class Database { - private $connection; - private $host; - private $user; - private $db_name; - private $pass; - private $console; // used for debug + private $_connection; + private $_host; + private $_user; + private $_db_name; + private $_pass; + private $_console; // used for debug public function __construct($host, $user, $db_name, $pass, $console) { - $this->host = $host; - $this->user = $user; - $this->db_name = $db_name; - $this->pass = $pass; - $this->console = $console; + $this->_host = $host; + $this->_user = $user; + $this->_db_name = $db_name; + $this->_pass = $pass; + $this->_console = $console; } /** @@ -33,9 +33,9 @@ public function __construct($host, $user, $db_name, $pass, $console) */ public function query(string $sql_query, array $params = array()) { - $this->console->addQuery($sql_query); + $this->_console->addQuery($sql_query); - $smtp = $this->connection->prepare($sql_query); + $smtp = $this->_connection->prepare($sql_query); $smtp->setFetchMode(\PDO::FETCH_ASSOC); $query = $smtp->execute($params); @@ -55,7 +55,7 @@ public function query(string $sql_query, array $params = array()) } if (strpos($sql_query, "INSERT INTO") !== false) { - $data = $this->connection->lastInsertId(); + $data = $this->_connection->lastInsertId(); } } @@ -67,7 +67,7 @@ public function query(string $sql_query, array $params = array()) */ public function getLastId(): int { - return $this->connection->lastInsertId(); + return $this->_connection->lastInsertId(); } /** @@ -76,16 +76,16 @@ public function getLastId(): int public function initialize(): void { try { - $temp_connection = new \PDO("mysql:host=" . $this->host . ";port=3306;dbname=" . $this->db_name, $this->user, $this->pass); + $temp_connection = new \PDO("mysql:host=" . $this->_host . ";port=3306;dbname=" . $this->_db_name, $this->_user, $this->_pass); $temp_connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); // true prepare statements $temp_connection->exec("SET NAMES 'utf8'"); $temp_connection->exec("SET CHARACTER SET utf8"); $temp_connection->exec("SET CHARACTER_SET_CONNECTION=utf8"); - $this->connection = $temp_connection; + $this->_connection = $temp_connection; } catch (\Throwable $th) { - $this->console->addDebugInfo("Error loading database"); + $this->_console->addDebugInfo("Error loading database"); } } @@ -96,7 +96,7 @@ public function destruct(): void { //More info about this here: https://php.net/pdo.connections //KILL CONNECTION_ID() - $this->connection->query('SELECT pg_terminate_backend(pg_backend_pid());'); - $this->connection = null; + $this->_connection->query('SELECT pg_terminate_backend(pg_backend_pid());'); + $this->_connection = null; } } diff --git a/system/library/Logger.php b/system/library/Logger.php index 4494e6b..b0184c2 100644 --- a/system/library/Logger.php +++ b/system/library/Logger.php @@ -11,22 +11,22 @@ class Logger { public $error_handle; - private $error_log_path; - private $notice_log_path; - private $warning_log_path; - private $unknown_errors_log_path; - private $console; + private $_error_log_path; + private $_notice_log_path; + private $_warning_log_path; + private $_unknown_errors_log_path; + private $_console; /** * Sets the Logger constructor */ public function __construct($error_log_path, $notice_log_path, $warning_log_path, $unknown_errors_log_path, $console) { - $this->error_log_path = $error_log_path; - $this->notice_log_path = $notice_log_path; - $this->warning_log_path = $warning_log_path; - $this->unknown_errors_log_path = $unknown_errors_log_path; - $this->console = $console; + $this->_error_log_path = $error_log_path; + $this->_notice_log_path = $notice_log_path; + $this->_warning_log_path = $warning_log_path; + $this->_unknown_errors_log_path = $unknown_errors_log_path; + $this->_console = $console; } /** @@ -80,10 +80,10 @@ public function myExceptionHandler(object $exception): void { $exception_message = $exception->getMessage(); - $this->console->addError($exception_message); + $this->_console->addError($exception_message); - $this->checkLogFile($this->error_log_path); - error_log($exception_message . "\n", 3, $this->error_log_path); + $this->checkLogFile($this->_error_log_path); + error_log($exception_message . "\n", 3, $this->_error_log_path); die($exception_message); } @@ -95,9 +95,9 @@ public function myExceptionHandler(object $exception): void */ public function noticeHandler(string $error_string): void { - $this->console->addWarning($error_string); - $this->checkLogFile($this->notice_log_path); - error_log($error_string . "\n", 3, $this->notice_log_path); + $this->_console->addWarning($error_string); + $this->checkLogFile($this->_notice_log_path); + error_log($error_string . "\n", 3, $this->_notice_log_path); } /** @@ -107,9 +107,9 @@ public function noticeHandler(string $error_string): void */ public function warningHandler(string $error_string): void { - $this->console->addWarning($error_string); - $this->checkLogFile($this->warning_log_path); - error_log($error_string . "\n", 3, $this->warning_log_path); + $this->_console->addWarning($error_string); + $this->checkLogFile($this->_warning_log_path); + error_log($error_string . "\n", 3, $this->_warning_log_path); } /** @@ -119,9 +119,9 @@ public function warningHandler(string $error_string): void */ public function errorHandler(string $error_string): void { - $this->console->addError($error_string); - $this->checkLogFile($this->error_log_path); - error_log($error_string . "\n", 3, $this->error_log_path); + $this->_console->addError($error_string); + $this->checkLogFile($this->_error_log_path); + error_log($error_string . "\n", 3, $this->_error_log_path); } /** @@ -131,9 +131,9 @@ public function errorHandler(string $error_string): void */ public function unknownErrorHandler(string $error_string): void { - $this->console->addError($error_string); - $this->checkLogFile($this->unknown_errors_log_path); - error_log($error_string . "\n", 3, $this->unknown_errors_log_path); + $this->_console->addError($error_string); + $this->checkLogFile($this->_unknown_errors_log_path); + error_log($error_string . "\n", 3, $this->_unknown_errors_log_path); } /** diff --git a/system/library/Util.php b/system/library/Util.php index f722b51..23a5243 100644 --- a/system/library/Util.php +++ b/system/library/Util.php @@ -137,9 +137,9 @@ public function checkPostCSRFToken(): void * @param $parameters An optional array of the additional parameters to be appended to the function * * Example usage to alter $array to get the second, third and fourth character from each value - * array_walk_recursive_referential($array, "substr", array("1","3")); + * arrayWalkRecursiveReferential($array, "substr", array("1","3")); */ - public function array_walk_recursive_referential(&$array, $function, $parameters = array()): void + public function arrayWalkRecursiveReferential(&$array, $function, $parameters = array()): void { $reference_function = function (&$value, $key, $userdata): void { $parameters = array_merge(array($value), $userdata[1]);