diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index c7aa95269..e8d8efd75 100644 --- a/Account/AccountStatus.php +++ b/Account/AccountStatus.php @@ -28,8 +28,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AccountStatus extends Enum { - /* public */ const ACTIVE = 1; - /* public */ const INACTIVE = 2; - /* public */ const TIMEOUT = 3; - /* public */ const BANNED = 4; + /* public */ const ACTIVE = 1; + /* public */ const INACTIVE = 2; + /* public */ const TIMEOUT = 3; + /* public */ const BANNED = 4; } diff --git a/Account/AccountType.php b/Account/AccountType.php index 92369d6c9..8e63e53b7 100644 --- a/Account/AccountType.php +++ b/Account/AccountType.php @@ -28,6 +28,6 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AccountType extends Enum { - /* public */ const USER = 0; - /* public */ const GROUP = 1; + /* public */ const USER = 0; + /* public */ const GROUP = 1; } diff --git a/Account/GroupStatus.php b/Account/GroupStatus.php index 14916b4ef..b5fdbf19c 100644 --- a/Account/GroupStatus.php +++ b/Account/GroupStatus.php @@ -28,9 +28,7 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class GroupStatus extends Enum { - /* public */ const ACTIVE = 1; - - /* public */ const INACTIVE = 2; - - /* public */ const HIDDEN = 4; + /* public */ const ACTIVE = 1; + /* public */ const INACTIVE = 2; + /* public */ const HIDDEN = 4; } diff --git a/Asset/AssetType.php b/Asset/AssetType.php index 7f710555f..95fd69919 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -28,7 +28,7 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class AssetType extends Enum { - /* public */ const CSS = 0; - /* public */ const JS = 1; - /* public */ const JSLATE = 2; + /* public */ const CSS = 0; + /* public */ const JS = 1; + /* public */ const JSLATE = 2; } diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index 8ce0352ae..b18aa8db0 100644 --- a/Auth/LoginReturnType.php +++ b/Auth/LoginReturnType.php @@ -30,14 +30,14 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class LoginReturnType extends Enum { - /* public */ const OK = 0; /* Everything is ok and the user got authed */ - /* public */ const FAILURE = -1; /* Authentication resulted in a unexpected failure */ - /* public */ const WRONG_PASSWORD = -2; /* Authentication with wrong password */ - /* public */ const WRONG_USERNAME = -3; /* Authentication with unknown user */ - /* public */ const WRONG_PERMISSION = -4; /* User doesn't have permission to authenticate */ - /* public */ const NOT_ACTIVATED = -5; /* The user is not activated yet */ + /* public */ const OK = 0; /* Everything is ok and the user got authed */ + /* public */ const FAILURE = -1; /* Authentication resulted in a unexpected failure */ + /* public */ const WRONG_PASSWORD = -2; /* Authentication with wrong password */ + /* public */ const WRONG_USERNAME = -3; /* Authentication with unknown user */ + /* public */ const WRONG_PERMISSION = -4; /* User doesn't have permission to authenticate */ + /* public */ const NOT_ACTIVATED = -5; /* The user is not activated yet */ /* public */ const WRONG_INPUT_EXCEEDED = -6; /* Too many wrong logins recently */ - /* public */ const TIMEOUTED = -7; /* User received a timeout and can not log in until a certain date */ - /* public */ const BANNED = -8; /* User is banned */ - /* public */ const INACTIVE = -9; /* User is inactive */ + /* public */ const TIMEOUTED = -7; /* User received a timeout and can not log in until a certain date */ + /* public */ const BANNED = -8; /* User is banned */ + /* public */ const INACTIVE = -9; /* User is inactive */ } diff --git a/Business/Marketing/NetPromoterScore.php b/Business/Marketing/NetPromoterScore.php index 81a857fd3..7063632af 100644 --- a/Business/Marketing/NetPromoterScore.php +++ b/Business/Marketing/NetPromoterScore.php @@ -65,8 +65,8 @@ class NetPromoterScore { */ public function getScore() : int { - $promoters = 0; - $passives = 0; + $promoters = 0; + $passives = 0; $detractors = 0; foreach($this->scores as $score) { diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 24aa590c7..26df425b6 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -505,7 +505,7 @@ class DataMapperAbstract implements DataMapperInterface */ private static function getObjectId($obj, \ReflectionClass $reflectionClass = null) { - $reflectionClass = $reflectionClass ?? new \ReflectionClass(get_class($obj)); + $reflectionClass = $reflectionClass ?? new \ReflectionClass(get_class($obj)); $reflectionProperty = $reflectionClass->getProperty(static::$columns[static::$primaryField]['internal']); if (!($isPublic = $reflectionProperty->isPublic())) { @@ -710,7 +710,7 @@ class DataMapperAbstract implements DataMapperInterface private static function createOwnsOne(string $propertyName, $obj) { if (is_object($obj)) { - $mapper = static::$ownsOne[$propertyName]['mapper']; + $mapper = static::$ownsOne[$propertyName]['mapper']; $primaryKey = $mapper::getObjectId($obj); if (empty($primaryKey)) { @@ -738,7 +738,7 @@ class DataMapperAbstract implements DataMapperInterface private static function createOwnsOneArray(string $propertyName, array &$obj) { if (is_array($obj)) { - $mapper = static::$ownsOne[$propertyName]['mapper']; + $mapper = static::$ownsOne[$propertyName]['mapper']; $primaryKey = $obj[static::$columns[static::$primaryField]['internal']]; if (empty($primaryKey)) { @@ -767,7 +767,7 @@ class DataMapperAbstract implements DataMapperInterface { if (is_object($obj)) { /** @var DataMapperAbstract $mapper */ - $mapper = static::$belongsTo[$propertyName]['mapper']; + $mapper = static::$belongsTo[$propertyName]['mapper']; $primaryKey = $mapper::getObjectId($obj); if (empty($primaryKey)) { @@ -796,7 +796,7 @@ class DataMapperAbstract implements DataMapperInterface { if (is_array($obj)) { /** @var DataMapperAbstract $mapper */ - $mapper = static::$belongsTo[$propertyName]['mapper']; + $mapper = static::$belongsTo[$propertyName]['mapper']; $primaryKey = $obj[static::$columns[static::$primaryField]['internal']]; if (empty($primaryKey)) { @@ -991,7 +991,7 @@ class DataMapperAbstract implements DataMapperInterface // todo: definately an error here. needs testing throw new \Exception(); $removes = array_diff_key($many[$member], $objsIds[$member]); - $adds = array_diff_key($objsIds[$member], $many[$member]); + $adds = array_diff_key($objsIds[$member], $many[$member]); if(!empty($removes)) { self::deleteRelationTable($propertyName, $removes, $objId); @@ -1122,7 +1122,7 @@ class DataMapperAbstract implements DataMapperInterface foreach (static::$columns as $key => $column) { if (isset(static::$ownsOne[$propertyName]) && $column['internal'] === $propertyName) { - $id = self::updateOwnsOne($propertyName, $property->getValue($obj)); + $id = self::updateOwnsOne($propertyName, $property->getValue($obj)); $value = self::parseValue($column['type'], $id); // todo: should not be done if the id didn't change. but for now don't know if id changed @@ -1164,9 +1164,10 @@ class DataMapperAbstract implements DataMapperInterface public static function update($obj, int $relations = RelationType::ALL) : int { self::extend(__CLASS__); + $reflectionClass = new \ReflectionClass(get_class($obj)); - $objId = self::getObjectId($obj, $reflectionClass); - $update = true; + $objId = self::getObjectId($obj, $reflectionClass); + $update = true; if(empty($objId)) { $update = false; @@ -1373,8 +1374,9 @@ class DataMapperAbstract implements DataMapperInterface public static function delete($obj, int $relations = RelationType::REFERENCE) { self::extend(__CLASS__); + $reflectionClass = new \ReflectionClass(get_class($obj)); - $objId = self::getObjectId($obj, $reflectionClass); + $objId = self::getObjectId($obj, $reflectionClass); if(empty($objId)) { return null; @@ -1521,8 +1523,9 @@ class DataMapperAbstract implements DataMapperInterface foreach ($result as $member => $values) { if (!empty($values)) { /** @var DataMapperAbstract $mapper */ - $mapper = static::$hasMany[$member]['mapper']; + $mapper = static::$hasMany[$member]['mapper']; $values = array_diff($values, array_keys(self::$initObjects[$mapper] ?? [])); + if(empty($values)) { continue; } @@ -1942,7 +1945,7 @@ class DataMapperAbstract implements DataMapperInterface self::extend(__CLASS__); $refKey = (array) $refKey; - $obj = []; + $obj = []; foreach ($refKey as $key => $value) { $toLoad = []; @@ -2125,7 +2128,7 @@ class DataMapperAbstract implements DataMapperInterface */ public static function getAllByQuery(Builder $query, int $relations = RelationType::ALL) : array { - $sth = self::$db->con->prepare($query->toSql()); + $sth = self::$db->con->prepare($query->toSql()); $sth->execute(); $results = $sth->fetchAll(\PDO::FETCH_ASSOC); @@ -2174,9 +2177,9 @@ class DataMapperAbstract implements DataMapperInterface */ public static function fillRelations(array &$obj, int $relations = RelationType::ALL) /* : void */ { - $hasMany = !empty(static::$hasMany); - $hasOne = !empty(static::$hasOne); - $ownsOne = !empty(static::$ownsOne); + $hasMany = !empty(static::$hasMany); + $hasOne = !empty(static::$hasOne); + $ownsOne = !empty(static::$ownsOne); $belongsTo = !empty(static::$belongsTo); if ($relations !== RelationType::NONE && ($hasMany || $hasOne || $ownsOne || $belongsTo)) { @@ -2213,9 +2216,9 @@ class DataMapperAbstract implements DataMapperInterface */ public static function fillRelationsArray(array &$obj, int $relations = RelationType::ALL) /* : void */ { - $hasMany = !empty(static::$hasMany); - $hasOne = !empty(static::$hasOne); - $ownsOne = !empty(static::$ownsOne); + $hasMany = !empty(static::$hasMany); + $hasOne = !empty(static::$hasOne); + $ownsOne = !empty(static::$ownsOne); $belongsTo = !empty(static::$belongsTo); if ($relations !== RelationType::NONE && ($hasMany || $hasOne || $ownsOne || $belongsTo)) { @@ -2331,7 +2334,7 @@ class DataMapperAbstract implements DataMapperInterface $query->where(static::$table . '.' . static::$language_field, '=', $lang, 'AND'); } - $sth = self::$db->con->prepare($query->toSql()); + $sth = self::$db->con->prepare($query->toSql()); $sth->execute(); $results = $sth->fetchAll(\PDO::FETCH_ASSOC); diff --git a/DataStorage/Database/DeleteMapperAbstract.php b/DataStorage/Database/DeleteMapperAbstract.php index 6e3bd8661..7ca8fed90 100644 --- a/DataStorage/Database/DeleteMapperAbstract.php +++ b/DataStorage/Database/DeleteMapperAbstract.php @@ -243,7 +243,7 @@ class DeleteMapperAbstract extends DataMapperBaseAbstract { self::extend(__CLASS__); $reflectionClass = new \ReflectionClass(get_class($obj)); - $objId = self::getObjectId($obj, $reflectionClass); + $objId = self::getObjectId($obj, $reflectionClass); if(empty($objId)) { return null; diff --git a/Message/Http/Header.php b/Message/Http/Header.php index 0a8e341b0..f53d0a24b 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -111,10 +111,10 @@ class Header extends HeaderAbstract */ private function isSecurityHeader(string $key) : bool { - return $key === 'content-security-policy' || - $key === 'x-xss-protection' || - $key === 'x-content-type-options' || - $key === 'x-frame-options'; + return $key === 'content-security-policy' + || $key === 'x-xss-protection' + || $key === 'x-content-type-options' + || $key === 'x-frame-options'; } /** diff --git a/Message/Http/OSType.php b/Message/Http/OSType.php index 343381749..3c5c76f66 100644 --- a/Message/Http/OSType.php +++ b/Message/Http/OSType.php @@ -30,27 +30,27 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class OSType extends Enum { - /* public */ const WINDOWS_81 = 'windows nt 6.3'; /* Windows 8.1 */ - /* public */ const WINDOWS_8 = 'windows nt 6.2'; /* Windows 8 */ - /* public */ const WINDOWS_7 = 'windows nt 6.1'; /* Windows 7 */ - /* public */ const WINDOWS_VISTA = 'windows nt 6.0'; /* Windows Vista */ + /* public */ const WINDOWS_81 = 'windows nt 6.3'; /* Windows 8.1 */ + /* public */ const WINDOWS_8 = 'windows nt 6.2'; /* Windows 8 */ + /* public */ const WINDOWS_7 = 'windows nt 6.1'; /* Windows 7 */ + /* public */ const WINDOWS_VISTA = 'windows nt 6.0'; /* Windows Vista */ /* public */ const WINDOWS_SERVER = 'windows nt 5.2'; /* Windows Server 2003/XP x64 */ - /* public */ const WINDOWS_XP = 'windows nt 5.1'; /* Windows XP */ - /* public */ const WINDOWS_XP_2 = 'windows xp'; /* Windows XP */ - /* public */ const WINDOWS_2000 = 'windows nt 5.0'; /* Windows 2000 */ - /* public */ const WINDOWS_ME = 'windows me'; /* Windows ME */ - /* public */ const WINDOWS_98 = 'win98'; /* Windows 98 */ - /* public */ const WINDOWS_95 = 'win95'; /* Windows 95 */ - /* public */ const WINDOWS_311 = 'win16'; /* Windows 3.11 */ - /* public */ const MAC_OS_X = 'macintosh'; /* Mac OS X */ - /* public */ const MAC_OS_X_2 = 'mac os x'; /* Mac OS X */ - /* public */ const MAC_OS_9 = 'mac_powerpc'; /* Mac OS 9 */ - /* public */ const LINUX = 'linux'; /* Linux */ - /* public */ const UBUNTU = 'ubuntu'; /* Ubuntu */ - /* public */ const IPHONE = 'iphone'; /* IPhone */ - /* public */ const IPOD = 'ipod'; /* IPod */ - /* public */ const IPAD = 'ipad'; /* IPad */ - /* public */ const ANDROID = 'android'; /* Android */ - /* public */ const BLACKBERRY = 'blackberry'; /* Blackberry */ - /* public */ const MOBILE = 'webos'; /* Mobile */ + /* public */ const WINDOWS_XP = 'windows nt 5.1'; /* Windows XP */ + /* public */ const WINDOWS_XP_2 = 'windows xp'; /* Windows XP */ + /* public */ const WINDOWS_2000 = 'windows nt 5.0'; /* Windows 2000 */ + /* public */ const WINDOWS_ME = 'windows me'; /* Windows ME */ + /* public */ const WINDOWS_98 = 'win98'; /* Windows 98 */ + /* public */ const WINDOWS_95 = 'win95'; /* Windows 95 */ + /* public */ const WINDOWS_311 = 'win16'; /* Windows 3.11 */ + /* public */ const MAC_OS_X = 'macintosh'; /* Mac OS X */ + /* public */ const MAC_OS_X_2 = 'mac os x'; /* Mac OS X */ + /* public */ const MAC_OS_9 = 'mac_powerpc'; /* Mac OS 9 */ + /* public */ const LINUX = 'linux'; /* Linux */ + /* public */ const UBUNTU = 'ubuntu'; /* Ubuntu */ + /* public */ const IPHONE = 'iphone'; /* IPhone */ + /* public */ const IPOD = 'ipod'; /* IPod */ + /* public */ const IPAD = 'ipad'; /* IPad */ + /* public */ const ANDROID = 'android'; /* Android */ + /* public */ const BLACKBERRY = 'blackberry'; /* Blackberry */ + /* public */ const MOBILE = 'webos'; /* Mobile */ } diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 6f29e33c4..b4ab48c72 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -140,9 +140,9 @@ class Request extends RequestAbstract */ private function initCurrentRequest() /* : void */ { - $this->uri = new Http(Http::getCurrent()); - $this->data = $_GET ?? []; - $this->files = $_FILES ?? []; + $this->uri = new Http(Http::getCurrent()); + $this->data = $_GET ?? []; + $this->files = $_FILES ?? []; $this->language = $this->loadRequestLanguage(); if (isset($_SERVER['CONTENT_TYPE'])) { @@ -330,6 +330,7 @@ class Request extends RequestAbstract if (!isset($this->os)) { $arr = OSType::getConstants(); $http_request_type = strtolower($_SERVER['HTTP_USER_AGENT']); + foreach ($arr as $key => $val) { if (stripos($http_request_type, $val)) { $this->os = $val; diff --git a/Message/Http/RequestMethod.php b/Message/Http/RequestMethod.php index c287f14ee..d68d133cf 100644 --- a/Message/Http/RequestMethod.php +++ b/Message/Http/RequestMethod.php @@ -28,10 +28,10 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class RequestMethod extends Enum { - /* public */ const GET = 'GET'; /* GET */ - /* public */ const POST = 'POST'; /* POST */ - /* public */ const PUT = 'PUT'; /* PUT */ - /* public */ const DELETE = 'DELETE'; /* DELETE */ - /* public */ const HEAD = 'HEAD'; /* HEAD */ - /* public */ const TRACE = 'TRACE'; /* TRACE */ + /* public */ const GET = 'GET'; /* GET */ + /* public */ const POST = 'POST'; /* POST */ + /* public */ const PUT = 'PUT'; /* PUT */ + /* public */ const DELETE = 'DELETE'; /* DELETE */ + /* public */ const HEAD = 'HEAD'; /* HEAD */ + /* public */ const TRACE = 'TRACE'; /* TRACE */ } diff --git a/Message/Http/RequestStatus.php b/Message/Http/RequestStatus.php index 537aabc46..0a573911a 100644 --- a/Message/Http/RequestStatus.php +++ b/Message/Http/RequestStatus.php @@ -29,112 +29,58 @@ use phpOMS\Stdlib\Base\Enum; abstract class RequestStatus extends Enum { /* public */ const R_100 = 'Continue'; - /* public */ const R_101 = 'Switching Protocols'; - /* public */ const R_102 = 'Processing'; - /* public */ const R_200 = 'OK'; - /* public */ const R_201 = 'Created'; - /* public */ const R_202 = 'Accepted'; - /* public */ const R_203 = 'Non-Authoritative Information'; - /* public */ const R_204 = 'No Content'; - /* public */ const R_205 = 'Reset Content'; - /* public */ const R_206 = 'Partial Content'; - /* public */ const R_207 = 'Multi-Status'; - /* public */ const R_300 = 'Multiple Choices'; - /* public */ const R_301 = 'Moved Permanently'; - /* public */ const R_302 = 'Found'; - /* public */ const R_303 = 'See Other'; - /* public */ const R_304 = 'Not Modified'; - /* public */ const R_305 = 'Use Proxy'; - /* public */ const R_306 = 'Switch Proxy'; - /* public */ const R_307 = 'Temporary Redirect'; - /* public */ const R_400 = 'Bad Request'; - /* public */ const R_401 = 'Unauthorized'; - /* public */ const R_402 = 'Payment Required'; - /* public */ const R_403 = 'Forbidden'; - /* public */ const R_404 = 'Not Found'; - /* public */ const R_405 = 'Method Not Allowed'; - /* public */ const R_406 = 'Not Acceptable'; - /* public */ const R_407 = 'Proxy Authentication Required'; - /* public */ const R_408 = 'Request Timeout'; - /* public */ const R_409 = 'Conflict'; - /* public */ const R_410 = 'Gone'; - /* public */ const R_411 = 'Length Required'; - /* public */ const R_412 = 'Precondition Failed'; - /* public */ const R_413 = 'Request Entity Too Large'; - /* public */ const R_414 = 'Request-URI Too Long'; - /* public */ const R_415 = 'Unsupported Media Type'; - /* public */ const R_416 = 'Requested Range Not Satisfiable'; - /* public */ const R_417 = 'Expectation Failed'; - /* public */ const R_418 = 'I\'m a teapot'; - /* public */ const R_422 = 'Unprocessable Entity'; - /* public */ const R_423 = 'Locked'; - /* public */ const R_424 = 'Failed Dependency'; - /* public */ const R_425 = 'Unordered Collection'; - /* public */ const R_426 = 'Upgrade Required'; - /* public */ const R_449 = 'Retry With'; - /* public */ const R_450 = 'Blocked by Windows Parental Controls'; - /* public */ const R_500 = 'Internal Server Error'; - /* public */ const R_501 = 'Not Implemented'; - /* public */ const R_502 = 'Bad Gateway'; - /* public */ const R_503 = 'Service Unavailable'; - /* public */ const R_504 = 'Gateway Timeout'; - /* public */ const R_505 = 'HTTP Version Not Supported'; - /* public */ const R_506 = 'Variant Also Negotiates'; - /* public */ const R_507 = 'Insufficient Storage'; - /* public */ const R_509 = 'Bandwidth Limit Exceeded'; - /* public */ const R_510 = 'Not Extended'; } diff --git a/Message/Http/RequestStatusCode.php b/Message/Http/RequestStatusCode.php index ea849833b..2d45d292c 100644 --- a/Message/Http/RequestStatusCode.php +++ b/Message/Http/RequestStatusCode.php @@ -28,112 +28,58 @@ use phpOMS\Stdlib\Base\Enum; abstract class RequestStatusCode extends Enum { /* public */ const R_100 = 100; - /* public */ const R_101 = 101; - /* public */ const R_102 = 102; - /* public */ const R_200 = 200; - /* public */ const R_201 = 201; - /* public */ const R_202 = 202; - /* public */ const R_203 = 203; - /* public */ const R_204 = 204; - /* public */ const R_205 = 205; - /* public */ const R_206 = 206; - /* public */ const R_207 = 207; - /* public */ const R_300 = 300; - /* public */ const R_301 = 301; - /* public */ const R_302 = 302; - /* public */ const R_303 = 303; - /* public */ const R_304 = 304; - /* public */ const R_305 = 305; - /* public */ const R_306 = 306; - /* public */ const R_307 = 307; - /* public */ const R_400 = 400; - /* public */ const R_401 = 401; - /* public */ const R_402 = 402; - /* public */ const R_403 = 403; - /* public */ const R_404 = 404; - /* public */ const R_405 = 405; - /* public */ const R_406 = 406; - /* public */ const R_407 = 407; - /* public */ const R_408 = 408; - /* public */ const R_409 = 409; - /* public */ const R_410 = 410; - /* public */ const R_411 = 411; - /* public */ const R_412 = 412; - /* public */ const R_413 = 413; - /* public */ const R_414 = 414; - /* public */ const R_415 = 415; - /* public */ const R_416 = 416; - /* public */ const R_417 = 417; - /* public */ const R_418 = 418; - /* public */ const R_422 = 422; - /* public */ const R_423 = 423; - /* public */ const R_424 = 424; - /* public */ const R_425 = 425; - /* public */ const R_426 = 426; - /* public */ const R_449 = 449; - /* public */ const R_450 = 450; - /* public */ const R_500 = 500; - /* public */ const R_501 = 501; - /* public */ const R_502 = 502; - /* public */ const R_503 = 503; - /* public */ const R_504 = 504; - /* public */ const R_505 = 505; - /* public */ const R_506 = 506; - /* public */ const R_507 = 507; - /* public */ const R_509 = 509; - /* public */ const R_510 = 510; } diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 5fce9799f..e6235cfb9 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -116,9 +116,9 @@ class ModuleManager */ public function getRoutedModules(Request $request) : array { - $files = $this->getUriLoad($request); - + $files = $this->getUriLoad($request); $modules = []; + if (isset($files[4])) { foreach ($files[4] as $module) { $modules[] = $module['module_load_file']; @@ -147,6 +147,7 @@ class ModuleManager $i = 1; $c = count($uriHash); + for ($k = 0; $k < $c; $k++) { $uriPdo .= ':pid' . $i . ','; $i++; diff --git a/System/File/ContentPutMode.php b/System/File/ContentPutMode.php index 1293af244..a7af7c67a 100644 --- a/System/File/ContentPutMode.php +++ b/System/File/ContentPutMode.php @@ -30,8 +30,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class ContentPutMode extends Enum { - /* public */ const APPEND = 1; - /* public */ const PREPEND = 2; - /* public */ const REPLACE = 4; - /* public */ const CREATE = 8; + /* public */ const APPEND = 1; + /* public */ const PREPEND = 2; + /* public */ const REPLACE = 4; + /* public */ const CREATE = 8; } \ No newline at end of file diff --git a/System/File/ExtensionType.php b/System/File/ExtensionType.php index 0eeb6ce57..7d034ee66 100644 --- a/System/File/ExtensionType.php +++ b/System/File/ExtensionType.php @@ -30,14 +30,14 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class ExtensionType extends Enum { - /* public */ const UNKNOWN = 1; - /* public */ const CODE = 2; - /* public */ const AUDIO = 4; - /* public */ const VIDEO = 8; - /* public */ const TEXT = 16; - /* public */ const SPREADSHEET = 32; - /* public */ const PDF = 64; - /* public */ const ARCHIVE = 128; + /* public */ const UNKNOWN = 1; + /* public */ const CODE = 2; + /* public */ const AUDIO = 4; + /* public */ const VIDEO = 8; + /* public */ const TEXT = 16; + /* public */ const SPREADSHEET = 32; + /* public */ const PDF = 64; + /* public */ const ARCHIVE = 128; /* public */ const PRESENTATION = 256; - /* public */ const IMAGE = 512; + /* public */ const IMAGE = 512; } \ No newline at end of file diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index 089c7e3c5..4819bb5b9 100644 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -26,15 +26,15 @@ namespace phpOMS\System\File; */ class FileUtils { - /* public */ const CODE_EXTENSION = ['cpp', 'c', 'h', 'hpp', 'cs', 'css', 'htm', 'html', 'php', 'rb']; - /* public */ const TEXT_EXTENSION = ['doc', 'docx', 'txt', 'md', 'csv']; + /* public */ const CODE_EXTENSION = ['cpp', 'c', 'h', 'hpp', 'cs', 'css', 'htm', 'html', 'php', 'rb']; + /* public */ const TEXT_EXTENSION = ['doc', 'docx', 'txt', 'md', 'csv']; /* public */ const PRESENTATION_EXTENSION = ['ppt', 'pptx']; - /* public */ const PDF_EXTENSION = ['pdf']; - /* public */ const ARCHIVE_EXTENSION = ['zip', '7z', 'rar']; - /* public */ const AUDIO_EXTENSION = ['mp3', 'wav']; - /* public */ const VIDEO_EXTENSION = ['mp4']; - /* public */ const SPREADSHEET_EXTENSION = ['xls', 'xlsm']; - /* public */ const IMAGE_EXTENSION = ['png', 'gif', 'jpg', 'jpeg', 'tiff', 'bmp']; + /* public */ const PDF_EXTENSION = ['pdf']; + /* public */ const ARCHIVE_EXTENSION = ['zip', '7z', 'rar']; + /* public */ const AUDIO_EXTENSION = ['mp3', 'wav']; + /* public */ const VIDEO_EXTENSION = ['mp4']; + /* public */ const SPREADSHEET_EXTENSION = ['xls', 'xlsm']; + /* public */ const IMAGE_EXTENSION = ['png', 'gif', 'jpg', 'jpeg', 'tiff', 'bmp']; private function __construct() { diff --git a/System/SystemType.php b/System/SystemType.php index a24a98490..5c630fe64 100644 --- a/System/SystemType.php +++ b/System/SystemType.php @@ -30,8 +30,8 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class SystemType extends Enum { - /* public */ const UNKNOWN = 1; - /* public */ const WIN = 2; - /* public */ const LINUX = 3; - /* public */ const OSX = 4; + /* public */ const UNKNOWN = 1; + /* public */ const WIN = 2; + /* public */ const LINUX = 3; + /* public */ const OSX = 4; } \ No newline at end of file diff --git a/Uri/UriScheme.php b/Uri/UriScheme.php index f616af2be..1f8f6df2d 100644 --- a/Uri/UriScheme.php +++ b/Uri/UriScheme.php @@ -28,19 +28,19 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class UriScheme extends Enum { - /* public */ const HTTP = 0; /* Http */ - /* public */ const FILE = 1; /* File */ + /* public */ const HTTP = 0; /* Http */ + /* public */ const FILE = 1; /* File */ /* public */ const MAILTO = 2; /* Mail */ - /* public */ const FTP = 3; /* FTP */ - /* public */ const HTTPS = 4; /* Https */ - /* public */ const IRC = 5; /* IRC */ - /* public */ const TEL = 6; /* Telephone */ + /* public */ const FTP = 3; /* FTP */ + /* public */ const HTTPS = 4; /* Https */ + /* public */ const IRC = 5; /* IRC */ + /* public */ const TEL = 6; /* Telephone */ /* public */ const TELNET = 7; /* Telnet */ - /* public */ const SSH = 8; /* SSH */ - /* public */ const SKYPE = 9; /* Skype */ - /* public */ const SSL = 10; /* SSL */ - /* public */ const NFS = 11; /* Network File System */ - /* public */ const GEO = 12; /* Geo location */ + /* public */ const SSH = 8; /* SSH */ + /* public */ const SKYPE = 9; /* Skype */ + /* public */ const SSL = 10; /* SSL */ + /* public */ const NFS = 11; /* Network File System */ + /* public */ const GEO = 12; /* Geo location */ /* public */ const MARKET = 13; /* Android Market */ - /* public */ const ITMS = 14; /* iTunes */ + /* public */ const ITMS = 14; /* iTunes */ } diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index f5907c521..814d4a3b9 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -294,6 +294,7 @@ class ArrayUtils // see collection collapse as alternative?! $flat = []; $stack = array_values($array); + while (!empty($stack)) { $value = array_shift($stack); @@ -322,7 +323,6 @@ class ArrayUtils { $count = $count === 0 ? count($array) : $start + $count; $sum = 0; - $array = array_values($array); for ($i = $start; $i <= $count - 1; $i++) { diff --git a/Utils/Permutation.php b/Utils/Permutation.php index 207530c4f..cdc0efd38 100644 --- a/Utils/Permutation.php +++ b/Utils/Permutation.php @@ -47,7 +47,9 @@ class Permutation $newArr = $toPermute; $newres = $result; $newres[] = $val; + unset($newArr[$key]); + $permutations = array_merge($permutations, self::permut($newArr, $newres)); } } diff --git a/Utils/StringUtils.php b/Utils/StringUtils.php index a0d175b0e..dcc3a2ce7 100644 --- a/Utils/StringUtils.php +++ b/Utils/StringUtils.php @@ -346,6 +346,15 @@ class StringUtils return $count; } + /** + * Calculate string entropy + * + * @param string $string String to analyze. + * + * @return float + * + * @since 1.0.0 + */ public static function getEntropy(string $value) : float { $entroy = 0.0; @@ -360,8 +369,17 @@ class StringUtils return $entroy; } + /** + * Count chars of utf-8 string. + * + * @param string $string String to count chars. + * + * @return int + * + * @since 1.0.0 + */ public static function mb_count_chars(string $input) { - $l = mb_strlen($input, 'UTF-8'); + $l = mb_strlen($input, 'UTF-8'); $unique = []; for($i = 0; $i < $l; $i++) {