From ce182bab92b0388d95304c79c4c8351d0dd06301 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 5 May 2016 11:27:16 +0200 Subject: [PATCH] Formatting & bug fixes --- Account/Account.php | 3 +- Account/AccountManager.php | 3 +- Account/AccountStatus.php | 6 +- Account/AccountType.php | 2 +- Asset/AssetType.php | 4 +- Auth/LoginReturnType.php | 18 +- Config/OptionsInterface.php | 4 +- Config/SettingsAbstract.php | 4 +- Console/CommandManager.php | 8 +- DataStorage/Cache/CacheInterface.php | 4 +- DataStorage/Cache/CacheStatus.php | 10 +- DataStorage/Cache/CacheType.php | 8 +- DataStorage/Cache/MemCache.php | 1 + DataStorage/Cookie/CookieJar.php | 4 +- DataStorage/Database/BuilderAbstract.php | 1 + .../Connection/ConnectionAbstract.php | 4 +- DataStorage/Database/DataMapperAbstract.php | 99 +- .../Database/DatabaseExceptionFactory.php | 2 +- DataStorage/Database/DatabaseStatus.php | 10 +- DataStorage/Database/DatabaseType.php | 4 +- DataStorage/Database/GrammarAbstract.php | 4 +- DataStorage/Database/Query/Builder.php | 8 +- .../Database/Query/Grammar/Grammar.php | 10 +- DataStorage/Database/Query/JoinType.php | 18 +- .../Schema/Exception/TableException.php | 8 +- DataStorage/Database/Schema/QueryType.php | 4 +- DataStorage/Session/HttpSession.php | 9 +- DataStorage/Session/SessionInterface.php | 4 +- Datatypes/AddressType.php | 6 +- Datatypes/Enum.php | 2 +- Datatypes/PhoneType.php | 6 +- Html/TagType.php | 16 +- Log/FileLogger.php | 18 +- Log/LogLevel.php | 14 +- Log/LoggerInterface.php | 18 +- Math/Finance/FinanceFormulas.php | 2 +- Math/Function/Fibunacci.php | 8 +- Math/Function/Functions.php | 25 +- Math/Matrix/IdentityMatrix.php | 11 +- Math/Matrix/Matrix.php | 172 +- Math/Matrix/Vector.php | 7 +- Math/Number/Integer.php | 103 +- Math/Number/Natural.php | 10 +- Math/Number/Number.php | 10 +- Math/Number/NumberInterface.php | 8 - Math/Number/Numbers.php | 6 +- Math/Number/OpperationInterface.php | 16 + Math/Number/Prime.php | 26 +- Math/Optimization/GaussianElimination.php | 22 +- Math/Optimization/Graph/Dijkstra.php | 34 +- Math/Optimization/Graph/EdgeInterface.php | 22 +- Math/Optimization/Graph/Graph.php | 13 +- Math/Optimization/Graph/NullEdge.php | 33 + Math/Optimization/Graph/NullVertice.php | 33 + Math/Optimization/Graph/VerticeInterface.php | 14 +- Math/Optimization/TSP/Tour.php | 4 +- Math/Shape/D2/Polygon.php | 3 +- Math/Statistic/Average.php | 14 +- .../Distribution/BinomialDistribution.php | 1 + .../Distribution/ChiSquaredDistribution.php | 1 + .../Distribution/GeometricDistribution.php | 4 +- .../Distribution/PoissonDistribution.php | 1 + .../UniformDistributionDiscrete.php | 2 +- Message/HeaderAbstract.php | 7 +- Message/Http/BrowserType.php | 20 +- Message/Http/Header.php | 8 +- Message/Http/OSType.php | 44 +- Message/Http/Request.php | 20 +- Message/Http/RequestMethod.php | 10 +- Message/Http/Response.php | 13 +- Message/Http/Rest.php | 3 +- Message/Mail/Imap.php | 16 +- Message/Mail/MailType.php | 8 +- Message/RequestAbstract.php | 4 +- Message/RequestSource.php | 4 +- Message/ResponseAbstract.php | 2 +- Message/ResponseType.php | 6 +- Model/Html/Meta.php | 8 +- Module/ActivateAbstract.php | 2 +- Module/DeactivateAbstract.php | 2 +- Module/InfoManager.php | 2 + Module/InstallerAbstract.php | 12 +- Module/ModuleFactory.php | 14 +- Module/ModuleManager.php | 102 +- Module/UninstallAbstract.php | 2 +- Module/UpdateAbstract.php | 2 +- Pattern/Observer.php | 1 - Pattern/Subject.php | 1 - Socket/Client/ClientConnection.php | 30 +- Socket/CommandManager.php | 10 +- Socket/Packets/PacketAbstract.php | 1 - Socket/Packets/PacketType.php | 20 +- Socket/Server/ClientManager.php | 12 +- Socket/Server/Server.php | 2 + Stdlib/Map/MultiMap.php | 13 +- Stdlib/Queue/PriorityQueue.php | 11 +- System/File/Directory.php | 41 +- System/File/File.php | 8 +- System/File/FileAbstract.php | 20 +- System/File/NullFile.php | 2 +- System/MimeType.php | 1958 ++++++++--------- System/OperatingSystem.php | 31 +- System/SystemType.php | 8 +- System/SystemUtils.php | 2 +- Uri/UriFactory.php | 4 +- Uri/UriScheme.php | 24 +- Utils/ArrayUtils.php | 8 +- Utils/Barcode/Aztec.php | 15 +- Utils/Barcode/C128Abstract.php | 14 +- Utils/Barcode/C128a.php | 12 +- Utils/Barcode/C128b.php | 2 +- Utils/Barcode/C25.php | 10 +- Utils/Barcode/C39.php | 8 +- Utils/Barcode/Codebar.php | 15 +- Utils/Barcode/OrientationType.php | 2 +- Utils/Color.php | 2 +- Utils/Compression/CompressionInterface.php | 8 +- Utils/Compression/LZW.php | 34 +- Utils/Converter/TemperatureType.php | 6 +- Utils/Encoding/Caesar.php | 27 +- Utils/Encoding/EncodingInterface.php | 8 +- Utils/Encoding/Gray.php | 3 +- Utils/Encoding/Xor.php | 13 +- Utils/Excel/Excel.php | 1 + Utils/Git/Author.php | 42 +- Utils/Git/{Branch => Branch.php} | 34 +- Utils/Git/Commit.php | 233 +- Utils/Git/Git.php | 62 +- Utils/Git/Repository.php | 17 +- Utils/Git/Tag.php | 32 + Utils/IO/Csv/CsvDatabaseMapper.php | 4 +- Utils/IO/Excel/ExcelDatabaseMapper.php | 2 +- Utils/IO/IODatabaseMapper.php | 6 +- Utils/JsonBuilder.php | 2 +- Utils/PDF/Pdf.php | 1 + Utils/Parser/Markdown/Markdown.php | 1121 ---------- Utils/Parser/Php/ClassParser.php | 31 +- Utils/Parser/Php/ClassType.php | 6 +- Utils/Parser/Php/FunctionParser.php | 27 +- Utils/Parser/Php/MemberParser.php | 15 +- Utils/Parser/Php/Visibility.php | 6 +- Utils/Permutation.php | 24 +- Utils/RnG/ArrayRandomize.php | 10 +- Utils/RnG/File.php | 3 +- Utils/RnG/LinearCongruentialGenerator.php | 7 +- Utils/RnG/Phone.php | 3 +- Utils/RnG/Text.php | 368 ++-- Utils/TaskSchedule/Cron.php | 7 +- Utils/TaskSchedule/CronJob.php | 4 +- Utils/TaskSchedule/Interval.php | 48 +- Utils/TaskSchedule/Schedule.php | 2 +- Utils/TaskSchedule/SchedulerFactory.php | 25 +- Utils/TaskSchedule/TaskFactory.php | 25 +- Utils/TaskSchedule/TaskInterface.php | 1 + Utils/TaskSchedule/TaskScheduler.php | 7 +- Validation/Base/BIC.php | 1 - Validation/Base/CreditCard.php | 7 +- Validation/Base/Email.php | 2 +- Validation/Base/Hostname.php | 1 - Validation/Base/IBAN.php | 1 - Validation/Base/IP.php | 1 - Validation/BitcoinValidator.php | 40 +- Validation/ModelValidationTrait.php | 7 +- Validation/Validator.php | 4 +- Views/View.php | 24 +- Views/ViewLayout.php | 22 +- 166 files changed, 2560 insertions(+), 3372 deletions(-) delete mode 100644 Math/Number/NumberInterface.php create mode 100644 Math/Number/OpperationInterface.php rename Utils/Git/{Branch => Branch.php} (79%) delete mode 100644 Utils/Parser/Markdown/Markdown.php diff --git a/Account/Account.php b/Account/Account.php index bd058a2bc..7b5503093 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -422,7 +422,8 @@ class Account $this->lastActive = new \DateTime('NOW'); } - public function setCreatedAt(\DateTime $created) { + public function setCreatedAt(\DateTime $created) + { $this->createdAt = $created; } diff --git a/Account/AccountManager.php b/Account/AccountManager.php index ec478dc7e..465177971 100644 --- a/Account/AccountManager.php +++ b/Account/AccountManager.php @@ -112,7 +112,8 @@ class AccountManager implements \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function count() : int { + public function count() : int + { return count($this->accounts); } diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index 4dd1b2ee2..93bc0d90c 100644 --- a/Account/AccountStatus.php +++ b/Account/AccountStatus.php @@ -30,8 +30,8 @@ use phpOMS\Datatypes\Enum; */ abstract class AccountStatus extends Enum { - const ACTIVE = 1; + const ACTIVE = 1; const INACTIVE = 2; - const TIMEOUT = 3; - const BANNED = 4; + const TIMEOUT = 3; + const BANNED = 4; } diff --git a/Account/AccountType.php b/Account/AccountType.php index bfd342cca..4c65e6392 100644 --- a/Account/AccountType.php +++ b/Account/AccountType.php @@ -30,6 +30,6 @@ use phpOMS\Datatypes\Enum; */ abstract class AccountType extends Enum { - const USER = 0; + const USER = 0; const GROUP = 1; } diff --git a/Asset/AssetType.php b/Asset/AssetType.php index 4b8a543db..e7313c97c 100644 --- a/Asset/AssetType.php +++ b/Asset/AssetType.php @@ -30,7 +30,7 @@ use phpOMS\Datatypes\Enum; */ abstract class AssetType extends Enum { - const CSS = 'css'; - const JS = 'js'; + const CSS = 'css'; + const JS = 'js'; const JSLATE = 'jslate'; } diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index 5a28855be..dc5a886af 100644 --- a/Auth/LoginReturnType.php +++ b/Auth/LoginReturnType.php @@ -32,14 +32,14 @@ use phpOMS\Datatypes\Enum; */ abstract class LoginReturnType extends Enum { - const OK = 0; /* Everything is ok and the user got authed */ - const FAILURE = 1; /* Authentication resulted in a unexpected failure */ - const WRONG_PASSWORD = 2; /* Authentication with wrong password */ - const WRONG_USERNAME = 3; /* Authentication with unknown user */ - const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */ - const NOT_ACTIVATED = 5; /* The user is not activated yet */ + const OK = 0; /* Everything is ok and the user got authed */ + const FAILURE = 1; /* Authentication resulted in a unexpected failure */ + const WRONG_PASSWORD = 2; /* Authentication with wrong password */ + const WRONG_USERNAME = 3; /* Authentication with unknown user */ + const WRONG_PERMISSION = 4; /* User doesn't have permission to authenticate */ + const NOT_ACTIVATED = 5; /* The user is not activated yet */ const WRONG_INPUT_EXCEEDED = 6; /* Too many wrong logins recently */ - const TIMEOUTED = 7; /* User received a timeout and can not log in until a certain date */ - const BANNED = 8; /* User is banned */ - const INACTIVE = 9; /* User is inactive */ + const TIMEOUTED = 7; /* User received a timeout and can not log in until a certain date */ + const BANNED = 8; /* User is banned */ + const INACTIVE = 9; /* User is inactive */ } diff --git a/Config/OptionsInterface.php b/Config/OptionsInterface.php index a97c31c1f..8066a9558 100644 --- a/Config/OptionsInterface.php +++ b/Config/OptionsInterface.php @@ -46,7 +46,7 @@ interface OptionsInterface * * @param mixed $key Unique option key * @param mixed $value Option value - * @param bool $overwrite Overwrite existing value + * @param bool $overwrite Overwrite existing value * * @return bool * @@ -59,7 +59,7 @@ interface OptionsInterface * Updating or adding settings. * * @param array $pair Key value pair - * @param bool $overwrite Overwrite existing value + * @param bool $overwrite Overwrite existing value * * @return bool * diff --git a/Config/SettingsAbstract.php b/Config/SettingsAbstract.php index a0ead306e..024302ca6 100644 --- a/Config/SettingsAbstract.php +++ b/Config/SettingsAbstract.php @@ -120,8 +120,8 @@ abstract class SettingsAbstract implements OptionsInterface /** * Set option by key. * - * @param string[] $options Column values for filtering - * @param bool $store Save this Setting immediately to database + * @param string[] $options Column values for filtering + * @param bool $store Save this Setting immediately to database * * @return mixed Option value * diff --git a/Console/CommandManager.php b/Console/CommandManager.php index 3c3cffdcf..e14f570f8 100644 --- a/Console/CommandManager.php +++ b/Console/CommandManager.php @@ -57,8 +57,8 @@ class CommandManager implements \Countable * Attach new command. * * @param string $cmd Command ID - * @param mixed $callback Function callback - * @param mixed $source Provider + * @param mixed $callback Function callback + * @param mixed $source Provider * @param bool $overwrite Overwrite existing * * @return bool @@ -82,7 +82,7 @@ class CommandManager implements \Countable * Detach existing command. * * @param string $cmd Command ID - * @param mixed $source Provider + * @param mixed $source Provider * * @return bool * @@ -105,7 +105,7 @@ class CommandManager implements \Countable * Trigger command. * * @param string $cmd Command ID - * @param mixed $para Parameters to pass + * @param mixed $para Parameters to pass * * @return mixed|bool * diff --git a/DataStorage/Cache/CacheInterface.php b/DataStorage/Cache/CacheInterface.php index ded2a8644..6e0890057 100644 --- a/DataStorage/Cache/CacheInterface.php +++ b/DataStorage/Cache/CacheInterface.php @@ -35,7 +35,7 @@ interface CacheInterface * @param mixed $key Unique cache key * @param mixed $value Cache value * @param CacheStatus $type Cache type - * @param int $expire Valid duration (in s) + * @param int $expire Valid duration (in s) * * @return void * @@ -50,7 +50,7 @@ interface CacheInterface * @param mixed $key Unique cache key * @param mixed $value Cache value * @param CacheStatus $type Cache type - * @param int $expire Valid duration (in s) + * @param int $expire Valid duration (in s) * * @return bool * diff --git a/DataStorage/Cache/CacheStatus.php b/DataStorage/Cache/CacheStatus.php index b7fc47e34..b54719ae2 100644 --- a/DataStorage/Cache/CacheStatus.php +++ b/DataStorage/Cache/CacheStatus.php @@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum; */ abstract class CacheStatus extends Enum { - const INACTIVE = 0; /* Caching is disabled */ - const ERROR = 1; /* Caching failed */ - const MEMCACHE = 2; /* Caching OK */ - const FILECACHE = 3; /* Caching OK */ + const INACTIVE = 0; /* Caching is disabled */ + const ERROR = 1; /* Caching failed */ + const MEMCACHE = 2; /* Caching OK */ + const FILECACHE = 3; /* Caching OK */ const REDISCACHE = 4; /* Caching OK */ - const WINCACHE = 5; /* Caching OK */ + const WINCACHE = 5; /* Caching OK */ } diff --git a/DataStorage/Cache/CacheType.php b/DataStorage/Cache/CacheType.php index 8fec57649..dd1734e27 100644 --- a/DataStorage/Cache/CacheType.php +++ b/DataStorage/Cache/CacheType.php @@ -33,8 +33,8 @@ use phpOMS\Datatypes\Enum; abstract class CacheType extends Enum { const _NUMERIC = 0; /* Data is numeric */ - const _STRING = 1; /* Data is string */ - const _ARRAY = 2; /* Data is array */ - const _OBJECT = 3; /* Data is object */ - const _HEX = 4; /* Data is object */ + const _STRING = 1; /* Data is string */ + const _ARRAY = 2; /* Data is array */ + const _OBJECT = 3; /* Data is object */ + const _HEX = 4; /* Data is object */ } diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index b8037ac21..7dc18a10d 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -124,6 +124,7 @@ class MemCache implements CacheInterface */ public function stats() : array { + /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ return $this->memc->getExtendedStats(); } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index ab25a125b..6a0248584 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -75,13 +75,13 @@ class CookieJar if (self::$isLocked) { throw new \Exception('Already locked'); } - + foreach ($this->cookies as $key => $cookie) { setcookie($key, $cookie['value'], $cookie['expiry'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']); } } - public static function lock() + public static function lock() { self::$isLocked = true; } diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 728d84919..3e016245c 100644 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -15,6 +15,7 @@ */ namespace phpOMS\DataStorage\Database; + use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; /** diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index 81f52207d..e49619dac 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -126,8 +126,8 @@ abstract class ConnectionAbstract implements ConnectionInterface } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function getGrammar() : Grammar { if (!isset($this->grammar)) { diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 3cd267728..dfb5a398c 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -262,7 +262,8 @@ abstract class DataMapperAbstract implements DataMapperInterface return $this; } - public function clear() { + public function clear() + { $this->fields = []; } @@ -305,7 +306,7 @@ abstract class DataMapperAbstract implements DataMapperInterface { $query = new Builder($this->db); $query->prefix($this->db->getPrefix()) - ->into(static::$table); + ->into(static::$table); $reflectionClass = new \ReflectionClass(get_class($obj)); $properties = $reflectionClass->getProperties(); @@ -361,12 +362,12 @@ abstract class DataMapperAbstract implements DataMapperInterface $value = isset($value) ? json_encode($value) : ''; } elseif ($column['type'] === 'Serializable') { $value = $value->serialize(); - } elseif(is_object($value)) { + } elseif (is_object($value)) { $value = $value->getId(); } $query->insert($column['name']) - ->value($value, $column['type']); + ->value($value, $column['type']); break; } } @@ -442,8 +443,8 @@ abstract class DataMapperAbstract implements DataMapperInterface /* is many->many */ $relQuery = new Builder($this->db); $relQuery->prefix($this->db->getPrefix()) - ->into(static::$hasMany[$pname]['table']) - ->insert(static::$hasMany[$pname]['src'], static::$hasMany[$pname]['dst']); + ->into(static::$hasMany[$pname]['table']) + ->insert(static::$hasMany[$pname]['src'], static::$hasMany[$pname]['dst']); foreach ($objsIds as $key => $src) { $relQuery->values($src, $objId); @@ -489,7 +490,7 @@ abstract class DataMapperAbstract implements DataMapperInterface $query = new Builder($this->db); $query->prefix($this->db->getPrefix()) - ->into(static::$table); + ->into(static::$table); $reflectionClass = new \ReflectionClass(get_class($obj)); $properties = $reflectionClass->getProperties(); @@ -510,7 +511,7 @@ abstract class DataMapperAbstract implements DataMapperInterface } $query->update($column['name']) - ->value($value); + ->value($value); break; } } @@ -551,7 +552,7 @@ abstract class DataMapperAbstract implements DataMapperInterface * Populate data. * * @param array $result Result set - * @param mixed $obj Object to populate + * @param mixed $obj Object to populate * * @return mixed * @@ -583,7 +584,7 @@ abstract class DataMapperAbstract implements DataMapperInterface * Is overwriting the hasOne id stored in the member variable by the object. * todo: hasMany needs to be implemented somehow?!?! * - * @param $obj Object to add the relations to + * @param $obj Object to add the relations to * @param int $relations Relations type * * @return mixed @@ -740,7 +741,7 @@ abstract class DataMapperAbstract implements DataMapperInterface * Get object. * * @param mixed $primaryKey Key - * @param int $relations Load relations + * @param int $relations Load relations * @param mixed $fill Object to fill * * @return mixed @@ -814,9 +815,9 @@ abstract class DataMapperAbstract implements DataMapperInterface * * This will fall back to the insert id if no datetime column is present. * - * @param int $limit Newest limit - * @param Builder $query Pre-defined query - * @param int $relations Load relations + * @param int $limit Newest limit + * @param Builder $query Pre-defined query + * @param int $relations Load relations * * @return mixed * @@ -827,9 +828,9 @@ abstract class DataMapperAbstract implements DataMapperInterface { $query = $query ?? new Builder($this->db); $query->prefix($this->db->getPrefix()) - ->select('*') - ->from(static::$table) - ->limit($limit); /* todo: limit is not working, setting this to 2 doesn't have any effect!!! */ + ->select('*') + ->from(static::$table) + ->limit($limit); /* todo: limit is not working, setting this to 2 doesn't have any effect!!! */ if (!empty(static::$createdAt)) { $query->orderBy(static::$table . '.' . static::$columns[static::$createdAt]['name'], 'DESC'); @@ -841,7 +842,7 @@ abstract class DataMapperAbstract implements DataMapperInterface $sth->execute(); $results = $sth->fetchAll(\PDO::FETCH_ASSOC); - $obj = $this->populateIterable(is_bool($results) ? [] : $results); + $obj = $this->populateIterable(is_bool($results) ? [] : $results); $this->fillRelations($obj, $relations); $this->clear(); @@ -853,8 +854,8 @@ abstract class DataMapperAbstract implements DataMapperInterface /** * Get all by custom query. * - * @param Builder $query Query - * @param bool $relations Relations + * @param Builder $query Query + * @param bool $relations Relations * * @return array * @@ -886,7 +887,7 @@ abstract class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function getRandom(int $relations = RelationType::ALL) + public function getRandom(int $relations = RelationType::ALL) { // todo: implement } @@ -894,15 +895,15 @@ abstract class DataMapperAbstract implements DataMapperInterface /** * Fill object with relations * - * @param mixed $obj Objects to fill - * @param int $relations Relations type + * @param mixed $obj Objects to fill + * @param int $relations Relations type * * @return array * * @since 1.0.0 * @author Dennis Eichhorn */ - public function fillRelations(array &$obj, int $relations = RelationType::ALL) + public function fillRelations(array &$obj, int $relations = RelationType::ALL) { $hasMany = count(static::$hasMany) > 0; $hasOne = count(static::$hasOne) > 0; @@ -942,9 +943,9 @@ abstract class DataMapperAbstract implements DataMapperInterface { $query = new Builder($this->db); $query->prefix($this->db->getPrefix()) - ->select('*') - ->from(static::$table) - ->where(static::$table . '.' . static::$primaryField, '=', $primaryKey); + ->select('*') + ->from(static::$table) + ->where(static::$table . '.' . static::$primaryField, '=', $primaryKey); $sth = $this->db->con->prepare($query->toSql()); $sth->execute(); @@ -968,8 +969,8 @@ abstract class DataMapperAbstract implements DataMapperInterface { $query = new Builder($this->db); $query->prefix($this->db->getPrefix()) - ->select('*') - ->from(static::$table); + ->select('*') + ->from(static::$table); $sth = $this->db->con->prepare($query->toSql()); $sth->execute(); @@ -983,7 +984,7 @@ abstract class DataMapperAbstract implements DataMapperInterface * Get raw by primary key * * @param mixed $primaryKey Primary key - * @param int $relations Load relations + * @param int $relations Load relations * * @return array * @@ -1001,27 +1002,27 @@ abstract class DataMapperAbstract implements DataMapperInterface if ($relations === RelationType::ALL) { $query->select($value['table'] . '.' . $value['src']) - ->from($value['table']) - ->where($value['table'] . '.' . $value['dst'], '=', $primaryKey); + ->from($value['table']) + ->where($value['table'] . '.' . $value['dst'], '=', $primaryKey); } elseif ($relations === RelationType::NEWEST) { -/* -SELECT c.*, p1.* -FROM customer c -JOIN purchase p1 ON (c.id = p1.customer_id) -LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND - (p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id)) -WHERE p2.id IS NULL; -*/ -/* - $query->select(static::$table . '.' . static::$primaryField, $value['table'] . '.' . $value['src']) - ->from(static::$table) - ->join($value['table']) - ->on(static::$table . '.' . static::$primaryField, '=', $value['table'] . '.' . $value['dst']) - ->leftOuterJoin($value['table']) - ->on(new And('1', new And(new Or('d1', 'd2'), 'id'))) - ->where($value['table'] . '.' . $value['dst'], '=', 'NULL'); - */ + /* + SELECT c.*, p1.* + FROM customer c + JOIN purchase p1 ON (c.id = p1.customer_id) + LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND + (p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id)) + WHERE p2.id IS NULL; + */ + /* + $query->select(static::$table . '.' . static::$primaryField, $value['table'] . '.' . $value['src']) + ->from(static::$table) + ->join($value['table']) + ->on(static::$table . '.' . static::$primaryField, '=', $value['table'] . '.' . $value['dst']) + ->leftOuterJoin($value['table']) + ->on(new And('1', new And(new Or('d1', 'd2'), 'id'))) + ->where($value['table'] . '.' . $value['dst'], '=', 'NULL'); + */ } $sth = $this->db->con->prepare($query->toSql()); diff --git a/DataStorage/Database/DatabaseExceptionFactory.php b/DataStorage/Database/DatabaseExceptionFactory.php index fc46ee28e..cc5000f5b 100644 --- a/DataStorage/Database/DatabaseExceptionFactory.php +++ b/DataStorage/Database/DatabaseExceptionFactory.php @@ -42,7 +42,7 @@ class DatabaseExceptionFactory */ public static function create(\PDOException $e) : \PDOException { - switch($e->getCode()) { + switch ($e->getCode()) { case '42S02': return self::createTableViewException($e); default: diff --git a/DataStorage/Database/DatabaseStatus.php b/DataStorage/Database/DatabaseStatus.php index f7ba77c81..bdb324fa6 100644 --- a/DataStorage/Database/DatabaseStatus.php +++ b/DataStorage/Database/DatabaseStatus.php @@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum; */ abstract class DatabaseStatus extends Enum { - const OK = 0; /* Database connection successful */ + const OK = 0; /* Database connection successful */ const MISSING_DATABASE = 1; /* Couldn't find database */ - const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ - const FAILURE = 3; /* Unknown failure */ - const READONLY = 4; /* Database connection is in readonly (but ok) */ - const CLOSED = 5; /* Database connection closed */ + const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ + const FAILURE = 3; /* Unknown failure */ + const READONLY = 4; /* Database connection is in readonly (but ok) */ + const CLOSED = 5; /* Database connection closed */ } diff --git a/DataStorage/Database/DatabaseType.php b/DataStorage/Database/DatabaseType.php index 10132b020..d1b163cf6 100644 --- a/DataStorage/Database/DatabaseType.php +++ b/DataStorage/Database/DatabaseType.php @@ -32,9 +32,9 @@ use phpOMS\Datatypes\Enum; */ abstract class DatabaseType extends Enum { - const MYSQL = 0; /* MySQL */ + const MYSQL = 0; /* MySQL */ const SQLITE = 1; /* SQLITE */ - const PGSQL = 2; /* PostgreSQL */ + const PGSQL = 2; /* PostgreSQL */ const ORACLE = 3; /* Oracle */ const SQLSRV = 4; /* Microsoft SQL Server */ } diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index 0092be031..05e5d39c5 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -89,7 +89,7 @@ abstract class GrammarAbstract implode(' ', array_filter( $this->compileComponents($query), - function($value) { + function ($value) { return (string) $value !== ''; } ) @@ -102,7 +102,7 @@ abstract class GrammarAbstract /** * Expressionize elements. * - * @param array $elements Elements + * @param array $elements Elements * @param string $prefix Prefix for table * * @return string diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 9e61fa8a7..3d7363b1f 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -382,7 +382,7 @@ class Builder extends BuilderAbstract * * @param string|array|\Closure $columns Columns * @param string|array $operator Operator - * @param mixed $values Values + * @param mixed $values Values * @param string|array $boolean Boolean condition * * @return Builder @@ -429,7 +429,7 @@ class Builder extends BuilderAbstract * Where in. * * @param string|array|\Closure $column Column - * @param mixed $values Values + * @param mixed $values Values * @param string $boolean Boolean condition * * @return Builder @@ -717,8 +717,8 @@ class Builder extends BuilderAbstract /** * Values to insert. * - * @param mixed $value Values - * @param string $type Data type to insert + * @param mixed $value Values + * @param string $type Data type to insert * * @return Builder * diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index cb2a6fe9b..f709e0850 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -172,7 +172,7 @@ class Grammar extends GrammarAbstract * * @param Builder $query Builder * @param array $wheres Where elmenets - * @param bool $first Is first element (usefull for nesting) + * @param bool $first Is first element (usefull for nesting) * * @return string * @@ -222,7 +222,7 @@ class Grammar extends GrammarAbstract * Compile value. * * @param array|string|\Closure $value Value - * @param string $prefix Prefix in case value is a table + * @param string $prefix Prefix in case value is a table * * @return string * @@ -262,7 +262,7 @@ class Grammar extends GrammarAbstract * Compile limit. * * @param Builder $query Builder - * @param int $limit Limit + * @param int $limit Limit * * @return string * @@ -278,7 +278,7 @@ class Grammar extends GrammarAbstract * Compile offset. * * @param Builder $query Builder - * @param int $offset Offset + * @param int $offset Offset * * @return string * @@ -361,7 +361,7 @@ class Grammar extends GrammarAbstract * Compile insert into table. * * @param Builder $query Builder - * @param string $table Table + * @param string $table Table * * @return string * diff --git a/DataStorage/Database/Query/JoinType.php b/DataStorage/Database/Query/JoinType.php index 8a904367c..6704e0f9d 100644 --- a/DataStorage/Database/Query/JoinType.php +++ b/DataStorage/Database/Query/JoinType.php @@ -30,15 +30,15 @@ use phpOMS\Datatypes\Enum; */ abstract class JoinType extends Enum { - const JOIN = 'JOIN'; - const LEFT_JOIN = 'LEFT JOIN'; - const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; - const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; - const RIGHT_JOIN = 'RIGHT JOIN'; + const JOIN = 'JOIN'; + const LEFT_JOIN = 'LEFT JOIN'; + const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; + const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; + const RIGHT_JOIN = 'RIGHT JOIN'; const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN'; const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN'; - const OUTER_JOIN = 'OUTER JOIN'; - const INNER_JOIN = 'INNER JOIN'; - const CROSS_JOIN = 'CROSS JOIN'; - const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; + const OUTER_JOIN = 'OUTER JOIN'; + const INNER_JOIN = 'INNER JOIN'; + const CROSS_JOIN = 'CROSS JOIN'; + const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; } diff --git a/DataStorage/Database/Schema/Exception/TableException.php b/DataStorage/Database/Schema/Exception/TableException.php index 836ad46c9..62e75f80f 100644 --- a/DataStorage/Database/Schema/Exception/TableException.php +++ b/DataStorage/Database/Schema/Exception/TableException.php @@ -47,16 +47,16 @@ class TableException extends \PDOException { $pos1 = strpos($message, '\''); - if($pos1 === false) { + if ($pos1 === false) { return $message; } - $pos2 = strpos($message, '\'', $pos1+1); + $pos2 = strpos($message, '\'', $pos1 + 1); - if($pos2 === false) { + if ($pos2 === false) { return $message; } - return substr($message, $pos1+1, $pos2-$pos1-1); + return substr($message, $pos1 + 1, $pos2 - $pos1 - 1); } } diff --git a/DataStorage/Database/Schema/QueryType.php b/DataStorage/Database/Schema/QueryType.php index f8af17edb..2a72296f7 100644 --- a/DataStorage/Database/Schema/QueryType.php +++ b/DataStorage/Database/Schema/QueryType.php @@ -34,6 +34,6 @@ abstract class QueryType extends Enum { const SELECT = 0; const CREATE = 1; - const DROP = 2; - const ALTER = 3; + const DROP = 2; + const ALTER = 3; } diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 6a4bbdcf9..3ddbe54d0 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -14,6 +14,7 @@ * @link http://orange-management.com */ namespace phpOMS\DataStorage\Session; + use phpOMS\Uri\UriFactory; use phpOMS\Utils\RnG\StringUtils; @@ -52,7 +53,7 @@ class HttpSession implements SessionInterface /** * Constructor. * - * @param int $liftetime Session life time + * @param int $liftetime Session life time * @param string|int|bool $sid Session id * * @throws \Exception @@ -73,7 +74,7 @@ class HttpSession implements SessionInterface session_set_cookie_params($liftetime, '/', null, false, true); session_start(); $this->sessionData = $_SESSION; - $_SESSION = null; + $_SESSION = null; $this->sid = session_id(); $this->setCsrfProtection(); @@ -87,7 +88,7 @@ class HttpSession implements SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private function setCsrfProtection() + private function setCsrfProtection() { $this->set('UID', 0, false); @@ -170,7 +171,7 @@ class HttpSession implements SessionInterface self::$isLocked = true; } - public static function isLocked() + public static function isLocked() { return self::$isLocked; } diff --git a/DataStorage/Session/SessionInterface.php b/DataStorage/Session/SessionInterface.php index 5445d0ca6..77a03f195 100644 --- a/DataStorage/Session/SessionInterface.php +++ b/DataStorage/Session/SessionInterface.php @@ -47,8 +47,8 @@ interface SessionInterface * Store session value by key. * * @param string|int $key Value key - * @param mixed $value Value to store - * @param bool $overwrite Overwrite existing values + * @param mixed $value Value to store + * @param bool $overwrite Overwrite existing values * * @return bool * diff --git a/Datatypes/AddressType.php b/Datatypes/AddressType.php index 4fd246ece..17541eb58 100644 --- a/Datatypes/AddressType.php +++ b/Datatypes/AddressType.php @@ -28,9 +28,9 @@ namespace phpOMS\Datatypes; */ abstract class AddressType extends Enum { - const HOME = 1; + const HOME = 1; const BUSINESS = 2; const SHIPPING = 3; - const BILLING = 4; - const WORK = 5; + const BILLING = 4; + const WORK = 5; } diff --git a/Datatypes/Enum.php b/Datatypes/Enum.php index 7b542d7bd..a2716b7eb 100644 --- a/Datatypes/Enum.php +++ b/Datatypes/Enum.php @@ -92,7 +92,7 @@ abstract class Enum * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getRandom() + public static function getRandom() { $constants = self::getConstants(); diff --git a/Datatypes/PhoneType.php b/Datatypes/PhoneType.php index fec760821..e505d07bb 100644 --- a/Datatypes/PhoneType.php +++ b/Datatypes/PhoneType.php @@ -28,8 +28,8 @@ namespace phpOMS\Datatypes; */ abstract class PhoneType extends Enum { - const HOME = 1; + const HOME = 1; const BUSINESS = 2; - const MOBILE = 3; - const WORK = 4; + const MOBILE = 3; + const WORK = 4; } diff --git a/Html/TagType.php b/Html/TagType.php index bdd342a51..cd8263136 100644 --- a/Html/TagType.php +++ b/Html/TagType.php @@ -30,13 +30,13 @@ use phpOMS\Datatypes\Enum; */ abstract class TagType extends Enum { - const INPUT = 0; /* */ - const BUTTON = 1; /*