From 843d97c6321e497eb006df1cf395d2f5c9feafcd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 26 Nov 2020 20:50:18 +0100 Subject: [PATCH] fix todos/move to todo list --- Algorithm/JobScheduling/Weighted.php | 2 +- Application/ApplicationAbstract.php | 6 --- .../Cache/Connection/ConnectionInterface.php | 14 ------ DataStorage/Cache/Connection/FileCache.php | 8 ---- .../Connection/ConnectionAbstract.php | 8 ---- DataStorage/Database/DataMapperAbstract.php | 5 --- DataStorage/Database/Query/Builder.php | 4 -- DataStorage/Database/Schema/Builder.php | 4 -- .../Database/Schema/Grammar/Grammar.php | 4 -- .../Database/Schema/Grammar/MysqlGrammar.php | 4 -- Message/Http/Rest.php | 2 +- Module/ModuleAbstract.php | 3 -- Module/ModuleManager.php | 34 +++----------- Module/StatusAbstract.php | 8 ---- Module/UninstallerAbstract.php | 4 -- System/File/Local/Directory.php | 35 --------------- System/File/Local/File.php | 45 ------------------- System/File/Local/FileAbstract.php | 45 +++++++++++++++++++ Utils/ArrayUtils.php | 11 ----- Utils/StringCompare.php | 2 - tests/Math/Matrix/MatrixTest.php | 5 --- tests/Utils/ArrayUtilsTest.php | 6 --- 22 files changed, 53 insertions(+), 206 deletions(-) diff --git a/Algorithm/JobScheduling/Weighted.php b/Algorithm/JobScheduling/Weighted.php index 58a9254c2..e2ce62490 100644 --- a/Algorithm/JobScheduling/Weighted.php +++ b/Algorithm/JobScheduling/Weighted.php @@ -55,7 +55,7 @@ final class Weighted } if ($j1->getEnd() !== null && $j2->getEnd() === null) { - return -1; // @todo: Implement test case + return -1; } return $j1->getEnd()->getTimestamp() <=> $j2->getEnd()->getTimestamp(); diff --git a/Application/ApplicationAbstract.php b/Application/ApplicationAbstract.php index 06a3a2acb..50effce73 100644 --- a/Application/ApplicationAbstract.php +++ b/Application/ApplicationAbstract.php @@ -194,9 +194,6 @@ class ApplicationAbstract * * @return void * - * @todo Orange-Management/phpOMS#218 - * As soon as readonly member variables are possible the magic methods should be removed. - * * @since 1.0.0 */ public function __set($name, $value) : void @@ -215,9 +212,6 @@ class ApplicationAbstract * * @return mixed Returns the value of the application member * - * @todo Orange-Management/phpOMS#218 - * As soon as readonly member variables are possible the magic methods should be removed. - * * @since 1.0.0 */ public function __get($name) diff --git a/DataStorage/Cache/Connection/ConnectionInterface.php b/DataStorage/Cache/Connection/ConnectionInterface.php index cc115ba6a..57bf90f80 100644 --- a/DataStorage/Cache/Connection/ConnectionInterface.php +++ b/DataStorage/Cache/Connection/ConnectionInterface.php @@ -23,20 +23,6 @@ use phpOMS\DataStorage\DataStorageConnectionInterface; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#184 - * Add more functions: - * * exists - Checks if the key exists - * * getLike - Get all by pattern - * * removeLike - Remove all by pattern - * * getMult - Get multiple results - * * removeMult - Remove multiple - * * setMult - Set multiple - * * updateExpiration - Update expiration - * * increment - Increment numeric value - * * decrement - Decrement numeric value - * * rename - Rename key - * * save - Save cache (to hard drive or somewhere else) */ interface ConnectionInterface extends DataStorageConnectionInterface { diff --git a/DataStorage/Cache/Connection/FileCache.php b/DataStorage/Cache/Connection/FileCache.php index 6070462eb..d507d2ec5 100644 --- a/DataStorage/Cache/Connection/FileCache.php +++ b/DataStorage/Cache/Connection/FileCache.php @@ -39,14 +39,6 @@ use phpOMS\System\File\Local\File; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#182 - * Create file locking - * The file caching should implement a locking solution for the cache files. - * Without it a different process may try to read it while the cache is still getting created. - * A solution could be to create a directory or file called _lock which is getting checked - * (if this file exists reading from cache, modifying or creating it is not allowed except the _lock file is 5 minutes or so old). - * File and or directory creation should be atomic, right? */ final class FileCache extends ConnectionAbstract { diff --git a/DataStorage/Database/Connection/ConnectionAbstract.php b/DataStorage/Database/Connection/ConnectionAbstract.php index dbb36ebbb..ddf540b4b 100644 --- a/DataStorage/Database/Connection/ConnectionAbstract.php +++ b/DataStorage/Database/Connection/ConnectionAbstract.php @@ -31,11 +31,6 @@ use phpOMS\DataStorage\Database\Schema\Grammar\Grammar as SchemaGrammar; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/Modules#100 - * Init only when used - * The database connection should only get initialized when used. - * Setup happens before but initialization should only happen on the first usage. */ abstract class ConnectionAbstract implements ConnectionInterface { @@ -196,9 +191,6 @@ abstract class ConnectionAbstract implements ConnectionInterface * * @return mixed Returns the value of the connection * - * @todo Orange-Management/phpOMS#218 - * As soon as readonly member variables are possible the magic methods should be removed. - * * @since 1.0.0 */ public function __get($name) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 7082d4459..c035d4c68 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -2578,11 +2578,6 @@ class DataMapperAbstract implements DataMapperInterface * * @return mixed * - * @todo Orange-Management/phpOMS#161 - * Reconsider get*() parameter order - * Check if the parameter order of all of the get functions makes sense or if another order would be better. - * Especially the fill parameter probably should be swapped with the depth filter. - * * @since 1.0.0 */ public static function get($primaryKey, int $relations = RelationType::ALL, int $depth = 3, string $ref = null, Builder $query = null) diff --git a/DataStorage/Database/Query/Builder.php b/DataStorage/Database/Query/Builder.php index 2c79d772d..a532584e0 100644 --- a/DataStorage/Database/Query/Builder.php +++ b/DataStorage/Database/Query/Builder.php @@ -25,10 +25,6 @@ use phpOMS\DataStorage\Database\Connection\ConnectionAbstract; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#33 - * Implement missing grammar & builder functions - * Missing elements are e.g. sum, merge etc. */ class Builder extends BuilderAbstract { diff --git a/DataStorage/Database/Schema/Builder.php b/DataStorage/Database/Schema/Builder.php index 2bbb42e84..2126ecfb2 100644 --- a/DataStorage/Database/Schema/Builder.php +++ b/DataStorage/Database/Schema/Builder.php @@ -24,10 +24,6 @@ use phpOMS\DataStorage\Database\Query\Builder as QueryBuilder; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#32 - * Implement schema grammar - * Basic create/drop schema grammar created. Next step is to be able to update existing schema and read existing schema. */ class Builder extends QueryBuilder { diff --git a/DataStorage/Database/Schema/Grammar/Grammar.php b/DataStorage/Database/Schema/Grammar/Grammar.php index aa3932b38..e96c21ba0 100644 --- a/DataStorage/Database/Schema/Grammar/Grammar.php +++ b/DataStorage/Database/Schema/Grammar/Grammar.php @@ -25,10 +25,6 @@ use phpOMS\DataStorage\Database\Schema\QueryType; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#32 - * Implement schema grammar - * Basic create/drop schema grammar created. Next step is to be able to update existing schema and read existing schema. */ class Grammar extends QueryGrammar { diff --git a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php index 25ce71138..fd7a8c82e 100644 --- a/DataStorage/Database/Schema/Grammar/MysqlGrammar.php +++ b/DataStorage/Database/Schema/Grammar/MysqlGrammar.php @@ -24,10 +24,6 @@ use phpOMS\DataStorage\Database\Query\Builder; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#32 - * Implement schema grammar - * Basic create/drop schema grammar created. Next step is to be able to update existing schema and read existing schema. */ class MysqlGrammar extends Grammar { diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index d95bf153e..6f8592f13 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -97,7 +97,7 @@ final class Rest * * according to the verbose output of curl the request is correct. this means the server must have a problem with it * - * the php webserver and apache2 both seem to be unable to populate the php://input correctly -> not a server isue but a php issue? + * the php webserver and apache2 both seem to be unable to populate the php://input correctly -> not a server issue but a php issue? */ $headers['content-type'] = 'Content-Type: multipart/form-data; boundary/' . $boundary; $headers['content-length'] = 'Content-Length: ' . \strlen($data); diff --git a/Module/ModuleAbstract.php b/Module/ModuleAbstract.php index 3c0d9798a..5ed67abb1 100644 --- a/Module/ModuleAbstract.php +++ b/Module/ModuleAbstract.php @@ -29,9 +29,6 @@ use phpOMS\Utils\StringUtils; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/Modules#113 - * Don't use name but id for identification */ abstract class ModuleAbstract { diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 0c2db3794..5e70be550 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -33,9 +33,6 @@ use phpOMS\System\File\PathException; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/Modules#113 - * Don't use name but id for identification */ final class ModuleManager { @@ -197,7 +194,6 @@ final class ModuleManager public function getActiveModules(bool $useCache = true) : array { if (empty($this->active) || !$useCache) { - // @todo: use ModuleMapper and return objects $query = new Builder($this->app->dbPool->get('select')); $sth = $query->select('module.module_path') ->from('module') @@ -263,8 +259,6 @@ final class ModuleManager public function getAllModules() : array { if (empty($this->all)) { - // @todo: return objects - \chdir($this->modulePath); $files = \glob('*', \GLOB_ONLYDIR); @@ -274,16 +268,11 @@ final class ModuleManager $c = $files === false ? 0 : \count($files); for ($i = 0; $i < $c; ++$i) { - $path = $this->modulePath . $files[$i] . '/info.json'; + $module = $this->loadInfo($files[$i]); - if (!\is_file($path)) { - continue; + if ($module !== null) { + $this->all[$files[$i]] = $module; } - - $content = \file_get_contents($path); - $json = \json_decode($content === false ? '[]' : $content, true); - - $this->all[(string) ($json['name']['internal'] ?? '?')] = $json === false ? [] : $json; } } @@ -314,7 +303,6 @@ final class ModuleManager public function getInstalledModules(bool $useCache = true) : array { if (empty($this->installed) || !$useCache) { - // @todo: use ModuleMapper and return objects $query = new Builder($this->app->dbPool->get('select')); $sth = $query->select('module.module_path') ->from('module') @@ -323,12 +311,6 @@ final class ModuleManager $installed = $sth->fetchAll(\PDO::FETCH_COLUMN); foreach ($installed as $module) { - $path = $this->modulePath . $module . '/info.json'; - - if (!\is_file($path)) { - continue; - } - $this->installed[$module] = $this->loadInfo($module); } } @@ -341,16 +323,16 @@ final class ModuleManager * * @param string $module Module name * - * @return ModuleInfo + * @return null|ModuleInfo * * @since 1.0.0 */ - private function loadInfo(string $module) : ModuleInfo + private function loadInfo(string $module) : ?ModuleInfo { $path = \realpath($oldPath = $this->modulePath . $module . '/info.json'); if ($path === false) { - throw new PathException($oldPath); + return null; } $info = new ModuleInfo($path); @@ -503,10 +485,6 @@ final class ModuleManager return false; } - /** - * @todo Orange-Management/Modules#193 - * Implement online database and downloading api for modules and updates - */ if (!\is_file($this->modulePath . $module . '/Admin/Installer.php')) { return false; } diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index 900b34851..f6a98f926 100644 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -53,10 +53,6 @@ abstract class StatusAbstract * * @return void * - * @todo Orange-Management/phpOMS#228 - * Remove/Add routes on module status change - * If the status of a module changes it should also change the routing file. - * * @since 1.0.0 */ private static function activateRoutes(string $destRoutePath, string $srcRoutePath) : void @@ -106,10 +102,6 @@ abstract class StatusAbstract * * @return void * - * @todo Orange-Management/phpOMS#228 - * Remove/Add routes on module status change - * If the status of a module changes it should also change the routing file. - * * @since 1.0.0 */ private static function deactivateRoutes(string $destRoutePath, string $srcRoutePath) : void diff --git a/Module/UninstallerAbstract.php b/Module/UninstallerAbstract.php index 577300282..992327a23 100644 --- a/Module/UninstallerAbstract.php +++ b/Module/UninstallerAbstract.php @@ -36,10 +36,6 @@ abstract class UninstallerAbstract * * @return void * - * @todo Orange-Management/phpOMS#228 - * Remove/Add routes on module status change - * If the status of a module changes it should also change the routing file. - * * @since 1.0.0 */ public static function uninstall(DatabasePool $dbPool, ModuleInfo $info) : void diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index 212a5df4b..11af19f81 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -317,42 +317,7 @@ final class Directory extends FileAbstract implements DirectoryInterface, LocalC return \implode('/', $path); } - /** - * {@inheritdoc} - * - * @todo Orange-Management/phpOMS#??? [p:low] [t:optimization] [d:beginner] [t:question] - * Consider to move this to fileAbastract since it should be the same for file and directory? - */ - public static function created(string $path) : \DateTime - { - if (!\is_dir($path)) { - throw new PathException($path); - } - $created = new \DateTime('now'); - $time = \filemtime($path); - - $created->setTimestamp($time === false ? 0 : $time); - - return $created; - } - - /** - * {@inheritdoc} - */ - public static function changed(string $path) : \DateTime - { - if (!\is_dir($path)) { - throw new PathException($path); - } - - $changed = new \DateTime(); - $time = \filectime($path); - - $changed->setTimestamp($time === false ? 0 : $time); - - return $changed; - } /** * {@inheritdoc} diff --git a/System/File/Local/File.php b/System/File/Local/File.php index 8ef25b70c..04d5820e7 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -203,51 +203,6 @@ final class File extends FileAbstract implements FileInterface, LocalContainerIn return \preg_replace($invalid, $replace, $path) ?? ''; } - /** - * {@inheritdoc} - */ - public static function created(string $path) : \DateTime - { - if (!\is_file($path)) { - throw new PathException($path); - } - - $time = \filemtime($path); - - return self::createFileTime($time === false ? 0 : $time); - } - - /** - * {@inheritdoc} - */ - public static function changed(string $path) : \DateTime - { - if (!\is_file($path)) { - throw new PathException($path); - } - - $time = \filemtime($path); - - return self::createFileTime($time === false ? 0 : $time); - } - - /** - * Create file time. - * - * @param int $time Time of the file - * - * @return \DateTime - * - * @since 1.0.0 - */ - private static function createFileTime(int $time) : \DateTime - { - $fileTime = new \DateTime(); - $fileTime->setTimestamp($time); - - return $fileTime; - } - /** * {@inheritdoc} */ diff --git a/System/File/Local/FileAbstract.php b/System/File/Local/FileAbstract.php index 5fe8c95c5..31dbd1a99 100644 --- a/System/File/Local/FileAbstract.php +++ b/System/File/Local/FileAbstract.php @@ -116,6 +116,51 @@ abstract class FileAbstract implements ContainerInterface $this->changedAt = new \DateTime('now'); } + /** + * {@inheritdoc} + */ + public static function created(string $path) : \DateTime + { + if (!\file_exists($path)) { + throw new PathException($path); + } + + $time = \filectime($path); + + return self::createFileTime($time === false ? 0 : $time); + } + + /** + * {@inheritdoc} + */ + public static function changed(string $path) : \DateTime + { + if (!\file_exists($path)) { + throw new PathException($path); + } + + $time = \filemtime($path); + + return self::createFileTime($time === false ? 0 : $time); + } + + /** + * Create file time. + * + * @param int $time Time of the file + * + * @return \DateTime + * + * @since 1.0.0 + */ + private static function createFileTime(int $time) : \DateTime + { + $fileTime = new \DateTime(); + $fileTime->setTimestamp($time); + + return $fileTime; + } + /** * {@inheritdoc} */ diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 92d06e371..1bc60ae07 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -21,11 +21,6 @@ namespace phpOMS\Utils; * @license OMS License 1.0 * @link https://orange-management.org * @since 1.0.0 - * - * @todo Orange-Management/phpOMS#154 - * Create excel operations on arrays - * In many cases there are values stored inside of arrays which need simple math operators performed on them. - * Instead of writing the expression it should be possible to do this in good old excel fasion. */ final class ArrayUtils { @@ -394,9 +389,6 @@ final class ArrayUtils * * @return float[] * - * @todo Orange-Management/phpOMS#223 - * In the ArrayUtils class the power* functions should be combined once union types become available. - * * @since 1.0.0 */ public static function powerFloat(array $values, float $exp = 2.0) : array @@ -418,9 +410,6 @@ final class ArrayUtils * * @return array * - * @todo Orange-Management/phpOMS#223 - * In the ArrayUtils class the power* functions should be combined once union types become available. - * * @since 1.0.0 */ public static function powerInt(array $values, int $exp = 2) : array diff --git a/Utils/StringCompare.php b/Utils/StringCompare.php index aed4220b8..d1afabe0a 100644 --- a/Utils/StringCompare.php +++ b/Utils/StringCompare.php @@ -171,8 +171,6 @@ final class StringCompare * * @return int * - * @todo: Consider to remove previous matches in words2. Otherwise the distance may be checked against the same word over and over. - * * @since 1.0.0 */ public static function valueWords(string $s1, string $s2) : int diff --git a/tests/Math/Matrix/MatrixTest.php b/tests/Math/Matrix/MatrixTest.php index 8cd406c48..4da5869c1 100644 --- a/tests/Math/Matrix/MatrixTest.php +++ b/tests/Math/Matrix/MatrixTest.php @@ -276,11 +276,6 @@ class MatrixTest extends \PHPUnit\Framework\TestCase self::markTestIncomplete(); - /** - * @todo Orange-Management/phpOMS#179 - * Create unit test for inverse. - * It seems like some columns are ordered in a different way - */ /*self::assertEquals([ [-0.9, -0.5, 2.2], [0.7, 0.5, -1.6], diff --git a/tests/Utils/ArrayUtilsTest.php b/tests/Utils/ArrayUtilsTest.php index c0ce0c8cf..e4075c0ce 100644 --- a/tests/Utils/ArrayUtilsTest.php +++ b/tests/Utils/ArrayUtilsTest.php @@ -283,9 +283,6 @@ class ArrayUtilsTest extends \PHPUnit\Framework\TestCase * @testdox All array values in an array can be potentiated by an integer * @covers phpOMS\Utils\ArrayUtils * - * @todo Orange-Management/phpOMS#223 - * In the ArrayUtils class the power* functions should be combined once union types become available. - * * @group framework */ public function testPowerInt() : void @@ -298,9 +295,6 @@ class ArrayUtilsTest extends \PHPUnit\Framework\TestCase * @testdox All array values in an array can be potentiated by a float * @covers phpOMS\Utils\ArrayUtils * - * @todo Orange-Management/phpOMS#223 - * In the ArrayUtils class the power* functions should be combined once union types become available. - * * @group framework */ public function testPowerFloat() : void