From dcdce3efc2f090874d468c3d4dd73d0089ef761f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 5 Nov 2016 21:47:18 +0100 Subject: [PATCH 01/53] Fix relation create and get --- DataStorage/Database/DataMapperAbstract.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index c8f97415f..0f05393d8 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -617,7 +617,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Create relation table entry * - * In cas of a many to many relation the relation has to be stored in a relation table + * In case of a many to many relation the relation has to be stored in a relation table * * @param string $propertyName Property name to initialize * @param array $objsIds Object ids to insert @@ -633,7 +633,11 @@ class DataMapperAbstract implements DataMapperInterface private static function createRelationTable(string $propertyName, array $objsIds, $objId) { /** @var string $table */ - if (static::$hasMany[$propertyName]['table'] !== static::$table && static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table) { + if ( + !empty($objsIds) + && static::$hasMany[$propertyName]['table'] !== static::$table + && static::$hasMany[$propertyName]['table'] !== static::$hasMany[$propertyName]['mapper']::$table + ) { $relQuery = new Builder(self::$db); $relQuery->prefix(self::$db->getPrefix()) ->into(static::$hasMany[$propertyName]['table']) @@ -824,7 +828,7 @@ class DataMapperAbstract implements DataMapperInterface } $objects = $mapper::get($values); - $reflectionProperty->setValue($obj, $objects); + $reflectionProperty->setValue($obj, !is_array($objects) ? [$objects] : $objects); if (!$accessible) { $reflectionProperty->setAccessible(false); From 0aad7e90ad306d884e052b2ad1eec9900b00bda9 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Nov 2016 14:42:31 +0100 Subject: [PATCH 02/53] Add comments --- Account/Group.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Account/Group.php b/Account/Group.php index 03b606361..b2681635a 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -64,14 +64,20 @@ class Group implements ArrayableInterface, \JsonSerializable protected $members = []; /** - * Parents . + * Parents. * * @var int[] * @since 1.0.0 */ protected $parents = []; - private $status = GroupStatus::INACTIVE; + /** + * Group status. + * + * @var int + * @since 1.0.0 + */ + protected $status = GroupStatus::INACTIVE; /** * Permissions. From 9bbdbcaf386506fc472c459873b9587c96db280d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Nov 2016 22:22:58 +0100 Subject: [PATCH 03/53] Fix docblocks --- Account/AccountMapper.php | 2 +- DataStorage/Database/DataMapperAbstract.php | 14 ++------------ DataStorage/Database/GrammarAbstract.php | 2 -- DataStorage/Database/Query/Builder.php | 2 +- DataStorage/Database/Query/Grammar/Grammar.php | 2 +- Localization/L11nManager.php | 4 +--- Log/FileLogger.php | 2 +- Math/Finance/FinanceFormulas.php | 2 +- Math/Matrix/Matrix.php | 4 ++-- Math/Statistic/Average.php | 16 ++++++---------- Math/Statistic/MeasureOfDispersion.php | 8 ++++---- .../Distribution/ChiSquaredDistribution.php | 8 ++++---- .../Distribution/ExponentialDistribution.php | 2 +- Message/Http/Request.php | 2 -- Router/Router.php | 4 ++-- 15 files changed, 27 insertions(+), 47 deletions(-) diff --git a/Account/AccountMapper.php b/Account/AccountMapper.php index c8d16a3dc..5222fd94f 100644 --- a/Account/AccountMapper.php +++ b/Account/AccountMapper.php @@ -25,7 +25,7 @@ class AccountMapper extends DataMapperAbstract /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = [ diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 0f05393d8..22993efd8 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -70,7 +70,7 @@ class DataMapperAbstract implements DataMapperInterface /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = []; @@ -337,8 +337,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -452,7 +450,7 @@ class DataMapperAbstract implements DataMapperInterface * * @return void * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -552,8 +550,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -588,8 +584,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -625,8 +619,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -696,8 +688,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return int * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index c3e716bd3..d101ae81f 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -78,8 +78,6 @@ abstract class GrammarAbstract * * @return string * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 0cfa63f4c..3ae96bb4a 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -429,7 +429,7 @@ class Builder extends BuilderAbstract * * @return Builder * - * @throws + * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index bd3b188a1..adfc0af90 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -98,7 +98,7 @@ class Grammar extends GrammarAbstract * * @return string[] * - * @throws + * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index 68cf4d21c..1b2143bea 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -89,7 +89,7 @@ class L11nManager * * @return void * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -120,8 +120,6 @@ class L11nManager * * @return void * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 59d34574d..a631eeb63 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -43,7 +43,7 @@ class FileLogger implements LoggerInterface * Potential values are null or an array filled with log timings. * This is used in order to profile code sections by ID. * - * @var array[float] + * @var array * @since 1.0.0 */ private $timings = []; diff --git a/Math/Finance/FinanceFormulas.php b/Math/Finance/FinanceFormulas.php index 2d4ec0665..926b910f9 100644 --- a/Math/Finance/FinanceFormulas.php +++ b/Math/Finance/FinanceFormulas.php @@ -1014,7 +1014,7 @@ class FinanceFormulas * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 3ac9dbdbb..2f512ced2 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -87,7 +87,7 @@ class Matrix implements \ArrayAccess, \Iterator * @param int $n Column * @param int $value Value * - * @throws + * @throws DimensionException * * @since 1.0.0 * @author Dennis Eichhorn @@ -109,7 +109,7 @@ class Matrix implements \ArrayAccess, \Iterator * * @return mixed * - * @throws + * @throws DimensionException * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index 40281364b..e52dfeb94 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -50,8 +50,6 @@ class Average * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -91,7 +89,7 @@ class Average * * @todo : allow counter i also to go into the future... required for forecast how? should be doable! * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -126,7 +124,7 @@ class Average * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -155,7 +153,7 @@ class Average * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -230,7 +228,7 @@ class Average * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -256,7 +254,7 @@ class Average * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -321,7 +319,7 @@ class Average * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -349,8 +347,6 @@ class Average * * @return string * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Math/Statistic/MeasureOfDispersion.php b/Math/Statistic/MeasureOfDispersion.php index 2663a16a6..059383a9b 100644 --- a/Math/Statistic/MeasureOfDispersion.php +++ b/Math/Statistic/MeasureOfDispersion.php @@ -60,7 +60,7 @@ class MeasureOfDispersion * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -102,7 +102,7 @@ class MeasureOfDispersion * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -127,7 +127,7 @@ class MeasureOfDispersion * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -160,7 +160,7 @@ class MeasureOfDispersion * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/ChiSquaredDistribution.php b/Math/Stochastic/Distribution/ChiSquaredDistribution.php index e6f5aa936..e49a73a6c 100644 --- a/Math/Stochastic/Distribution/ChiSquaredDistribution.php +++ b/Math/Stochastic/Distribution/ChiSquaredDistribution.php @@ -35,7 +35,7 @@ class ChiSquaredDistribution /** * Chi square table. * - * @var array + * @var array * @since 1.0.0 */ const TABLE = [ @@ -88,7 +88,7 @@ class ChiSquaredDistribution * * @return array * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -154,7 +154,7 @@ class ChiSquaredDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -236,7 +236,7 @@ class ChiSquaredDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/ExponentialDistribution.php b/Math/Stochastic/Distribution/ExponentialDistribution.php index 630c10452..e8e2c6bb3 100644 --- a/Math/Stochastic/Distribution/ExponentialDistribution.php +++ b/Math/Stochastic/Distribution/ExponentialDistribution.php @@ -127,7 +127,7 @@ class ExponentialDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 5ce28b8f1..a59766a64 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -103,8 +103,6 @@ class Request extends RequestAbstract * * @return void * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Router/Router.php b/Router/Router.php index 0145c3ead..161581ebc 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -34,7 +34,7 @@ class Router /** * Routes. * - * @var array + * @var array * @since 1.0.0 */ private $routes = []; @@ -103,7 +103,7 @@ class Router * * @return string[] * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn From d1f6921b20c3abf8ec9d03559bfe63848161ca44 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 7 Nov 2016 17:38:11 +0100 Subject: [PATCH 04/53] Comment fixes --- DataStorage/Database/DataMapperAbstract.php | 2 + Stdlib/Graph/Tree.php | 2 - Utils/TaskSchedule/SchedulerAbstract.php | 2 +- Utils/TaskSchedule/TaskScheduler.php | 71 ++++++++++++++++++++- 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 22993efd8..dba3be76e 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -1330,6 +1330,8 @@ class DataMapperAbstract implements DataMapperInterface /** * Get model based on request object * + * @todo: change to graphql + * * @param RequestAbstract $request Request object * * @return mixed diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 8ffa06b7b..4d1a29e36 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -15,8 +15,6 @@ */ namespace phpOMS\Datatypes; -use phpOMS\Validation\Base\IbanEnum; - /** * Tree class. * diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index a49553ff8..d64854ae1 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -95,7 +95,7 @@ abstract class SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function list() : array + public function getAll() : array { return $this->tasks; } diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index 95ec74115..81f847587 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -29,6 +29,16 @@ namespace phpOMS\Utils\TaskSchedule; class TaskScheduler extends SchedulerAbstract { + const BIN = ''; + + /** + * Env variables. + * + * @var array + * @since 1.0.0 + */ + private $envOptions = []; + public function save() { @@ -41,12 +51,69 @@ class TaskScheduler extends SchedulerAbstract * * @return array * + * @throws \Exception + * * @since 1.0.0 * @author Dennis Eichhorn */ public function run(string $cmd) : array { - // TODO: Implement run() method. - return []; + $cmd = 'cd ' . escapeshellarg(dirname(self::BIN)) . ' && ' . basename(self::BIN) . ' -C ' . escapeshellarg(__DIR__) . ' ' . $cmd; + + $pipes = []; + $desc = [ + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + + if (count($_ENV) === 0) { + $env = null; + foreach ($this->envOptions as $key => $value) { + putenv(sprintf("%s=%s", $key, $value)); + } + } else { + $env = array_merge($_ENV, $this->envOptions); + } + + $resource = proc_open($cmd, $desc, $pipes, __DIR__, $env); + $stdout = stream_get_contents($pipes[1]); + $stderr = stream_get_contents($pipes[2]); + + foreach ($pipes as $pipe) { + fclose($pipe); + } + + $status = trim(proc_close($resource)); + + if ($status == -1) { + throw new \Exception($stderr); + } + + return trim($stdout); + } + + public function getAll() : array + { + return str_getcsv($this->run('/query /v /fo CSV')); + } + + public function get(string $id) + { + + } + + public function getByName(string $name) : Schedule + { + + } + + public function getAllByName(string $name) : array + { + return str_getcsv($this->run('/query /v /fo CSV /tn ' . escapeshellarg($name))); + } + + public function create(Schedule $task) + { + } } From ed79ead1374c8aeb0e96aeb0e0ff2ed28a3cf54a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 7 Nov 2016 20:14:06 +0100 Subject: [PATCH 05/53] Fix comments --- Math/Differential/FiniteDifference.php | 2 +- Math/Optimization/TSP/BruteForce.php | 2 +- .../Distribution/BernoulliDistribution.php | 2 +- .../Stochastic/Distribution/BinomialDistribution.php | 2 +- .../Distribution/GeometricDistribution.php | 4 ---- Math/Stochastic/Distribution/LaplaceDistribution.php | 2 +- .../Distribution/UniformDistributionContinuous.php | 6 ------ .../Distribution/UniformDistributionDiscrete.php | 2 +- Module/ModuleManager.php | 8 ++++---- Utils/Encoding/Huffman/Dictionary.php | 4 ++-- Utils/Git/Commit.php | 4 +--- Utils/TaskSchedule/Interval.php | 12 ++++++------ Validation/ModelValidationTrait.php | 2 +- Views/View.php | 6 +++--- 14 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Math/Differential/FiniteDifference.php b/Math/Differential/FiniteDifference.php index 393ba0a21..026a79b8b 100644 --- a/Math/Differential/FiniteDifference.php +++ b/Math/Differential/FiniteDifference.php @@ -86,7 +86,7 @@ class FiniteDifference * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Optimization/TSP/BruteForce.php b/Math/Optimization/TSP/BruteForce.php index c1758c55d..4b5fb0cce 100644 --- a/Math/Optimization/TSP/BruteForce.php +++ b/Math/Optimization/TSP/BruteForce.php @@ -50,7 +50,7 @@ class BruteForce * * @param CityPool $pool City pool * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/BernoulliDistribution.php b/Math/Stochastic/Distribution/BernoulliDistribution.php index b506b0640..f12ac6f63 100644 --- a/Math/Stochastic/Distribution/BernoulliDistribution.php +++ b/Math/Stochastic/Distribution/BernoulliDistribution.php @@ -37,7 +37,7 @@ class BernoulliDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/BinomialDistribution.php b/Math/Stochastic/Distribution/BinomialDistribution.php index 1fe29f17b..d81ec63cf 100644 --- a/Math/Stochastic/Distribution/BinomialDistribution.php +++ b/Math/Stochastic/Distribution/BinomialDistribution.php @@ -40,7 +40,7 @@ class BinomialDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/GeometricDistribution.php b/Math/Stochastic/Distribution/GeometricDistribution.php index a8fddd10a..f6ad5d5bb 100644 --- a/Math/Stochastic/Distribution/GeometricDistribution.php +++ b/Math/Stochastic/Distribution/GeometricDistribution.php @@ -37,8 +37,6 @@ class GeometricDistribution * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -55,8 +53,6 @@ class GeometricDistribution * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Math/Stochastic/Distribution/LaplaceDistribution.php b/Math/Stochastic/Distribution/LaplaceDistribution.php index cab2beac8..50e38a23b 100644 --- a/Math/Stochastic/Distribution/LaplaceDistribution.php +++ b/Math/Stochastic/Distribution/LaplaceDistribution.php @@ -132,7 +132,7 @@ class LaplaceDistribution * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Math/Stochastic/Distribution/UniformDistributionContinuous.php b/Math/Stochastic/Distribution/UniformDistributionContinuous.php index 2ab995e82..3e8d69fa9 100644 --- a/Math/Stochastic/Distribution/UniformDistributionContinuous.php +++ b/Math/Stochastic/Distribution/UniformDistributionContinuous.php @@ -38,8 +38,6 @@ class UniformDistributionContinuous * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -57,8 +55,6 @@ class UniformDistributionContinuous * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -76,8 +72,6 @@ class UniformDistributionContinuous * * @return float * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Math/Stochastic/Distribution/UniformDistributionDiscrete.php b/Math/Stochastic/Distribution/UniformDistributionDiscrete.php index f56a44799..b083e5945 100644 --- a/Math/Stochastic/Distribution/UniformDistributionDiscrete.php +++ b/Math/Stochastic/Distribution/UniformDistributionDiscrete.php @@ -55,7 +55,7 @@ class UniformDistributionDiscrete * * @return float * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index d1a8bfd92..f3ad39463 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -351,7 +351,7 @@ class ModuleManager * * @return bool * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -586,7 +586,7 @@ class ModuleManager * * @param string|array $modules Module name * - * @throws + * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn @@ -613,7 +613,7 @@ class ModuleManager * * @return void * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -635,7 +635,7 @@ class ModuleManager * * @return \phpOMS\Module\ModuleAbstract * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index c577c5602..c6dce1b57 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -138,7 +138,7 @@ final class Dictionary * * @return void * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -177,7 +177,7 @@ final class Dictionary * * @return string * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index 6e4f73f35..33f1ca00a 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -160,8 +160,6 @@ class Commit * * @param string $message Commit message * - * @throws - * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -344,7 +342,7 @@ class Commit * @param string $old Old line * @param string $new New line * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index b3762679f..1ef28ad8b 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -296,7 +296,7 @@ class Interval implements \Serializable * @param int $step Step * @param bool $any Any * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -362,7 +362,7 @@ class Interval implements \Serializable * @param int $step Step * @param bool $any Any * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -402,7 +402,7 @@ class Interval implements \Serializable * @param bool $last Last * @param int $nearest Nearest day * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -472,7 +472,7 @@ class Interval implements \Serializable * @param bool $any Any * @param bool $last Last * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -537,7 +537,7 @@ class Interval implements \Serializable * @param int $step Step * @param bool $any Any * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn @@ -575,7 +575,7 @@ class Interval implements \Serializable * @param int $step Step * @param bool $any Any * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Validation/ModelValidationTrait.php b/Validation/ModelValidationTrait.php index 68e99fd7c..861e78a88 100644 --- a/Validation/ModelValidationTrait.php +++ b/Validation/ModelValidationTrait.php @@ -80,7 +80,7 @@ trait ModelValidationTrait * * @return bool * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Views/View.php b/Views/View.php index a4a1a5696..d8fc1d380 100644 --- a/Views/View.php +++ b/Views/View.php @@ -156,13 +156,13 @@ class View extends ViewAbstract /** * Get translation. * + * @param string $translation Text * @param string $module Module name * @param string $theme Theme name - * @param string $translation Text - * + * * @return array * - * @throws + * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn From 968d4823b5560a51018840ef72d6d08bc96e92da Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 7 Nov 2016 21:45:35 +0100 Subject: [PATCH 06/53] Fixing console web run --- Localization/Localization.php | 2 ++ Uri/Http.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Localization/Localization.php b/Localization/Localization.php index fdc8eb585..8c0c9bfaa 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -224,6 +224,8 @@ class Localization * * @return void * + * @throws InvalidEnumValue + * * @since 1.0.0 * @author Dennis Eichhorn */ diff --git a/Uri/Http.php b/Uri/Http.php index 8d0c9b6cf..7c9bf561e 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -155,7 +155,7 @@ class Http implements UriInterface $this->port = $url['port'] ?? null; $this->user = $url['user'] ?? null; $this->pass = $url['pass'] ?? null; - $this->path = $url['path'] ?? null; + $this->path = $url['path'] ?? ''; if (StringUtils::endsWith($this->path, '.php')) { $this->path = substr($this->path, 0, -4); @@ -183,7 +183,7 @@ class Http implements UriInterface public static function getCurrent() : string { /** @noinspection PhpUndefinedConstantInspection */ - return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + return 'http://' . ($_SERVER['HTTP_HOST'] ?? '') . ($_SERVER['REQUEST_URI'] ?? ''); } /** From e3ac43df34d4681e920d3a1e7a7511155f60d4d8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 7 Nov 2016 22:29:35 +0100 Subject: [PATCH 07/53] Fixing empty modules --- Module/ModuleFactory.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Module/ModuleFactory.php b/Module/ModuleFactory.php index 040b4913e..a63294078 100644 --- a/Module/ModuleFactory.php +++ b/Module/ModuleFactory.php @@ -16,6 +16,7 @@ namespace phpOMS\Module; use phpOMS\ApplicationAbstract; +use phpOMS\Autoloader; /** * ModuleFactory class. @@ -74,14 +75,19 @@ class ModuleFactory */ public static function getInstance(string $module, ApplicationAbstract $app) : ModuleAbstract { + $class = '\\Modules\\' . $module . '\\Controller'; + if (!isset(self::$loaded[$module])) { - try { - $class = '\\Modules\\' . $module . '\\Controller'; - $obj = new $class($app); - self::$loaded[$module] = $obj; - self::registerRequesting($obj); - self::registerProvided($obj); - } catch (\Exception $e) { + if(Autoloader::exists($class) !== false) { + try { + $obj = new $class($app); + self::$loaded[$module] = $obj; + self::registerRequesting($obj); + self::registerProvided($obj); + } catch (\Exception $e) { + self::$loaded[$module] = new NullModule($app); + } + } else { self::$loaded[$module] = new NullModule($app); } } From ba2a8d9f6203b4b67bf952a9c494641ad1fe6b23 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 9 Nov 2016 21:12:34 +0100 Subject: [PATCH 08/53] Implemented --- Validation/Base/DateTime.php | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Validation/Base/DateTime.php diff --git a/Validation/Base/DateTime.php b/Validation/Base/DateTime.php new file mode 100644 index 000000000..51f887528 --- /dev/null +++ b/Validation/Base/DateTime.php @@ -0,0 +1,51 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Validation\Base; + +use phpOMS\Validation\ValidatorAbstract; + +/** + * Validator abstract. + * + * @category Validation + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class DateTime extends ValidatorAbstract +{ + + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function __construct() + { + } + + /** + * {@inheritdoc} + */ + public static function isValid($value) + { + return (bool) strtotime($value); + } +} From a6a56883a8679ccb3e168a1d7f94b03078880b8b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 9 Nov 2016 21:12:50 +0100 Subject: [PATCH 09/53] Adjust windows scheduler --- Utils/ImageUtils.php | 40 ++++ Utils/TaskSchedule/Schedule.php | 10 +- Utils/TaskSchedule/SchedulerFactory.php | 2 +- Utils/TaskSchedule/TaskAbstract.php | 304 +++++++++++++++++++++--- Utils/TaskSchedule/TaskFactory.php | 8 +- Utils/TaskSchedule/TaskScheduler.php | 103 +++++++- 6 files changed, 411 insertions(+), 56 deletions(-) create mode 100644 Utils/ImageUtils.php diff --git a/Utils/ImageUtils.php b/Utils/ImageUtils.php new file mode 100644 index 000000000..f6e4322e1 --- /dev/null +++ b/Utils/ImageUtils.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Utils; + +/** + * Image utils class. + * + * This class provides static helper functionalities for images. + * + * @category Framework + * @package phpOMS\Utils + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class ImageUtils +{ + public static function decodeBase64Image(string $img) : string + { + $img = str_replace('data:image/png;base64,', '', $img); + $img = str_replace(' ', '+', $img); + + return base64_decode($img); + } +} diff --git a/Utils/TaskSchedule/Schedule.php b/Utils/TaskSchedule/Schedule.php index 63ebe1745..16664e121 100644 --- a/Utils/TaskSchedule/Schedule.php +++ b/Utils/TaskSchedule/Schedule.php @@ -37,15 +37,9 @@ class Schedule extends TaskAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function __construct(Interval $interval = null, string $cmd = '') + public function __construct(string $name, string $cmd = '') { - if (!isset($interval)) { - $this->interval = new Interval(); - } else { - $this->interval = $interval; - } - - $this->command = $cmd; + parent::__construct($name, $cmd); } /** diff --git a/Utils/TaskSchedule/SchedulerFactory.php b/Utils/TaskSchedule/SchedulerFactory.php index 083ec0b95..09e360f85 100644 --- a/Utils/TaskSchedule/SchedulerFactory.php +++ b/Utils/TaskSchedule/SchedulerFactory.php @@ -42,7 +42,7 @@ final class SchedulerFactory * @since 1.0.0 * @author Dennis Eichhorn */ - public static function create() : ScheduleInterface + public static function create() : SchedulerAbstract { switch (OperatingSystem::getSystem()) { case SystemType::WIN: diff --git a/Utils/TaskSchedule/TaskAbstract.php b/Utils/TaskSchedule/TaskAbstract.php index 0a457ca64..7f645d660 100644 --- a/Utils/TaskSchedule/TaskAbstract.php +++ b/Utils/TaskSchedule/TaskAbstract.php @@ -37,21 +37,42 @@ abstract class TaskAbstract protected $id = ''; /** - * Interval. - * - * @var Interval - * @since 1.0.0 - */ - protected $interval = null; - - /** - * Command. + * Command used for creating the task * * @var string * @since 1.0.0 */ protected $command = ''; + /** + * Command/script to run. + * + * @var string + * @since 1.0.0 + */ + protected $run = ''; + + protected $status = ''; + + protected $nextRunTime = null; + + protected $lastRunTime = null; + + protected $start = null; + + protected $end = null; + + protected $comment = ''; + + protected $results = []; + + protected $author = ''; + + public function __construct(string $name, string $cmd = '') { + $this->id = $name; + $this->command = $cmd; + } + /** * Get id. * @@ -65,34 +86,6 @@ abstract class TaskAbstract return $this->id; } - /** - * Get interval. - * - * @return Interval - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function getInterval() : Interval - { - return $this->interval; - } - - /** - * Set interval. - * - * @param Interval $interval Interval - * - * @return void - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function setInterval(Interval $interval) - { - $this->interval = $interval; - } - /** * Get command. * @@ -120,4 +113,241 @@ abstract class TaskAbstract { $this->command = $command; } + + /** + * Get run. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getRun() : string + { + return $this->run; + } + + /** + * Set run. + * + * @param string $run Command/script to run + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setRun(string $run) + { + $this->run = $run; + } + + /** + * Get status. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getStatus() : string + { + return $this->status; + } + + /** + * Set status. + * + * @param string $status Status + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setStatus(string $status) + { + $this->status = $status; + } + + /** + * Get next run time. + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getNextRunTime() + { + return $this->nextRunTime; + } + + /** + * Set next run time. + * + * @param \DateTime $nextRunTime Next run time + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setNextRunTime(\DateTime $nextRunTime) + { + $this->nextRuntime = $nextRunTime; + } + + /** + * Get last run time. + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getLastRuntime() + { + return $this->lastRunTime; + } + + /** + * Set last run time. + * + * @param \DateTime $lastRunTime Last run time + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setLastRuntime(\DateTime $lastRunTime) + { + $this->lastRunTime = $lastRunTime; + } + + /** + * Get start. + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getStart() + { + return $this->start; + } + + /** + * Set start. + * + * @param \DateTime $start Start + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setStart(\DateTime $start) + { + $this->start = $start; + } + + /** + * Get end. + * + * @return \DateTime + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getEnd() + { + return $this->end; + } + + /** + * Set end. + * + * @param \DateTime $end End + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setEnd(\DateTime $end) + { + $this->end = $end; + } + + /** + * Get author. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getAuthor() : string + { + return $this->author; + } + + /** + * Set author. + * + * @param string $author Author + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setAuthor(string $author) + { + $this->author = $author; + } + + /** + * Get comment. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function getComment() : string + { + return $this->comment; + } + + /** + * Set comment. + * + * @param string $comment Comment + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setComment(string $comment) + { + $this->comment = $comment; + } + + /** + * Get comment. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function addResult(string $result) + { + $this->results[] = $result; + } } diff --git a/Utils/TaskSchedule/TaskFactory.php b/Utils/TaskSchedule/TaskFactory.php index 9e42e5e50..db20362d9 100644 --- a/Utils/TaskSchedule/TaskFactory.php +++ b/Utils/TaskSchedule/TaskFactory.php @@ -35,7 +35,7 @@ final class TaskFactory /** * Create task instance. * - * @param Interval $interval Task interval + * @param string $id Task id * @param string $cmd Command to run * * @return TaskInterface @@ -45,13 +45,13 @@ final class TaskFactory * @since 1.0.0 * @author Dennis Eichhorn */ - public static function create(Interval $interval = null, string $cmd = '') : TaskInterface + public static function create(string $id = null, string $cmd = '') : TaskAbstract { switch (OperatingSystem::getSystem()) { case SystemType::WIN: - return new Schedule($interval, $cmd); + return new Schedule($id, $cmd); case SystemType::LINUX: - return new CronJob($interval, $cmd); + return new CronJob($id, $cmd); default: throw new \Exception('Unsupported system.'); } diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index 81f847587..dc92396e2 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -15,6 +15,8 @@ */ namespace phpOMS\Utils\TaskSchedule; +use phpOMS\Validation\Base\DateTime; + /** * Task scheduler class. * @@ -29,7 +31,7 @@ namespace phpOMS\Utils\TaskSchedule; class TaskScheduler extends SchedulerAbstract { - const BIN = ''; + protected static $bin = 'c:/WINDOWS/system32/schtasks.exe'; /** * Env variables. @@ -39,6 +41,29 @@ class TaskScheduler extends SchedulerAbstract */ private $envOptions = []; + /** + * Test git. + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function test() : bool + { + $pipes = []; + $resource = proc_open(escapeshellarg(self::$bin), [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); + + $stdout = stream_get_contents($pipes[1]); + $stderr = stream_get_contents($pipes[2]); + + foreach ($pipes as $pipe) { + fclose($pipe); + } + + return trim(proc_close($resource)) !== 127; + } + public function save() { @@ -56,9 +81,9 @@ class TaskScheduler extends SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function run(string $cmd) : array + private function run(string $cmd) : string { - $cmd = 'cd ' . escapeshellarg(dirname(self::BIN)) . ' && ' . basename(self::BIN) . ' -C ' . escapeshellarg(__DIR__) . ' ' . $cmd; + $cmd = 'cd ' . escapeshellarg(dirname(self::$bin)) . ' && ' . basename(self::$bin) . ' ' . $cmd; $pipes = []; $desc = [ @@ -92,9 +117,52 @@ class TaskScheduler extends SchedulerAbstract return trim($stdout); } + private function normalize(string $raw) : string + { + return str_replace("\r\n", "\n", $raw); + } + + private function parseJobList(array $jobData) { + $job = TaskFactory::create($jobData[1], ''); + + $job->setRun($jobData[8]); + $job->setStatus($jobData[3]); + + if(DateTime::isValid($jobData[2])) { + $job->setNextRunTime(new \DateTime($jobData[2])); + } + + if(DateTime::isValid($jobData[5])) { + $job->setLastRunTime(new \DateTime($jobData[5])); + } + + $job->setAuthor($jobData[7]); + $job->setComment($jobData[10]); + + if(DateTime::isValid($jobData[20])) { + $job->setStart(new \DateTime($jobData[20])); + } + + if(DateTime::isValid($jobData[21])) { + $job->setEnd(new \DateTime($jobData[21])); + } + + $job->addResult($jobData[6]); + + return $job; + } + public function getAll() : array { - return str_getcsv($this->run('/query /v /fo CSV')); + $lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV'))); + unset($lines[0]); + + $jobs = []; + foreach($lines as $line) { + $jobs[] = $this->parseJobList(str_getcsv($line)); + } + + return $jobs; } public function get(string $id) @@ -107,9 +175,32 @@ class TaskScheduler extends SchedulerAbstract } - public function getAllByName(string $name) : array + public function getAllByName(string $name, bool $exact = true) : array { - return str_getcsv($this->run('/query /v /fo CSV /tn ' . escapeshellarg($name))); + if($exact) { + $lines = $this->run('/query /v /fo CSV /tn ' . escapeshellarg($name)); + unset($lines[0]); + + $jobs = []; + foreach($lines as $line) { + $jobs[] = $this->parseJobList(str_getcsv($line)); + } + } else { + $lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV'))); + $jobs = []; + + unset($lines[0]); + + foreach($lines as $key => $line) { + $line = str_getcsv($line); + + if(strpos($line[1], $name) !== false) { + $jobs[] = $this->parseJobList($line); + } + } + } + + return $jobs; } public function create(Schedule $task) From 0c5e3bfad436f16f95953d8cecafdc0b0849ff4e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 11 Nov 2016 21:34:04 +0100 Subject: [PATCH 10/53] fixes #79 --- Uri/UriFactory.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 3536802bd..89b0ed548 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -87,6 +87,38 @@ class UriFactory return false; } + public static function clearAll() : bool + { + self::$uri = []; + + return true; + } + + public static function clear(string $key) : bool + { + if(isset(self::$uri[$key])) { + unset(self::$uri[$key]); + + return true; + } + + return false; + } + + public static function clearLike(string $pattern) : bool + { + $success = false; + + foreach(self::$uri as $key => $value) { + if(((bool) preg_match('~^' . $pattern . '$~', $key))) { + unset(self::$uri[$key]); + $success = true; + } + } + + return success; + } + /** * Simplify url * From b66afdf9f04d79d4de30f239e8b44ed2a24297ed Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 11 Nov 2016 22:37:56 +0100 Subject: [PATCH 11/53] Preparing for usage --- System/File/Storage.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/System/File/Storage.php b/System/File/Storage.php index 0df22ac37..11886e068 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -61,16 +61,19 @@ final class Storage if(is_string(self::$registered[$env])) { $env = self::$registered[$env]::getInstance(); } elseif(self::$registered[$env] instanceof StorageAbstract) { - $env = self::$registered[$env]::getInstance(); + $env = self::$registered[$env]; } elseif(self::$registered[$env] instanceof ContainerInterface) { $env = self::$registered[$env]; } else { throw new \Exception('Invalid type'); } } else { + $stg = $env; $env = ucfirst(strtolower($env)); $env = __NAMESPACE__ . '\\' . $env . '\\' . $env . 'Storage'; $env = $env::getInstance(); + + self::$registered[$stg] = $env; } return $env; From cc289916715ce2d0f52d3fe7853c023b6aeecbc4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 12 Nov 2016 21:40:30 +0100 Subject: [PATCH 12/53] Added config --- ApplicationAbstract.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index a827cf25d..517a95efa 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -37,6 +37,14 @@ class ApplicationAbstract */ public $appName = ''; + /** + * Config. + * + * @var array + * @since 1.0.0 + */ + private $config = []; + /** * Database object. * From 2ef8358771ddf2e759fa1fbbde3bbb1a28ab1dfe Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 12 Nov 2016 21:40:39 +0100 Subject: [PATCH 13/53] Add return --- Math/Matrix/Matrix.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 2f512ced2..7c3d6b962 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -767,7 +767,7 @@ class Matrix implements \ArrayAccess, \Iterator */ public function valid() { - $this->offsetExists($this->position); + return $this->offsetExists($this->position); } /** From e605eb38858df8d82811c1afe391570c65b84e27 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 12 Nov 2016 21:40:53 +0100 Subject: [PATCH 14/53] Remove environment variable --- Utils/Git/Repository.php | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 0a42fe7c6..03ef83baa 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -55,14 +55,6 @@ class Repository */ private $bare = false; - /** - * Env variables. - * - * @var array - * @since 1.0.0 - */ - private $envOptions = []; - /** * Current branch. * @@ -189,16 +181,7 @@ class Repository 2 => ['pipe', 'w'], ]; - if (count($_ENV) === 0) { - $env = null; - foreach ($this->envOptions as $key => $value) { - putenv(sprintf("%s=%s", $key, $value)); - } - } else { - $env = array_merge($_ENV, $this->envOptions); - } - - $resource = proc_open($cmd, $desc, $pipes, $this->path, $env); + $resource = proc_open($cmd, $desc, $pipes, $this->path, null); $stdout = stream_get_contents($pipes[1]); $stderr = stream_get_contents($pipes[2]); @@ -639,22 +622,6 @@ class Repository return file_get_contents($this->getDirectoryPath() . '/description'); } - /** - * Set environment value. - * - * @param string $key Key - * @param string $value Value - * - * @return void - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public function setEnv(string $key, string $value) - { - $this->envOptions[$key] = $value; - } - /** * Count files in repository. * From 5bcefc9a404b66f2c5fc38e3e183cf43abdf84bd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 12 Nov 2016 21:41:11 +0100 Subject: [PATCH 15/53] Static job path added --- Utils/TaskSchedule/SchedulerAbstract.php | 65 +++++++++++++++++++++++- Utils/TaskSchedule/TaskScheduler.php | 45 +--------------- 2 files changed, 65 insertions(+), 45 deletions(-) diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index d64854ae1..bbd7f50a8 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -29,13 +29,76 @@ namespace phpOMS\Utils\TaskSchedule; abstract class SchedulerAbstract { /** - * tasks. + * Tasks. * * @var TaskAbstract[] * @since 1.0.0 */ protected $tasks = []; + /** + * Bin path. + * + * @var string + * @since 1.0.0 + */ + protected static $bin = ''; + + /** + * Get git binary. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getBin() : string + { + return self::$bin; + } + + /** + * Set git binary. + * + * @param string $path Git path + * + * @throws PathException + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function setBin(string $path) + { + if (realpath($path) === false) { + throw new PathException($path); + } + + self::$bin = realpath($path); + } + + /** + * Test git. + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function test() : bool + { + $pipes = []; + $resource = proc_open(escapeshellarg(self::$bin), [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); + + $stdout = stream_get_contents($pipes[1]); + $stderr = stream_get_contents($pipes[2]); + + foreach ($pipes as $pipe) { + fclose($pipe); + } + + return trim(proc_close($resource)) !== 127; + } + /** * Add task * diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index dc92396e2..e37378a3f 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -30,40 +30,6 @@ use phpOMS\Validation\Base\DateTime; */ class TaskScheduler extends SchedulerAbstract { - - protected static $bin = 'c:/WINDOWS/system32/schtasks.exe'; - - /** - * Env variables. - * - * @var array - * @since 1.0.0 - */ - private $envOptions = []; - - /** - * Test git. - * - * @return bool - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - public static function test() : bool - { - $pipes = []; - $resource = proc_open(escapeshellarg(self::$bin), [1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); - - $stdout = stream_get_contents($pipes[1]); - $stderr = stream_get_contents($pipes[2]); - - foreach ($pipes as $pipe) { - fclose($pipe); - } - - return trim(proc_close($resource)) !== 127; - } - public function save() { @@ -91,16 +57,7 @@ class TaskScheduler extends SchedulerAbstract 2 => ['pipe', 'w'], ]; - if (count($_ENV) === 0) { - $env = null; - foreach ($this->envOptions as $key => $value) { - putenv(sprintf("%s=%s", $key, $value)); - } - } else { - $env = array_merge($_ENV, $this->envOptions); - } - - $resource = proc_open($cmd, $desc, $pipes, __DIR__, $env); + $resource = proc_open($cmd, $desc, $pipes, __DIR__, null); $stdout = stream_get_contents($pipes[1]); $stderr = stream_get_contents($pipes[2]); From c38bbd1fa4dc01cc5831b1812c338ade3605e1fd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 12 Nov 2016 21:41:23 +0100 Subject: [PATCH 16/53] Complete collection implementation --- Stdlib/Collection/Collection.php | 69 +++++++++++++++++--------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/Stdlib/Collection/Collection.php b/Stdlib/Collection/Collection.php index 7ad3cbec3..5367be1d8 100644 --- a/Stdlib/Collection/Collection.php +++ b/Stdlib/Collection/Collection.php @@ -310,10 +310,6 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return $this; } - public function range() - { - } - public function has($key) : bool { return isset($this->collection[$key]); @@ -478,14 +474,17 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab public function shuffle() : Collection { + return new self(shuffle($this->collection)); } - public function slice() + public function slice(int $offset, int $length) : Collection { + return new self(array_slice($this->collection, $offset, $length)); } - public function splice() + public function splice(int $offset, int $length) : Collection { + return new self(array_splice($this->collection, $offset, $length)); } public function push($value) : Collection @@ -503,7 +502,25 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function current() { - // TODO: Implement current() method. + return current($this->collection); + } + + /** + * Offset to retrieve + * @link http://php.net/manual/en/arrayaccess.offsetget.php + * @param mixed $offset

+ * The offset to retrieve. + *

+ * @return mixed Can return all value types. + * @since 5.0.0 + */ + public function offsetGet($offset) + { + if(!isset($this->collection[$offset])) { + throw new \Exception('Invalid offset'); + } + + return $this->collection[$offset]; } /** @@ -514,7 +531,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function next() { - // TODO: Implement next() method. + next($this->collection); } /** @@ -525,7 +542,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function key() { - // TODO: Implement key() method. + return key($this->collection); } /** @@ -537,18 +554,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function valid() { - // TODO: Implement valid() method. - } - - /** - * Rewind the Iterator to the first element - * @link http://php.net/manual/en/iterator.rewind.php - * @return void Any returned value is ignored. - * @since 5.0.0 - */ - public function rewind() - { - // TODO: Implement rewind() method. + return isset($this->collection[key($this->collection)]); } /** @@ -565,21 +571,18 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function offsetExists($offset) { - // TODO: Implement offsetExists() method. + return isset($this->collection[$offset]); } /** - * Offset to retrieve - * @link http://php.net/manual/en/arrayaccess.offsetget.php - * @param mixed $offset

- * The offset to retrieve. - *

- * @return mixed Can return all value types. + * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. * @since 5.0.0 */ - public function offsetGet($offset) + public function rewind() { - // TODO: Implement offsetGet() method. + rewind($this->collection); } /** @@ -596,7 +599,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function offsetSet($offset, $value) { - // TODO: Implement offsetSet() method. + $this->collection[$offset] = $value; } /** @@ -610,6 +613,8 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab */ public function offsetUnset($offset) { - // TODO: Implement offsetUnset() method. + if(isset($this->collection[$offset])) { + unset($this->collection[$offset]); + } } } \ No newline at end of file From cd8799d8a59f93d62f0a77da1a9494e61d67915d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 13 Nov 2016 00:13:46 +0100 Subject: [PATCH 17/53] fixes #75 Some binary tree implementations maybe can get implemented for general trees/graphs? --- Stdlib/Graph/BinaryTree.php | 81 +++++++++++++++++++++++++++++++++++-- Stdlib/Graph/Tree.php | 68 ++++++++++++++++++------------- 2 files changed, 118 insertions(+), 31 deletions(-) diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index 4f481ea45..bad8940e0 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -46,11 +46,11 @@ class BinaryTree extends Tree } public function getLeft() { - return $this->nodes[0]; + return $this->nodes[0] ?? null; } public function getRight() { - return $this->nodes[1]; + return $this->nodes[1] ?? null; } public function setLeft(BinaryTree $left) { @@ -61,7 +61,80 @@ class BinaryTree extends Tree $this->nodes[1] = $right; } - public function inOrder() { - + public function preOrder(\Closure $callback) { + if(count($this->nodes) === 0) { + return; + } + + $callback($this); + $this->nodes[0]->inOrder($callback); + $this->nodes[1]->inOrder($callback); + } + + public function inOrder(\Closure $callback) { + if(count($this->nodes) === 0) { + return; + } + + $this->nodes[0]->inOrder($callback); + $callback($this); + $this->nodes[1]->inOrder($callback); + } + + public function postOrder(\Closure $callback) { + if(count($this->nodes) === 0) { + return; + } + + $this->nodes[0]->inOrder($callback); + $this->nodes[1]->inOrder($callback); + $callback($this); + } + + private function getVerticalOrder(int $horizontalDistance = 0, array &$order) + { + if(!isset($order[$horizontalDistance])) { + $order[$horizontalDistance] = []; + } + + $order[$horizontalDistance][] = $this; + + if(isset($this->nodes[0])) { + $this->nodes[0]->getVerticalOrder($horizontalDistance-1, $order); + } + + if(isset($this->nodes[1])) { + $this->nodes[1]->getVerticalOrder($horizontalDistance+1, $order); + } + } + + public function verticalOrder(\Closure $callback) + { + $order = []; + $this->getVerticalOrder(0, $order); + + foreach($order as $level) { + foreach($level as $node) { + $callback($node); + } + } + } + + public function isSymmetric() : bool { + // todo: compare values? true symmetry requires the values to be the same + if(isset($this->nodes[0]) && isset($this->nodes[1])) { + return isSymmetric($this->nodes[0], $this->nodes[1]); + } + + return false; + } + + public function symmetric(BinaryTree $tree1, BinaryTree $tree2) : bool { + // todo: compare values? true symmetry requires the values to be the same + if(($tree1 !== null && $tree2 !== null) || $tree1 === $tree2) { + return isSymmetric($tree1->getLeft(), $tree1->getRight()) && isSymmetric($tree2->getRight(), $tree2->getLeft()); + } + + return false; } } \ No newline at end of file diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 4d1a29e36..82514b0cc 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -32,6 +32,18 @@ class Tree extends Graph { protected $nodes = []; + public function add(Tree $node) { + $this->nodes[] = $node; + + return $this; + } + + public function set($key, Tree $node) { + $this->nodes[$key] = $node; + + return $this; + } + public function getMaxDepth() : int { $depth = [0]; @@ -54,42 +66,44 @@ class Tree extends Graph return min($depth) + 1; } - public function postOrder() - { - - } - - public function preOrder() - { - - } - - public function levelOrder() - { - - } - - public function levelOrder2() - { - - } - - public function verticalOrder() + public function levelOrder(\Closure $callback) { + $depth = $this->getMaxDepth(); + for($i = 1; $i < $depth; $i++) { + $nodes = $this->getLevel($i); + callback($nodes); + } } public function isLeaf() : bool { - - } - - public function isSymmetric() : bool { - + return count($this->nodes) === 0; } public function getDimension() : int { - + $size = 1; + + foreach($this->nodes as $node) { + $size += $node->getDimension() + 1; + } + + return $size; + } + + public function getLevelNodes(int $level, array &$nodes) + { + --$level; + + foreach($this->nodes as $node) { + if($level === 0) { + $nodes[] = $this; + + return $nodes; + } else { + $this->getLevelNodes($level, $nodes); + } + } } } \ No newline at end of file From 5522cf06fc370d57c2508240fa19421de4fe030b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 13 Nov 2016 20:00:09 +0100 Subject: [PATCH 18/53] Algorithm placeholder --- Algorithm/AlgorithmType.php | 0 Algorithm/Knappsack/Backpack.php | 90 +++++++++++++++++++++++++++ Algorithm/Knappsack/ItemInterface.php | 0 3 files changed, 90 insertions(+) create mode 100644 Algorithm/AlgorithmType.php create mode 100644 Algorithm/Knappsack/Backpack.php create mode 100644 Algorithm/Knappsack/ItemInterface.php diff --git a/Algorithm/AlgorithmType.php b/Algorithm/AlgorithmType.php new file mode 100644 index 000000000..e69de29bb diff --git a/Algorithm/Knappsack/Backpack.php b/Algorithm/Knappsack/Backpack.php new file mode 100644 index 000000000..0e7f3f4a3 --- /dev/null +++ b/Algorithm/Knappsack/Backpack.php @@ -0,0 +1,90 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm\Knappsack; + +/** + * Knappsack algorithm implementations + * + * @category Framework + * @package phpOMS\Auth + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Backpack +{ + private $costMaximum = 0; + + private $value = 0; + + private $cost = 0; + + private $items = []; + + private $population = []; + + public function __construct(float $costMaximum) + { + $this->costMaximum = $costMaximum; + } + + public function addPopulationItem(ItemInterface $item) : bool + { + if(isset($this->population[$item->getId()])) { + return false; + } + + $this->population[$item->getId()] = $item; + + return true; + } + + public function setPopulationItem(ItemInterface $item) + { + $this->population[$item->getId()] = $item; + } + + public function setCostCalculation(\Closure $callback) + { + + } + + public function setValueCalculation(\Closure $callback) + { + + } + + public function setTestPopulationBuilder(\Closure $callback) + { + + } + + public function pack(int $type) + { + switch($type) { + case AlgorithmType::BRUTEFORCE: + return $this->bruteforce(); + default: + throw new \Exception('Invalid algorithm type'); + } + } + + public function bruteforce() + { + } +} \ No newline at end of file diff --git a/Algorithm/Knappsack/ItemInterface.php b/Algorithm/Knappsack/ItemInterface.php new file mode 100644 index 000000000..e69de29bb From 4dd9f346708c6ac1fd74906fc64c31482689e685 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 13 Nov 2016 20:31:08 +0100 Subject: [PATCH 19/53] fixes #76 Still many unimplemented elements but the basic functions are usable?! --- Stdlib/Graph/BinaryTree.php | 105 ++++++++-------- Stdlib/Graph/Edge.php | 53 ++++++++ Stdlib/Graph/Graph.php | 239 ++++++++++++++++++++++++++++++++++++ Stdlib/Graph/Node.php | 33 +++++ Stdlib/Graph/Tree.php | 136 +++++++++++++------- 5 files changed, 474 insertions(+), 92 deletions(-) create mode 100644 Stdlib/Graph/Edge.php create mode 100644 Stdlib/Graph/Node.php diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index bad8940e0..152c2fad3 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -45,73 +45,78 @@ class BinaryTree extends Tree return $list; } - public function getLeft() { - return $this->nodes[0] ?? null; + public function getLeft(Node $base) + { + $neighbors = $base->getNeighbors($base); + + // todo: index can be wrong, see setLeft/setRight + return $neighbors[0] ?? null; } - public function getRight() { - return $this->nodes[1] ?? null; + public function getRight(Node $base) + { + $neighbors = $base->getNeighbors($base); + + // todo: index can be wrong, see setLeft/setRight + return $neighbors[1] ?? null; } - public function setLeft(BinaryTree $left) { - $this->nodes[0] = $left; + public function setLeft(Node $base, Node $left) + { + if($this->getLeft($base) === null) { + $this->addNode($base, $left); + // todo: doesn't know that this is left + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } } - public function setRight(BinaryTree $right) { - $this->nodes[1] = $right; + public function setRight(Node $base, Node $right) + { + if($this->getRight($base) === null) { + $this->addNode($base, $right); + // todo: doesn't know that this is right + // todo: maybe need to add numerics to edges? + } else { + // todo: replace node + } } - public function preOrder(\Closure $callback) { + public function inOrder(Node $node, \Closure $callback) + { if(count($this->nodes) === 0) { return; } - $callback($this); - $this->nodes[0]->inOrder($callback); - $this->nodes[1]->inOrder($callback); + $this->inOrder($this->getLeft($node), $callback); + $callback($node); + $this->inOrder($this->getRight($node), $callback); } - public function inOrder(\Closure $callback) { - if(count($this->nodes) === 0) { - return; - } - - $this->nodes[0]->inOrder($callback); - $callback($this); - $this->nodes[1]->inOrder($callback); - } - - public function postOrder(\Closure $callback) { - if(count($this->nodes) === 0) { - return; - } - - $this->nodes[0]->inOrder($callback); - $this->nodes[1]->inOrder($callback); - $callback($this); - } - - private function getVerticalOrder(int $horizontalDistance = 0, array &$order) + private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) { if(!isset($order[$horizontalDistance])) { $order[$horizontalDistance] = []; } - $order[$horizontalDistance][] = $this; + $order[$horizontalDistance][] = $node; + $left = $this->getLeft($node); + $right = $this->getRight($node); - if(isset($this->nodes[0])) { - $this->nodes[0]->getVerticalOrder($horizontalDistance-1, $order); + if(isset($left)) { + $this->getVerticalOrder($left, $horizontalDistance-1, $order); } - if(isset($this->nodes[1])) { - $this->nodes[1]->getVerticalOrder($horizontalDistance+1, $order); + if(isset($right)) { + $this->getVerticalOrder($right, $horizontalDistance+1, $order); } } - public function verticalOrder(\Closure $callback) + public function verticalOrder(Node $node, \Closure $callback) { $order = []; - $this->getVerticalOrder(0, $order); + $this->getVerticalOrder($node, 0, $order); foreach($order as $level) { foreach($level as $node) { @@ -120,19 +125,21 @@ class BinaryTree extends Tree } } - public function isSymmetric() : bool { - // todo: compare values? true symmetry requires the values to be the same - if(isset($this->nodes[0]) && isset($this->nodes[1])) { - return isSymmetric($this->nodes[0], $this->nodes[1]); + public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool + { + if(!isset($node1) && !isset($node2)) { + return true; } - return false; - } + $left1 = $this->getLeft($node1); + $right1 = $this->getRight($node1); + + $left2 = isset($node2) ? $this->getLeft($node1) : $this->getLeft($node2); + $right2 = isset($node2) ? $this->getRight($node1) : $this->getRight($node2); - public function symmetric(BinaryTree $tree1, BinaryTree $tree2) : bool { // todo: compare values? true symmetry requires the values to be the same - if(($tree1 !== null && $tree2 !== null) || $tree1 === $tree2) { - return isSymmetric($tree1->getLeft(), $tree1->getRight()) && isSymmetric($tree2->getRight(), $tree2->getLeft()); + if(isset($node1) && isset($node2)) { + return $this->isSymmetric($left1, $right2) && $this->isSymmetric($right1, $left2); } return false; diff --git a/Stdlib/Graph/Edge.php b/Stdlib/Graph/Edge.php new file mode 100644 index 000000000..b4bd7ce33 --- /dev/null +++ b/Stdlib/Graph/Edge.php @@ -0,0 +1,53 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Datatypes; + +/** + * Tree class. + * + * @category Framework + * @package phpOMS\Datatypes + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Edge +{ + private $node1 = null; + + private $node2 = null; + + private $directed = false; + + public function __construct(Node $node1, Node $node2, bool $directed = false) + { + $this->node1 = $node1; + $this->node2 = $node2; + $this->directed = $directed; + } + + public function getNodes() : array + { + return [$this->node1, $this->node2]; + } + + public function isDirected() : bool + { + return $this->directed; + } +} \ No newline at end of file diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index e69de29bb..63a67fdb4 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -0,0 +1,239 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Datatypes; + +/** + * Tree class. + * + * @category Framework + * @package phpOMS\Datatypes + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Graph +{ + protected $nodes = []; + + protected $edges = []; + + public function addNode(Node $node) + { + $this->nodes[] = $node; + + return $this; + } + + public function setNode($key, Node $node) + { + $this->nodes[$key] = $node; + + return $this; + } + + public function addEdge(Edge $edge) + { + $this->edges[] = $edge; + + return $this; + } + + public function setEdge($key, Edge $edge) + { + $this->edges[$key] = $edge; + + return $this; + } + + public function getNode($key) : Node + { + return $this->nodes[$key]; + } + + public function getEdge($key) : Edge + { + return $this->edges[$key]; + } + + public function getEdgesOfNode($node) : array + { + if(!($node instanceof Node)) { + $node = $this->getNode($node); + } + + $edges = []; + foreach($this->edges as $edge) { + $nodes = $edge->getNodes(); + + if($nodes[0] === $node || $nodes[1] === $node) { + $edges[] = $edge; + } + } + + return $edges; + } + + public function getNeighbors($node) : array + { + if(!($node instanceof Node)) { + $node = $this->getNode($node); + } + + $edges = $this->getEdgesOfNode($node); + $neighbors = []; + + foreach($edges as $edge) { + $nodes = $edge->getNodes(); + + if($nodes[0] !== $node && $nodes[0] !== null) { + $neighbors[] = $nodes[0]; + } elseif($nodes[1] !== $node && $nodes[0] !== null) { + $neighbors[] = $nodes[1]; + } + } + + return $neighbors; + } + + public function getDimension() : int + { + return 0; + } + + public function getBridges() : array + { + return []; + } + + public function getKruskalMinimalSpanningTree() : Tree + { + return new Tree(); + } + + public function getPrimMinimalSpanningTree() : Tree + { + return new Tree(); + } + + public function getCircle() : array + { + + } + + public function getFloydWarshallShortestPath() : array + { + + } + + public function getDijkstraShortestPath() : array + { + + } + + public function depthFirstTraversal() : array + { + + } + + public function breadthFirstTraversal() : array + { + + } + + public function longestPath() : array + { + + } + + public function longestPathBetweenNodes() : array + { + + } + + public function getOrder() : int + { + return count($this->nodes); + } + + public function getSize() : int + { + return count($this->edges); + } + + public function getDiameter() : int + { + $diameter = 0; + + foreach($this->nodes as $node1) { + foreach($this->nodes as $node2) { + if($node1 === $node2) { + continue; + } + + $diameter = max($diameter, $this->getFloydWarshallShortestPath($node1, $node2)); + } + } + + return $diameter; + } + + public function getGirth() : int + { + + } + + public function getCircuitRank() : int + { + + } + + public function getNodeConnectivity() : int + { + + } + + public function getEdgeConnectivity() : int + { + + } + + public function isConnected() : bool + { + return true; + } + + public function getUnconnected() : array + { + // get all unconnected sub graphs + } + + public function isBipartite() : bool + { + return true; + } + + public function isTriangleFree() : bool + { + return true; + } + + public function isCircleFree() : bool + { + return true; + } +} \ No newline at end of file diff --git a/Stdlib/Graph/Node.php b/Stdlib/Graph/Node.php new file mode 100644 index 000000000..e556d3be6 --- /dev/null +++ b/Stdlib/Graph/Node.php @@ -0,0 +1,33 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Datatypes; + +/** + * Tree class. + * + * @category Framework + * @package phpOMS\Datatypes + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + * + * @todo : there is a bug with Hungary ibans since they have two k (checksums) in their definition + */ +class Node +{ +} \ No newline at end of file diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 82514b0cc..7a6213502 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -25,44 +25,58 @@ namespace phpOMS\Datatypes; * @license OMS License 1.0 * @link http://orange-management.com * @since 1.0.0 - * - * @todo : there is a bug with Hungary ibans since they have two k (checksums) in their definition */ class Tree extends Graph { - protected $nodes = []; + private $root = null; - public function add(Tree $node) { - $this->nodes[] = $node; - - return $this; - } - - public function set($key, Tree $node) { - $this->nodes[$key] = $node; - - return $this; - } - - public function getMaxDepth() : int + public function __construct() { - $depth = [0]; + $root = new Node(); + $this->addNode($root); + } - foreach($this->nodes as $node) { - $depth[] = $node->getMaxDepth(); + public function addNode(Node $base, Node $node) + { + parent::addNode($node); + parent::addEdge(new Edge($base, $node)); + } + + public function getMaxDepth(Node $node = null) : int + { + $currentNode = $node ?? $this->root; + + if(!isset($currentNode)) { + return 0; } - return max($depth) + 1; + $depth = 1; + $neighbors = $this->getNeighbors($currentNode); + + foreach($neighbors as $neighbor) { + $depth = max($depth, $depth + $this->getMaxDepth($neighbor)); + } + + return $depth; } - public function getMinDepth() : int + public function getMinDepth(Node $node = null) : int { - $depth = [0]; + $currentNode = $node ?? $this->root; - foreach($this->nodes as $node) { - $depth[] = $node->getMinDepth(); + if(!isset($currentNode)) { + return 0; } + $depth = []; + $neighbors = $this->getNeighbors($currentNode); + + foreach($neighbors as $neighbor) { + $depth[] = $this->getMaxDepth($neighbor); + } + + $depth = empty($depth) ? 0 : $depth; + return min($depth) + 1; } @@ -76,34 +90,70 @@ class Tree extends Graph } } - public function isLeaf() : bool + public function isLeaf(Node $node) : bool { - return count($this->nodes) === 0; + return count($this->getEdgesOfNode($node)) === 1; } - public function getDimension() : int - { - $size = 1; - - foreach($this->nodes as $node) { - $size += $node->getDimension() + 1; - } - - return $size; - } - - public function getLevelNodes(int $level, array &$nodes) + public function getLevelNodes(int $level, Node $node) : array { --$level; + $neighbors = $this->getNeighbors($node); + $nodes = []; + + if($level === 1) { + return $neighbors; + } + + foreach($neighbors as $neighbor) { + array_merge($nodes, $this->getLevelNodes($level, $neighbor)); + } + + return $nodes; + } + + public function isFull(int $type) : bool { + if(count($this->edges) % $type !== 0) { + return false; + } foreach($this->nodes as $node) { - if($level === 0) { - $nodes[] = $this; + $neighbors = count($this->getNeighbors($node)); - return $nodes; - } else { - $this->getLevelNodes($level, $nodes); + if($neighbors !== $type && $neighbors !== 0) { + return false; } } + + return true; + } + + public function preOrder(Node $node, \Closure $callback) { + if(count($this->nodes) === 0) { + return; + } + + $callback($node); + $neighbors = $this->getNeighbors(); + + foreach($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->preOrder($neighbor, $callback); + } + } + + public function postOrder(Node $node, \Closure $callback) { + if(count($this->nodes) === 0) { + return; + } + + $neighbors = $this->getNeighbors(); + + foreach($neighbors as $neighbor) { + // todo: get neighbors needs to return in ordered way + $this->postOrder($neighbor, $callback); + } + + $callback($node); } } \ No newline at end of file From 7749528746fa1a06b254b6074922e39857b3649f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 13 Nov 2016 23:09:54 +0100 Subject: [PATCH 20/53] Format fix --- Localization/Default/en_US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Localization/Default/en_US.json b/Localization/Default/en_US.json index 8f193ad3f..ebcb6af2e 100644 --- a/Localization/Default/en_US.json +++ b/Localization/Default/en_US.json @@ -14,7 +14,7 @@ "light": "g", "medium": "kg", "heavy": "t", - "very_heavy": "t", + "very_heavy": "t" }, "speed": { "very_slow": "ms", @@ -56,6 +56,6 @@ "short": "m.y", "medium": "d.m.Y", "long": "d.m.Y h:i", - "very_long": "d.m.Y h:i:s", + "very_long": "d.m.Y h:i:s" } } \ No newline at end of file From 33631435b91641d19c9a46e4d32c42c3cf8a29ad Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 14 Nov 2016 17:45:12 +0100 Subject: [PATCH 21/53] Added cache todo --- DataStorage/Cache/FileCache.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index 44657bda5..2a9aa9232 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -142,6 +142,7 @@ class FileCache implements CacheInterface return false; } + // todo: allow $key to contain / as char and create subdirectory if necessary. This is important for cleaner caching. $path = File::sanitize($key, '~'); file_put_contents($this->cachePath . '/' . $path . '.cache', $this->build($value, $expire)); From b3ffd525d45b179194adec7453225e79e299dd4a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 14 Nov 2016 19:36:02 +0100 Subject: [PATCH 22/53] Fix minor unit test bugs --- Localization/L11nManager.php | 2 +- Log/FileLogger.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index 1b2143bea..ac2cb1cc2 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -149,7 +149,7 @@ class L11nManager { if (!isset($module) && isset($this->language[$language])) { return $this->language[$language]; - } elseif (isset($this->language[$language])) { + } elseif (isset($this->language[$language]) && isset($this->language[$language][$module])) { return $this->language[$language][$module]; } else { return []; diff --git a/Log/FileLogger.php b/Log/FileLogger.php index a631eeb63..216fd62c0 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -138,7 +138,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getInstance(string $path = '', bool $verbose = true) : FileLogger + public static function getInstance(string $path = '', bool $verbose = false) : FileLogger { if (self::$instance === null) { self::$instance = new self($path, $verbose); From 8a68def05d44c1b913b2f5bcaad2b884cc105c68 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 15 Nov 2016 11:46:23 +0100 Subject: [PATCH 23/53] Fix bugs for documentor --- Algorithm/AlgorithmType.php | 34 +++ Algorithm/Knappsack/ItemInterface.php | 32 +++ DataStorage/Cache/MemCache.php | 32 ++- DataStorage/Cache/NullCache.php | 31 ++- DataStorage/Cache/RedisCache.php | 31 ++- DataStorage/Cache/WinCache.php | 31 ++- .../CubicSplineInterpolation.php | 31 +++ .../Interpolation/LinearInterpolation.php | 31 +++ .../Interpolation/PolynomialInterpolation.php | 31 +++ Stdlib/Graph/BinaryTree.php | 4 +- Stdlib/Graph/Edge.php | 2 +- Stdlib/Graph/Graph.php | 2 +- Stdlib/Graph/Node.php | 2 +- Stdlib/Graph/Tree.php | 6 +- Stdlib/Queue/PriorityMode.php | 2 +- System/File/Ftp/FtpStorage.php | 215 +++++++++++++++++- System/File/Local/LocalStorage.php | 90 +++++++- 17 files changed, 561 insertions(+), 46 deletions(-) diff --git a/Algorithm/AlgorithmType.php b/Algorithm/AlgorithmType.php index e69de29bb..5d9d7bf0e 100644 --- a/Algorithm/AlgorithmType.php +++ b/Algorithm/AlgorithmType.php @@ -0,0 +1,34 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm; + +use phpOMS\Datatypes\Enum; + +/** + * Task status enum. + * + * @category Tasks + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class AlgorithmType extends Enum +{ + const BRUTEFORCE = 0; +} diff --git a/Algorithm/Knappsack/ItemInterface.php b/Algorithm/Knappsack/ItemInterface.php index e69de29bb..f9f53790b 100644 --- a/Algorithm/Knappsack/ItemInterface.php +++ b/Algorithm/Knappsack/ItemInterface.php @@ -0,0 +1,32 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Algorithm\Knappsack; + +/** + * Shape interface. + * + * @category Framework + * @package phpOMS\Math + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +interface ItemInterface +{ + +} diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index f14d7bcda..faab742e1 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -74,7 +74,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) { $this->memc->set($key, $value, false, $expire); } @@ -82,7 +82,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { return $this->memc->add($key, $value, false, $expire); } @@ -90,7 +90,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { return $this->memc->get($key); } @@ -98,7 +98,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { $this->memc->delete($key); } @@ -106,15 +106,27 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { $this->memc->flush(); + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + $this->memc->flush(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { $this->memc->replace($key, $value, false, $expire); } @@ -136,6 +148,14 @@ class MemCache implements CacheInterface return $this->threshold; } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) + { + $this->status = $status; + } + /** * Destructor. * diff --git a/DataStorage/Cache/NullCache.php b/DataStorage/Cache/NullCache.php index 404ee2cd2..ada8a005b 100644 --- a/DataStorage/Cache/NullCache.php +++ b/DataStorage/Cache/NullCache.php @@ -32,7 +32,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) { // TODO: Implement set() method. } @@ -40,7 +40,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -48,7 +48,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -56,7 +56,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -64,15 +64,27 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -93,4 +105,11 @@ class NullCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) + { + // TODO: Implement setStatus() method. + } } diff --git a/DataStorage/Cache/RedisCache.php b/DataStorage/Cache/RedisCache.php index e93fb1167..b3afb4cc9 100644 --- a/DataStorage/Cache/RedisCache.php +++ b/DataStorage/Cache/RedisCache.php @@ -34,7 +34,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) { // TODO: Implement set() method. } @@ -42,7 +42,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -50,7 +50,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -58,7 +58,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -66,15 +66,27 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -95,4 +107,11 @@ class RedisCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) + { + // TODO: Implement setStatus() method. + } } diff --git a/DataStorage/Cache/WinCache.php b/DataStorage/Cache/WinCache.php index 0690cded2..a41bfe7f9 100644 --- a/DataStorage/Cache/WinCache.php +++ b/DataStorage/Cache/WinCache.php @@ -34,7 +34,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, CacheStatus $type = null, int $expire = 2592000) + public function set($key, $value, int $expire = -1) { // TODO: Implement set() method. } @@ -42,7 +42,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function add($key, $value, CacheStatus $type = null, int $expire = 2592000) : bool + public function add($key, $value, int $expire = -1) : bool { // TODO: Implement add() method. } @@ -50,7 +50,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function get($key, CacheStatus $type = null) + public function get($key, int $expire = -1) { // TODO: Implement get() method. } @@ -58,7 +58,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function delete($key, CacheStatus $type = null) : bool + public function delete($key, int $expire = -1) : bool { // TODO: Implement delete() method. } @@ -66,15 +66,27 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function flush(CacheStatus $type = null) + public function flush(int $expire = 0) : bool { // TODO: Implement flush() method. + + return true; } /** * {@inheritdoc} */ - public function replace($key, $value, CacheType $type = null, int $expire = -1) : bool + public function flushAll() : bool + { + // TODO: Implement flush() method. + + return true; + } + + /** + * {@inheritdoc} + */ + public function replace($key, $value, int $expire = -1) : bool { // TODO: Implement replace() method. } @@ -95,4 +107,11 @@ class WinCache implements CacheInterface // TODO: Implement getThreshold() method. } + /** + * {@inheritdoc} + */ + public function setStatus(int $status) + { + // TODO: Implement setStatus() method. + } } diff --git a/Math/Numerics/Interpolation/CubicSplineInterpolation.php b/Math/Numerics/Interpolation/CubicSplineInterpolation.php index e69de29bb..4c4d52af1 100644 --- a/Math/Numerics/Interpolation/CubicSplineInterpolation.php +++ b/Math/Numerics/Interpolation/CubicSplineInterpolation.php @@ -0,0 +1,31 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Math\Numerics\Interpolation; + +/** + * Web module interface. + * + * @category Framework + * @package phpOMS\Module + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class CubicSplineInterpolation +{ +} diff --git a/Math/Numerics/Interpolation/LinearInterpolation.php b/Math/Numerics/Interpolation/LinearInterpolation.php index e69de29bb..83791c413 100644 --- a/Math/Numerics/Interpolation/LinearInterpolation.php +++ b/Math/Numerics/Interpolation/LinearInterpolation.php @@ -0,0 +1,31 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Math\Numerics\Interpolation; + +/** + * Web module interface. + * + * @category Framework + * @package phpOMS\Module + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class LinearInterpolation +{ +} diff --git a/Math/Numerics/Interpolation/PolynomialInterpolation.php b/Math/Numerics/Interpolation/PolynomialInterpolation.php index e69de29bb..771a69536 100644 --- a/Math/Numerics/Interpolation/PolynomialInterpolation.php +++ b/Math/Numerics/Interpolation/PolynomialInterpolation.php @@ -0,0 +1,31 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Math\Numerics\Interpolation; + +/** + * Web module interface. + * + * @category Framework + * @package phpOMS\Module + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class PolynomialInterpolation +{ +} diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index 152c2fad3..e84bf8736 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -13,9 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Datatypes; - -use phpOMS\Validation\Base\IbanEnum; +namespace phpOMS\Stdlib\Graph; /** * Tree class. diff --git a/Stdlib/Graph/Edge.php b/Stdlib/Graph/Edge.php index b4bd7ce33..87207d6c6 100644 --- a/Stdlib/Graph/Edge.php +++ b/Stdlib/Graph/Edge.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Datatypes; +namespace phpOMS\Stdlib\Graph; /** * Tree class. diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index 63a67fdb4..c300429ee 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Datatypes; +namespace phpOMS\Stdlib\Graph; /** * Tree class. diff --git a/Stdlib/Graph/Node.php b/Stdlib/Graph/Node.php index e556d3be6..8dd79e6dd 100644 --- a/Stdlib/Graph/Node.php +++ b/Stdlib/Graph/Node.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Datatypes; +namespace phpOMS\Stdlib\Graph; /** * Tree class. diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 7a6213502..2797ae0ec 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -13,7 +13,7 @@ * @version 1.0.0 * @link http://orange-management.com */ -namespace phpOMS\Datatypes; +namespace phpOMS\Stdlib\Graph; /** * Tree class. @@ -33,10 +33,10 @@ class Tree extends Graph public function __construct() { $root = new Node(); - $this->addNode($root); + parent::addNode($root); } - public function addNode(Node $base, Node $node) + public function addRelativeNode(Node $base, Node $node) { parent::addNode($node); parent::addEdge(new Edge($base, $node)); diff --git a/Stdlib/Queue/PriorityMode.php b/Stdlib/Queue/PriorityMode.php index 9ddc1319b..2b2ce5b0c 100644 --- a/Stdlib/Queue/PriorityMode.php +++ b/Stdlib/Queue/PriorityMode.php @@ -28,7 +28,7 @@ use phpOMS\Datatypes\Enum; * @link http://orange-management.com * @since 1.0.0 */ -abstract class PrioirtyMode extends Enum +abstract class PriorityMode extends Enum { const FIFO = 0; const LIFO = 0; diff --git a/System/File/Ftp/FtpStorage.php b/System/File/Ftp/FtpStorage.php index b27836860..503fc0ce5 100644 --- a/System/File/Ftp/FtpStorage.php +++ b/System/File/Ftp/FtpStorage.php @@ -32,127 +32,225 @@ use phpOMS\System\File\StorageAbstract; */ class FtpStorage extends StorageAbstract { - + /** + * {@inheritdoc} + */ public static function created(string $path) : \DateTime { // TODO: Implement created() method. } + /** + * {@inheritdoc} + */ public static function changed(string $path) : \DateTime { // TODO: Implement changed() method. } + /** + * {@inheritdoc} + */ public static function owner(string $path) : int { // TODO: Implement owner() method. } - public static function permission(string $path) : int + /** + * {@inheritdoc} + */ + public static function permission(string $path) : string { // TODO: Implement permission() method. } + /** + * {@inheritdoc} + */ public static function parent(string $path) : string { // TODO: Implement parent() method. } + /** + * {@inheritdoc} + */ public static function create(string $path) : bool { // TODO: Implement create() method. } + /** + * {@inheritdoc} + */ public static function delete(string $path) : bool { // TODO: Implement delete() method. } + /** + * {@inheritdoc} + */ public static function copy(string $from, string $to, bool $overwrite = false) : bool { // TODO: Implement copy() method. } + /** + * {@inheritdoc} + */ public static function move(string $from, string $to, bool $overwrite = false) : bool { // TODO: Implement move() method. } - public static function size(string $path) : int + /** + * {@inheritdoc} + */ + public static function size(string $path, bool $recursive = true) : int { // TODO: Implement size() method. } + /** + * {@inheritdoc} + */ public static function exists(string $path) : bool { // TODO: Implement exists() method. } - public function getCount() : int + /** + * {@inheritdoc} + */ + public static function name(string $path) : string + { + // TODO: Implement name() method. + } + + /** + * {@inheritdoc} + */ + public static function basename(string $path) : string + { + // TODO: Implement basename() method. + } + + /** + * {@inheritdoc} + */ + public static function count(string $path, bool $recursive = true, array $ignore = []) : int + { + // TODO: Implement count() method. + } + + /** + * {@inheritdoc} + */ + public function getCount(bool $recursive = false) : int { // TODO: Implement getCount() method. } - public function getSize() : int + /** + * {@inheritdoc} + */ + public function getSize(bool $recursive = false) : int { // TODO: Implement getSize() method. } + /** + * {@inheritdoc} + */ public function getName() : string { // TODO: Implement getName() method. } + /** + * {@inheritdoc} + */ public function getPath() : string { // TODO: Implement getPath() method. } + /** + * {@inheritdoc} + */ public function getParent() : ContainerInterface { // TODO: Implement getParent() method. } + /** + * {@inheritdoc} + */ public function createNode() : bool { // TODO: Implement createNode() method. } - public function copyNode() : bool + /** + * {@inheritdoc} + */ + public function copyNode(string $to, bool $overwrite = false) : bool { // TODO: Implement copyNode() method. } - public function moveNode() : bool + /** + * {@inheritdoc} + */ + public function moveNode(string $to, bool $overwrite = false) : bool { // TODO: Implement moveNode() method. } + /** + * {@inheritdoc} + */ public function deleteNode() : bool { // TODO: Implement deleteNode() method. } + /** + * {@inheritdoc} + */ public function getCreatedAt() : \DateTime { // TODO: Implement getCreatedAt() method. } + /** + * {@inheritdoc} + */ public function getChangedAt() : \DateTime { // TODO: Implement getChangedAt() method. } + /** + * {@inheritdoc} + */ public function getOwner() : int { // TODO: Implement getOwner() method. } + /** + * {@inheritdoc} + */ public function getPermission() : string { // TODO: Implement getPermission() method. } + /** + * {@inheritdoc} + */ public function index() { // TODO: Implement index() method. @@ -276,28 +374,123 @@ class FtpStorage extends StorageAbstract // TODO: Implement offsetUnset() method. } - public static function put(string $path, string $content, bool $overwrite = true) : bool + /** + * {@inheritdoc} + */ + public static function put(string $path, string $content, int $mode = 0) : bool { // TODO: Implement put() method. } + /** + * {@inheritdoc} + */ public static function get(string $path) : string { // TODO: Implement get() method. } - public function putContent() : bool + /** + * {@inheritdoc} + */ + public function putContent(string $content, int $mode = 0) : bool { // TODO: Implement putContent() method. } + /** + * {@inheritdoc} + */ public function getContent() : string { // TODO: Implement getContent() method. } - protected function getType() : ContainerInterface + /** + * {@inheritdoc} + */ + public static function sanitize(string $path, string $replace = '') : string { - // TODO: Implement getType() method. + // TODO: Implement sanitize() method. + } + + /** + * {@inheritdoc} + */ + public function getNode(string $name) + { + // TODO: Implement getNode() method. + } + + /** + * {@inheritdoc} + */ + public function addNode($file) : bool + { + // TODO: Implement addNode() method. + } + + /** + * {@inheritdoc} + */ + public static function set(string $path, string $content) : bool + { + // TODO: Implement set() method. + } + + /** + * {@inheritdoc} + */ + public static function append(string $path, string $content) : bool + { + // TODO: Implement append() method. + } + + /** + * {@inheritdoc} + */ + public static function prepend(string $path, string $content) : bool + { + // TODO: Implement prepend() method. + } + + /** + * {@inheritdoc} + */ + public static function extension(string $path) : string + { + // TODO: Implement extension() method. + } + + /** + * {@inheritdoc} + */ + public function setContent(string $content) : bool + { + // TODO: Implement setContent() method. + } + + /** + * {@inheritdoc} + */ + public function appendContent(string $content) : bool + { + // TODO: Implement appendContent() method. + } + + /** + * {@inheritdoc} + */ + public function prependContent(string $content) : bool + { + // TODO: Implement prependContent() method. + } + + /** + * {@inheritdoc} + */ + public function getExtension() : string + { + // TODO: Implement getExtension() method. } } \ No newline at end of file diff --git a/System/File/Local/LocalStorage.php b/System/File/Local/LocalStorage.php index 4c964fb88..5c757ba0f 100644 --- a/System/File/Local/LocalStorage.php +++ b/System/File/Local/LocalStorage.php @@ -139,7 +139,7 @@ class LocalStorage extends StorageAbstract /** * {@inheritdoc} */ - public static function count(string $path, bool $recursive = false) : int + public static function count(string $path, bool $recursive = true, array $ignore = []) : int { // TODO: Implement count() method. } @@ -405,4 +405,92 @@ class LocalStorage extends StorageAbstract { // TODO: Implement getContent() method. } + + /** + * {@inheritdoc} + */ + public static function sanitize(string $path, string $replace = '') : string + { + // TODO: Implement sanitize() method. + } + + /** + * {@inheritdoc} + */ + public function getNode(string $name) + { + // TODO: Implement getNode() method. + } + + /** + * {@inheritdoc} + */ + public function addNode($file) : bool + { + // TODO: Implement addNode() method. + } + + /** + * {@inheritdoc} + */ + public static function set(string $path, string $content) : bool + { + // TODO: Implement set() method. + } + + /** + * {@inheritdoc} + */ + public static function append(string $path, string $content) : bool + { + // TODO: Implement append() method. + } + + /** + * {@inheritdoc} + */ + public static function prepend(string $path, string $content) : bool + { + // TODO: Implement prepend() method. + } + + /** + * {@inheritdoc} + */ + public static function extension(string $path) : string + { + // TODO: Implement extension() method. + } + + /** + * {@inheritdoc} + */ + public function setContent(string $content) : bool + { + // TODO: Implement setContent() method. + } + + /** + * {@inheritdoc} + */ + public function appendContent(string $content) : bool + { + // TODO: Implement appendContent() method. + } + + /** + * {@inheritdoc} + */ + public function prependContent(string $content) : bool + { + // TODO: Implement prependContent() method. + } + + /** + * {@inheritdoc} + */ + public function getExtension() : string + { + // TODO: Implement getExtension() method. + } } \ No newline at end of file From 8212751b2e6837e1c1cb5841d719481f4e21629a Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 15 Nov 2016 15:08:52 +0100 Subject: [PATCH 24/53] Fixing formula --- Math/Finance/FinanceFormulas.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Math/Finance/FinanceFormulas.php b/Math/Finance/FinanceFormulas.php index 926b910f9..8dac877a9 100644 --- a/Math/Finance/FinanceFormulas.php +++ b/Math/Finance/FinanceFormulas.php @@ -34,7 +34,7 @@ class FinanceFormulas /** * Annual Percentage Yield * - * @latex APY = \left(\frac{1 + r}{n}\right)^{n}-1 + * @latex APY = \left(1+ \frac{r}{n}\right)^{n}-1 * * @param float $r Stated annual interest rate * @param int $n number of times compounded From 3ec569fa9e592523eb7450071b7c77fa95bd6b98 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 15 Nov 2016 21:25:39 +0100 Subject: [PATCH 25/53] Comments --- Account/Group.php | 17 ++ DataStorage/Database/GrammarAbstract.php | 40 +++ DataStorage/Database/Query/Builder.php | 140 ++++++++++ .../Database/Query/Grammar/Grammar.php | 15 ++ DataStorage/Session/HttpSession.php | 28 +- Log/FileLogger.php | 10 +- Math/Functions/Functions.php | 44 +++ Stdlib/Collection/Collection.php | 127 ++++++++- Stdlib/Graph/BinaryTree.php | 87 +++++- Stdlib/Graph/Graph.php | 254 ++++++++++++++++-- Stdlib/Graph/Tree.php | 112 +++++++- System/File/Storage.php | 6 + Utils/TaskSchedule/TaskScheduler.php | 47 +++- 13 files changed, 890 insertions(+), 37 deletions(-) diff --git a/Account/Group.php b/Account/Group.php index b2681635a..159698ade 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -179,13 +179,30 @@ class Group implements ArrayableInterface, \JsonSerializable $this->description = $description; } + /** + * Get group status. + * + * @return int Group status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getStatus() : int { return $this->status; } + /** + * Set group status. + * + * @param int $status Group status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setStatus(int $status) { + // todo: check valid $this->status = $status; } diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index d101ae81f..1c91395c3 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -69,6 +69,12 @@ abstract class GrammarAbstract */ protected $or = 'OR'; + /** + * Table prefix. + * + * @var string + * @since 1.0.0 + */ protected $tablePrefix = ''; /** @@ -95,18 +101,52 @@ abstract class GrammarAbstract ) . ';'; } + /** + * Compile query components. + * + * @param BuilderAbstract $query Builder + * + * @return array Parsed query components + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ abstract protected function compileComponents(BuilderAbstract $query) : array; + /** + * Get date format. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDateFormat() : string { return 'Y-m-d H:i:s'; } + /** + * Get table prefix. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getTablePrefix() : string { return $this->tablePrefix; } + /** + * Set table prefix. + * + * @param string $prefix Table prefix + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setTablePrefix(string $prefix) { $this->tablePrefix = $prefix; diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 3ae96bb4a..ffa6ce35e 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -704,43 +704,103 @@ class Builder extends BuilderAbstract return $this; } + /** + * Lock query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function lock() { } + /** + * Lock for update query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function lockUpdate() { } + /** + * Create query string. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __toString() { return $this->grammar->compileQuery($this); } + /** + * Find query. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function find() { } + /** + * Count results. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function count() { } + /** + * Check if exists. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function exists() { } + /** + * Select minimum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function min() { } + /** + * Select maximum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function max() { } + /** + * Select sum. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function sum() { } + /** + * Select average. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function avg() { } @@ -821,6 +881,16 @@ class Builder extends BuilderAbstract return $this; } + /** + * Update columns. + * + * @param array $columns Column names to update + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function update(...$columns) : Builder { $this->type = QueryType::UPDATE; @@ -832,44 +902,106 @@ class Builder extends BuilderAbstract return $this; } + /** + * Increment value. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function increment() { } + /** + * Decrement value. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function decrement() { } + /** + * Join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function join($table1, $table2, $column1, $opperator, $column2) { return $this; } + /** + * Join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function joinWhere() { } + /** + * Left join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function leftJoin() { } + /** + * Left join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function leftJoinWhere() { } + /** + * Right join. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rightJoin() { } + /** + * Right join where. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rightJoinWhere() { } + /** + * Rollback. + * + * @return Builder + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function rollback() { return $this; } + /** + * On. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function on() { @@ -892,6 +1024,14 @@ class Builder extends BuilderAbstract return clone($this); } + /** + * Execute query. + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function execute() { $sth = $this->connection->con->prepare($this->toSql()); diff --git a/DataStorage/Database/Query/Grammar/Grammar.php b/DataStorage/Database/Query/Grammar/Grammar.php index adfc0af90..91a5a99e1 100644 --- a/DataStorage/Database/Query/Grammar/Grammar.php +++ b/DataStorage/Database/Query/Grammar/Grammar.php @@ -214,6 +214,18 @@ class Grammar extends GrammarAbstract return 'WHERE ' . $expression; } + /** + * Compile where element. + * + * @param array $element Element data + * @param Builder $query Query builder + * @param bool $first Is first element (usefull for nesting) + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ protected function compileWhereElement(array $element, Builder $query, bool $first = true) : string { $expression = ''; @@ -265,6 +277,9 @@ class Grammar extends GrammarAbstract return $value; } + // todo: fix for injection + // todo: implement binding + return $this->valueQuotes . $value . $this->valueQuotes; } elseif (is_int($value)) { return $value; diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 926439333..1514d4c03 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -129,12 +129,26 @@ class HttpSession implements SessionInterface return $this->sessionData[$key] ?? null; } + /** + * Lock session from further adjustments. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function lock() { self::$isLocked = true; } - public static function isLocked() + /** + * Check if session is locked. + * + * @return bool Lock status + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function isLocked() : bool { return self::$isLocked; } @@ -177,10 +191,18 @@ class HttpSession implements SessionInterface $this->sid = $sid; } + /** + * Destruct session. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __destruct() { - $_SESSION = $this->sessionData; - session_write_close(); + if(!self::$isLocked) { + $_SESSION = $this->sessionData; + session_write_close(); + } } } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 216fd62c0..93a32da8a 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -119,9 +119,17 @@ class FileLogger implements LoggerInterface $this->path = $path; } + /** + * Create logging file. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function createFile() { - if (!file_exists($this->path) && !$this->created) { + if (!$this->created && !file_exists($this->path)) { File::create($this->path); $this->created = true; } diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index 2728e6e2b..5ea36b9fd 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -206,6 +206,17 @@ class Functions return $t; } + /** + * Modular implementation for negative values. + * + * @param int $a + * @param int $b + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function mod($a, $b) { if ($a < 0) { @@ -215,6 +226,16 @@ class Functions return $a % $b; } + /** + * Check if value is odd. + * + * @param int $a Value to test + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function isOdd($a) : bool { if ($a & 1) { @@ -224,6 +245,16 @@ class Functions return false; } + /** + * Check if value is even. + * + * @param int $a Value to test + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function isEven($a) : bool { if ($a & 1) { @@ -233,6 +264,19 @@ class Functions return true; } + /** + * Gets the relative position on a circular construct. + * + * @example The relative fiscal month (August) in a company where the fiscal year starts in July. + * @example 2 = getRelativeDegree(8, 12, 7); + * + * @param int $a Value to test + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function getRelativeDegree($value, $length, $start = 0) { return abs(self::mod($value - $start, $length)); diff --git a/Stdlib/Collection/Collection.php b/Stdlib/Collection/Collection.php index 5367be1d8..3ccb31be9 100644 --- a/Stdlib/Collection/Collection.php +++ b/Stdlib/Collection/Collection.php @@ -18,7 +18,7 @@ namespace phpOMS\Stdlib\Collection; use phpOMS\Utils\ArrayUtils; /** - * Multimap utils. + * Collection. * * @category Framework * @package phpOMS\Stdlib @@ -30,28 +30,78 @@ use phpOMS\Utils\ArrayUtils; */ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializable { + /** + * Collection. + * + * @var array + * @since 1.0.0 + */ private $collection = []; + /** + * Create collection from array. + * + * @param array $data Collection data + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct(array $data) { $this->collection = $data; } + /** + * Turn collection to array. + * + * @return array Collection array representation + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function toArray() : array { return $this->collection; } + /** + * Json serialize. + * + * @return string + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function jsonSerialize() { return json_encode($this->collection); } + /** + * Get average of collection data. + * + * @param mixed $filter Filter for average calculation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function avg($filter = null) { return $this->sum($filter) / $this->count(); } + /** + * Get sum of collection data. + * + * @param mixed $filter Filter for sum calculation + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function sum($filter = null) { $sum = 0; @@ -77,16 +127,51 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return $sum; } + /** + * Get collection count. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function count() { return count($this->collection); } - public function chunk(int $size) : Collection + /** + * Chunk collection. + * + * Creates new collection in the specified size. + * + * @param int $size Chunk size + * + * @return Collection[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function chunk(int $size) : array { - return new self(array_chunk($this->collection, $size)); + $arrays = array_chunk($this->collection, $size); + $collections = []; + + foreach($arrays as $array) { + $collections[] = new self($array); + } + + return $collections; } + /** + * Collapse collection. + * + * @return Collection + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function collapse() : Collection { $return = []; @@ -116,12 +201,22 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return $this; } + /** + * Check if collection contains a value. + * + * @param string|int|float|\Closure $find Needle + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function contains($find) : bool { foreach ($this->collection as $key => $value) { if (is_string($find) && ((is_string($value) && $find === $value) || (is_array($value) && in_array($find, $value)))) { return true; - } elseif ($find instanceof Collection) { + } elseif ($find instanceof \Closure) { $result = $find($value, $key); if ($result) { @@ -133,13 +228,23 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return false; } - public function diff(array $compare) : array + /** + * Diff of collection. + * + * @param Collection|array $compare To compare with + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function diff($compare) : array { $diff = []; foreach ($this->collection as $key => $value) { if ($value !== current($compare)) { - $diff = $value; + $diff[] = $value; } next($compare); @@ -163,6 +268,16 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return $diff; } + /** + * Get collection that contains every n-th element. + * + * @param $int $n Every n-th element + * + * @return Collection + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function every(int $n) : Collection { $values = array_values($this->collection); diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index e84bf8736..1255068eb 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -43,6 +43,16 @@ class BinaryTree extends Tree return $list; } + /** + * Get left node of a node. + * + * @param Node $node Tree node + * + * @return Node Left node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getLeft(Node $base) { $neighbors = $base->getNeighbors($base); @@ -51,6 +61,16 @@ class BinaryTree extends Tree return $neighbors[0] ?? null; } + /** + * Get right node of a node. + * + * @param Node $node Tree node + * + * @return Node Right node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getRight(Node $base) { $neighbors = $base->getNeighbors($base); @@ -59,7 +79,18 @@ class BinaryTree extends Tree return $neighbors[1] ?? null; } - public function setLeft(Node $base, Node $left) + /** + * Set left node of node. + * + * @param Node $base Base node + * @param Node $left Left node + * + * @return BinaryTree + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setLeft(Node $base, Node $left) : BinaryTree { if($this->getLeft($base) === null) { $this->addNode($base, $left); @@ -68,8 +99,21 @@ class BinaryTree extends Tree } else { // todo: replace node } + + return $this; } + /** + * Set right node of node. + * + * @param Node $base Base node + * @param Node $right Right node + * + * @return BinaryTree + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setRight(Node $base, Node $right) { if($this->getRight($base) === null) { @@ -81,17 +125,32 @@ class BinaryTree extends Tree } } + /** + * Perform action on tree in in-order. + * + * @param Node $node Tree node + * @param \Closure $callback Task to perform on node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function inOrder(Node $node, \Closure $callback) { - if(count($this->nodes) === 0) { - return; - } - $this->inOrder($this->getLeft($node), $callback); $callback($node); $this->inOrder($this->getRight($node), $callback); } + /** + * Get nodes in vertical order. + * + * @param Node $node Tree node + * @param int $horizontalDistance Horizontal distance + * @param Node[] &$order Ordered nodes by horizontal distance + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function getVerticalOrder(Node $node, int $horizontalDistance = 0, array &$order) { if(!isset($order[$horizontalDistance])) { @@ -111,6 +170,15 @@ class BinaryTree extends Tree } } + /** + * Perform action on tree in vertical-order. + * + * @param Node $node Tree node + * @param \Closure $callback Task to perform on node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function verticalOrder(Node $node, \Closure $callback) { $order = []; @@ -123,6 +191,15 @@ class BinaryTree extends Tree } } + /** + * Check if tree is symmetric. + * + * @param Node $node1 Tree node1 + * @param Node $node2 Tree node2 (optional, can be different tree) + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function isSymmetric(Node $node1 = null, Node $node2 = null) : bool { if(!isset($node1) && !isset($node2)) { diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index c300429ee..fdb493e7e 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -28,31 +28,85 @@ namespace phpOMS\Stdlib\Graph; */ class Graph { + /** + * Nodes. + * + * @var array + * @since 1.0.0 + */ protected $nodes = []; + /** + * Edges. + * + * @var array + * @since 1.0.0 + */ protected $edges = []; - public function addNode(Node $node) + /** + * Add node to graph. + * + * @param Node $node Graph node + * + * @return Graph + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function addNode(Node $node) : Graph { $this->nodes[] = $node; return $this; } - public function setNode($key, Node $node) + /** + * Set node in graph. + * + * @param mixed $key Key of node + * @param Node $node Graph node + * + * @return Graph + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function setNode($key, Node $node) : Graph { $this->nodes[$key] = $node; return $this; } - public function addEdge(Edge $edge) + /** + * Add edge to graph. + * + * @param Edge $edge Graph edge + * + * @return Graph + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function addEdge(Edge $edge) : Graph { $this->edges[] = $edge; return $this; } + /** + * Set edge in graph. + * + * @param mixed $key Edge key + * @param Edge $edge Edge to set + * + * @return Graph + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setEdge($key, Edge $edge) { $this->edges[$key] = $edge; @@ -60,16 +114,46 @@ class Graph return $this; } + /** + * Get graph node + * + * @param mixed $key Node key + * + * @return Node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getNode($key) : Node { return $this->nodes[$key]; } + /** + * Get graph edge. + * + * @param mixed $key Edge key + * + * @return Edge + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getEdge($key) : Edge { return $this->edges[$key]; } + /** + * Get all edges of a node + * + * @param mixed $node Node + * + * @return Edge[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getEdgesOfNode($node) : array { if(!($node instanceof Node)) { @@ -88,6 +172,16 @@ class Graph return $edges; } + /** + * Get all node neighbors. + * + * @param Node $node Graph node + * + * @return Node[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getNeighbors($node) : array { if(!($node instanceof Node)) { @@ -110,71 +204,196 @@ class Graph return $neighbors; } + /** + * Get graph dimension. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDimension() : int { + // todo: implement return 0; } + /** + * Get all bridges. + * + * @return Edge[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getBridges() : array { + // todo: implement return []; } + /** + * Get minimal spanning tree using Kruskal's algorithm. + * + * @return Tree + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getKruskalMinimalSpanningTree() : Tree { + // todo: implement return new Tree(); } + /** + * Get minimal spanning tree using Prim's algorithm + * + * @return Tree + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getPrimMinimalSpanningTree() : Tree { + // todo: implement return new Tree(); } + /** + * Get circles in graph. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getCircle() : array { - + // todo: implement } + /** + * Get shortest path using Floyd Warschall algorithm. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getFloydWarshallShortestPath() : array { - + // todo: implement } + /** + * Get shortest path using Dijkstra algorithm. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDijkstraShortestPath() : array { - + // todo: implement } + /** + * Perform depth first traversal. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function depthFirstTraversal() : array { - + // todo: implement } + /** + * Perform breadth first traversal. + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function breadthFirstTraversal() : array { - + // todo: implement } + /** + * Get longest path in graph. + * + * @return Node[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function longestPath() : array { - + // todo: implement } - public function longestPathBetweenNodes() : array + /** + * Get longest path between two nodes. + * + * @param Node $node1 Graph node + * @param Node $node2 Graph node + * + * @return Node[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function longestPathBetweenNodes(Node $node1, Node $node2) : array { - + // todo: implement } + /** + * Get order of the graph. + * + * The order of a graph is the amount of nodes it contains. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getOrder() : int { return count($this->nodes); } + /** + * Get size of the graph. + * + * The size of the graph is the amount of edges it contains. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getSize() : int { return count($this->edges); } + /** + * Get diameter of graph. + * + * The diameter of a graph is the longest shortest path between two nodes. + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getDiameter() : int { $diameter = 0; @@ -194,46 +413,51 @@ class Graph public function getGirth() : int { - + // todo: implement } public function getCircuitRank() : int { - + // todo: implement } public function getNodeConnectivity() : int { - + // todo: implement } public function getEdgeConnectivity() : int { - + // todo: implement } public function isConnected() : bool { + // todo: implement return true; } public function getUnconnected() : array { + // todo: implement // get all unconnected sub graphs } public function isBipartite() : bool { + // todo: implement return true; } public function isTriangleFree() : bool { + // todo: implement return true; } public function isCircleFree() : bool { + // todo: implement return true; } } \ No newline at end of file diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php index 2797ae0ec..2fcb61dc9 100644 --- a/Stdlib/Graph/Tree.php +++ b/Stdlib/Graph/Tree.php @@ -28,20 +28,55 @@ namespace phpOMS\Stdlib\Graph; */ class Tree extends Graph { + /** + * Root node. + * + * @var Node + * @since 1.0.0 + */ private $root = null; + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function __construct() { $root = new Node(); parent::addNode($root); } - public function addRelativeNode(Node $base, Node $node) + /** + * Add a note relative to a node. + * + * @param Node $base Base node + * @param Node $node Node to add + * + * @return Tree + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function addRelativeNode(Node $base, Node $node) : Tree { parent::addNode($node); parent::addEdge(new Edge($base, $node)); + + return $this; } + /** + * Get maximum tree depth. + * + * @param Node $node Tree node + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getMaxDepth(Node $node = null) : int { $currentNode = $node ?? $this->root; @@ -60,6 +95,16 @@ class Tree extends Graph return $depth; } + /** + * Get minimum tree path. + * + * @param Node $node Tree node + * + * @return int + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getMinDepth(Node $node = null) : int { $currentNode = $node ?? $this->root; @@ -80,7 +125,18 @@ class Tree extends Graph return min($depth) + 1; } - public function levelOrder(\Closure $callback) + /** + * Perform task on tree nodes in level order. + * + * @param Node $node Tree node + * @param \Closure $callback Task to perform + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function levelOrder(Node $node, \Closure $callback) { $depth = $this->getMaxDepth(); @@ -90,11 +146,32 @@ class Tree extends Graph } } + /** + * Check if node is leaf. + * + * @param Node $node Tree node + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function isLeaf(Node $node) : bool { return count($this->getEdgesOfNode($node)) === 1; } + /** + * Get all nodes of a specific level. + * + * @param int $level Level to retrieve + * @param Node $node Tree node + * + * @return Node[] + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function getLevelNodes(int $level, Node $node) : array { --$level; @@ -112,7 +189,18 @@ class Tree extends Graph return $nodes; } - public function isFull(int $type) : bool { + /** + * Check if the tree is full. + * + * @param int $type Child nodes per non-leaf node + * + * @return bool + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function isFull(int $type) : bool + { if(count($this->edges) % $type !== 0) { return false; } @@ -128,6 +216,15 @@ class Tree extends Graph return true; } + /** + * Perform action on tree in pre-order. + * + * @param Node $node Tree node + * @param \Closure $callback Task to perform on node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function preOrder(Node $node, \Closure $callback) { if(count($this->nodes) === 0) { return; @@ -142,6 +239,15 @@ class Tree extends Graph } } + /** + * Perform action on tree in post-order. + * + * @param Node $node Tree node + * @param \Closure $callback Task to perform on node + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function postOrder(Node $node, \Closure $callback) { if(count($this->nodes) === 0) { return; diff --git a/System/File/Storage.php b/System/File/Storage.php index 11886e068..7b9c0caa8 100644 --- a/System/File/Storage.php +++ b/System/File/Storage.php @@ -38,6 +38,12 @@ final class Storage */ private static $registered = []; + /** + * Constructor. + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function __construct() { diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index e37378a3f..e9055b63d 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -30,6 +30,9 @@ use phpOMS\Validation\Base\DateTime; */ class TaskScheduler extends SchedulerAbstract { + /** + * {@inheritdoc} + */ public function save() { @@ -74,12 +77,33 @@ class TaskScheduler extends SchedulerAbstract return trim($stdout); } + /** + * Normalize run result for easier parsing + * + * @param string $raw Raw command output + * + * @return string Normalized string for parsing + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ private function normalize(string $raw) : string { return str_replace("\r\n", "\n", $raw); } - private function parseJobList(array $jobData) { + /** + * Parse a list of jobs + * + * @param array $jobData Csv data containing the job information + * + * @return TaskAbstract Parsed job + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function parseJobList(array $jobData) : TaskAbstract + { $job = TaskFactory::create($jobData[1], ''); $job->setRun($jobData[8]); @@ -109,6 +133,9 @@ class TaskScheduler extends SchedulerAbstract return $job; } + /** + * {@inheritdoc} + */ public function getAll() : array { $lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV'))); @@ -122,16 +149,25 @@ class TaskScheduler extends SchedulerAbstract return $jobs; } + /** + * {@inheritdoc} + */ public function get(string $id) { - + // todo: implement } + /** + * {@inheritdoc} + */ public function getByName(string $name) : Schedule { - + // todo: implement } + /** + * {@inheritdoc} + */ public function getAllByName(string $name, bool $exact = true) : array { if($exact) { @@ -160,8 +196,11 @@ class TaskScheduler extends SchedulerAbstract return $jobs; } + /** + * {@inheritdoc} + */ public function create(Schedule $task) { - + // todo: implement } } From baeb32b51e18c1edf6e33b364c6b13a2b98269a4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 23 Nov 2016 23:46:55 +0100 Subject: [PATCH 26/53] Minor debugging fixes --- Localization/Localization.php | 4 +- Localization/Money.php | 27 ++++++++- Log/FileLogger.php | 2 +- Math/Finance/FinanceFormulas.php | 91 +++++++++++++++++++++++++++++- Uri/Http.php | 2 +- Uri/UriFactory.php | 2 +- Utils/Parser/Markdown/Markdown.php | 6 +- 7 files changed, 123 insertions(+), 11 deletions(-) diff --git a/Localization/Localization.php b/Localization/Localization.php index 8c0c9bfaa..edfdb6a18 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -359,7 +359,7 @@ class Localization */ public function setAngle(string $angle) { - $this->temperature = $angle; + $this->angle = $angle; } /** @@ -381,7 +381,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTemperatur(string $temperature) + public function setTemperature(string $temperature) { $this->temperature = $temperature; } diff --git a/Localization/Money.php b/Localization/Money.php index 1676f0bf0..492131381 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -53,6 +53,22 @@ class Money implements \Serializable */ private $decimal = '.'; + /** + * Currency symbol position + * + * @var string + * @since 1.0.0 + */ + private $position = 1; + + /** + * Currency symbol. + * + * @var string + * @since 1.0.0 + */ + private $symbol = ISO4217SymbolEnum::_USD; + /** * Value. * @@ -118,6 +134,8 @@ class Money implements \Serializable * @param string $symbol Currency symbol * @param int $position Symbol position * + * @return Money + * * @since 1.0.0 * @author Dennis Eichhorn */ @@ -127,6 +145,8 @@ class Money implements \Serializable $this->decimal = $decimal; $this->symbol = $symbol; $this->position = $position; + + return $this; } /** @@ -158,7 +178,7 @@ class Money implements \Serializable */ public function getCurrency(int $decimals = 2) : string { - return ($position === 0 ? $smbol : '') . $this->getAmount($decimals, $thousands, $decimal) . ($position === 1 ? $smbol : ''); + return ($this->position === 0 ? $this->symbol : '') . $this->getAmount($decimals) . ($this->position === 1 ? $this->symbol : ''); } /** @@ -199,6 +219,8 @@ class Money implements \Serializable $this->value += $value; } elseif ($value instanceof Money) { $this->value += $value->getInt(); + } else { + throw new \InvalidArgumentException(); } return $this; @@ -235,8 +257,11 @@ class Money implements \Serializable $this->value -= $value; } elseif ($value instanceof Money) { $this->value -= $value->getInt(); + } else { + throw new \InvalidArgumentException(); } + return $this; } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 93a32da8a..15e5c317f 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -317,7 +317,7 @@ class FileLogger implements LoggerInterface $this->fp = false; } - if ($this->verbose || php_sapi_name() === 'cli') { + if ($this->verbose) { echo $message, "\n"; } } diff --git a/Math/Finance/FinanceFormulas.php b/Math/Finance/FinanceFormulas.php index 8dac877a9..260b9010e 100644 --- a/Math/Finance/FinanceFormulas.php +++ b/Math/Finance/FinanceFormulas.php @@ -34,7 +34,7 @@ class FinanceFormulas /** * Annual Percentage Yield * - * @latex APY = \left(1+ \frac{r}{n}\right)^{n}-1 + * @latex APY = \left(1+ \frac{r}{n}\right)^{n}-1 * * @param float $r Stated annual interest rate * @param int $n number of times compounded @@ -52,7 +52,7 @@ class FinanceFormulas /** * Annual Percentage Yield * - * @latex r = \left(\left(APY + 1\right)^{\frac{1}{n}} - 1\right) \cdot n + * @latex r = \left(\left(APY + 1\right)^{\frac{1}{n}} - 1\right) \cdot n * * @param float $apy Annual percentage yield * @param int $n Number of times compounded @@ -437,7 +437,7 @@ class FinanceFormulas */ public static function getPeriodsOfPVAD(float $PV, float $P, float $r) : int { - return (int) round((($PV - $P) / $P * $r - 1) / log(1 + $r) + 1); + return (int) round(-(log(-($PV - $P) / $P * $r + 1) / log(1 + $r) - 1)); } /** @@ -572,6 +572,40 @@ class FinanceFormulas return $P * (pow(1 + $r, $n) - 1); } + /** + * Principal of compound interest + * + * @param float $C Compound interest + * @param float $r Rate per period + * @param int $n Number of periods + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPrincipalOfCompundInterest(float $C, float $r, int $n) : float + { + return $C / (pow(1 + $r, $n) - 1); + } + + /** + * Principal of compound interest + * + * @param float $P Principal + * @param float $C Compound interest + * @param float $r Rate per period + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPeriodsOfCompundInterest(float $P, float $C, float $r) : float + { + return log($C / $P + 1) / log(1 + $r); + } + /** * Continuous Compounding * @@ -589,6 +623,57 @@ class FinanceFormulas return $P * exp($r * $t); } + /** + * Continuous Compounding + * + * @param float $C Compounding + * @param float $r Rate per period + * @param int $t Time + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPrincipalOfContinuousCompounding(float $C, float $r, int $t) : float + { + return $C / exp($r * $t); + } + + /** + * Continuous Compounding + * + * @param float $P Principal + * @param float $C Compounding + * @param float $r Rate per period + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getPeriodsOfContinuousCompounding(float $P, float $C, float $r) : float + { + return log($C / $P) / $r; + } + + /** + * Continuous Compounding + * + * @param float $P Principal + * @param float $C Compounding + * @param float $t Time + * + * @return float + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public static function getRateOfContinuousCompounding(float $P, float $C, float $t) : float + { + return log($C / $P) / $t; + } + /** * Current Ratio * diff --git a/Uri/Http.php b/Uri/Http.php index 7c9bf561e..d4756a623 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -204,7 +204,7 @@ class Http implements UriInterface */ public function getRootPath() : string { - return $this->rootPath ?? ''; + return $this->rootPath; } /** diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 89b0ed548..9e2d70d7d 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -116,7 +116,7 @@ class UriFactory } } - return success; + return $success; } /** diff --git a/Utils/Parser/Markdown/Markdown.php b/Utils/Parser/Markdown/Markdown.php index 2b79709c2..5615ea09c 100644 --- a/Utils/Parser/Markdown/Markdown.php +++ b/Utils/Parser/Markdown/Markdown.php @@ -82,10 +82,12 @@ class Markdown public function parse(string $raw) : string { - $raw = $this->cleanup($raw); + /*$raw = $this->cleanup($raw); $lines = explode("\n", $raw); - return trim($this->parseLines($lines), " \n"); + return trim($this->parseLines($lines), " \n");*/ + + return $raw; } private function cleanup(string $raw) : string From 7b36dafa5796541b7903c4935d2577bc648396d3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 24 Nov 2016 15:37:24 +0100 Subject: [PATCH 27/53] Fix session lock Still needs improvment. Shouldn't be static! --- DataStorage/Session/HttpSession.php | 14 ++++++-------- Message/HeaderAbstract.php | 3 +-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 1514d4c03..6134baebe 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -85,8 +85,6 @@ class HttpSession implements SessionInterface $this->sid = session_id(); $this->setCsrfProtection(); - - self::$isLocked = true; } /** @@ -135,7 +133,7 @@ class HttpSession implements SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function lock() + public function lock() { self::$isLocked = true; } @@ -158,7 +156,10 @@ class HttpSession implements SessionInterface */ public function save() { - + if(!self::$isLocked) { + $_SESSION = $this->sessionData; + session_write_close(); + } } /** @@ -199,10 +200,7 @@ class HttpSession implements SessionInterface */ public function __destruct() { - if(!self::$isLocked) { - $_SESSION = $this->sessionData; - session_write_close(); - } + $this->save(); } } diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index 27683905a..650206aab 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -93,8 +93,7 @@ abstract class HeaderAbstract */ public static function lock() { - CookieJar::lock(); - HttpSession::lock(); + // todo: maybe pass session as member and make lock not static self::$isLocked = true; } From 7bd0bc7067d8e47b68b4e0d7c0fc1213040215ac Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 3 Dec 2016 21:54:32 +0100 Subject: [PATCH 28/53] Fix locking --- Log/FileLogger.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 15e5c317f..deb278542 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -311,8 +311,10 @@ class FileLogger implements LoggerInterface $this->createFile(); $this->fp = fopen($this->path, 'a'); - if ($this->fp !== false) { + if (flock($this->fp, LOCK_EX) && $this->fp !== false) { fwrite($this->fp, $message . "\n"); + fflush($this->fp); + flock($this->fp, LOCK_UN); fclose($this->fp); $this->fp = false; } From ab5e11a242e093cc1146e3760ac621c9eeb817c7 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 3 Dec 2016 21:59:21 +0100 Subject: [PATCH 29/53] Preparing for void return type --- Account/Account.php | 14 ++++++------ Account/Group.php | 6 +++--- Algorithm/Knappsack/Backpack.php | 8 +++---- Config/SettingsAbstract.php | 2 +- DataStorage/Cache/FileCache.php | 2 +- DataStorage/Cache/MemCache.php | 4 ++-- DataStorage/Cache/NullCache.php | 4 ++-- DataStorage/Cache/RedisCache.php | 4 ++-- DataStorage/Cache/WinCache.php | 4 ++-- DataStorage/Database/DataMapperAbstract.php | 4 ++-- DataStorage/Database/GrammarAbstract.php | 2 +- DataStorage/Database/Query/Builder.php | 2 +- DataStorage/Database/Query/Column.php | 2 +- DataStorage/Database/Schema/Builder.php | 2 +- DataStorage/Session/ConsoleSession.php | 2 +- DataStorage/Session/HttpSession.php | 4 ++-- DataStorage/Session/SocketSession.php | 2 +- Datatypes/Address.php | 6 +++--- Datatypes/ExactFloat.php | 2 +- Datatypes/Iban.php | 2 +- Datatypes/Location.php | 14 ++++++------ Localization/Localization.php | 18 ++++++++-------- Localization/Money.php | 4 ++-- Math/Matrix/Matrix.php | 2 +- Math/Number/Complex.php | 4 ++-- Math/Optimization/TSP/Population.php | 2 +- Math/Optimization/TSP/Tour.php | 2 +- Math/Shape/D2/Polygon.php | 8 +++---- Message/Http/Request.php | 2 +- Message/Http/Response.php | 2 +- Message/Http/Rest.php | 2 +- Message/Mail/Mail.php | 6 +++--- Message/RequestAbstract.php | 12 +++++------ Message/ResponseAbstract.php | 6 +++--- Model/Html/Head.php | 8 +++---- Model/Html/Meta.php | 8 +++---- Module/InfoManager.php | 2 +- Security/Encryption/Encryption.php | 8 +++---- Socket/Client/ClientConnection.php | 8 +++---- Socket/Packets/Header.php | 12 +++++------ Socket/Packets/PacketAbstract.php | 2 +- Socket/Server/Server.php | 2 +- Stdlib/Collection/Collection.php | 2 +- Stdlib/Graph/BinaryTree.php | 2 +- Stdlib/Graph/Graph.php | 2 +- Stdlib/Queue/PriorityQueue.php | 2 +- Uri/Http.php | 4 ++-- Utils/Barcode/C128Abstract.php | 6 +++--- Utils/Barcode/C128a.php | 2 +- Utils/Barcode/C25.php | 2 +- Utils/Barcode/C39.php | 2 +- Utils/Barcode/Codebar.php | 2 +- Utils/Encoding/Huffman/Dictionary.php | 2 +- Utils/Encoding/Huffman/Huffman.php | 2 +- Utils/Git/Author.php | 6 +++--- Utils/Git/Branch.php | 2 +- Utils/Git/Commit.php | 12 +++++------ Utils/Git/Git.php | 2 +- Utils/Git/Repository.php | 4 ++-- Utils/Git/Tag.php | 2 +- Utils/IO/Csv/CsvDatabaseMapper.php | 4 ++-- Utils/IO/Excel/ExcelDatabaseMapper.php | 4 ++-- Utils/JobQueue/Job.php | 2 +- Utils/JobQueue/JobQueue.php | 8 +++---- Utils/JsonBuilder.php | 2 +- Utils/Parser/Php/ClassParser.php | 12 +++++------ Utils/Parser/Php/FunctionParser.php | 16 +++++++------- Utils/Parser/Php/MemberParser.php | 10 ++++----- Utils/RnG/Text.php | 4 ++-- Utils/TaskSchedule/CronJob.php | 2 +- Utils/TaskSchedule/Interval.php | 24 ++++++++++----------- Utils/TaskSchedule/Schedule.php | 2 +- Utils/TaskSchedule/SchedulerAbstract.php | 4 ++-- Utils/TaskSchedule/TaskAbstract.php | 18 ++++++++-------- Validation/ModelValidationTrait.php | 4 ++-- Views/View.php | 2 +- Views/ViewAbstract.php | 4 ++-- 77 files changed, 196 insertions(+), 196 deletions(-) diff --git a/Account/Account.php b/Account/Account.php index 3484f238b..306c455dd 100644 --- a/Account/Account.php +++ b/Account/Account.php @@ -199,7 +199,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setL11n(Localization $l11n) + public function setL11n(Localization $l11n) /* : void */ { $this->l11n = $l11n; } @@ -322,7 +322,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName1(string $name) + public function setName1(string $name) /* : void */ { $this->name1 = $name; } @@ -337,7 +337,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName2(string $name) + public function setName2(string $name) /* : void */ { $this->name2 = $name; } @@ -352,7 +352,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName3(string $name) + public function setName3(string $name) /* : void */ { $this->name3 = $name; } @@ -367,7 +367,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEmail(string $email) + public function setEmail(string $email) /* : void */ { if (!Email::isValid($email)) { throw new \InvalidArgumentException(); @@ -386,7 +386,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { if (!AccountStatus::isValidValue($status)) { throw new \InvalidArgumentException(); @@ -405,7 +405,7 @@ class Account implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setType(int $type) + public function setType(int $type) /* : void */ { if (!AccountType::isValidValue($type)) { throw new \InvalidArgumentException(); diff --git a/Account/Group.php b/Account/Group.php index 159698ade..cbc1c5213 100644 --- a/Account/Group.php +++ b/Account/Group.php @@ -148,7 +148,7 @@ class Group implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = $name; } @@ -174,7 +174,7 @@ class Group implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDescription(string $description) + public function setDescription(string $description) /* : void */ { $this->description = $description; } @@ -200,7 +200,7 @@ class Group implements ArrayableInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { // todo: check valid $this->status = $status; diff --git a/Algorithm/Knappsack/Backpack.php b/Algorithm/Knappsack/Backpack.php index 0e7f3f4a3..7da98193a 100644 --- a/Algorithm/Knappsack/Backpack.php +++ b/Algorithm/Knappsack/Backpack.php @@ -54,22 +54,22 @@ class Backpack return true; } - public function setPopulationItem(ItemInterface $item) + public function setPopulationItem(ItemInterface $item) /* : void */ { $this->population[$item->getId()] = $item; } - public function setCostCalculation(\Closure $callback) + public function setCostCalculation(\Closure $callback) /* : void */ { } - public function setValueCalculation(\Closure $callback) + public function setValueCalculation(\Closure $callback) /* : void */ { } - public function setTestPopulationBuilder(\Closure $callback) + public function setTestPopulationBuilder(\Closure $callback) /* : void */ { } diff --git a/Config/SettingsAbstract.php b/Config/SettingsAbstract.php index f14798ec2..c6cedb85e 100644 --- a/Config/SettingsAbstract.php +++ b/Config/SettingsAbstract.php @@ -131,7 +131,7 @@ abstract class SettingsAbstract implements OptionsInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(array $options, bool $store = false) + public function set(array $options, bool $store = false) /* : void */ { $this->setOptions($options); diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index 2a9aa9232..cef68a849 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -136,7 +136,7 @@ class FileCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { if($this->status !== CacheStatus::ACTIVE) { return false; diff --git a/DataStorage/Cache/MemCache.php b/DataStorage/Cache/MemCache.php index faab742e1..3779cbc34 100644 --- a/DataStorage/Cache/MemCache.php +++ b/DataStorage/Cache/MemCache.php @@ -74,7 +74,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { $this->memc->set($key, $value, false, $expire); } @@ -151,7 +151,7 @@ class MemCache implements CacheInterface /** * {@inheritdoc} */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { $this->status = $status; } diff --git a/DataStorage/Cache/NullCache.php b/DataStorage/Cache/NullCache.php index ada8a005b..5e748907e 100644 --- a/DataStorage/Cache/NullCache.php +++ b/DataStorage/Cache/NullCache.php @@ -32,7 +32,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -108,7 +108,7 @@ class NullCache implements CacheInterface /** * {@inheritdoc} */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { // TODO: Implement setStatus() method. } diff --git a/DataStorage/Cache/RedisCache.php b/DataStorage/Cache/RedisCache.php index b3afb4cc9..f9a5447d3 100644 --- a/DataStorage/Cache/RedisCache.php +++ b/DataStorage/Cache/RedisCache.php @@ -34,7 +34,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -110,7 +110,7 @@ class RedisCache implements CacheInterface /** * {@inheritdoc} */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { // TODO: Implement setStatus() method. } diff --git a/DataStorage/Cache/WinCache.php b/DataStorage/Cache/WinCache.php index a41bfe7f9..4c5864480 100644 --- a/DataStorage/Cache/WinCache.php +++ b/DataStorage/Cache/WinCache.php @@ -34,7 +34,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function set($key, $value, int $expire = -1) + public function set($key, $value, int $expire = -1) /* : void */ { // TODO: Implement set() method. } @@ -110,7 +110,7 @@ class WinCache implements CacheInterface /** * {@inheritdoc} */ - public function setStatus(int $status) + public function setStatus(int $status) /* : void */ { // TODO: Implement setStatus() method. } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index dba3be76e..c2af1d607 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -175,7 +175,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function setConnection(ConnectionAbstract $con) + public static function setConnection(ConnectionAbstract $con) /* : void */ { self::$db = $con; } @@ -425,7 +425,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private static function setObjectId(\ReflectionClass $reflectionClass, $obj, $objId) + private static function setObjectId(\ReflectionClass $reflectionClass, $obj, $objId) /* : void */ { $reflectionProperty = $reflectionClass->getProperty(static::$columns[static::$primaryField]['internal']); diff --git a/DataStorage/Database/GrammarAbstract.php b/DataStorage/Database/GrammarAbstract.php index 1c91395c3..1aabee83f 100644 --- a/DataStorage/Database/GrammarAbstract.php +++ b/DataStorage/Database/GrammarAbstract.php @@ -147,7 +147,7 @@ abstract class GrammarAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTablePrefix(string $prefix) + public function setTablePrefix(string $prefix) /* : void */ { $this->tablePrefix = $prefix; } diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index ffa6ce35e..35147355b 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -226,7 +226,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setConnection(ConnectionAbstract $connection) + public function setConnection(ConnectionAbstract $connection) /* : void */ { $this->connection = $connection; $this->grammar = $connection->getGrammar(); diff --git a/DataStorage/Database/Query/Column.php b/DataStorage/Database/Query/Column.php index 1587e7c2b..34efc0865 100644 --- a/DataStorage/Database/Query/Column.php +++ b/DataStorage/Database/Query/Column.php @@ -64,7 +64,7 @@ class Column return $this->column; } - public function setColumn(string $column) + public function setColumn(string $column) /* : void */ { $this->column = $column; } diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index e1113a6b9..60a80dfce 100644 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -51,7 +51,7 @@ class Builder extends BuilderAbstract $this->grammar = $connection->getSchemaGrammar(); } - public function select(...$table) + public function select(...$table) /* : void */ { $this->type = QueryType::SELECT; $this->table += $table; diff --git a/DataStorage/Session/ConsoleSession.php b/DataStorage/Session/ConsoleSession.php index 088e25b82..9f6ae47f8 100644 --- a/DataStorage/Session/ConsoleSession.php +++ b/DataStorage/Session/ConsoleSession.php @@ -84,7 +84,7 @@ class ConsoleSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 6134baebe..2bc104b2d 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -93,7 +93,7 @@ class HttpSession implements SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private function setCsrfProtection() + private function setCsrfProtection() /* : void */ { $this->set('UID', 0, false); @@ -187,7 +187,7 @@ class HttpSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } diff --git a/DataStorage/Session/SocketSession.php b/DataStorage/Session/SocketSession.php index 0ae50a265..462857ebd 100644 --- a/DataStorage/Session/SocketSession.php +++ b/DataStorage/Session/SocketSession.php @@ -84,7 +84,7 @@ class SocketSession implements SessionInterface /** * {@inheritdoc} */ - public function setSID($sid) + public function setSID($sid) /* : void */ { $this->sid = $sid; } diff --git a/Datatypes/Address.php b/Datatypes/Address.php index 868651f12..200244417 100644 --- a/Datatypes/Address.php +++ b/Datatypes/Address.php @@ -87,7 +87,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRecipient(string $recipient) + public function setRecipient(string $recipient) /* : void */ { $this->recipient = $recipient; } @@ -115,7 +115,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setFAO(string $fao) + public function setFAO(string $fao) /* : void */ { $this->fao = $fao; } @@ -143,7 +143,7 @@ class Address implements \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLocation(Location $location) + public function setLocation(Location $location) /* : void */ { $this->location = $location; } diff --git a/Datatypes/ExactFloat.php b/Datatypes/ExactFloat.php index 41aa4efc3..2fe5a96ee 100644 --- a/Datatypes/ExactFloat.php +++ b/Datatypes/ExactFloat.php @@ -20,7 +20,7 @@ class ExactFloat private static $length = 0; - public static function setLength($length) + public static function setLength($length) /* : void */ { self::$length = (int) $length; } diff --git a/Datatypes/Iban.php b/Datatypes/Iban.php index 1d529a752..484683d2d 100644 --- a/Datatypes/Iban.php +++ b/Datatypes/Iban.php @@ -276,7 +276,7 @@ class Iban implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() + public function serialize() /* : void */ { return $this->prettyPrint(); } diff --git a/Datatypes/Location.php b/Datatypes/Location.php index aa40936aa..d20399da6 100644 --- a/Datatypes/Location.php +++ b/Datatypes/Location.php @@ -106,7 +106,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setPostal(string $postal) + public function setPostal(string $postal) /* : void */ { $this->postal = $postal; } @@ -130,7 +130,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCity(string $city) + public function setCity(string $city) /* : void */ { $this->city = $city; } @@ -154,7 +154,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCountry(string $country) + public function setCountry(string $country) /* : void */ { $this->country = $country; } @@ -178,7 +178,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAddress(string $address) + public function setAddress(string $address) /* : void */ { $this->address = $address; } @@ -202,7 +202,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setState(string $state) + public function setState(string $state) /* : void */ { $this->state = $state; } @@ -226,7 +226,7 @@ class Location implements \JsonSerializable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setGeo(array $geo) + public function setGeo(array $geo) /* : void */ { $this->geo = $geo; } @@ -237,7 +237,7 @@ class Location implements \JsonSerializable, \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() + public function serialize() /* : void */ { return $this->jsonSerialize(); } diff --git a/Localization/Localization.php b/Localization/Localization.php index edfdb6a18..bea87e1cb 100644 --- a/Localization/Localization.php +++ b/Localization/Localization.php @@ -171,7 +171,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCountry(string $country) + public function setCountry(string $country) /* : void */ { if (!ISO3166TwoEnum::isValidValue($country)) { throw new InvalidEnumValue($country); @@ -199,7 +199,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTimezone(string $timezone) + public function setTimezone(string $timezone) /* : void */ { if (!TimeZoneEnumArray::isValidValue($timezone)) { throw new InvalidEnumValue($timezone); @@ -229,7 +229,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLanguage(string $language) + public function setLanguage(string $language) /* : void */ { if (!ISO639x1Enum::isValidValue($language)) { throw new InvalidEnumValue($language); @@ -257,7 +257,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCurrency(string $currency) + public function setCurrency(string $currency) /* : void */ { if (!ISO4217Enum::isValidValue($currency)) { throw new InvalidEnumValue($currency); @@ -285,7 +285,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDatetime(string $datetime) + public function setDatetime(string $datetime) /* : void */ { $this->datetime = $datetime; } @@ -309,7 +309,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDecimal(string $decimal) + public function setDecimal(string $decimal) /* : void */ { $this->decimal = $decimal; } @@ -333,7 +333,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setThousands(string $thousands) + public function setThousands(string $thousands) /* : void */ { $this->thousands = $thousands; } @@ -357,7 +357,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAngle(string $angle) + public function setAngle(string $angle) /* : void */ { $this->angle = $angle; } @@ -381,7 +381,7 @@ class Localization * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTemperature(string $temperature) + public function setTemperature(string $temperature) /* : void */ { $this->temperature = $temperature; } diff --git a/Localization/Money.php b/Localization/Money.php index 492131381..7e4cfb5f9 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -139,7 +139,7 @@ class Money implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLocalization(string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) + public function setLocalization(string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) /* : void */ { $this->thousands = $thousands; $this->decimal = $decimal; @@ -345,7 +345,7 @@ class Money implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { return $this->getInt(); } diff --git a/Math/Matrix/Matrix.php b/Math/Matrix/Matrix.php index 7c3d6b962..1b52176e3 100644 --- a/Math/Matrix/Matrix.php +++ b/Math/Matrix/Matrix.php @@ -92,7 +92,7 @@ class Matrix implements \ArrayAccess, \Iterator * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(int $m, int $n, $value) + public function set(int $m, int $n, $value) /* : void */ { if (!isset($this->matrix[$m][$n])) { throw new DimensionException($m, $n); diff --git a/Math/Number/Complex.php b/Math/Number/Complex.php index e7364fc02..653492655 100644 --- a/Math/Number/Complex.php +++ b/Math/Number/Complex.php @@ -25,11 +25,11 @@ class Complex { } - public function setReal() + public function setReal() /* : void */ { } - public function setImaginary() + public function setImaginary() /* : void */ { } diff --git a/Math/Optimization/TSP/Population.php b/Math/Optimization/TSP/Population.php index 9d8024ed3..2a0ca90c1 100644 --- a/Math/Optimization/TSP/Population.php +++ b/Math/Optimization/TSP/Population.php @@ -79,7 +79,7 @@ class Population implements \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(int $index, Tour $tour) + public function set(int $index, Tour $tour) /* : void */ { $this->tours[$index] = $tour; asort($this->tours); diff --git a/Math/Optimization/TSP/Tour.php b/Math/Optimization/TSP/Tour.php index 6b1b64a53..50f1b66ed 100644 --- a/Math/Optimization/TSP/Tour.php +++ b/Math/Optimization/TSP/Tour.php @@ -164,7 +164,7 @@ class Tour implements \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCity(int $index, City $city) + public function setCity(int $index, City $city) /* : void */ { $this->cities[$index] = $city; asort($this->cities); diff --git a/Math/Shape/D2/Polygon.php b/Math/Shape/D2/Polygon.php index cfcc16577..4949aad4c 100644 --- a/Math/Shape/D2/Polygon.php +++ b/Math/Shape/D2/Polygon.php @@ -201,7 +201,7 @@ class Polygon implements D2ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCoordinates($coord) + public function setCoordinates($coord) /* : void */ { $this->coord = $coord; } @@ -218,7 +218,7 @@ class Polygon implements D2ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCoordinate($i, $x, $y) + public function setCoordinate($i, $x, $y) /* : void */ { $this->coord[$i] = ['x' => $x, 'y' => $y]; } @@ -278,7 +278,7 @@ class Polygon implements D2ShapeInterface /** * {@inheritdoc} */ - public function setSurface($surface) + public function setSurface($surface) /* : void */ { $this->reset(); @@ -326,7 +326,7 @@ class Polygon implements D2ShapeInterface /** * {@inheritdoc} */ - public function setPerimeter($perimeter) + public function setPerimeter($perimeter) /* : void */ { $this->reset(); diff --git a/Message/Http/Request.php b/Message/Http/Request.php index a59766a64..310a3b487 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -196,7 +196,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private function setupUriBuilder() + private function setupUriBuilder() /* : void */ { UriFactory::setQuery('/scheme', $this->uri->getScheme()); UriFactory::setQuery('/host', $this->uri->getHost()); diff --git a/Message/Http/Response.php b/Message/Http/Response.php index 37b9f10ed..da1932868 100644 --- a/Message/Http/Response.php +++ b/Message/Http/Response.php @@ -58,7 +58,7 @@ class Response extends ResponseAbstract implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setResponse(array $response) + public function setResponse(array $response) /* : void */ { $this->response = $response; } diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 8e7ef1a65..245315d71 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -44,7 +44,7 @@ class Rest * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRequest(Request $request) + public function setRequest(Request $request) /* : void */ { $this->request = $request; } diff --git a/Message/Mail/Mail.php b/Message/Mail/Mail.php index 130862ad9..bcd525ee6 100644 --- a/Message/Mail/Mail.php +++ b/Message/Mail/Mail.php @@ -208,7 +208,7 @@ class Mail * @since 1.0.0 * @author Dennis Eichhorn */ - public function setBody(string $body) + public function setBody(string $body) /* : void */ { $this->body = $body; } @@ -223,7 +223,7 @@ class Mail * @since 1.0.0 * @author Dennis Eichhorn */ - public function setOverview(string $overview) + public function setOverview(string $overview) /* : void */ { $this->overview = $overview; } @@ -238,7 +238,7 @@ class Mail * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEncoding(int $encoding) + public function setEncoding(int $encoding) /* : void */ { $this->encoding = $encoding; } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index 53fa0da1d..dd72bb544 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -163,7 +163,7 @@ abstract class RequestAbstract implements MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setUri(UriInterface $uri) + public function setUri(UriInterface $uri) /* : void */ { $this->uri = $uri; } @@ -192,7 +192,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public function setRequestSource($source) + public function setRequestSource($source) /* : void */ { if (!RequestSource::isValidValue($source)) { throw new InvalidEnumValue($source); @@ -219,7 +219,7 @@ abstract class RequestAbstract implements MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMethod(string $method) + public function setMethod(string $method) /* : void */ { $this->method = $method; } @@ -246,7 +246,7 @@ abstract class RequestAbstract implements MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setType(string $type) + public function setType(string $type) /* : void */ { $this->type = $type; } @@ -332,7 +332,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public function setAccount(int $account) + public function setAccount(int $account) /* : void */ { $this->account = $account; } @@ -340,7 +340,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public function setStatusCode(string $status) + public function setStatusCode(string $status) /* : void */ { $this->status = $status; } diff --git a/Message/ResponseAbstract.php b/Message/ResponseAbstract.php index ddf9525b2..28b1c1ae3 100644 --- a/Message/ResponseAbstract.php +++ b/Message/ResponseAbstract.php @@ -107,7 +107,7 @@ abstract class ResponseAbstract implements MessageInterface, \JsonSerializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function set($key, $response, bool $overwrite = true) + public function set($key, $response, bool $overwrite = true) /* : void */ { $this->response = ArrayUtils::setArray($key, $this->response, $response, ':', $overwrite); } @@ -116,7 +116,7 @@ abstract class ResponseAbstract implements MessageInterface, \JsonSerializable * {@inheritdoc} * todo: shouldn't this only be available in the header?! */ - public function setStatusCode(string $status) + public function setStatusCode(string $status) /* : void */ { $this->status = $status; $this->header->generate($status); @@ -142,7 +142,7 @@ abstract class ResponseAbstract implements MessageInterface, \JsonSerializable /** * {@inheritdoc} */ - public function setAccount(int $account) + public function setAccount(int $account) /* : void */ { $this->account = $account; } diff --git a/Model/Html/Head.php b/Model/Html/Head.php index ccc02840b..c9b52190c 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -138,7 +138,7 @@ class Head implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTitle(string $title) + public function setTitle(string $title) /* : void */ { $this->title = $title; } @@ -169,7 +169,7 @@ class Head implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLanguage(string $language) + public function setLanguage(string $language) /* : void */ { $this->language = $language; } @@ -242,7 +242,7 @@ class Head implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStyle(string $key, string $style, bool $overwrite = true) + public function setStyle(string $key, string $style, bool $overwrite = true) /* : void */ { if ($overwrite || !isset($this->script[$key])) { $this->style[$key] = $style; @@ -261,7 +261,7 @@ class Head implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setScript(string $key, string $script, bool $overwrite = true) + public function setScript(string $key, string $script, bool $overwrite = true) /* : void */ { if ($overwrite || !isset($this->script[$key])) { $this->script[$key] = $script; diff --git a/Model/Html/Meta.php b/Model/Html/Meta.php index 74e3240b6..337b9cbf5 100644 --- a/Model/Html/Meta.php +++ b/Model/Html/Meta.php @@ -124,7 +124,7 @@ class Meta implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAuthor(string $author) + public function setAuthor(string $author) /* : void */ { $this->author = $author; } @@ -152,7 +152,7 @@ class Meta implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCharset(string $charset) + public function setCharset(string $charset) /* : void */ { $this->charset = $charset; } @@ -180,7 +180,7 @@ class Meta implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDescription(string $description) + public function setDescription(string $description) /* : void */ { $this->description = $description; } @@ -208,7 +208,7 @@ class Meta implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLanguage(string $language) + public function setLanguage(string $language) /* : void */ { $this->language = $language; } diff --git a/Module/InfoManager.php b/Module/InfoManager.php index 66b3dc112..f7929f4c7 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -103,7 +103,7 @@ class InfoManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(string $path, $data, string $delim = '/') + public function set(string $path, $data, string $delim = '/') /* : void */ { if (!is_scalar($data) || !is_array($data)) { throw new \InvalidArgumentException('Type of $data "' . gettype($data) . '" is not supported.'); diff --git a/Security/Encryption/Encryption.php b/Security/Encryption/Encryption.php index 498d0b7b0..915620536 100644 --- a/Security/Encryption/Encryption.php +++ b/Security/Encryption/Encryption.php @@ -101,7 +101,7 @@ class Encryption * @since 1.0.0 * @author Dennis Eichhorn */ - public function setKey(string $key) + public function setKey(string $key) /* : void */ { $this->key = $key; } @@ -129,7 +129,7 @@ class Encryption * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCipher(string $key) + public function setCipher(string $key) /* : void */ { $this->key = $key; } @@ -157,7 +157,7 @@ class Encryption * @since 1.0.0 * @author Dennis Eichhorn */ - public function setBlock(int $block) + public function setBlock(int $block) /* : void */ { $this->block = $block; } @@ -185,7 +185,7 @@ class Encryption * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMode(string $mode) + public function setMode(string $mode) /* : void */ { $this->mode = $mode; } diff --git a/Socket/Client/ClientConnection.php b/Socket/Client/ClientConnection.php index d440df019..d178a48e7 100644 --- a/Socket/Client/ClientConnection.php +++ b/Socket/Client/ClientConnection.php @@ -50,7 +50,7 @@ class ClientConnection return $this->socket; } - public function setSocket($socket) + public function setSocket($socket) /* : void */ { $this->socket = $socket; } @@ -60,7 +60,7 @@ class ClientConnection return $this->handshake; } - public function setHandshake($handshake) + public function setHandshake($handshake) /* : void */ { $this->handshake = $handshake; } @@ -70,7 +70,7 @@ class ClientConnection return $this->pid; } - public function setPid($pid) + public function setPid($pid) /* : void */ { $this->pid = $pid; } @@ -80,7 +80,7 @@ class ClientConnection return $this->connected; } - public function setConnected(bool $connected) + public function setConnected(bool $connected) /* : void */ { $this->connected = $connected; } diff --git a/Socket/Packets/Header.php b/Socket/Packets/Header.php index 7a1936882..b676689f9 100644 --- a/Socket/Packets/Header.php +++ b/Socket/Packets/Header.php @@ -63,7 +63,7 @@ class Header implements \Serializable return $this->sendFrom; } - public function setSendFrom($sendFrom) + public function setSendFrom($sendFrom) /* : void */ { $this->sendFrom = $sendFrom; } @@ -73,7 +73,7 @@ class Header implements \Serializable return $this->sendTo; } - public function setSendTo($sendTo) + public function setSendTo($sendTo) /* : void */ { $this->sendTo = $sendTo; } @@ -97,7 +97,7 @@ class Header implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLength($length) + public function setLength($length) /* : void */ { $this->length = $length; } @@ -121,7 +121,7 @@ class Header implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setType($type) + public function setType($type) /* : void */ { $this->type = $type; } @@ -145,7 +145,7 @@ class Header implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setSubtype($subtype) + public function setSubtype($subtype) /* : void */ { $this->subtype = $subtype; } @@ -158,7 +158,7 @@ class Header implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { return $this->__toString(); } diff --git a/Socket/Packets/PacketAbstract.php b/Socket/Packets/PacketAbstract.php index cc70c4c1b..a4ce6beba 100644 --- a/Socket/Packets/PacketAbstract.php +++ b/Socket/Packets/PacketAbstract.php @@ -95,7 +95,7 @@ abstract class PacketAbstract implements \Serializable * @var Header * @since 1.0.0 */ - public function setHeader(Header $header) + public function setHeader(Header $header) /* : void */ { $this->header = $header; } diff --git a/Socket/Server/Server.php b/Socket/Server/Server.php index d3603f900..24099cbf3 100644 --- a/Socket/Server/Server.php +++ b/Socket/Server/Server.php @@ -127,7 +127,7 @@ class Server extends SocketAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLimit(int $limit) + public function setLimit(int $limit) /* : void */ { $this->limit = $limit; } diff --git a/Stdlib/Collection/Collection.php b/Stdlib/Collection/Collection.php index 3ccb31be9..1d8064142 100644 --- a/Stdlib/Collection/Collection.php +++ b/Stdlib/Collection/Collection.php @@ -567,7 +567,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab return $total; } - public function search($filter, bool $strict = true) + public function search($filter, bool $strict = true) /* : void */ { if (is_scalar($filter)) { array_search($filter, $this->collection, $strict); diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php index 1255068eb..bd93d3bf4 100644 --- a/Stdlib/Graph/BinaryTree.php +++ b/Stdlib/Graph/BinaryTree.php @@ -114,7 +114,7 @@ class BinaryTree extends Tree * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRight(Node $base, Node $right) + public function setRight(Node $base, Node $right) /* : void */ { if($this->getRight($base) === null) { $this->addNode($base, $right); diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php index fdb493e7e..75e9c2548 100644 --- a/Stdlib/Graph/Graph.php +++ b/Stdlib/Graph/Graph.php @@ -107,7 +107,7 @@ class Graph * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEdge($key, Edge $edge) + public function setEdge($key, Edge $edge) /* : void */ { $this->edges[$key] = $edge; diff --git a/Stdlib/Queue/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php index 01150bde1..f13021398 100644 --- a/Stdlib/Queue/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -163,7 +163,7 @@ class PriorityQueue implements \Countable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setPriority(int $id, float $priority) + public function setPriority(int $id, float $priority) /* : void */ { $this->queue[$id]['priority'] = $priority; } diff --git a/Uri/Http.php b/Uri/Http.php index d4756a623..3725c43c2 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -145,7 +145,7 @@ class Http implements UriInterface /** * {@inheritdoc} */ - public function set(string $uri) + public function set(string $uri) /* : void */ { $this->uri = $uri; $url = parse_url($this->uri); @@ -210,7 +210,7 @@ class Http implements UriInterface /** * {@inheritdoc} */ - public function setRootPath(string $root) + public function setRootPath(string $root) /* : void */ { $this->rootPath = $root; $this->set($this->uri); diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index f43f76a71..6cc9e593c 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -155,7 +155,7 @@ abstract class C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setSize(int $size) + public function setSize(int $size) /* : void */ { if ($size < 0) { throw new \OutOfBoundsException($size); @@ -172,7 +172,7 @@ abstract class C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setOrientation(int $orientation) + public function setOrientation(int $orientation) /* : void */ { if (!OrientationType::isValidValue($orientation)) { throw new InvalidEnumValue($orientation); @@ -202,7 +202,7 @@ abstract class C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setContent(string $content) + public function setContent(string $content) /* : void */ { $this->content = $content; } diff --git a/Utils/Barcode/C128a.php b/Utils/Barcode/C128a.php index bc33735a9..e3c9ad734 100644 --- a/Utils/Barcode/C128a.php +++ b/Utils/Barcode/C128a.php @@ -108,7 +108,7 @@ class C128a extends C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setContent(string $content) + public function setContent(string $content) /* : void */ { parent::setContent(strtoupper($content)); } diff --git a/Utils/Barcode/C25.php b/Utils/Barcode/C25.php index e68099154..b914d0bc5 100644 --- a/Utils/Barcode/C25.php +++ b/Utils/Barcode/C25.php @@ -93,7 +93,7 @@ class C25 extends C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setContent(string $content) + public function setContent(string $content) /* : void */ { if (!ctype_digit($content)) { throw new \InvalidArgumentException($content); diff --git a/Utils/Barcode/C39.php b/Utils/Barcode/C39.php index 0b6558c05..e8126f120 100644 --- a/Utils/Barcode/C39.php +++ b/Utils/Barcode/C39.php @@ -88,7 +88,7 @@ class C39 extends C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setContent(string $content) + public function setContent(string $content) /* : void */ { parent::setContent(strtoupper($content)); } diff --git a/Utils/Barcode/Codebar.php b/Utils/Barcode/Codebar.php index a7be5d673..414324a91 100644 --- a/Utils/Barcode/Codebar.php +++ b/Utils/Barcode/Codebar.php @@ -89,7 +89,7 @@ class Codebar extends C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setContent(string $content) + public function setContent(string $content) /* : void */ { parent::setContent(strtoupper($content)); } diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index c6dce1b57..3304f80c6 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -143,7 +143,7 @@ final class Dictionary * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(string $entry, string $value) + public function set(string $entry, string $value) /* : void */ { if (strlen($entry) !== 1) { throw new \Exception('Must be a character.'); diff --git a/Utils/Encoding/Huffman/Huffman.php b/Utils/Encoding/Huffman/Huffman.php index 906e715ec..4166a000d 100644 --- a/Utils/Encoding/Huffman/Huffman.php +++ b/Utils/Encoding/Huffman/Huffman.php @@ -68,7 +68,7 @@ final class Huffman * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDictionary(Dictionary $dictionary) + public function setDictionary(Dictionary $dictionary) /* : void */ { $this->dictionary = $dictionary; } diff --git a/Utils/Git/Author.php b/Utils/Git/Author.php index fb80d482d..351602a35 100644 --- a/Utils/Git/Author.php +++ b/Utils/Git/Author.php @@ -132,7 +132,7 @@ class Author * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCommitCount(int $count) + public function setCommitCount(int $count) /* : void */ { $this->commitCount = $count; } @@ -147,7 +147,7 @@ class Author * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAdditionCount(int $count) + public function setAdditionCount(int $count) /* : void */ { $this->additionsCount = $count; } @@ -175,7 +175,7 @@ class Author * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRemovalCount(int $count) + public function setRemovalCount(int $count) /* : void */ { $this->removalsCount = $count; } diff --git a/Utils/Git/Branch.php b/Utils/Git/Branch.php index e6047c198..a16a57957 100644 --- a/Utils/Git/Branch.php +++ b/Utils/Git/Branch.php @@ -70,7 +70,7 @@ class Branch * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = escapeshellarg($name); } diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index 33f1ca00a..6d17fdb08 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -163,7 +163,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMessage(string $message) + public function setMessage(string $message) /* : void */ { $this->message = $message; } @@ -223,7 +223,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAuthor(Author $author) + public function setAuthor(Author $author) /* : void */ { $this->author = $author; } @@ -249,7 +249,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setBranch(Branch $branch) + public function setBranch(Branch $branch) /* : void */ { $this->branch = $branch; } @@ -275,7 +275,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTag(Tag $tag) + public function setTag(Tag $tag) /* : void */ { $this->tag = $tag; } @@ -303,7 +303,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDate(\DateTime $date) + public function setDate(\DateTime $date) /* : void */ { $this->date = $date; } @@ -329,7 +329,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRepository(Repository $repository) + public function setRepository(Repository $repository) /* : void */ { $this->repository = $repository; } diff --git a/Utils/Git/Git.php b/Utils/Git/Git.php index 81e456dfc..6100ccd8c 100644 --- a/Utils/Git/Git.php +++ b/Utils/Git/Git.php @@ -84,7 +84,7 @@ class Git * @since 1.0.0 * @author Dennis Eichhorn */ - public static function setBin(string $path) + public static function setBin(string $path) /* : void */ { if (realpath($path) === false) { throw new PathException($path); diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index 03ef83baa..bf64936b7 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -87,7 +87,7 @@ class Repository * @since 1.0.0 * @author Dennis Eichhorn */ - private function setPath(string $path) + private function setPath(string $path) /* : void */ { if (!is_dir($path)) { throw new PathException($path); @@ -604,7 +604,7 @@ class Repository * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDescription(string $description) + public function setDescription(string $description) /* : void */ { file_put_contents($this->getDirectoryPath(), $description); } diff --git a/Utils/Git/Tag.php b/Utils/Git/Tag.php index e4aa91bbb..c6a985597 100644 --- a/Utils/Git/Tag.php +++ b/Utils/Git/Tag.php @@ -78,7 +78,7 @@ class Tag * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMessage(string $message) + public function setMessage(string $message) /* : void */ { $this->message = escapeshellarg($message); } diff --git a/Utils/IO/Csv/CsvDatabaseMapper.php b/Utils/IO/Csv/CsvDatabaseMapper.php index 4882c7089..260a2b8be 100644 --- a/Utils/IO/Csv/CsvDatabaseMapper.php +++ b/Utils/IO/Csv/CsvDatabaseMapper.php @@ -43,7 +43,7 @@ class CsvDatabaseMapper implements IODatabaseMapper $this->sources = array_unique($this->sources); } - public function setSources(array $sources) + public function setSources(array $sources) /* : void */ { $this->sources = $sources; } @@ -53,7 +53,7 @@ class CsvDatabaseMapper implements IODatabaseMapper $this->autoIdentifyCsvSettings = $identify; } - public function setLineBuffer(int $buffer) + public function setLineBuffer(int $buffer) /* : void */ { $this->lineBuffer = $buffer; } diff --git a/Utils/IO/Excel/ExcelDatabaseMapper.php b/Utils/IO/Excel/ExcelDatabaseMapper.php index 1a3c8596d..5e3f98e54 100644 --- a/Utils/IO/Excel/ExcelDatabaseMapper.php +++ b/Utils/IO/Excel/ExcelDatabaseMapper.php @@ -27,12 +27,12 @@ class ExcelDatabaseMapper implements IODatabaseMapper $this->sources[] = $source; } - public function setLineBuffer(int $buffer) + public function setLineBuffer(int $buffer) /* : void */ { $this->lineBuffer = $buffer; } - public function setSources(array $sources) + public function setSources(array $sources) /* : void */ { $this->sources = $sources; } diff --git a/Utils/JobQueue/Job.php b/Utils/JobQueue/Job.php index 010c123c0..78f98d770 100644 --- a/Utils/JobQueue/Job.php +++ b/Utils/JobQueue/Job.php @@ -48,7 +48,7 @@ class Job return $this->priority; } - public function setPriority(float $priority) + public function setPriority(float $priority) /* : void */ { $this->priority = $priority; } diff --git a/Utils/JobQueue/JobQueue.php b/Utils/JobQueue/JobQueue.php index 0c8ebb7eb..0a7134911 100644 --- a/Utils/JobQueue/JobQueue.php +++ b/Utils/JobQueue/JobQueue.php @@ -101,7 +101,7 @@ class JobQueue register_shutdown_function('shutdown'); } - public function setRunning(bool $run = true) + public function setRunning(bool $run = true) /* : void */ { $this->run = $run; $this->suspended = $run; @@ -117,7 +117,7 @@ class JobQueue return $this->suspended; } - public function setSuspended(bool $suspended = true) + public function setSuspended(bool $suspended = true) /* : void */ { $this->suspended = $suspended; } @@ -127,7 +127,7 @@ class JobQueue return $this->isTerminating; } - public function setTerminating(bool $terminating = true) + public function setTerminating(bool $terminating = true) /* : void */ { $this->isTerminating = $terminating; } @@ -137,7 +137,7 @@ class JobQueue return $this->isDeamonized; } - public function setDeamonized(bool $deamonized) + public function setDeamonized(bool $deamonized) /* : void */ { $this->isDeamonized = $deamonized; } diff --git a/Utils/JsonBuilder.php b/Utils/JsonBuilder.php index 96a4aa6b6..5f438cead 100644 --- a/Utils/JsonBuilder.php +++ b/Utils/JsonBuilder.php @@ -98,7 +98,7 @@ class JsonBuilder implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() + public function serialize() /* : void */ { return json_encode($this->json); } diff --git a/Utils/Parser/Php/ClassParser.php b/Utils/Parser/Php/ClassParser.php index 11fe81c5e..2b504a66f 100644 --- a/Utils/Parser/Php/ClassParser.php +++ b/Utils/Parser/Php/ClassParser.php @@ -167,7 +167,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setFinal(bool $final) + public function setFinal(bool $final) /* : void */ { $this->isFinal = $final; } @@ -195,7 +195,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAbstract(bool $abstract) + public function setAbstract(bool $abstract) /* : void */ { $this->isAbstract = $abstract; } @@ -238,7 +238,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setType(string $type) + public function setType(string $type) /* : void */ { $this->type = $type; } @@ -266,7 +266,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setExtends(string $extends) + public function setExtends(string $extends) /* : void */ { $this->extends = $extends; } @@ -307,7 +307,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setNamespace(string $namespace) + public function setNamespace(string $namespace) /* : void */ { $this->namespace = $namespace; } @@ -389,7 +389,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = $name; } diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index 19f19effd..3cb9ac6b1 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -117,7 +117,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = $name; } @@ -132,7 +132,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function seBody(string $body) + public function seBody(string $body) /* : void */ { $this->body = $body; } @@ -186,7 +186,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setVisibility(string $visibility) + public function setVisibility(string $visibility) /* : void */ { $this->visibility = $visibility; } @@ -201,7 +201,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatic(bool $static) + public function setStatic(bool $static) /* : void */ { $this->isStatic = $static; } @@ -229,7 +229,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setFinal(bool $final) + public function setFinal(bool $final) /* : void */ { $this->isFinal = $final; } @@ -257,7 +257,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAbstract(bool $abstract) + public function setAbstract(bool $abstract) /* : void */ { $this->isAbstract = $abstract; @@ -317,7 +317,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setReturn(string $return) + public function setReturn(string $return) /* : void */ { $this->return = $return; } @@ -356,7 +356,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { $function = ''; $function .= str_repeat(' ', ClassParser::INDENT); diff --git a/Utils/Parser/Php/MemberParser.php b/Utils/Parser/Php/MemberParser.php index 75b4882d8..941ef2d1a 100644 --- a/Utils/Parser/Php/MemberParser.php +++ b/Utils/Parser/Php/MemberParser.php @@ -93,7 +93,7 @@ class MemberParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setName(string $name) + public function setName(string $name) /* : void */ { $this->name = $name; } @@ -121,7 +121,7 @@ class MemberParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setVisibility(string $visibility) + public function setVisibility(string $visibility) /* : void */ { $this->visibility = $visibility; } @@ -136,7 +136,7 @@ class MemberParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatic(bool $static) + public function setStatic(bool $static) /* : void */ { $this->isStatic = $static; @@ -168,7 +168,7 @@ class MemberParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setConst(bool $const) + public function setConst(bool $const) /* : void */ { $this->isConst = $const; @@ -200,7 +200,7 @@ class MemberParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDefault($default) + public function setDefault($default) /* : void */ { $this->default = $default; } diff --git a/Utils/RnG/Text.php b/Utils/RnG/Text.php index 3ae931f2c..5aa6d8f94 100644 --- a/Utils/RnG/Text.php +++ b/Utils/RnG/Text.php @@ -248,7 +248,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - public function setFormatting($hasFormatting) + public function setFormatting($hasFormatting) /* : void */ { $this->hasFormatting = $hasFormatting; } @@ -263,7 +263,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - public function setParagraphs($hasParagraphs) + public function setParagraphs($hasParagraphs) /* : void */ { $this->hasParagraphs = $hasParagraphs; } diff --git a/Utils/TaskSchedule/CronJob.php b/Utils/TaskSchedule/CronJob.php index 05c882d6b..9b362c91f 100644 --- a/Utils/TaskSchedule/CronJob.php +++ b/Utils/TaskSchedule/CronJob.php @@ -57,7 +57,7 @@ class CronJob extends TaskAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { $minute = $this->printValue($this->interval->getMinute()); $hour = $this->printValue($this->interval->getHour()); diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index 1ef28ad8b..43c5612ac 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -243,7 +243,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStart(\DateTime $start) + public function setStart(\DateTime $start) /* : void */ { $this->start = $start; } @@ -271,7 +271,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEnd(\DateTime $end) + public function setEnd(\DateTime $end) /* : void */ { $this->end = $end; } @@ -301,7 +301,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMinute(array $minute, int $step = 0, bool $any = false) + public function setMinute(array $minute, int $step = 0, bool $any = false) /* : void */ { if ($this->validateTime($minute, $step, 0, 59)) { $this->hour = [ @@ -367,7 +367,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setHour(array $hour, int $step = 0, bool $any = false) + public function setHour(array $hour, int $step = 0, bool $any = false) /* : void */ { if ($this->validateTime($hour, $step, 0, 23)) { $this->hour = [ @@ -407,7 +407,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDayOfMonth(array $dayOfMonth, int $step = 0, bool $any = false, bool $last = false, int $nearest = 0) + public function setDayOfMonth(array $dayOfMonth, int $step = 0, bool $any = false, bool $last = false, int $nearest = 0) /* : void */ { if ($this->validateDayOfMonth($arr = [ 'dayOfMonth' => $dayOfMonth, @@ -477,7 +477,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setDayOfWeek(array $dayOfWeek, int $step = 0, bool $any = false, bool $last = false) + public function setDayOfWeek(array $dayOfWeek, int $step = 0, bool $any = false, bool $last = false) /* : void */ { if ($this->validateDayOfWeek($arr = [ 'dayOfWeek' => $dayOfWeek, @@ -542,7 +542,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setMonth(array $month, int $step = 0, bool $any = false) + public function setMonth(array $month, int $step = 0, bool $any = false) /* : void */ { if ($this->validateTime($month, $step, 1, 12)) { $this->month = [ @@ -580,7 +580,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setYear(array $year, int $step = 0, bool $any = false) + public function setYear(array $year, int $step = 0, bool $any = false) /* : void */ { if ($this->validateYear($arr = [ 'year' => $year, @@ -617,7 +617,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { $minute = $this->serializeTime($this->minute['minutes'], $this->minute['step']); $hour = $this->serializeTime($this->hour['hours'], $this->hour['step']); @@ -640,7 +640,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serializeTime($time, $step) + public function serializeTime($time, $step) /* : void */ { if (($count = count($time)) > 0) { $serialize = implode(',', $time); @@ -664,7 +664,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serializeDayOfMonth() + public function serializeDayOfMonth() /* : void */ { if (($count = count($this->dayOfMonth['dayOfMonth'])) > 0) { $serialize = implode(',', $this->dayOfMonth['dayOfMonth']); @@ -692,7 +692,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serializeDayOfWeek() + public function serializeDayOfWeek() /* : void */ { if (($count = count($this->dayOfWeek['dayOfWeek'])) > 0) { $serialize = implode(',', $this->dayOfWeek['dayOfWeek']); diff --git a/Utils/TaskSchedule/Schedule.php b/Utils/TaskSchedule/Schedule.php index 16664e121..5d211dd85 100644 --- a/Utils/TaskSchedule/Schedule.php +++ b/Utils/TaskSchedule/Schedule.php @@ -48,7 +48,7 @@ class Schedule extends TaskAbstract implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() + public function serialize() /* : void */ { // TODO: Implement serialize() method. } diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index bbd7f50a8..8b2dba090 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -67,7 +67,7 @@ abstract class SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function setBin(string $path) + public static function setBin(string $path) /* : void */ { if (realpath($path) === false) { throw new PathException($path); @@ -173,7 +173,7 @@ abstract class SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function set(TaskAbstract $task) + public function set(TaskAbstract $task) /* : void */ { $this->tasks[$task->getId()] = $task; } diff --git a/Utils/TaskSchedule/TaskAbstract.php b/Utils/TaskSchedule/TaskAbstract.php index 7f645d660..479dbaf8b 100644 --- a/Utils/TaskSchedule/TaskAbstract.php +++ b/Utils/TaskSchedule/TaskAbstract.php @@ -109,7 +109,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setCommand(string $command) + public function setCommand(string $command) /* : void */ { $this->command = $command; } @@ -137,7 +137,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setRun(string $run) + public function setRun(string $run) /* : void */ { $this->run = $run; } @@ -165,7 +165,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatus(string $status) + public function setStatus(string $status) /* : void */ { $this->status = $status; } @@ -193,7 +193,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setNextRunTime(\DateTime $nextRunTime) + public function setNextRunTime(\DateTime $nextRunTime) /* : void */ { $this->nextRuntime = $nextRunTime; } @@ -221,7 +221,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setLastRuntime(\DateTime $lastRunTime) + public function setLastRuntime(\DateTime $lastRunTime) /* : void */ { $this->lastRunTime = $lastRunTime; } @@ -249,7 +249,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStart(\DateTime $start) + public function setStart(\DateTime $start) /* : void */ { $this->start = $start; } @@ -277,7 +277,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setEnd(\DateTime $end) + public function setEnd(\DateTime $end) /* : void */ { $this->end = $end; } @@ -305,7 +305,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAuthor(string $author) + public function setAuthor(string $author) /* : void */ { $this->author = $author; } @@ -333,7 +333,7 @@ abstract class TaskAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setComment(string $comment) + public function setComment(string $comment) /* : void */ { $this->comment = $comment; } diff --git a/Validation/ModelValidationTrait.php b/Validation/ModelValidationTrait.php index 861e78a88..311a8fbb5 100644 --- a/Validation/ModelValidationTrait.php +++ b/Validation/ModelValidationTrait.php @@ -38,7 +38,7 @@ trait ModelValidationTrait * @since 1.0.0 * @author Dennis Eichhorn */ - public function setForce($var, $name) + public function setForce($var, $name) /* : void */ { if (!property_exists($this, $var)) { throw new \Exception('Unknown property.'); @@ -85,7 +85,7 @@ trait ModelValidationTrait * @since 1.0.0 * @author Dennis Eichhorn */ - protected function setValidation($var, $name) + protected function setValidation($var, $name) /* : void */ { /** @noinspection PhpUndefinedFieldInspection */ if (!isset(self::${$name . '_validate'}) || Validator::isValid($var, self::$validation[$name]) === true) { diff --git a/Views/View.php b/Views/View.php index d8fc1d380..c525f57f2 100644 --- a/Views/View.php +++ b/Views/View.php @@ -113,7 +113,7 @@ class View extends ViewAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function setData(string $id, $data) + public function setData(string $id, $data) /* : void */ { $this->data[$id] = $data; } diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 35b0af89f..e609e3f79 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -100,7 +100,7 @@ abstract class ViewAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function setTemplate(string $template) + public function setTemplate(string $template) /* : void */ { $this->template = $template; } @@ -203,7 +203,7 @@ abstract class ViewAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() + public function serialize() /* : void */ { if (empty($this->template)) { return $this->toArray(); From cbc6205bf78115c593f028aeed1bf6d2e63cfb8b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 3 Dec 2016 23:00:05 +0100 Subject: [PATCH 30/53] Type hint fixes/prep for null return type --- Asset/AssetManager.php | 2 +- Config/OptionsTrait.php | 2 +- DataStorage/Cookie/CookieJar.php | 10 ++++++--- DataStorage/Database/BuilderAbstract.php | 4 ++-- .../Connection/ConnectionAbstract.php | 2 +- .../Connection/ConnectionInterface.php | 4 ++-- .../Database/Connection/MysqlConnection.php | 2 +- .../Connection/SqlServerConnection.php | 2 +- DataStorage/Database/DataMapperAbstract.php | 6 ++--- DataStorage/Database/DatabasePool.php | 6 ++--- DataStorage/Database/Query/Builder.php | 4 ++-- DataStorage/Session/HttpSession.php | 2 +- DataStorage/Session/SessionInterface.php | 4 ++-- DataStorage/Session/SocketSession.php | 2 +- Datatypes/Iban.php | 4 ++-- Datatypes/Location.php | 2 +- Event/EventManager.php | 4 ++-- Localization/L11nManager.php | 8 +++---- Localization/Money.php | 2 +- Log/FileLogger.php | 22 +++++++++---------- Log/LoggerInterface.php | 18 +++++++-------- Math/Functions/Functions.php | 6 ++--- Math/Shape/D2/Ellipse.php | 4 ++-- Math/Shape/D2/Polygon.php | 4 ++-- Math/Shape/D3/Sphere.php | 8 +++---- Math/Statistic/Average.php | 10 ++++----- Message/HeaderAbstract.php | 4 ++-- Message/Http/Request.php | 14 ++++++------ Message/MessageInterface.php | 4 ++-- Message/RequestAbstract.php | 4 ++-- Model/Html/Head.php | 2 +- Module/ActivateAbstract.php | 6 ++--- Module/DeactivateAbstract.php | 6 ++--- Module/InfoManager.php | 4 ++-- Module/InstallerAbstract.php | 12 +++++----- Module/ModuleAbstract.php | 5 ++--- Module/ModuleFactory.php | 4 ++-- Module/ModuleManager.php | 18 ++++++++------- Module/UninstallAbstract.php | 2 +- Module/UpdateAbstract.php | 2 +- Pattern/Mediator.php | 8 +++---- Router/Router.php | 2 +- Socket/Packets/Header.php | 2 +- Stdlib/Map/MultiMap.php | 4 +++- Stdlib/Queue/PriorityQueue.php | 4 ++-- System/File/Local/Directory.php | 2 +- System/File/Local/File.php | 2 +- System/File/Local/FileAbstract.php | 2 +- System/File/StorageAbstract.php | 2 +- UnhandledHandler.php | 4 ++-- Uri/Http.php | 2 +- Uri/UriFactory.php | 8 +++---- Utils/ArrayUtils.php | 2 +- Utils/Converter/Currency.php | 2 +- Utils/Encoding/Huffman/Dictionary.php | 6 ++--- Utils/Encoding/Huffman/Huffman.php | 2 +- Utils/Git/Commit.php | 2 +- Utils/JsonBuilder.php | 6 ++--- Utils/Parser/Php/ClassParser.php | 18 +++++++-------- Utils/Parser/Php/FunctionParser.php | 8 +++---- Utils/RnG/DateTime.php | 2 +- Utils/RnG/Name.php | 2 +- Utils/RnG/Text.php | 10 ++++----- Utils/TaskSchedule/CronJob.php | 2 +- Utils/TaskSchedule/Interval.php | 2 +- Utils/TaskSchedule/Schedule.php | 2 +- Utils/TaskSchedule/SchedulerAbstract.php | 4 ++-- Utils/TaskSchedule/TaskScheduler.php | 2 +- Validation/Base/BIC.php | 2 +- Validation/Base/CreditCard.php | 2 +- Validation/Base/DateTime.php | 2 +- Validation/Base/Hostname.php | 2 +- Validation/Base/IP.php | 2 +- Validation/ModelValidationTrait.php | 2 +- Validation/Validator.php | 12 +++++----- Views/View.php | 8 +++---- Views/ViewAbstract.php | 4 ++-- 77 files changed, 194 insertions(+), 187 deletions(-) diff --git a/Asset/AssetManager.php b/Asset/AssetManager.php index c5108af37..92e9d6bbd 100644 --- a/Asset/AssetManager.php +++ b/Asset/AssetManager.php @@ -101,7 +101,7 @@ class AssetManager implements \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function get(string $id) + public function get(string $id) /* : ?string */ { if (isset($this->assets[$id])) { return $this->assets[$id]; diff --git a/Config/OptionsTrait.php b/Config/OptionsTrait.php index 0ecec2485..0a6fe85f0 100644 --- a/Config/OptionsTrait.php +++ b/Config/OptionsTrait.php @@ -36,7 +36,7 @@ trait OptionsTrait /** * {@inheritdoc} */ - public function exists($key) + public function exists($key) : bool { return isset($this->options[$key]); } diff --git a/DataStorage/Cookie/CookieJar.php b/DataStorage/Cookie/CookieJar.php index 958c17235..ff1c47e8d 100644 --- a/DataStorage/Cookie/CookieJar.php +++ b/DataStorage/Cookie/CookieJar.php @@ -63,7 +63,7 @@ class CookieJar * @since 1.0.0 * @author Dennis Eichhorn */ - public static function lock() + public static function lock() /* : void */ { self::$isLocked = true; } @@ -126,7 +126,7 @@ class CookieJar * @since 1.0.0 * @author Dennis Eichhorn */ - public function delete(string $id) + public function delete(string $id) /* : void */ { $this->remove($id); setcookie($id, '', time() - 3600); @@ -156,10 +156,14 @@ class CookieJar /** * Save cookie * + * @return void + * + * @throws LockException + * * @since 1.0.0 * @author Dennis Eichhorn */ - public function save() + public function save() /* : void */ { if (self::$isLocked) { throw new LockException('CookieJar'); diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 3e016245c..0aba6abd5 100644 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -68,12 +68,12 @@ abstract class BuilderAbstract * * @param string $prefix Prefix * - * @return $this + * @return BuilderAbstract * * @since 1.0.0 * @author Dennis Eichhorn */ - public function prefix(string $prefix) + public function prefix(string $prefix) : BuilderAbstract { $this->prefix = $prefix; diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index e49619dac..1c59d9f66 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -165,7 +165,7 @@ abstract class ConnectionAbstract implements ConnectionInterface /** * {@inheritdoc} */ - public function close() + public function close() /* : void */ { $this->con = null; $this->status = DatabaseStatus::CLOSED; diff --git a/DataStorage/Database/Connection/ConnectionInterface.php b/DataStorage/Database/Connection/ConnectionInterface.php index 935902421..2ab211839 100644 --- a/DataStorage/Database/Connection/ConnectionInterface.php +++ b/DataStorage/Database/Connection/ConnectionInterface.php @@ -44,7 +44,7 @@ interface ConnectionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function connect(array $dbdata); + public function connect(array $dbdata) /* : void */; /** * Get the database type. @@ -74,7 +74,7 @@ interface ConnectionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function close(); + public function close() /* : void */; /** * Return grammar for this connection. diff --git a/DataStorage/Database/Connection/MysqlConnection.php b/DataStorage/Database/Connection/MysqlConnection.php index 937b6b87a..9487afad7 100644 --- a/DataStorage/Database/Connection/MysqlConnection.php +++ b/DataStorage/Database/Connection/MysqlConnection.php @@ -58,7 +58,7 @@ class MysqlConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) + public function connect(array $dbdata = null) /* : void */ { $this->close(); diff --git a/DataStorage/Database/Connection/SqlServerConnection.php b/DataStorage/Database/Connection/SqlServerConnection.php index b8779b650..5c7a22f82 100644 --- a/DataStorage/Database/Connection/SqlServerConnection.php +++ b/DataStorage/Database/Connection/SqlServerConnection.php @@ -57,7 +57,7 @@ class SqlServerConnection extends ConnectionAbstract /** * {@inheritdoc} */ - public function connect(array $dbdata = null) + public function connect(array $dbdata = null) /* : void */ { $this->close(); diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index c2af1d607..c08cd14df 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -216,7 +216,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private static function extend($class) + private static function extend($class) /* : void */ { /* todo: have to implement this in the queries, so far not used */ self::$collection['primaryField'][] = $class::$primaryField; @@ -264,7 +264,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function with(...$objects) + public static function with(...$objects) /* : void */ { // todo: how to handle with of parent objects/extends/relations @@ -283,7 +283,7 @@ class DataMapperAbstract implements DataMapperInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function clear() + public static function clear() /* : void */ { self::$overwrite = true; self::$primaryField = ''; diff --git a/DataStorage/Database/DatabasePool.php b/DataStorage/Database/DatabasePool.php index ca9a19b7b..67e68d932 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -78,15 +78,15 @@ class DatabasePool * * @param mixed $key Database key * - * @return ConnectionAbstract|false + * @return ConnectionAbstract|null * * @since 1.0.0 * @author Dennis Eichhorn */ - public function get(string $key = 'core') + public function get(string $key = 'core') /* : ?ConnectionAbstract */ { if (!isset($this->pool[$key])) { - return false; /* todo: return nullconnection */ + return null; /* todo: return nullconnection */ } return $this->pool[$key]; diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 35147355b..2ed7e587e 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -481,7 +481,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function andWhere(Where $where) + public function andWhere(Where $where) : Builder { $this->wheres[][] = [ 'column' => $where, @@ -501,7 +501,7 @@ class Builder extends BuilderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function orWhere(Where $where) + public function orWhere(Where $where) : Builder { $this->wheres[][] = [ 'column' => $where, diff --git a/DataStorage/Session/HttpSession.php b/DataStorage/Session/HttpSession.php index 2bc104b2d..29875f5be 100644 --- a/DataStorage/Session/HttpSession.php +++ b/DataStorage/Session/HttpSession.php @@ -154,7 +154,7 @@ class HttpSession implements SessionInterface /** * {@inheritdoc} */ - public function save() + public function save() /* : void */ { if(!self::$isLocked) { $_SESSION = $this->sessionData; diff --git a/DataStorage/Session/SessionInterface.php b/DataStorage/Session/SessionInterface.php index 77a03f195..2f0a43868 100644 --- a/DataStorage/Session/SessionInterface.php +++ b/DataStorage/Session/SessionInterface.php @@ -79,7 +79,7 @@ interface SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function save(); + public function save() /* : void */; /** * @return int|string @@ -97,6 +97,6 @@ interface SessionInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setSID($sid); + public function setSID($sid) /* : void */; } diff --git a/DataStorage/Session/SocketSession.php b/DataStorage/Session/SocketSession.php index 462857ebd..a956edd18 100644 --- a/DataStorage/Session/SocketSession.php +++ b/DataStorage/Session/SocketSession.php @@ -92,7 +92,7 @@ class SocketSession implements SessionInterface /** * {@inheritdoc} */ - public function save() + public function save() /* : void */ { } diff --git a/Datatypes/Iban.php b/Datatypes/Iban.php index 484683d2d..c395f4c3c 100644 --- a/Datatypes/Iban.php +++ b/Datatypes/Iban.php @@ -63,7 +63,7 @@ class Iban implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - private function parse(string $iban) + private function parse(string $iban) /* : void */ { $this->iban = self::normalize($iban); @@ -276,7 +276,7 @@ class Iban implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() /* : void */ + public function serialize() { return $this->prettyPrint(); } diff --git a/Datatypes/Location.php b/Datatypes/Location.php index d20399da6..af42b8c72 100644 --- a/Datatypes/Location.php +++ b/Datatypes/Location.php @@ -237,7 +237,7 @@ class Location implements \JsonSerializable, \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() /* : void */ + public function serialize() { return $this->jsonSerialize(); } diff --git a/Event/EventManager.php b/Event/EventManager.php index be7446beb..b970dca52 100644 --- a/Event/EventManager.php +++ b/Event/EventManager.php @@ -75,7 +75,7 @@ class EventManager implements Mediator /** * {@inheritdoc} */ - public function trigger(string $group, string $id = '') + public function trigger(string $group, string $id = '') /* : void */ { if (isset($this->groups[$group])) { unset($this->groups[$group][$id]); @@ -117,7 +117,7 @@ class EventManager implements Mediator /** * {@inheritdoc} */ - public function addGroup(string $group, string $id) + public function addGroup(string $group, string $id) /* : void */ { if (!isset($this->groups[$group])) { $this->groups[$group] = []; diff --git a/Localization/L11nManager.php b/Localization/L11nManager.php index ac2cb1cc2..9ae1bd211 100644 --- a/Localization/L11nManager.php +++ b/Localization/L11nManager.php @@ -94,7 +94,7 @@ class L11nManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function loadLanguage(string $language, string $from, array $translation) + public function loadLanguage(string $language, string $from, array $translation) /* : void */ { if (!isset($translation[$from])) { throw new \Exception('Unexpected language key: ' . $from); @@ -123,7 +123,7 @@ class L11nManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function loadLanguageFromFile(string $language, string $from, string $file) + public function loadLanguageFromFile(string $language, string $from, string $file) /* : void */ { $lang = []; if (file_exists(file)) { @@ -164,12 +164,12 @@ class L11nManager * @param string $theme Theme * @param string $translation Text * - * @return array + * @return string * * @since 1.0.0 * @author Dennis Eichhorn */ - public function getText(string $code, string $module, string $theme, string $translation) + public function getText(string $code, string $module, string $theme, string $translation) : string { if (!isset($this->language[$code][$module][$translation])) { /** @var ModuleAbstract $class */ diff --git a/Localization/Money.php b/Localization/Money.php index 7e4cfb5f9..bd0a5fb7a 100644 --- a/Localization/Money.php +++ b/Localization/Money.php @@ -345,7 +345,7 @@ class Money implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { return $this->getInt(); } diff --git a/Log/FileLogger.php b/Log/FileLogger.php index deb278542..7d5b976f2 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -127,7 +127,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private function createFile() + private function createFile() /* : void */ { if (!$this->created && !file_exists($this->path)) { File::create($this->path); @@ -306,7 +306,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - private function write(string $message) + private function write(string $message) /* : void */ { $this->createFile(); $this->fp = fopen($this->path, 'a'); @@ -335,7 +335,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function emergency(string $message, array $context = []) + public function emergency(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::EMERGENCY); $this->write($message); @@ -355,7 +355,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function alert(string $message, array $context = []) + public function alert(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::ALERT); $this->write($message); @@ -374,7 +374,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function critical(string $message, array $context = []) + public function critical(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::CRITICAL); $this->write($message); @@ -392,7 +392,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function error(string $message, array $context = []) + public function error(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::ERROR); $this->write($message); @@ -412,7 +412,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function warning(string $message, array $context = []) + public function warning(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::WARNING); $this->write($message); @@ -429,7 +429,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function notice(string $message, array $context = []) + public function notice(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::NOTICE); $this->write($message); @@ -448,7 +448,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function info(string $message, array $context = []) + public function info(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::INFO); $this->write($message); @@ -465,7 +465,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function debug(string $message, array $context = []) + public function debug(string $message, array $context = []) /* : void */ { $message = $this->interpolate($message, $context, LogLevel::DEBUG); $this->write($message); @@ -483,7 +483,7 @@ class FileLogger implements LoggerInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function log(string $level, string $message, array $context = []) + public function log(string $level, string $message, array $context = []) /* : void */ { if (!LogLevel::isValidValue($level)) { throw new InvalidEnumValue($level); diff --git a/Log/LoggerInterface.php b/Log/LoggerInterface.php index 01ac8761a..c2ef56e71 100644 --- a/Log/LoggerInterface.php +++ b/Log/LoggerInterface.php @@ -37,7 +37,7 @@ interface LoggerInterface * * @return null */ - public function emergency(string $message, array $context = []); + public function emergency(string $message, array $context = []) /* : void */; /** * Action must be taken immediately. @@ -50,7 +50,7 @@ interface LoggerInterface * * @return null */ - public function alert(string $message, array $context = []); + public function alert(string $message, array $context = []) /* : void */; /** * Critical conditions. @@ -62,7 +62,7 @@ interface LoggerInterface * * @return null */ - public function critical(string $message, array $context = []); + public function critical(string $message, array $context = []) /* : void */; /** * Runtime errors that do not require immediate action but should typically @@ -73,7 +73,7 @@ interface LoggerInterface * * @return null */ - public function error(string $message, array $context = []); + public function error(string $message, array $context = []) /* : void */; /** * Exceptional occurrences that are not errors. @@ -86,7 +86,7 @@ interface LoggerInterface * * @return null */ - public function warning(string $message, array $context = []); + public function warning(string $message, array $context = []) /* : void */; /** * Normal but significant events. @@ -96,7 +96,7 @@ interface LoggerInterface * * @return null */ - public function notice(string $message, array $context = []); + public function notice(string $message, array $context = []) /* : void */; /** * Interesting events. @@ -108,7 +108,7 @@ interface LoggerInterface * * @return null */ - public function info(string $message, array $context = []); + public function info(string $message, array $context = []) /* : void */; /** * Detailed debug information. @@ -118,7 +118,7 @@ interface LoggerInterface * * @return null */ - public function debug(string $message, array $context = []); + public function debug(string $message, array $context = []) /* : void */; /** * Logs with an arbitrary level. @@ -129,5 +129,5 @@ interface LoggerInterface * * @return null */ - public function log(string $level, string $message, array $context = []); + public function log(string $level, string $message, array $context = []) /* : void */; } diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index 5ea36b9fd..9c5e5c195 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -170,7 +170,7 @@ class Functions * @since 1.0.0 * @author Dennis Eichhorn */ - public static function invMod(int $a, int $n) + public static function invMod(int $a, int $n) : int { if ($n < 0) { $n = -$n; @@ -217,7 +217,7 @@ class Functions * @since 1.0.0 * @author Dennis Eichhorn */ - public static function mod($a, $b) + public static function mod($a, $b) : int { if ($a < 0) { return ($a + $b) % $b; @@ -277,7 +277,7 @@ class Functions * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getRelativeDegree($value, $length, $start = 0) + public static function getRelativeDegree($value, $length, $start = 0) : int { return abs(self::mod($value - $start, $length)); } diff --git a/Math/Shape/D2/Ellipse.php b/Math/Shape/D2/Ellipse.php index e7583011d..5ac9b28dd 100644 --- a/Math/Shape/D2/Ellipse.php +++ b/Math/Shape/D2/Ellipse.php @@ -45,7 +45,7 @@ class Ellipse implements D2ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getSurface(float $a, float $b) + public static function getSurface(float $a, float $b) : float { return pi() * $a * $b; } @@ -66,7 +66,7 @@ class Ellipse implements D2ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getPerimeter(float $a, float $b) + public static function getPerimeter(float $a, float $b) : float { return pi() * ($a + $b) * (3 * ($a - $b) ** 2 / (($a + $b) ** 2 * (sqrt(-3 * ($a - $b) ** 2 / (($a + $b) ** 2) + 4) + 10)) + 1); } diff --git a/Math/Shape/D2/Polygon.php b/Math/Shape/D2/Polygon.php index 4949aad4c..9cb6e4453 100644 --- a/Math/Shape/D2/Polygon.php +++ b/Math/Shape/D2/Polygon.php @@ -288,7 +288,7 @@ class Polygon implements D2ShapeInterface /** * {@inheritdoc} */ - public function reset() + public function reset() /* : void */ { $this->coord = []; $this->barycenter = ['x' => 0.0, 'y' => 0.0]; @@ -311,7 +311,7 @@ class Polygon implements D2ShapeInterface /** * {@inheritdoc} */ - public function getPerimeter() + public function getPerimeter() : float { $count = count($this->coord); $this->perimeter = sqrt(($this->coord[0]['x'] - $this->coord[$count - 1]['x']) ** 2 + ($this->coord[0]['y'] - $this->coord[$count - 1]['y']) ** 2); diff --git a/Math/Shape/D3/Sphere.php b/Math/Shape/D3/Sphere.php index 18711b2b0..7c05d3633 100644 --- a/Math/Shape/D3/Sphere.php +++ b/Math/Shape/D3/Sphere.php @@ -88,7 +88,7 @@ class Sphere implements D3ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getRadiusByVolume(float $V) + public static function getRadiusByVolume(float $V) : float { return pow($V * 3 / (4 * pi()), 1 / 3); } @@ -108,7 +108,7 @@ class Sphere implements D3ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getRadiusBySurface(float $S) + public static function getRadiusBySurface(float $S) : float { return sqrt($S / (4 * pi())); } @@ -128,7 +128,7 @@ class Sphere implements D3ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getVolumeByRadius(float $r) + public static function getVolumeByRadius(float $r) : float { return 4 / 3 * pi() * $r ** 3; } @@ -153,7 +153,7 @@ class Sphere implements D3ShapeInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getSurfaceByRadius(float $r) + public static function getSurfaceByRadius(float $r) : float { return 4 * pi() * $r ** 2; } diff --git a/Math/Statistic/Average.php b/Math/Statistic/Average.php index e52dfeb94..b003dc352 100644 --- a/Math/Statistic/Average.php +++ b/Math/Statistic/Average.php @@ -158,7 +158,7 @@ class Average * @since 1.0.0 * @author Dennis Eichhorn */ - public static function arithmeticMean(array $values) + public static function arithmeticMean(array $values) : float { $count = count($values); @@ -233,7 +233,7 @@ class Average * @since 1.0.0 * @author Dennis Eichhorn */ - public static function geometricMean(array $values, int $offset = 0) + public static function geometricMean(array $values, int $offset = 0) : float { $count = count($values); @@ -259,7 +259,7 @@ class Average * @since 1.0.0 * @author Dennis Eichhorn */ - public static function harmonicMean(array $values, int $offset = 0) + public static function harmonicMean(array $values, int $offset = 0) : float { sort($values); @@ -294,7 +294,7 @@ class Average * @since 1.0.0 * @author Dennis Eichhorn */ - public static function angleMean($angles, int $offset = 0) + public static function angleMean($angles, int $offset = 0) : float { $y = $x = 0; $size = count($angles); @@ -371,7 +371,7 @@ class Average * @since 1.0.0 * @author Dennis Eichhorn */ - public static function angleMean2(array $angles, int $offset = 0) + public static function angleMean2(array $angles, int $offset = 0) : float { sort($angles); diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index 650206aab..f16233686 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -59,7 +59,7 @@ abstract class HeaderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - abstract public function generate(string $statusCode); + abstract public function generate(string $statusCode) /* : void */; /** * Get header by key. @@ -91,7 +91,7 @@ abstract class HeaderAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function lock() + public static function lock() /* : void */ { // todo: maybe pass session as member and make lock not static self::$isLocked = true; diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 310a3b487..75ffee681 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -106,7 +106,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function init($uri = null) + public function init($uri = null) /* : void */ { if (!isset($uri)) { $this->initCurrentRequest(); @@ -135,7 +135,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private function initCurrentRequest() + private function initCurrentRequest() /* : void */ { $this->data = $_GET ?? []; $this->files = $_FILES ?? []; @@ -166,7 +166,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private function initPseudoRequest($uri) + private function initPseudoRequest($uri) /* : void */ { $this->setMethod($uri['type']); $this->uri->set($uri['uri']); @@ -180,7 +180,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private function cleanupGlobals() + private function cleanupGlobals() /* : void */ { unset($_FILES); unset($_GET); @@ -224,7 +224,7 @@ class Request extends RequestAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private function createRequestHashs() + private function createRequestHashs() /* : void */ { $this->hash = []; foreach ($this->path as $key => $path) { @@ -312,12 +312,12 @@ class Request extends RequestAbstract /** * Determine request OS. * - * @return OSType + * @return string * * @since 1.0.0 * @author Dennis Eichhorn */ - public function getOS() : OSType + public function getOS() : string { if (!isset($this->os)) { $arr = OSType::getConstants(); diff --git a/Message/MessageInterface.php b/Message/MessageInterface.php index ff64bb3b0..57585e026 100644 --- a/Message/MessageInterface.php +++ b/Message/MessageInterface.php @@ -67,7 +67,7 @@ interface MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setStatusCode(string $status); + public function setStatusCode(string $status) /* : void */; /** * Get status code. @@ -99,5 +99,5 @@ interface MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function setAccount(int $account); + public function setAccount(int $account) /* : void */; } diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index dd72bb544..b8496cf24 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -227,7 +227,7 @@ abstract class RequestAbstract implements MessageInterface /** * {@inheritdoc} */ - public function getPath($key = null) + public function getPath($key = null) /* : ?string */ { if ($key === null) { return $this->path; @@ -316,7 +316,7 @@ abstract class RequestAbstract implements MessageInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function lock() + public function lock() /* : void */ { $this->lock = true; } diff --git a/Model/Html/Head.php b/Model/Html/Head.php index c9b52190c..497b69b46 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -154,7 +154,7 @@ class Head implements RenderableInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public function addAsset(string $type, string $uri) + public function addAsset(string $type, string $uri) /* : void */ { $this->assets[$uri] = $type; } diff --git a/Module/ActivateAbstract.php b/Module/ActivateAbstract.php index aa9675124..9fddaff36 100644 --- a/Module/ActivateAbstract.php +++ b/Module/ActivateAbstract.php @@ -43,7 +43,7 @@ class ActivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function activate(DatabasePool $dbPool, InfoManager $info) + public static function activate(DatabasePool $dbPool, InfoManager $info) /* : void */ { self::activateRoutes(ROOT_PATH . '/Web/Routes.php', ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes/http.php'); self::activateInDatabase($dbPool, $info); @@ -60,7 +60,7 @@ class ActivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private static function activateRoutes(string $destRoutePath, string $srcRoutePath) + private static function activateRoutes(string $destRoutePath, string $srcRoutePath) /* : void */ { // todo: remove route } @@ -76,7 +76,7 @@ class ActivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function activateInDatabase(DatabasePool $dbPool, InfoManager $info) + public static function activateInDatabase(DatabasePool $dbPool, InfoManager $info) /* : void */ { switch ($dbPool->get()->getType()) { case DatabaseType::MYSQL: diff --git a/Module/DeactivateAbstract.php b/Module/DeactivateAbstract.php index 9fa0c0c71..ae4bdf904 100644 --- a/Module/DeactivateAbstract.php +++ b/Module/DeactivateAbstract.php @@ -43,7 +43,7 @@ class DeactivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function deactivate(DatabasePool $dbPool, InfoManager $info) + public static function deactivate(DatabasePool $dbPool, InfoManager $info) /* : void */ { self::deactivateRoutes(ROOT_PATH . '/Web/Routes.php', ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes/http.php'); self::deactivateInDatabase($dbPool, $info); @@ -60,7 +60,7 @@ class DeactivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private static function deactivateRoutes(string $destRoutePath, string $srcRoutePath) + private static function deactivateRoutes(string $destRoutePath, string $srcRoutePath) /* : void */ { // todo: remove route } @@ -76,7 +76,7 @@ class DeactivateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function deactivateInDatabase(DatabasePool $dbPool, InfoManager $info) + public static function deactivateInDatabase(DatabasePool $dbPool, InfoManager $info) /* : void */ { switch ($dbPool->get()->getType()) { case DatabaseType::MYSQL: diff --git a/Module/InfoManager.php b/Module/InfoManager.php index f7929f4c7..83b083f07 100644 --- a/Module/InfoManager.php +++ b/Module/InfoManager.php @@ -71,7 +71,7 @@ class InfoManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function load() + public function load() /* : void */ { if (!file_exists($this->path)) { throw new PathException($this->path); @@ -88,7 +88,7 @@ class InfoManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function update() + public function update() /* : void */ { file_put_contents($this->path, json_encode($this->info, JSON_PRETTY_PRINT)); } diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 922349482..d2fc22ab9 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -46,7 +46,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function registerInDatabase(DatabasePool $dbPool, InfoManager $info) + public static function registerInDatabase(DatabasePool $dbPool, InfoManager $info) /* : void */ { switch ($dbPool->get()->getType()) { case DatabaseType::MYSQL: @@ -99,7 +99,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function install(string $routePath, DatabasePool $dbPool, InfoManager $info) + public static function install(string $routePath, DatabasePool $dbPool, InfoManager $info) /* : void */ { self::registerInDatabase($dbPool, $info); self::initRoutes($routePath, $info); @@ -117,7 +117,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private static function activate(DatabasePool $dbPool, InfoManager $info) + private static function activate(DatabasePool $dbPool, InfoManager $info) /* : void */ { /** @var ActivateAbstract $class */ $class = '\Modules\\' . $info->getDirectory() . '\Admin\Activate'; @@ -135,7 +135,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function reInit(string $routePath, InfoManager $info) + public static function reInit(string $routePath, InfoManager $info) /* : void */ { self::initRoutes($routePath, $info); } @@ -153,7 +153,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private static function initRoutes(string $routePath, InfoManager $info) + private static function initRoutes(string $routePath, InfoManager $info) /* : void */ { // todo: maybe use static::__DIR__ ? $directories = new Directory(ROOT_PATH . '/Modules/' . $info->getDirectory() . '/Admin/Routes'); @@ -180,7 +180,7 @@ class InstallerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - private static function installRoutes(string $destRoutePath, string $srcRoutePath) + private static function installRoutes(string $destRoutePath, string $srcRoutePath) /* : void */ { if (!file_exists($destRoutePath)) { file_put_contents($destRoutePath, ' */ - public static function installExternal() + public static function installExternal() /* : void */ { - return false; } /** @@ -135,7 +134,7 @@ abstract class ModuleAbstract /** * {@inheritdoc} */ - public function addReceiving(string $module) + public function addReceiving(string $module) /* : void */ { $this->receiving[] = $module; } diff --git a/Module/ModuleFactory.php b/Module/ModuleFactory.php index a63294078..783063bdd 100644 --- a/Module/ModuleFactory.php +++ b/Module/ModuleFactory.php @@ -103,7 +103,7 @@ class ModuleFactory * @since 1.0.0 * @author Dennis Eichhorn */ - private static function registerRequesting(ModuleAbstract $obj) + private static function registerRequesting(ModuleAbstract $obj) /* : void */ { foreach ($obj->getProviding() as $providing) { if (isset(self::$loaded[$providing])) { @@ -122,7 +122,7 @@ class ModuleFactory * @since 1.0.0 * @author Dennis Eichhorn */ - private static function registerProvided(ModuleAbstract $obj) + private static function registerProvided(ModuleAbstract $obj) /* : void */ { $name = $obj->getName(); if (isset(self::$providing[$name])) { diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index f3ad39463..d16dfae30 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -433,7 +433,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - private function installDependencies(array $dependencies) + private function installDependencies(array $dependencies) /* : void */ { foreach ($dependencies as $key => $version) { $this->install($key); @@ -452,7 +452,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - private function installModule(InfoManager $info) + private function installModule(InfoManager $info) /* : void */ { /** @var $class InstallerAbstract */ $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Installer'; @@ -476,7 +476,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - private function deactivateModule(InfoManager $info) + private function deactivateModule(InfoManager $info) /* : void */ { $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Deactivate'; @@ -500,7 +500,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - private function activateModule(InfoManager $info) + private function activateModule(InfoManager $info) /* : void */ { $class = '\\Modules\\' . $info->getDirectory() . '\\Admin\\Deactivate'; @@ -572,7 +572,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function installProviding(string $from, string $for) + public function installProviding(string $from, string $for) /* : void */ { if (file_exists(self::MODULE_PATH . '/' . $from . '/Admin/Install/' . $for . '.php')) { $class = '\\Modules\\' . $from . '\\Admin\\Install\\' . $for; @@ -586,12 +586,14 @@ class ModuleManager * * @param string|array $modules Module name * + * @return void + * * @throws \InvalidArgumentException * * @since 1.0.0 * @author Dennis Eichhorn */ - public function initModule($modules) + public function initModule($modules) /* : void */ { $modules = (array) $modules; @@ -618,7 +620,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - private function initModuleController(string $module) + private function initModuleController(string $module) /* : void */ { try { $this->running[$module] = ModuleFactory::getInstance($module, $this->app); @@ -640,7 +642,7 @@ class ModuleManager * @since 1.0.0 * @author Dennis Eichhorn */ - public function get(string $module) + public function get(string $module) : ModuleAbstract { try { if (!isset($this->running[$module])) { diff --git a/Module/UninstallAbstract.php b/Module/UninstallAbstract.php index b80667e3d..9162b6774 100644 --- a/Module/UninstallAbstract.php +++ b/Module/UninstallAbstract.php @@ -42,7 +42,7 @@ class UninstallAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function uninstall(DatabasePool $dbPool, InfoManager $info) + public static function uninstall(DatabasePool $dbPool, InfoManager $info) /* : void */ { } diff --git a/Module/UpdateAbstract.php b/Module/UpdateAbstract.php index 6c43b7b83..3b93e90b3 100644 --- a/Module/UpdateAbstract.php +++ b/Module/UpdateAbstract.php @@ -42,7 +42,7 @@ class UpdateAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function update(DatabasePool $dbPool, InfoManager $info) + public static function update(DatabasePool $dbPool, InfoManager $info) /* : void */ { } } diff --git a/Pattern/Mediator.php b/Pattern/Mediator.php index 39c5e6f4b..f291f7f07 100644 --- a/Pattern/Mediator.php +++ b/Pattern/Mediator.php @@ -38,12 +38,12 @@ interface Mediator extends \Countable * @param \Closure $callback Function to call if the event gets triggered * @param bool $remove Remove event after execution * - * @return void + * @return bool * * @since 1.0.0 * @author Dennis Eichhorn */ - public function attach(string $group, \Closure $callback, bool $remove = false); + public function attach(string $group, \Closure $callback, bool $remove = false) : bool; /** * Removing a event. @@ -70,7 +70,7 @@ interface Mediator extends \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function addGroup(string $group, string $id); + public function addGroup(string $group, string $id) /* : void */; /** * Trigger event. @@ -85,5 +85,5 @@ interface Mediator extends \Countable * @since 1.0.0 * @author Dennis Eichhorn */ - public function trigger(string $group, string $id); + public function trigger(string $group, string $id) /* : void */; } diff --git a/Router/Router.php b/Router/Router.php index 161581ebc..b429c8c80 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -83,7 +83,7 @@ class Router * @since 1.0.0 * @author Dennis Eichhorn */ - public function add(string $route, $destination, int $verb = RouteVerb::GET) + public function add(string $route, $destination, int $verb = RouteVerb::GET) /* : void */ { if (!isset($this->routes[$route])) { $this->routes[$route] = []; diff --git a/Socket/Packets/Header.php b/Socket/Packets/Header.php index b676689f9..f9d5a7461 100644 --- a/Socket/Packets/Header.php +++ b/Socket/Packets/Header.php @@ -158,7 +158,7 @@ class Header implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { return $this->__toString(); } diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index f1d3b3b96..46e0200fd 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -121,10 +121,12 @@ class MultiMap implements \Countable /** * Garbage collect unreferenced values/keys * + * @return void + * * @since 1.0.0 * @author Dennis Eichhorn */ - private function garbageCollect() + private function garbageCollect() /* : void */ { /* garbage collect keys */ foreach ($this->keys as $key => $keyValue) { diff --git a/Stdlib/Queue/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php index f13021398..b924a9d22 100644 --- a/Stdlib/Queue/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -102,7 +102,7 @@ class PriorityQueue implements \Countable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function increaseAll(float $increase = 0.1) + public function increaseAll(float $increase = 0.1) /* : void */ { foreach ($this->queue as $key => &$ele) { $ele['priority'] += $increase; @@ -132,7 +132,7 @@ class PriorityQueue implements \Countable, \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function delete(int $id = null) + public function delete(int $id = null) /* : void */ { if ($id === null) { $this->remove(); diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 65d116a8d..b9732c1a0 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -73,7 +73,7 @@ class Directory extends FileAbstract implements DirectoryInterface /** * {@inheritdoc} */ - public function index() + public function index() /* : void */ { parent::index(); diff --git a/System/File/Local/File.php b/System/File/Local/File.php index 62d0199fa..b21a26501 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -57,7 +57,7 @@ class File extends FileAbstract implements FileInterface /** * {@inheritdoc} */ - public function index() + public function index() /* : void */ { parent::index(); diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 7fdcf2f7a..b52bc6105 100644 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -187,7 +187,7 @@ abstract class FileAbstract implements ContainerInterface /** * {@inheritdoc} */ - public function index() + public function index() /* : void */ { $this->createdAt->setTimestamp(filemtime($this->path)); $this->changedAt->setTimestamp(filectime($this->path)); diff --git a/System/File/StorageAbstract.php b/System/File/StorageAbstract.php index f5a8b4274..03dd15c33 100644 --- a/System/File/StorageAbstract.php +++ b/System/File/StorageAbstract.php @@ -64,7 +64,7 @@ abstract class StorageAbstract implements DirectoryInterface, FileInterface * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getInstance() + public static function getInstance() : StorageAbstract { if(!isset(static::$instance)) { static::$instance = new static(); diff --git a/UnhandledHandler.php b/UnhandledHandler.php index ae3a77f08..d695d5464 100644 --- a/UnhandledHandler.php +++ b/UnhandledHandler.php @@ -37,7 +37,7 @@ final class UnhandledHandler * @since 1.0.0 * @author Dennis Eichhorn */ - public static function exceptionHandler($e) + public static function exceptionHandler($e) /* : void */ { $logger = FileLogger::getInstance(ROOT_PATH . '/Logs'); $logger->critical(FileLogger::MSG_FULL, [ @@ -109,7 +109,7 @@ final class UnhandledHandler * @since 1.0.0 * @author Dennis Eichhorn */ - public static function shutdownHandler() + public static function shutdownHandler() /* : void */ { $e = error_get_last(); diff --git a/Uri/Http.php b/Uri/Http.php index 3725c43c2..6c92721f9 100644 --- a/Uri/Http.php +++ b/Uri/Http.php @@ -280,7 +280,7 @@ class Http implements UriInterface /** * {@inheritdoc} */ - public function getQuery(string $key = null) + public function getQuery(string $key = null) /* : ?string */ { return isset($key) ? $this->query[$key] ?? null : $this->queryString ?? ''; } diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 9e2d70d7d..04db9dcd9 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -54,14 +54,14 @@ class UriFactory * * @param string $key Replacement key * - * @return false|string + * @return null|string * * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getQuery(string $key) + public static function getQuery(string $key) /* : ?string */ { - return self::$uri[$key] ?? false; + return self::$uri[$key] ?? null; } /** @@ -181,7 +181,7 @@ class UriFactory * @since 1.0.0 * @author Dennis Eichhorn */ - public static function build(string $uri, array $toMatch = []) + public static function build(string $uri, array $toMatch = []) /* : ?string */ { $parsed = preg_replace_callback('(\{[\/#\?@\.\$][a-zA-Z0-9\-]*\})', function ($match) use ($toMatch) { $match = substr($match[0], 1, strlen($match[0]) - 2); diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 20fceefa0..b64d09181 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -237,7 +237,7 @@ class ArrayUtils * @since 1.0.0 * @author Dennis Eichhorn */ - public static function getArg(string $id, array $args) + public static function getArg(string $id, array $args) /* : ?string */ { if (($key = array_search($id, $args)) === false || $key === count($args) - 1) { return null; diff --git a/Utils/Converter/Currency.php b/Utils/Converter/Currency.php index 3cce7aaf7..c5f6b7a96 100644 --- a/Utils/Converter/Currency.php +++ b/Utils/Converter/Currency.php @@ -55,7 +55,7 @@ class Currency * @since 1.0.0 * @author Dennis Eichhorn */ - public static function resetCurrencies() + public static function resetCurrencies() /* : void */ { self::$ecbCurrencies = null; } diff --git a/Utils/Encoding/Huffman/Dictionary.php b/Utils/Encoding/Huffman/Dictionary.php index 3304f80c6..480c582bb 100644 --- a/Utils/Encoding/Huffman/Dictionary.php +++ b/Utils/Encoding/Huffman/Dictionary.php @@ -77,7 +77,7 @@ final class Dictionary * @since 1.0.0 * @author Dennis Eichhorn */ - public function generate(string $source) + public function generate(string $source) /* : void */ { $this->dictionary = []; $this->min = -1; @@ -113,7 +113,7 @@ final class Dictionary * @since 1.0.0 * @author Dennis Eichhorn */ - private function fill(string $entry, string $value = '') + private function fill(string $entry, string $value = '') /* : void */ { if (!is_array($entry[0][1])) { $this->set($entry[0][1], $value . '0'); @@ -205,7 +205,7 @@ final class Dictionary * @since 1.0.0 * @author Dennis Eichhorn */ - public function getEntry(&$value) + public function getEntry(&$value) /* : ?string */ { $length = strlen($value); if ($length < $this->min) { diff --git a/Utils/Encoding/Huffman/Huffman.php b/Utils/Encoding/Huffman/Huffman.php index 4166a000d..e455cbd87 100644 --- a/Utils/Encoding/Huffman/Huffman.php +++ b/Utils/Encoding/Huffman/Huffman.php @@ -42,7 +42,7 @@ final class Huffman * @since 1.0.0 * @author Dennis Eichhorn */ - public function removeDictionary() + public function removeDictionary() /* : void */ { $this->dictionary = null; } diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index 6d17fdb08..291592ef5 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -347,7 +347,7 @@ class Commit * @since 1.0.0 * @author Dennis Eichhorn */ - private function addChange(string $path, int $line, string $old, string $new) + private function addChange(string $path, int $line, string $old, string $new) /* : void */ { if (!isset($this->files[$path])) { throw new \Exception(); diff --git a/Utils/JsonBuilder.php b/Utils/JsonBuilder.php index 5f438cead..6f597cd62 100644 --- a/Utils/JsonBuilder.php +++ b/Utils/JsonBuilder.php @@ -72,7 +72,7 @@ class JsonBuilder implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function add(string $path, $value, bool $overwrite = true) + public function add(string $path, $value, bool $overwrite = true) /* : void */ { $this->json = ArrayUtils::setArray($path, $this->json, $value, '/', $overwrite); } @@ -87,7 +87,7 @@ class JsonBuilder implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function remove(string $path) + public function remove(string $path) /* : void */ { $this->json = ArrayUtils::unsetArray($path, $this->json, '/'); } @@ -98,7 +98,7 @@ class JsonBuilder implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() /* : void */ + public function serialize() { return json_encode($this->json); } diff --git a/Utils/Parser/Php/ClassParser.php b/Utils/Parser/Php/ClassParser.php index 2b504a66f..e66497b27 100644 --- a/Utils/Parser/Php/ClassParser.php +++ b/Utils/Parser/Php/ClassParser.php @@ -152,7 +152,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function createFile(string $path) + public function createFile(string $path) /* : void */ { // todo: implement } @@ -279,7 +279,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function removeExtends() + public function removeExtends() /* : void */ { $this->extends = ''; } @@ -320,7 +320,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function removeNamespace() + public function removeNamespace() /* : void */ { $this->namespace = ''; } @@ -336,7 +336,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addUse(string $namespace, string $as = null) + public function addUse(string $namespace, string $as = null) /* : void */ { if (isset($as)) { $this->use[$as] = $namespace; @@ -404,7 +404,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addImplements(string $implements) + public function addImplements(string $implements) /* : void */ { $this->implements[] = $implements; @@ -421,7 +421,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addInclude(string $include) + public function addInclude(string $include) /* : void */ { $this->includes[] = $include; @@ -438,7 +438,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addRequire(string $require) + public function addRequire(string $require) /* : void */ { $this->requires[] = $require; @@ -456,7 +456,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addTrait(string $trait, string $as = null) + public function addTrait(string $trait, string $as = null) /* : void */ { if (isset($as)) { $this->traits[$as] = $trait; @@ -496,7 +496,7 @@ class ClassParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addMember(MemberParser $member) + public function addMember(MemberParser $member) /* : void */ { $this->members[$member->getName()] = $member; } diff --git a/Utils/Parser/Php/FunctionParser.php b/Utils/Parser/Php/FunctionParser.php index 3cb9ac6b1..e76910a6c 100644 --- a/Utils/Parser/Php/FunctionParser.php +++ b/Utils/Parser/Php/FunctionParser.php @@ -158,7 +158,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function removeBody() + public function removeBody() /* : void */ { $this->body = ''; } @@ -289,7 +289,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function removeReturn() + public function removeReturn() /* : void */ { $this->return = null; } @@ -334,7 +334,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function addParameter(string $name, string $typehint = null, string $default = null) + public function addParameter(string $name, string $typehint = null, string $default = null) /* : void */ { $this->parameters[$name]['name'] = $name; $this->parameters[$name]['typehint'] = $typehint; @@ -356,7 +356,7 @@ class FunctionParser * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { $function = ''; $function .= str_repeat(' ', ClassParser::INDENT); diff --git a/Utils/RnG/DateTime.php b/Utils/RnG/DateTime.php index 036810327..4f4927840 100644 --- a/Utils/RnG/DateTime.php +++ b/Utils/RnG/DateTime.php @@ -40,7 +40,7 @@ class DateTime * @since 1.0.0 * @author Dennis Eichhorn */ - public static function generateDateTime($start, $end) + public static function generateDateTime(string $start, string $end) : \DateTime { $startDate = strtotime($start); $endDate = strtotime($end); diff --git a/Utils/RnG/Name.php b/Utils/RnG/Name.php index 8b4d161b8..cf757541c 100644 --- a/Utils/RnG/Name.php +++ b/Utils/RnG/Name.php @@ -482,7 +482,7 @@ class Name * @since 1.0.0 * @author Dennis Eichhorn */ - public static function generateName(array $type, string $origin = 'western') + public static function generateName(array $type, string $origin = 'western') : string { $rndType = rand(0, count($type) - 1); diff --git a/Utils/RnG/Text.php b/Utils/RnG/Text.php index 5aa6d8f94..d46c3daa5 100644 --- a/Utils/RnG/Text.php +++ b/Utils/RnG/Text.php @@ -276,7 +276,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - public function getSentences() + public function getSentences() : int { return $this->sentences; } @@ -292,7 +292,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - public function generateText($length, $words = null) + public function generateText(int $length, $words = null) : string { if ($length === 0) { return ''; @@ -383,7 +383,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - private function generatePunctuation($length) + private function generatePunctuation(int $length) : string { $minSentences = 4; $maxSentences = 20; @@ -450,7 +450,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - private function generateParagraph($length) + private function generateParagraph(int $length) /* : void */ { $minSentence = 3; $maxSentence = 10; @@ -481,7 +481,7 @@ class Text * @since 1.0.0 * @author Dennis Eichhorn */ - private function generateFormatting($length) + private function generateFormatting(int $length) : array { $probCursive = 0.005; $probBold = 0.005; diff --git a/Utils/TaskSchedule/CronJob.php b/Utils/TaskSchedule/CronJob.php index 9b362c91f..05c882d6b 100644 --- a/Utils/TaskSchedule/CronJob.php +++ b/Utils/TaskSchedule/CronJob.php @@ -57,7 +57,7 @@ class CronJob extends TaskAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { $minute = $this->printValue($this->interval->getMinute()); $hour = $this->printValue($this->interval->getHour()); diff --git a/Utils/TaskSchedule/Interval.php b/Utils/TaskSchedule/Interval.php index 43c5612ac..d82f665c8 100644 --- a/Utils/TaskSchedule/Interval.php +++ b/Utils/TaskSchedule/Interval.php @@ -617,7 +617,7 @@ class Interval implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { $minute = $this->serializeTime($this->minute['minutes'], $this->minute['step']); $hour = $this->serializeTime($this->hour['hours'], $this->hour['step']); diff --git a/Utils/TaskSchedule/Schedule.php b/Utils/TaskSchedule/Schedule.php index 5d211dd85..16664e121 100644 --- a/Utils/TaskSchedule/Schedule.php +++ b/Utils/TaskSchedule/Schedule.php @@ -48,7 +48,7 @@ class Schedule extends TaskAbstract implements \Serializable * @return string the string representation of the object or null * @since 5.1.0 */ - public function serialize() /* : void */ + public function serialize() { // TODO: Implement serialize() method. } diff --git a/Utils/TaskSchedule/SchedulerAbstract.php b/Utils/TaskSchedule/SchedulerAbstract.php index 8b2dba090..686738e8c 100644 --- a/Utils/TaskSchedule/SchedulerAbstract.php +++ b/Utils/TaskSchedule/SchedulerAbstract.php @@ -109,7 +109,7 @@ abstract class SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function add(TaskAbstract $task) + public function add(TaskAbstract $task) /* : void */ { $this->tasks[$task->getId()] = $task; } @@ -186,5 +186,5 @@ abstract class SchedulerAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - abstract public function save(); + abstract public function save() /* : void */; } diff --git a/Utils/TaskSchedule/TaskScheduler.php b/Utils/TaskSchedule/TaskScheduler.php index e9055b63d..e2198d8bd 100644 --- a/Utils/TaskSchedule/TaskScheduler.php +++ b/Utils/TaskSchedule/TaskScheduler.php @@ -33,7 +33,7 @@ class TaskScheduler extends SchedulerAbstract /** * {@inheritdoc} */ - public function save() + public function save() /* : void */ { } diff --git a/Validation/Base/BIC.php b/Validation/Base/BIC.php index 5589039d0..3d41f747a 100644 --- a/Validation/Base/BIC.php +++ b/Validation/Base/BIC.php @@ -44,7 +44,7 @@ class BIC extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value) + public static function isValid($value) : bool { return (bool) preg_match('/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i', $value); } diff --git a/Validation/Base/CreditCard.php b/Validation/Base/CreditCard.php index 7cfc93047..924aa9930 100644 --- a/Validation/Base/CreditCard.php +++ b/Validation/Base/CreditCard.php @@ -44,7 +44,7 @@ abstract class CreditCard extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value) + public static function isValid($value) : bool { $value = preg_replace('/\D/', '', $value); diff --git a/Validation/Base/DateTime.php b/Validation/Base/DateTime.php index 51f887528..f921c25b8 100644 --- a/Validation/Base/DateTime.php +++ b/Validation/Base/DateTime.php @@ -44,7 +44,7 @@ abstract class DateTime extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value) + public static function isValid($value) : bool { return (bool) strtotime($value); } diff --git a/Validation/Base/Hostname.php b/Validation/Base/Hostname.php index 4abc95f05..f640e26af 100644 --- a/Validation/Base/Hostname.php +++ b/Validation/Base/Hostname.php @@ -44,7 +44,7 @@ abstract class Hostname extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value) + public static function isValid($value) : bool { return filter_var(gethostbyname($value), FILTER_VALIDATE_IP); } diff --git a/Validation/Base/IP.php b/Validation/Base/IP.php index a06883447..a25c8e438 100644 --- a/Validation/Base/IP.php +++ b/Validation/Base/IP.php @@ -44,7 +44,7 @@ abstract class IP extends ValidatorAbstract /** * {@inheritdoc} */ - public static function isValid($value) + public static function isValid($value) : bool { return filter_var($value, FILTER_VALIDATE_IP); } diff --git a/Validation/ModelValidationTrait.php b/Validation/ModelValidationTrait.php index 311a8fbb5..a52560d23 100644 --- a/Validation/ModelValidationTrait.php +++ b/Validation/ModelValidationTrait.php @@ -60,7 +60,7 @@ trait ModelValidationTrait * @since 1.0.0 * @author Dennis Eichhorn */ - protected function isValid($var, $name) + protected function isValid($var, $name) : bool { /** @noinspection PhpUndefinedFieldInspection */ if (!isset(self::${$name . '_validate'})) { diff --git a/Validation/Validator.php b/Validation/Validator.php index b792a418a..59c5bf4ec 100644 --- a/Validation/Validator.php +++ b/Validation/Validator.php @@ -38,7 +38,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function isValid($var, array $constraints) + public static function isValid($var, array $constraints) : bool { foreach ($constraints as $callback => $settings) { $valid = self::$callback($var, ...$settings); @@ -63,7 +63,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function isType($var, $constraint) + public static function isType($var, $constraint) : bool { if (!is_array($constraint)) { $constraint = [$constraint]; @@ -90,7 +90,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function hasLength(string $var, int $min = 0, int $max = PHP_INT_MAX) + public static function hasLength(string $var, int $min = 0, int $max = PHP_INT_MAX) : bool { $length = strlen($var); @@ -112,7 +112,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function contains(string $var, $substr) + public static function contains(string $var, $substr) : bool { return is_string($substr) ? strpos($var, $substr) !== false : StringUtils::contains($var, $substr); } @@ -128,7 +128,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function matches(string $var, string $pattern) + public static function matches(string $var, string $pattern) : bool { return (preg_match($pattern, $var) !== false ? true : false); } @@ -145,7 +145,7 @@ final class Validator extends ValidatorAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public static function hasLimit($var, $min = 0, $max = PHP_INT_MAX) + public static function hasLimit($var, $min = 0, $max = PHP_INT_MAX) : bool { if ($var <= $max && $var >= $min) { return true; diff --git a/Views/View.php b/Views/View.php index c525f57f2..0ef7e2bcf 100644 --- a/Views/View.php +++ b/Views/View.php @@ -99,7 +99,7 @@ class View extends ViewAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function getData($id) + public function getData(string $id) { return $this->data[$id] ?? null; } @@ -160,14 +160,14 @@ class View extends ViewAbstract * @param string $module Module name * @param string $theme Theme name * - * @return array + * @return string * * @throws \Exception * * @since 1.0.0 * @author Dennis Eichhorn */ - protected function getText(string $translation, string $module = null, string $theme = null) + protected function getText(string $translation, string $module = null, string $theme = null) : string { if (!isset($module)) { $match = '/Modules/'; @@ -202,7 +202,7 @@ class View extends ViewAbstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function getRequest() + public function getRequest() : Request { return $this->request; } diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index e609e3f79..3d32a8558 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -166,7 +166,7 @@ abstract class ViewAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function editView(string $id, View $view, $order = null) + public function editView(string $id, View $view, $order = null) /* : void */ { $this->addView($id, $view, $order, true); } @@ -203,7 +203,7 @@ abstract class ViewAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function serialize() /* : void */ + public function serialize() { if (empty($this->template)) { return $this->toArray(); From 56a29501ce0fc8bc92c59dd87d9c8f6093c9bbed Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 3 Dec 2016 23:03:17 +0100 Subject: [PATCH 31/53] Typehint fix --- Views/ViewAbstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Views/ViewAbstract.php b/Views/ViewAbstract.php index 3d32a8558..c572cc0e1 100644 --- a/Views/ViewAbstract.php +++ b/Views/ViewAbstract.php @@ -184,7 +184,7 @@ abstract class ViewAbstract implements \Serializable * @since 1.0.0 * @author Dennis Eichhorn */ - public function addView(string $id, View $view, int $order = 0, bool $overwrite = true) + public function addView(string $id, View $view, int $order = 0, bool $overwrite = true) /* : void */ { if ($overwrite || !isset($this->views[$id])) { $this->views[$id] = $view; From cae11dd4f60c4f5dea03513ede44488fe562af63 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 5 Dec 2016 22:48:04 +0100 Subject: [PATCH 32/53] Draft --- Utils/Barcode/HIBCC.php | 132 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 Utils/Barcode/HIBCC.php diff --git a/Utils/Barcode/HIBCC.php b/Utils/Barcode/HIBCC.php new file mode 100644 index 000000000..4f77f569a --- /dev/null +++ b/Utils/Barcode/HIBCC.php @@ -0,0 +1,132 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ + +namespace phpOMS\Utils\Barcode; + +/** + * Aztec class. + * + * @category Log + * @package Framework + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class HIBCC +{ + private $identifier = ''; + private $productId = ''; + private $measureOfUnit = 0; + private $dateFormat = ''; + private $expirationDate = null; + private $productionDate = null; + private $lot = ''; + private $checkValue = 0; + + public function __construct() + { + + } + + public function setIdentifier(string $identifier) /* : void */ + { + $this->identifer = $identifier; + } + + public function getIdentifier() : string + { + return $this->identifer; + } + + public function setProductId(string $id) /* : void */ + { + $this->productId = $id; + } + + public function getProductId() : string + { + return $this->productId; + } + + public function setMeasureOfUnit(int $measure) /* : void */ + { + $this->measureOfUnit = $measure; + } + + public function getMeasureOfUnit() : int + { + return $this->measureOfUnit; + } + + public function setDateFormat(string $format) /* : void */ + { + $this->dateFormat = $format; + } + + public function getDateFormat() : string + { + return $this->dateFormat(); + } + + public function setExpirationDate(\DateTime $date) /* : void */ + { + $this->expirationDate = $date; + } + + public function getExpirationDate() : \Datetime + { + return $this->expirationDate; + } + + public function setPrductionDate(\DateTime $date) /* : void */ + { + $this->productionDate = $date; + } + + public function getProductionDate() : \DateTime + { + return $this->productionDate; + } + + public function setLOT(string $lot) /* : void */ + { + $this->lot = $lot; + } + + public function getLOT() : string + { + return $this->lot; + } + + public function getCheckValue() : int + { + return $this->checkValue; + } + + public function getPrimaryDI() : string + { + return ''; + } + + public function getSecondaryDI() : string + { + return ''; + } + + +} From 3164e78032b17989d072093699cdb2658221fe8e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 5 Dec 2016 22:48:14 +0100 Subject: [PATCH 33/53] Better dimension handling --- Utils/Barcode/C128Abstract.php | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index 6cc9e593c..a0eb29fd3 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -70,14 +70,6 @@ abstract class C128Abstract */ protected $orientation = 0; - /** - * Barcode height. - * - * @var int - * @since 1.0.0 - */ - protected $size = 0; - /** * Barcode dimension. * @@ -140,28 +132,34 @@ abstract class C128Abstract * @since 1.0.0 * @author Dennis Eichhorn */ - public function __construct(string $content = '', int $size = 20, int $orientation = OrientationType::HORIZONTAL) + public function __construct(string $content = '', int $width = 20, int $height = 20, int $orientation = OrientationType::HORIZONTAL) { $this->content = $content; - $this->setSize($size); + $this->setDimension($width, $height); $this->setOrientation($orientation); } /** - * Set barcode height + * Set barcode dimensions * - * @param int $size Barcode height + * @param int $width Barcode width + * @param int $height Barcode height * * @since 1.0.0 * @author Dennis Eichhorn */ - public function setSize(int $size) /* : void */ + public function setDimension(int $width, int $height) /* : void */ { - if ($size < 0) { - throw new \OutOfBoundsException($size); + if ($width < 0) { + throw new \OutOfBoundsException($width); } - $this->size = $size; + if ($height < 0) { + throw new \OutOfBoundsException($height); + } + + $this->dimension['width'] = $width; + $this->dimension['height'] = $height; } /** @@ -268,11 +266,11 @@ abstract class C128Abstract } if ($this->orientation === OrientationType::HORIZONTAL) { - $imgWidth = $codeLength; - $imgHeight = $this->size; + $imgWidth = max($codeLength, $this->dimension['width']); + $imgHeight = $this->dimension['height']; } else { - $imgWidth = $this->size; - $imgHeight = $codeLength; + $imgWidth = $this->dimension['width']; + $imgHeight = max($codeLength, $this->dimension['height']); } $image = imagecreate($imgWidth, $imgHeight); From 8e010e95b8f67402895e15cc7d3a507925878e6c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 6 Dec 2016 22:54:03 +0100 Subject: [PATCH 34/53] Default header generation --- Message/Http/Header.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Message/Http/Header.php b/Message/Http/Header.php index c1245f024..faa6bf109 100644 --- a/Message/Http/Header.php +++ b/Message/Http/Header.php @@ -220,7 +220,7 @@ class Header extends HeaderAbstract $this->generate503(); break; default: - throw new \Exception('Unexpected header code'); + $this->generate500(); } } @@ -282,6 +282,22 @@ class Header extends HeaderAbstract } + /** + * Generate predefined header. + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + private function generate500() + { + $this->set('HTTP', 'HTTP/1.0 500 Internal Server Error'); + $this->set('Status', 'Status: 500 Internal Server Error'); + $this->set('Retry-After', 'Retry-After: 300'); + http_response_code(500); + } + /** * Generate predefined header. * From d6dd1a5a963c86bde7078a7fa325aa775f1e6132 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 20:22:40 +0100 Subject: [PATCH 35/53] Prepare const visibility --- Account/AccountStatus.php | 8 +- Account/AccountType.php | 4 +- Account/GroupStatus.php | 6 +- Algorithm/AlgorithmType.php | 2 +- Asset/AssetType.php | 6 +- Auth/LoginReturnType.php | 20 +- DataStorage/Cache/CacheStatus.php | 6 +- DataStorage/Cache/CacheType.php | 14 +- DataStorage/Cache/FileCache.php | 2 +- DataStorage/Database/DatabaseStatus.php | 12 +- DataStorage/Database/DatabaseType.php | 10 +- DataStorage/Database/Query/Builder.php | 2 +- DataStorage/Database/Query/JoinType.php | 22 +- DataStorage/Database/Query/QueryType.php | 12 +- DataStorage/Database/RelationType.php | 6 +- DataStorage/Database/Schema/QueryType.php | 8 +- Datatypes/AddressType.php | 10 +- Datatypes/Enum.php | 2 +- Datatypes/PhoneType.php | 8 +- Datatypes/SmartDateTime.php | 4 +- Html/TagType.php | 18 +- Localization/ISO3166CharEnum.php | 498 ++--- Localization/ISO3166NameEnum.php | 500 ++--- Localization/ISO3166NumEnum.php | 498 ++--- Localization/ISO3166TwoEnum.php | 500 ++--- Localization/ISO4217CharEnum.php | 228 +- Localization/ISO4217DecimalEnum.php | 356 +-- Localization/ISO4217Enum.php | 228 +- Localization/ISO4217NumEnum.php | 356 +-- Localization/ISO4217SubUnitEnum.php | 308 +-- Localization/ISO4217SymbolEnum.php | 218 +- Localization/ISO639Enum.php | 368 +-- Localization/ISO639x1Enum.php | 342 +-- Localization/ISO639x2Enum.php | 368 +-- Localization/Money.php | 2 +- Localization/PhoneEnum.php | 458 ++-- Log/FileLogger.php | 6 +- Log/LogLevel.php | 16 +- Math/Differential/FiniteDifference.php | 2 +- .../Forecasting/ClassicalDecomposition.php | 4 +- Math/Matrix/InverseType.php | 2 +- Math/Number/NumberType.php | 18 +- Math/Optimization/TSP/BruteForce.php | 2 +- Math/Optimization/TSP/GA.php | 6 +- Math/Statistic/Average.php | 22 +- .../Forecast/ForecastIntervalMultiplier.php | 28 +- .../Distribution/ChiSquaredDistribution.php | 2 +- Message/Http/BrowserType.php | 22 +- Message/Http/OSType.php | 46 +- Message/Http/RequestMethod.php | 12 +- Message/Http/RequestStatus.php | 110 +- Message/Mail/MailType.php | 10 +- Message/RequestSource.php | 6 +- Message/ResponseType.php | 8 +- Module/ModuleAbstract.php | 6 +- Module/ModuleManager.php | 2 +- Router/RouteVerb.php | 10 +- Socket/Packets/PacketType.php | 22 +- Socket/SocketType.php | 6 +- Stdlib/Map/KeyType.php | 4 +- Stdlib/Map/OrderType.php | 4 +- Stdlib/Queue/PriorityMode.php | 12 +- System/File/ContentPutMode.php | 8 +- System/MimeType.php | 1972 ++++++++--------- System/SystemType.php | 8 +- Uri/UriScheme.php | 30 +- Utils/Barcode/OrientationType.php | 4 +- Utils/Converter/AngleType.php | 20 +- Utils/Converter/AreaType.php | 26 +- Utils/Converter/EnergyPowerType.php | 18 +- Utils/Converter/FileSizeType.php | 20 +- Utils/Converter/Ip.php | 4 +- Utils/Converter/LengthType.php | 42 +- Utils/Converter/Numeric.php | 2 +- Utils/Converter/PressureType.php | 26 +- Utils/Converter/SpeedType.php | 68 +- Utils/Converter/TemperatureType.php | 16 +- Utils/Converter/TimeType.php | 18 +- Utils/Converter/VolumeType.php | 76 +- Utils/Converter/WeightType.php | 28 +- Utils/Encoding/Caesar.php | 4 +- Utils/Parser/Php/ClassParser.php | 2 +- Utils/Parser/Php/ClassType.php | 6 +- Utils/Parser/Php/Visibility.php | 8 +- Utils/RnG/DistributionType.php | 4 +- Validation/Base/IbanEnum.php | 164 +- Validation/Base/IbanErrorType.php | 10 +- Views/ViewLayout.php | 24 +- 88 files changed, 4203 insertions(+), 4203 deletions(-) diff --git a/Account/AccountStatus.php b/Account/AccountStatus.php index 93bc0d90c..b10692dc0 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 INACTIVE = 2; - const TIMEOUT = 3; - 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 4c65e6392..ef866b602 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 GROUP = 1; + /* public */ const USER = 0; + /* public */ const GROUP = 1; } diff --git a/Account/GroupStatus.php b/Account/GroupStatus.php index 8699f72c8..7b8328214 100644 --- a/Account/GroupStatus.php +++ b/Account/GroupStatus.php @@ -30,9 +30,9 @@ use phpOMS\Datatypes\Enum; */ abstract class GroupStatus extends Enum { - const ACTIVE = 1; + /* public */ const ACTIVE = 1; - const INACTIVE = 2; + /* public */ const INACTIVE = 2; - const HIDDEN = 4; + /* public */ const HIDDEN = 4; } diff --git a/Algorithm/AlgorithmType.php b/Algorithm/AlgorithmType.php index 5d9d7bf0e..e2d642da1 100644 --- a/Algorithm/AlgorithmType.php +++ b/Algorithm/AlgorithmType.php @@ -30,5 +30,5 @@ use phpOMS\Datatypes\Enum; */ abstract class AlgorithmType extends Enum { - const BRUTEFORCE = 0; + /* public */ const BRUTEFORCE = 0; } diff --git a/Asset/AssetType.php b/Asset/AssetType.php index e7313c97c..3c9c1fbbf 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 JSLATE = 'jslate'; + /* public */ const CSS = 'css'; + /* public */ const JS = 'js'; + /* public */ const JSLATE = 'jslate'; } diff --git a/Auth/LoginReturnType.php b/Auth/LoginReturnType.php index dc5a886af..2cb2efc0f 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 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 */ + /* 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 */ } diff --git a/DataStorage/Cache/CacheStatus.php b/DataStorage/Cache/CacheStatus.php index 527f2c584..bc9cab7c7 100644 --- a/DataStorage/Cache/CacheStatus.php +++ b/DataStorage/Cache/CacheStatus.php @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class CacheStatus extends Enum { - const ACTIVE = 0; - const INACTIVE = 1; - const ERROR = 2; + /* public */ const ACTIVE = 0; + /* public */ const INACTIVE = 1; + /* public */ const ERROR = 2; } diff --git a/DataStorage/Cache/CacheType.php b/DataStorage/Cache/CacheType.php index 36960335e..e2c6c2258 100644 --- a/DataStorage/Cache/CacheType.php +++ b/DataStorage/Cache/CacheType.php @@ -32,11 +32,11 @@ use phpOMS\Datatypes\Enum; */ abstract class CacheType extends Enum { - const _INT = 0; /* Data is integer */ - const _STRING = 1; /* Data is string */ - const _ARRAY = 2; /* Data is array */ - const _SERIALIZABLE = 3; /* Data is object */ - const _JSONSERIALIZABLE = 6; - const _FLOAT = 4; /* Data is float */ - const _BOOL = 5; /* Data is float */ + /* public */ const _INT = 0; /* Data is integer */ + /* public */ const _STRING = 1; /* Data is string */ + /* public */ const _ARRAY = 2; /* Data is array */ + /* public */ const _SERIALIZABLE = 3; /* Data is object */ + /* public */ const _JSONSERIALIZABLE = 6; + /* public */ const _FLOAT = 4; /* Data is float */ + /* public */ const _BOOL = 5; /* Data is float */ } diff --git a/DataStorage/Cache/FileCache.php b/DataStorage/Cache/FileCache.php index cef68a849..5941b020a 100644 --- a/DataStorage/Cache/FileCache.php +++ b/DataStorage/Cache/FileCache.php @@ -41,7 +41,7 @@ class FileCache implements CacheInterface * @var string * @since 1.0.0 */ - const DELIM = '$'; + /* public */ const DELIM = '$'; /** * Cache path. diff --git a/DataStorage/Database/DatabaseStatus.php b/DataStorage/Database/DatabaseStatus.php index bdb324fa6..d851f0bb6 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 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 */ + /* public */ const OK = 0; /* Database connection successful */ + /* public */ const MISSING_DATABASE = 1; /* Couldn't find database */ + /* public */ const MISSING_TABLE = 2; /* One of the core tables couldn't be found */ + /* public */ const FAILURE = 3; /* Unknown failure */ + /* public */ const READONLY = 4; /* Database connection is in readonly (but ok) */ + /* public */ const CLOSED = 5; /* Database connection closed */ } diff --git a/DataStorage/Database/DatabaseType.php b/DataStorage/Database/DatabaseType.php index d1b163cf6..3d7c0c121 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 SQLITE = 1; /* SQLITE */ - const PGSQL = 2; /* PostgreSQL */ - const ORACLE = 3; /* Oracle */ - const SQLSRV = 4; /* Microsoft SQL Server */ + /* public */ const MYSQL = 0; /* MySQL */ + /* public */ const SQLITE = 1; /* SQLITE */ + /* public */ const PGSQL = 2; /* PostgreSQL */ + /* public */ const ORACLE = 3; /* Oracle */ + /* public */ const SQLSRV = 4; /* Microsoft SQL Server */ } diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 2ed7e587e..92b6a09d2 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -173,7 +173,7 @@ class Builder extends BuilderAbstract * @var string[] * @since 1.0.0 */ - const operators = [ + /* public */ const operators = [ '=', '<', '>', diff --git a/DataStorage/Database/Query/JoinType.php b/DataStorage/Database/Query/JoinType.php index 6704e0f9d..e972996a9 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 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'; + /* public */ const JOIN = 'JOIN'; + /* public */ const LEFT_JOIN = 'LEFT JOIN'; + /* public */ const LEFT_OUTER_JOIN = 'LEFT OUTER JOIN'; + /* public */ const LEFT_INNER_JOIN = 'LEFT INNER JOIN'; + /* public */ const RIGHT_JOIN = 'RIGHT JOIN'; + /* public */ const RIGHT_OUTER_JOIN = 'RIGHT OUTER JOIN'; + /* public */ const RIGHT_INNER_JOIN = 'RIGHT INNER JOIN'; + /* public */ const OUTER_JOIN = 'OUTER JOIN'; + /* public */ const INNER_JOIN = 'INNER JOIN'; + /* public */ const CROSS_JOIN = 'CROSS JOIN'; + /* public */ const FULL_OUTER_JOIN = 'FULL OUTER JOIN'; } diff --git a/DataStorage/Database/Query/QueryType.php b/DataStorage/Database/Query/QueryType.php index 6c6c373d0..fde16f1aa 100644 --- a/DataStorage/Database/Query/QueryType.php +++ b/DataStorage/Database/Query/QueryType.php @@ -30,10 +30,10 @@ use phpOMS\Datatypes\Enum; */ abstract class QueryType extends Enum { - const SELECT = 0; - const INSERT = 1; - const UPDATE = 2; - const DELETE = 3; - const RANDOM = 4; - const RAW = 5; + /* public */ const SELECT = 0; + /* public */ const INSERT = 1; + /* public */ const UPDATE = 2; + /* public */ const DELETE = 3; + /* public */ const RANDOM = 4; + /* public */ const RAW = 5; } diff --git a/DataStorage/Database/RelationType.php b/DataStorage/Database/RelationType.php index bf37831c7..45f32fd0e 100644 --- a/DataStorage/Database/RelationType.php +++ b/DataStorage/Database/RelationType.php @@ -32,7 +32,7 @@ use phpOMS\Datatypes\Enum; */ abstract class RelationType extends Enum { - const NONE = 0; - const NEWEST = 1; - const ALL = 2; + /* public */ const NONE = 0; + /* public */ const NEWEST = 1; + /* public */ const ALL = 2; } diff --git a/DataStorage/Database/Schema/QueryType.php b/DataStorage/Database/Schema/QueryType.php index 2a72296f7..091558084 100644 --- a/DataStorage/Database/Schema/QueryType.php +++ b/DataStorage/Database/Schema/QueryType.php @@ -32,8 +32,8 @@ use phpOMS\Datatypes\Enum; */ abstract class QueryType extends Enum { - const SELECT = 0; - const CREATE = 1; - const DROP = 2; - const ALTER = 3; + /* public */ const SELECT = 0; + /* public */ const CREATE = 1; + /* public */ const DROP = 2; + /* public */ const ALTER = 3; } diff --git a/Datatypes/AddressType.php b/Datatypes/AddressType.php index 17541eb58..08d4feb95 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 BUSINESS = 2; - const SHIPPING = 3; - const BILLING = 4; - const WORK = 5; + /* public */ const HOME = 1; + /* public */ const BUSINESS = 2; + /* public */ const SHIPPING = 3; + /* public */ const BILLING = 4; + /* public */ const WORK = 5; } diff --git a/Datatypes/Enum.php b/Datatypes/Enum.php index 5f7a0a8d1..623b5f8e5 100644 --- a/Datatypes/Enum.php +++ b/Datatypes/Enum.php @@ -124,7 +124,7 @@ abstract class Enum /** * Checking enum name. * - * Checking if a certain const name exists (case sensitive) + * Checking if a certain /* public */ const name exists (case sensitive) * * @param string $name Name of the value (case sensitive) * diff --git a/Datatypes/PhoneType.php b/Datatypes/PhoneType.php index e505d07bb..f0ed9fc07 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 BUSINESS = 2; - const MOBILE = 3; - const WORK = 4; + /* public */ const HOME = 1; + /* public */ const BUSINESS = 2; + /* public */ const MOBILE = 3; + /* public */ const WORK = 4; } diff --git a/Datatypes/SmartDateTime.php b/Datatypes/SmartDateTime.php index edd8e4b53..4a5728194 100644 --- a/Datatypes/SmartDateTime.php +++ b/Datatypes/SmartDateTime.php @@ -36,7 +36,7 @@ class SmartDateTime extends \DateTime * @var string * @since 1.0.0 */ - const FORMAT = 'Y-m-d hh:mm:ss'; + /* public */ const FORMAT = 'Y-m-d hh:mm:ss'; /** * Default timezone @@ -44,7 +44,7 @@ class SmartDateTime extends \DateTime * @var string * @since 1.0.0 */ - const TIMEZONE = 'UTC'; + /* public */ const TIMEZONE = 'UTC'; /** * {@inheritdoc} diff --git a/Html/TagType.php b/Html/TagType.php index cd8263136..c28b96746 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; /*