diff --git a/app/common/controller/home.php b/app/common/controller/home.php index b18887a..0759faf 100644 --- a/app/common/controller/home.php +++ b/app/common/controller/home.php @@ -8,8 +8,16 @@ use Phacil\Framework\Controller; +/** @package */ class ControllerCommonHome extends Controller { + /** + * @return void + * @throws TypeError + * @throws Mustache_Exception_UnknownTemplateException + * @throws SmartyException + * @throws Exception + */ public function index() { var_dump('oi'); $this->document->setTitle("Hello World! %s"); diff --git a/app/common/helper/Data.php b/app/common/helper/Data.php index 92e54d1..013697f 100644 --- a/app/common/helper/Data.php +++ b/app/common/helper/Data.php @@ -7,6 +7,8 @@ */ class TestOfHelp { + + /** @return string */ function helpme(){ return 'saved'; } diff --git a/app/common/model/teste.php b/app/common/model/teste.php index 59b2219..adfc5c9 100644 --- a/app/common/model/teste.php +++ b/app/common/model/teste.php @@ -4,5 +4,6 @@ use Phacil\Framework\Model; class ModelCommonTeste extends Model { + /** @return string */ public function oi() {return "ta"; } } \ No newline at end of file diff --git a/system/caches/caches.php b/system/caches/caches.php index 182448f..e833deb 100644 --- a/system/caches/caches.php +++ b/system/caches/caches.php @@ -9,10 +9,19 @@ namespace Phacil\Framework; final class Caches { + /** + * + * @var int + */ private $expire = 3600; + /** + * + * @var string + */ public $dirCache = "caches/"; + /** @return void */ public function __construct() { $this->dirCache = DIR_CACHE."caches/"; @@ -23,6 +32,10 @@ final class Caches { } + /** + * @param string $key + * @return bool + */ public function verify($key) { $files = $this->valid($key); @@ -36,10 +49,18 @@ final class Caches { } } + /** + * @param string $key + * @return bool + */ public function check($key) { return $this->verify($key); } + /** + * @param string $key + * @return mixed + */ public function get($key) { $file = $this->valid($key); @@ -51,6 +72,12 @@ final class Caches { } } + /** + * @param string $key + * @param mixed $value + * @param bool $expire + * @return int|false + */ public function set($key, $value, $expire = true) { $this->delete($key); @@ -60,6 +87,10 @@ final class Caches { } + /** + * @param string $key + * @return int + */ public function delete($key) { $files = glob($this->dirCache . preg_replace('/[^A-Z0-9\.\*_-]/i', '', $key) . '.cache'); @@ -77,6 +108,10 @@ final class Caches { return (count($files)); } + /** + * @param mixed $value + * @return string|binary + */ private function encode($value){ if(function_exists('igbinary_serialize')){ diff --git a/system/caches/phpfastcache.php b/system/caches/phpfastcache.php index d88d13f..902a8ac 100644 --- a/system/caches/phpfastcache.php +++ b/system/caches/phpfastcache.php @@ -2,19 +2,49 @@ require_once __DIR__."/Phpfastcache/autoload.php"; -//require_once __DIR__."/caches.php"; +namespace Phacil\Framework; use Phpfastcache\CacheManager; use Phpfastcache\Config\ConfigurationOption; - +use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; +use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException; +use Phpfastcache\Exceptions\PhpfastcacheInvalidConfigurationException; +use Phpfastcache\Exceptions\PhpfastcacheDriverNotFoundException; +use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; +use Phpfastcache\Exceptions\PhpfastcacheDriverException; +use Phpfastcache\Exceptions\PhpfastcacheInstanceNotFoundException; +use stdClass; + +/** @package Phacil\Framework */ final class Caches { - private $expire = 3600; - + /** + * + * @var int + */ + private $expire = (int) 3600; + + /** + * + * @var ExtendedCacheItemPoolInterface + */ private $phpfastcache; + /** + * + * @var string + */ public $dirCache = DIR_CACHE . "caches/"; + /** + * @return void + * @throws PhpfastcacheDriverCheckException + * @throws PhpfastcacheInvalidConfigurationException + * @throws PhpfastcacheDriverNotFoundException + * @throws PhpfastcacheInvalidArgumentException + * @throws PhpfastcacheDriverException + * @throws PhpfastcacheInstanceNotFoundException + */ public function __construct() { if (!file_exists($this->dirCache)) { @@ -36,6 +66,11 @@ final class Caches } + /** + * @param string $key + * @return bool + * @throws PhpfastcacheInvalidArgumentException + */ public function verify($key) { @@ -44,11 +79,21 @@ final class Caches return $CachedString->isHit(); } + /** + * @param string $key + * @return bool + * @throws PhpfastcacheInvalidArgumentException + */ public function check($key) { return $this->verify($key); } + /** + * @param string $key + * @return mixed + * @throws PhpfastcacheInvalidArgumentException + */ public function get($key) { @@ -58,6 +103,13 @@ final class Caches } + /** + * @param string $key + * @param mixed $value + * @param bool $expire + * @return bool + * @throws PhpfastcacheInvalidArgumentException + */ public function set($key, $value, $expire = true) { $this->delete($key); @@ -75,6 +127,10 @@ final class Caches } + /** + * @param string $key + * @return void + */ public function delete($key) { @@ -83,20 +139,23 @@ final class Caches } + /** @return bool */ public function deleteAll(){ return $this->phpfastcache->clear(); } + /** @return bool */ public function clear() { return $this->deleteAll(); } + /** @return stdClass */ public function stats() { //var_dump($this->phpfastcache->getStats()); - $obj = new stdClass(); + $obj = new \stdClass(); $obj->size = $this->phpfastcache->getStats()->getSize(); $obj->info = $this->phpfastcache->getStats()->getInfo(); diff --git a/system/captcha/autoload.php b/system/captcha/autoload.php index 1b7caea..f9d6d28 100644 --- a/system/captcha/autoload.php +++ b/system/captcha/autoload.php @@ -8,6 +8,9 @@ namespace Phacil\Framework; +use Exception; + +/** @package Phacil\Framework */ class Captcha { protected $code; public $height = 40; @@ -20,7 +23,15 @@ class Captcha { public $fonts = "/fonts/*/*.ttf"; public $pos = 'ABCDEFGHJKLMNOPQRSTUWVXZ0123456789abcdefhijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUWVXZ0123456789'; - function __construct($width = NULL, $height = NULL, $numChar = 6, $background = 'black') { + /** + * @param int|null $width + * @param int|null $height + * @param int $numChar + * @param string $background + * @return void + * @throws Exception + */ + function __construct(int $width = NULL, int $height = NULL, $numChar = 6, $background = 'black') { $this->fonts = __DIR__."/fonts/*/*.ttf"; @@ -44,6 +55,7 @@ class Captcha { } + /** @return void */ public function __help() { $helpTxt = array( @@ -56,10 +68,15 @@ class Captcha { var_dump($helpTxt, true); } + /** @return string */ function getCode(){ return implode("", $this->code); } + /** + * @param string $format + * @return void + */ function showImage($format = 'png') { $image = imagecreatetruecolor($this->width, $this->height); @@ -359,6 +376,7 @@ class Captcha { return $this->im; } + /** @return float */ protected function frand() { return 0.0001 * mt_rand(0,9999); diff --git a/system/config/autoload.php b/system/config/autoload.php index ae8f37a..018877a 100644 --- a/system/config/autoload.php +++ b/system/config/autoload.php @@ -8,21 +8,43 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Config { + /** + * + * @var array + */ private $data = array(); + /** + * @param string|int $key + * @return null|array|string + */ public function get($key) { return (isset($this->data[$key]) ? $this->data[$key] : null); } + /** + * @param string $key + * @param mixed $value + * @return void + */ public function set($key, $value) { $this->data[$key] = $value; } + /** + * @param string|int $key + * @return bool + */ public function has($key) { return isset($this->data[$key]); } + /** + * @param string $filename + * @return void + */ public function load($filename) { $file = DIR_CONFIG . $filename . '.php'; diff --git a/system/database/library/db.php b/system/database/library/db.php index 734d9eb..8add049 100644 --- a/system/database/library/db.php +++ b/system/database/library/db.php @@ -8,11 +8,30 @@ namespace Phacil\Framework; +use Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException; + +/** @package Phacil\Framework */ final class DB { + /** + * + * @var object + */ private $driver; + /** + * + * @var string + */ private $cachePrefix = "SQL_"; + /** + * @param string $driver + * @param string $hostname + * @param string $username + * @param string $password + * @param string $database + * @return void + */ public function __construct($driver, $hostname, $username, $password, $database) { if (file_exists(DIR_DATABASE .'database/'. $driver . '.php')) { require_once(DIR_DATABASE .'database/'. $driver . '.php'); @@ -23,6 +42,12 @@ final class DB { $this->driver = new $driver($hostname, $username, $password, $database); } + /** + * @param string $sql + * @param bool $cacheUse + * @return object|\Phacil\Framework\DB::Cache + * @throws PhpfastcacheInvalidArgumentException + */ public function query($sql, $cacheUse = true) { if(defined('SQL_CACHE') && SQL_CACHE == true && $cacheUse == true) { @@ -36,18 +61,33 @@ final class DB { } + /** + * @param string $value + * @return mixed + */ public function escape($value) { return $this->driver->escape($value); } + /** @return int */ public function countAffected() { return $this->driver->countAffected(); } + /** @return mixed */ public function getLastId() { return $this->driver->getLastId(); } + /** + * @param string $sql + * @param int $pageNum_exibe + * @param int $maxRows_exibe + * @param bool $cache + * @param mixed|null $sqlTotal + * @return object + * @throws PhpfastcacheInvalidArgumentException + */ public function pagination($sql, $pageNum_exibe = 1, $maxRows_exibe = 10, $cache = true, $sqlTotal = null){ if (($pageNum_exibe >= 1)) { @@ -83,6 +123,11 @@ final class DB { return $exibe; } + /** + * @param string $sql + * @return object + * @throws PhpfastcacheInvalidArgumentException + */ private function Cache($sql) { if(class_exists('Caches')) { $cache = new Caches(); @@ -106,6 +151,11 @@ final class DB { } } + /** + * @param string $nome + * @param object $object + * @return void + */ public function createSubBase($nome, $object) { $this->$nome = $object; diff --git a/system/ecompress/active.php b/system/ecompress/active.php index 8ea8eab..a1892ed 100644 --- a/system/ecompress/active.php +++ b/system/ecompress/active.php @@ -6,4 +6,3 @@ $_SESSION['reset'] = ($_GET['reset'] == "true") ? 'true' : 'false'; echo "Reset caches: ".($_SESSION['reset']); -?> \ No newline at end of file diff --git a/system/ecompress/cssMin.php b/system/ecompress/cssMin.php index 1cd611d..6fd7686 100644 --- a/system/ecompress/cssMin.php +++ b/system/ecompress/cssMin.php @@ -1,5 +1,9 @@ \ No newline at end of file diff --git a/system/ecompress/includes.php b/system/ecompress/includes.php index a10261b..4c84a57 100644 --- a/system/ecompress/includes.php +++ b/system/ecompress/includes.php @@ -1,14 +1,6 @@ file; } + /** @return string */ public function getClass() { return $this->class; } + /** @return string */ public function getMethod() { return $this->method; } + /** @return array */ public function getArgs() { return $this->args; } } + + +/** @package Phacil\Framework */ final class ActionSystem { protected $file; protected $class; protected $method; protected $args = array(); + /** + * @param string $route + * @param array $args + * @return void + */ public function __construct($route, $args = array()) { $path = ''; @@ -132,20 +150,23 @@ final class ActionSystem { } } + /** @return string */ public function getFile() { return $this->file; } + /** @return string */ public function getClass() { return $this->class; } + /** @return string */ public function getMethod() { return $this->method; } + /** @return array */ public function getArgs() { return $this->args; } } -?> \ No newline at end of file diff --git a/system/engine/autoload.php b/system/engine/autoload.php index 2b456ca..fdd43b5 100644 --- a/system/engine/autoload.php +++ b/system/engine/autoload.php @@ -34,7 +34,7 @@ spl_autoload_register(function ($class) { 'document', 'response', 'classes', - 'caches' + //'caches' ]; if($namespace[0] == "Phacil" && in_array($class, $allowed)){ diff --git a/system/engine/classes.php b/system/engine/classes.php index 3e3ae49..5db0e83 100644 --- a/system/engine/classes.php +++ b/system/engine/classes.php @@ -8,6 +8,7 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ class Classes { private $format; @@ -18,6 +19,10 @@ class Classes { } + /** + * @param string|null $origin + * @return string + */ public function classes($origin = NULL){ $mClass = get_declared_classes(); @@ -45,6 +50,7 @@ class Classes { return($pegaClass); } + /** @return array|string */ public function functions(){ $classes = $this->classes('intern'); diff --git a/system/engine/controller.php b/system/engine/controller.php index 21eceeb..b4eff9b 100644 --- a/system/engine/controller.php +++ b/system/engine/controller.php @@ -8,18 +8,59 @@ namespace Phacil\Framework; +use TypeError; +use Mustache_Exception_UnknownTemplateException; +use RuntimeException; +use SmartyException; +use Exception; + +/** @package Phacil\Framework */ abstract class Controller { + /** + * + * @var Registry + */ protected $registry; protected $id; protected $layout; protected $template; + + /** + * + * @var array + */ protected $children = array(); + + /** + * + * @var array + */ protected $data = array(); + + /** + * + * @var array + */ protected $twig = array(); + + /** + * + * @var array + */ protected $error = array(); + protected $output; + + /** + * + * @var string[] + */ public $templateTypes = ["tpl", "twig", "mustache", "smarty", "dwoo"]; + /** + * @param \Phacil\Framework\Registry $registry + * @return void + */ public function __construct($registry) { $this->registry = $registry; } @@ -32,17 +73,32 @@ abstract class Controller { $this->registry->set($key, $value); } - protected function forward($route, $args = array()) { + /** + * @param string $route + * @param array $args + * @return Action + */ + protected function forward($route, array $args = array()) { return new Action($route, $args); } + /** + * @param string $url + * @param int $status + * @return never + */ protected function redirect($url, $status = 302) { header('Status: ' . $status); header('Location: ' . str_replace('&', '&', $url)); exit(); } - protected function getChild($child, $args = array()) { + /** + * @param string $child + * @param array $args + * @return mixed + */ + protected function getChild($child, array $args = array()) { $action = new Action($child, $args); $file = $action->getFile(); $class = $action->getClass(); @@ -62,6 +118,14 @@ abstract class Controller { } } + /** + * @return mixed + * @throws TypeError + * @throws Mustache_Exception_UnknownTemplateException + * @throws RuntimeException + * @throws SmartyException + * @throws Exception + */ protected function render() { foreach ($this->children as $child) { @@ -227,6 +291,15 @@ abstract class Controller { } } + /** + * @param bool $commonChildren + * @return mixed + * @throws TypeError + * @throws Mustache_Exception_UnknownTemplateException + * @throws RuntimeException + * @throws SmartyException + * @throws Exception + */ protected function out ($commonChildren = true) { if($commonChildren === true){ $this->children = array_merge(array( diff --git a/system/engine/document.php b/system/engine/document.php index c45c272..7ba8c74 100644 --- a/system/engine/document.php +++ b/system/engine/document.php @@ -8,6 +8,7 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ class Document { private $title; private $description; @@ -17,6 +18,10 @@ class Document { private $scripts = array(); private $fbmetas = array(); + /** + * @param string $title + * @return void + */ public function setTitle($title) { if(PATTERSITETITLE != false) { $this->title = sprintf($title, PATTERSITETITLE); @@ -25,26 +30,42 @@ class Document { } } + /** @return string */ public function getTitle() { return $this->title; } + /** + * @param string $description + * @return void + */ public function setDescription($description) { $this->description = $description; } + /** @return string */ public function getDescription() { return $this->description; } + /** + * @param string $keywords + * @return void + */ public function setKeywords($keywords) { $this->keywords = $keywords; } + /** @return string */ public function getKeywords() { return $this->keywords; } + /** + * @param string $href + * @param string $rel + * @return void + */ public function addLink($href, $rel) { $this->links[md5($href)] = array( 'href' => $href, @@ -52,11 +73,16 @@ class Document { ); } + /** @return array */ public function getLinks() { return $this->links; } - private function checkCDN($var) { + /** + * @param string $var + * @return string + */ + private function checkCDN( $var) { if(defined('CDN')) { if($this->checkLocal($var)){ @@ -68,6 +94,13 @@ class Document { } + /** + * @param string $href + * @param string $rel + * @param string $media + * @param bool $minify + * @return void + */ public function addStyle($href, $rel = 'stylesheet', $media = 'screen', $minify = true) { if ($minify) $href = $this->cacheMinify($href, 'css'); @@ -81,16 +114,24 @@ class Document { ); } + /** @return array */ public function getStyles() { return $this->styles; } - public function addScript($script, $sort = '0', $minify = true) { + /** + * @param string $script + * @param int|string $sort + * @param bool $minify + * @return void + */ + public function addScript($script, $sort = 0, $minify = true) { if($minify) $script = $this->cacheMinify($script, 'js'); $script = $this->checkCDN($script); $this->scripts[($sort)][md5($script)] = $script; } + /** @return array */ public function getScripts() { $a = $this->scripts; ksort($a); @@ -102,6 +143,11 @@ class Document { return (isset($b)) ? $b : []; } + /** + * @param string $property + * @param string $content + * @return void + */ public function addFBMeta($property, $content = ''){ $this->fbmetas[md5($property)] = array( 'property' => $property, @@ -109,21 +155,26 @@ class Document { ); } + /** @return array */ public function getFBMetas(){ return $this->fbmetas; } + /** + * @param string $val + * @return bool + */ private function checkLocal ($val) { $testaProtocolo = substr($val, 0, 7); - if($testaProtocolo != "http://" && $testaProtocolo != "https:/"){ - return true; - } else { - return false; - } - + return ($testaProtocolo != "http://" && $testaProtocolo != "https:/"); } + /** + * @param string $ref + * @param string $type + * @return string + */ private function cacheMinify($ref, $type) { $dir = "css-js-cache/"; diff --git a/system/engine/front.php b/system/engine/front.php index 435fff7..ccb7c59 100644 --- a/system/engine/front.php +++ b/system/engine/front.php @@ -8,20 +8,48 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Front { + + /** + * + * @var Registry + */ protected $registry; + + /** + * + * @var array + */ protected $pre_action = array(); + protected $error; - public function __construct($registry) { + /** + * + * @param Registry $registry + * @return void + */ + public function __construct(Registry $registry) { $this->registry = $registry; } - public function addPreAction($pre_action) { + + /** + * @param ActionSystem $pre_action + * @return void + */ + public function addPreAction(\Phacil\Framework\ActionSystem $pre_action) { $this->pre_action[] = $pre_action; } - public function dispatch($action, $error) { + + /** + * @param Action $action + * @param Action $error + * @return void + */ + public function dispatch(\Phacil\Framework\Action $action, \Phacil\Framework\Action $error) { $this->error = $error; foreach ($this->pre_action as $pre_action) { diff --git a/system/engine/loader.php b/system/engine/loader.php index e08e3eb..b2718b9 100644 --- a/system/engine/loader.php +++ b/system/engine/loader.php @@ -8,10 +8,15 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Loader { protected $registry; - public function __construct($registry) { + /** + * @param Registry $registry + * @return void + */ + public function __construct(\Phacil\Framework\Registry $registry) { $this->registry = $registry; } @@ -23,6 +28,10 @@ final class Loader { $this->registry->set($key, $value); } + /** + * @param string $library + * @return bool + */ public function library($library) { $file = DIR_SYSTEM . 'library/' . $library . '.php'; @@ -34,6 +43,10 @@ final class Loader { } } + /** + * @param string $model + * @return void + */ public function model(string $model) { $parts = explode('/', str_replace('../', '', (string)$model)); @@ -66,6 +79,10 @@ final class Loader { } + /** + * @param string $helper + * @return void + */ public function helper(string $helper) { $parts = explode('/', str_replace('../', '', (string)$helper)); @@ -88,10 +105,18 @@ final class Loader { } - public function control($model) { //temp alias, consider change to loader controller function - $this->controller($model); + /** + * @param string $control + * @return void + */ + public function control($control) { //temp alias, consider change to loader controller function + $this->controller($control); } + /** + * @param string $control + * @return void + */ public function controller($control) { $file = DIR_APPLICATION . 'controller/' . $control . '.php'; $class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $control); @@ -106,6 +131,16 @@ final class Loader { } } + /** + * @param string $driver + * @param string $hostname + * @param string $username + * @param string $password + * @param string $database + * @param int|null $port + * @param string|null $charset + * @return string[]|string|null + */ public function database($driver, $hostname, $username, $password, $database, $port = NULL, $charset = NULL) { $file = DIR_SYSTEM . 'database/database/' . $driver . '.php'; $class = ($driver); @@ -130,12 +165,19 @@ final class Loader { } } + /** + * @param string $config + * @return void + */ public function config($config) { $this->config->load($config); } + /** + * @param string $language + * @return mixed + */ public function language($language) { return $this->language->load($language); } } -?> \ No newline at end of file diff --git a/system/engine/log.php b/system/engine/log.php index fb2cd9a..e0e081f 100644 --- a/system/engine/log.php +++ b/system/engine/log.php @@ -8,17 +8,32 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Log { + + /** + * + * @var resource|false + */ private $filename; + /** + * @param string $filename + * @return void + */ public function __construct($filename = "error.log") { $this->filename = fopen(DIR_LOGS . $filename, 'a'); } + /** + * @param string $message + * @return void + */ public function write($message) { fwrite($this->filename, date('Y-m-d G:i:s') . ' - ' . print_r($message, true)." | ".$_SERVER['REQUEST_URI'] . PHP_EOL); } + /** @return void */ public function __destruct() { fclose($this->filename); } diff --git a/system/engine/model.php b/system/engine/model.php index 54b7d3d..8b77129 100644 --- a/system/engine/model.php +++ b/system/engine/model.php @@ -9,10 +9,20 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ abstract class Model { + + /** + * + * @var Registry + */ protected $registry; - public function __construct($registry) { + /** + * @param Registry $registry + * @return void + */ + public function __construct(Registry $registry) { $this->registry = $registry; } diff --git a/system/engine/registry.php b/system/engine/registry.php index 6b4b887..10f29fa 100644 --- a/system/engine/registry.php +++ b/system/engine/registry.php @@ -8,17 +8,31 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Registry { private $data = array(); + /** + * @param string $key + * @return mixed + */ public function get($key) { return (isset($this->data[$key]) ? $this->data[$key] : NULL); } + /** + * @param string $key + * @param string $value + * @return void + */ public function set($key, $value) { $this->data[$key] = $value; } + /** + * @param string $key + * @return bool + */ public function has($key) { return isset($this->data[$key]); } diff --git a/system/engine/response.php b/system/engine/response.php index b07e224..5a5e559 100644 --- a/system/engine/response.php +++ b/system/engine/response.php @@ -8,25 +8,56 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Response { + + /** + * + * @var array + */ private $headers = array(); + + /** + * + * @var int + */ private $level = 0; + private $output; + /** + * @param string $header + * @return void + */ public function addHeader($header) { $this->headers[] = $header; } + /** + * @param string $url + * @return never + */ public function redirect($url) { header('Location: ' . $url); exit; } + /** + * @param int $level + * @return void + */ public function setCompression($level) { $this->level = $level; } - public function setOutput($output, bool $isJSON = false, int $HTTPCODE = 0, string $HTTPDESC = null) { + /** + * @param mixed $output + * @param bool $isJSON + * @param int $HTTPCODE + * @param string|null $HTTPDESC + * @return void + */ + public function setOutput($output, $isJSON = false, $HTTPCODE = 0, $HTTPDESC = null) { if($isJSON) $this->isJSON(); @@ -37,6 +68,11 @@ final class Response { $this->output = $output; } + /** + * @param mixed $data + * @param int $level + * @return string|false + */ private function compress($data, $level = 0) { if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)) { $encoding = 'gzip'; @@ -67,6 +103,7 @@ final class Response { return gzencode($data, (int)$level); } + /** @return void */ public function output() { if ($this->output) { if ($this->level) { @@ -85,10 +122,16 @@ final class Response { } } + /** @return void */ public function isJSON() { $this->addHeader('Content-Type: application/json'); } + /** + * @param int $code + * @param string|null $description + * @return void + */ public function code(int $code, string $description = null){ $this->addHeader("HTTP/1.1 ".$code.(($description) ? " ". $description : "")); $this->addHeader("Status: ".$code.""); diff --git a/system/image/autoload.php b/system/image/autoload.php index 09296f2..f6c2385 100644 --- a/system/image/autoload.php +++ b/system/image/autoload.php @@ -8,11 +8,19 @@ namespace Phacil\Framework; +use Exception; + +/** @package Phacil\Framework */ final class Image { private $file; private $image; private $info; + /** + * @param string $file + * @return void + * @throws Exception + */ public function __construct($file) { if(!extension_loaded('gd')){ throw new \Exception("The image function requires GD extension on PHP!"); @@ -25,6 +33,11 @@ final class Image { } + /** + * @param string $file + * @param bool $infoFile + * @return bool + */ private function infoChk($file, $infoFile = true){ if (file_exists($file)) { $this->file = $file; @@ -46,6 +59,10 @@ final class Image { } } + /** + * @param string $image + * @return GdImage|false|void + */ private function create($image) { $info = getimagesize($image); $mime = $info['mime']; @@ -59,6 +76,11 @@ final class Image { } } + /** + * @param string $file + * @param int $quality + * @return void + */ public function save($file, $quality = 90) { $info = pathinfo($file); @@ -75,6 +97,11 @@ final class Image { imagedestroy($this->image); } + /** + * @param int $width + * @param int $height + * @return void + */ public function resize($width = 0, $height = 0) { if (!$this->info['width'] || !$this->info['height']) { return; @@ -115,6 +142,12 @@ final class Image { $this->info['height'] = $height; } + /** + * @param string $file + * @param string $position + * @param int $opacity + * @return false|void + */ public function watermark($file, $position = 'bottomright', $opacity = 100) { if($this->infoChk($file, false)) @@ -164,6 +197,13 @@ final class Image { imagedestroy($watermark); } + /** + * @param int $top_x + * @param int $top_y + * @param int $bottom_x + * @param int $bottom_y + * @return void + */ public function crop($top_x, $top_y, $bottom_x, $bottom_y) { $image_old = $this->image; $this->image = imagecreatetruecolor($bottom_x - $top_x, $bottom_y - $top_y); @@ -175,6 +215,11 @@ final class Image { $this->info['height'] = $bottom_y - $top_y; } + /** + * @param int $degree + * @param string $color + * @return void + */ public function rotate($degree, $color = 'FFFFFF') { $rgb = $this->html2rgb($color); @@ -184,16 +229,35 @@ final class Image { $this->info['height'] = imagesy($this->image); } + /** + * @param mixed $filter + * @return void + */ private function filter($filter) { imagefilter($this->image, $filter); } + /** + * @param string $text + * @param int $x + * @param int $y + * @param int $size + * @param string $color + * @return void + */ private function text($text, $x = 0, $y = 0, $size = 5, $color = '000000') { $rgb = $this->html2rgb($color); imagestring($this->image, $size, $x, $y, $text, imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2])); } + /** + * @param string $file + * @param int $x + * @param int $y + * @param int $opacity + * @return void + */ private function merge($file, $x = 0, $y = 0, $opacity = 100) { $merge = $this->create($file); @@ -203,6 +267,10 @@ final class Image { imagecopymerge($this->image, $merge, $x, $y, 0, 0, $merge_width, $merge_height, $opacity); } + /** + * @param string $color + * @return false|(int|float)[] + */ private function html2rgb($color) { if ($color[0] == '#') { $color = substr($color, 1); diff --git a/system/library/encryption.php b/system/library/encryption.php index 4402d8c..2ea2739 100644 --- a/system/library/encryption.php +++ b/system/library/encryption.php @@ -1,9 +1,24 @@ key = $this->hash($key); @@ -16,10 +31,20 @@ final class Encryption { } + /** + * @param string $value + * @return string|false + */ public function hash($value) { return hash('sha256', $value, true); } + /** + * + * @param mixed $value + * @param mixed|null $key + * @return string + */ public function encrypt ($value, $key = NULL) { $this->key = ($key != NULL) ? $key : $this->key; @@ -30,6 +55,12 @@ final class Encryption { } } + /** + * + * @param mixed $value + * @param mixed|null $key + * @return string|false + */ public function decrypt ($value, $key = NULL) { $this->key = ($key != NULL) ? $key : $this->key; @@ -40,6 +71,10 @@ final class Encryption { } } + /** + * @param string $value + * @return string + */ function base64Encrypt($value) { if (!$this->key) { return $value; @@ -58,6 +93,10 @@ final class Encryption { return base64_encode($output); } + /** + * @param string $value + * @return string|false + */ function base64Decrypt($value) { if (!$this->key) { return $value; @@ -78,6 +117,10 @@ final class Encryption { return $output; } + /** + * @param string $value + * @return string + */ private function opensslEncrypt ($value) { $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher)); @@ -92,6 +135,10 @@ final class Encryption { } + /** + * @param string $value + * @return string|false + */ private function opensslDecrypt ($value) { $c = $this->base64Decrypt(strtr($value, '-_,', '+/=')); diff --git a/system/login/autoload.php b/system/login/autoload.php index 0f50a9b..b05950c 100644 --- a/system/login/autoload.php +++ b/system/login/autoload.php @@ -9,13 +9,37 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ class login { + /** + * + * @var array + */ private $MM_authorizedUsers = array(); + + /** + * + * @var string + */ private $MM_donotCheckaccess = "false"; + + /** + * + * @var Request + */ private $request = ''; + + /** + * + * @var Session + */ private $session; + /** + * @param arrray $authorizedUsers + * @return void + */ public function __construct($authorizedUsers){ $this->MM_authorizedUsers = $authorizedUsers; $this->request = new Request(); @@ -24,6 +48,13 @@ class login { } // *** Restrict Access To Page: Grant or deny access to this page + /** + * @param mixed $strUsers + * @param mixed $strGroups + * @param mixed $UserName + * @param mixed $UserGroup + * @return bool + */ public function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. @@ -50,6 +81,10 @@ class login { return $isValid; } + /** + * @param mixed $restrictGoTo + * @return void + */ public function check($restrictGoTo) { $MM_restrictGoTo = $restrictGoTo; @@ -66,12 +101,14 @@ class login { } } + /** @return bool */ public function isLogged () { $lgged = $this->isAuthorized("",$this->MM_authorizedUsers, $this->session->data['MM_Username'], $this->session->data['MM_UserGroup']); return($lgged); } + /** @return void */ public function logout() { unset($this->session->data['user_id']); @@ -81,10 +118,9 @@ class login { session_destroy(); } + /** @return string */ public function getUserName() { return $this->session->data['MM_Username']; } - - } \ No newline at end of file diff --git a/system/mail/mail.php b/system/mail/mail.php index f96c611..8f7a646 100644 --- a/system/mail/mail.php +++ b/system/mail/mail.php @@ -8,60 +8,178 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Mail { + + /** + * + * @var string + */ protected $to; + + /** + * + * @var string + */ protected $from; + + /** + * + * @var string + */ protected $sender; + + /** + * + * @var string + */ protected $subject; + + /** + * + * @var string + */ protected $text; + + /** + * + * @var string + */ protected $html; + + /** + * + * @var array + */ protected $attachments = array(); + + /** + * + * @var string + */ public $protocol = 'mail'; + + /** + * + * @var string + */ public $hostname; + + /** + * + * @var string + */ public $username; + + /** + * + * @var string + */ public $password; + + /** + * + * @var int + */ public $port = 25; + + /** + * + * @var int + */ public $timeout = 5; + + /** + * + * @var string + */ public $newline = "\n"; + + /** + * + * @var string + */ public $crlf = "\r\n"; + + /** + * + * @var bool + */ public $verp = false; + + + /** + * + * @var string + */ public $parameter = ''; + /** + * @param string $to + * @return void + */ public function setTo($to) { $this->to = $to; } + /** + * + * @param string $from + * @return void + */ public function setFrom($from) { $this->from = $from; } + /** + * @param string $sender + * @return void + */ public function setSender($sender) { $this->sender = html_entity_decode($sender, ENT_QUOTES, 'UTF-8'); } + /** + * @param string $subject + * @return void + */ public function setSubject($subject) { $this->subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8'); } + /** + * @param string $text + * @return void + */ public function setText($text) { $this->text = $text; } + /** + * @param string $html + * @return void + */ public function setHtml($html) { $this->html = $html; } + /** + * @param string $file + * @param string $filename + * @return void + */ public function addAttachment($file, $filename = '') { if (!$filename) { $filename = basename($file); } - $this->attachments[] = array( + $this->attachments[] = [ 'filename' => $filename, 'file' => $file - ); + ]; } + /** @return void */ public function send() { if (!$this->to) { trigger_error('Error: E-Mail to required!'); diff --git a/system/pagination/autoload.php b/system/pagination/autoload.php index 186a34e..6696a04 100644 --- a/system/pagination/autoload.php +++ b/system/pagination/autoload.php @@ -8,23 +8,100 @@ namespace Phacil\Framework; +/** @package Phacil\Framework */ final class Pagination { + + /** + * + * @var int + */ public $total = 0; + + /** + * + * @var int + */ public $page = 1; + + /** + * + * @var int + */ public $limit = 20; + + /** + * + * @var int + */ public $num_links = 10; + + /** + * + * @var string + */ public $url = ''; + + /** + * + * @var string + */ public $text = 'Showing {start} to {end} of {total} ({pages} Pages)'; + + /** + * + * @var string + */ public $text_first = '|<'; + + /** + * + * @var string + */ public $text_last = '>|'; + + /** + * + * @var string + */ public $text_next = '>'; + + /** + * + * @var string + */ public $text_prev = '<'; + + /** + * + * @var string + */ public $style_links = 'links'; + + /** + * + * @var string + */ public $style_results = 'results'; + + /** + * + * @var string[] + */ public $links_html = array('begin'=>'', 'end'=>''); + + /** + * + * @var string[] + */ public $output_html = array('begin'=>'', 'end'=>''); + + /** + * + * @var string[] + */ public $no_link_html = array('begin'=>'', 'end'=>''); + /** @return string */ public function render() { $total = $this->total; @@ -106,4 +183,3 @@ final class Pagination { return ($output ? '