diff --git a/ApplicationAbstract.php b/ApplicationAbstract.php index 96eca6760..ca3ba4103 100644 --- a/ApplicationAbstract.php +++ b/ApplicationAbstract.php @@ -23,7 +23,7 @@ namespace phpOMS; * * @property string $appName * @property \phpOMS\DataStorage\Database\DatabasePool $dbPool - * @property \phpOMS\Localization\L11nManager 4l11nManager + * @property \phpOMS\Localization\L11nManager $l11nManager * @property \phpOMS\Router\Router $router * @property \phpOMS\DataStorage\Session\SessionInterface $sessionManager * @property \phpOMS\Module\ModuleManager $moduleManager diff --git a/DataStorage/Cache/CachePool.php b/DataStorage/Cache/CachePool.php index 8146449b1..4b2047e13 100644 --- a/DataStorage/Cache/CachePool.php +++ b/DataStorage/Cache/CachePool.php @@ -17,6 +17,7 @@ namespace phpOMS\DataStorage\Cache; use phpOMS\DataStorage\DataStoragePoolInterface; use phpOMS\DataStorage\DataStorageConnectionInterface; use phpOMS\DataStorage\Cache\Connection\ConnectionFactory; +use phpOMS\DataStorage\Cache\Connection\NullCache; /** * Cache class. @@ -51,7 +52,7 @@ class CachePool implements DataStoragePoolInterface /** * Add database. * - * @param mixed $key Database key + * @param string $key Database key * @param DataStorageConnectionInterface $cache Cache * * @return bool @@ -72,7 +73,7 @@ class CachePool implements DataStoragePoolInterface /** * Remove database. * - * @param mixed $key Database key + * @param string $key Database key * * @return bool * @@ -94,14 +95,14 @@ class CachePool implements DataStoragePoolInterface * * @param string $key Cache to request * - * @return \phpOMS\DataStorage\Cache\CacheInterface + * @return DataStorageConnectionInterface * * @since 1.0.0 */ - public function get(string $key = '') /* : ?CacheInterface */ + public function get(string $key = '') : DataStorageConnectionInterface { if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { - return null; + return new NullCache(); } if (empty($key)) { @@ -114,8 +115,8 @@ class CachePool implements DataStoragePoolInterface /** * Create Cache. * - * @param mixed $key Database key - * @param array $config Database config data + * @param string $key Database key + * @param array $config Database config data * * @return bool * diff --git a/DataStorage/DataStoragePoolInterface.php b/DataStorage/DataStoragePoolInterface.php index 09d8bb96d..bc3bd597f 100644 --- a/DataStorage/DataStoragePoolInterface.php +++ b/DataStorage/DataStoragePoolInterface.php @@ -48,7 +48,7 @@ interface DataStoragePoolInterface * * @since 1.0.0 */ - public function get(string $key = ''); + public function get(string $key = '') : DataStorageConnectionInterface; /** * Remove connection. diff --git a/DataStorage/Database/BuilderAbstract.php b/DataStorage/Database/BuilderAbstract.php index 2f87241eb..9331e34b7 100644 --- a/DataStorage/Database/BuilderAbstract.php +++ b/DataStorage/Database/BuilderAbstract.php @@ -119,4 +119,13 @@ abstract class BuilderAbstract { return $this->type; } + + /** + * Parsing to sql string. + * + * @return string + * + * @since 1.0.0 + */ + abstract public function toSql() : string; } diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index ff6c103a8..f18ab5bca 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -682,6 +682,17 @@ class DataMapperAbstract implements DataMapperInterface } } + /** + * Create has one + * + * @param string $propertyName Property name to initialize + * @param Object $obj Object to create + * + * @return mixed + * @todo implement??? + * + * @since 1.0.0 + */ private static function createHasOne(\ReflectionClass $reflectionClass, $obj) { throw new \Exception(); @@ -2431,16 +2442,13 @@ class DataMapperAbstract implements DataMapperInterface $query->select($value['table'] . '.' . $src) ->from($value['table']) ->where($value['table'] . '.' . $value['dst'], '=', $primaryKey); - } elseif ($relations === RelationType::NEWEST) { - /* + } /*elseif ($relations === RelationType::NEWEST) { SELECT c.*, p1.* FROM customer c JOIN purchase p1 ON (c.id = p1.customer_id) LEFT OUTER JOIN purchase p2 ON (c.id = p2.customer_id AND (p1.date < p2.date OR p1.date = p2.date AND p1.id < p2.id)) WHERE p2.id IS NULL; - */ - /* $query->select(static::$table . '.' . static::$primaryField, $value['table'] . '.' . $value['src']) ->from(static::$table) ->join($value['table']) @@ -2448,8 +2456,8 @@ class DataMapperAbstract implements DataMapperInterface ->leftOuterJoin($value['table']) ->on(new And('1', new And(new Or('d1', 'd2'), 'id'))) ->where($value['table'] . '.' . $value['dst'], '=', 'NULL'); - */ - } + + }*/ $sth = self::$db->con->prepare($query->toSql()); $sth->execute(); diff --git a/DataStorage/Database/DatabasePool.php b/DataStorage/Database/DatabasePool.php index fc1706c04..df1fadf2a 100644 --- a/DataStorage/Database/DatabasePool.php +++ b/DataStorage/Database/DatabasePool.php @@ -75,11 +75,11 @@ class DatabasePool implements DataStoragePoolInterface * * @param string $key Database key * - * @return ConnectionAbstract + * @return DataStorageConnectionInterface * * @since 1.0.0 */ - public function get(string $key = '') : ConnectionAbstract + public function get(string $key = '') : DataStorageConnectionInterface { if ((!empty($key) && !isset($this->pool[$key])) || empty($this->pool)) { return new NullConnection(); diff --git a/Stdlib/Map/MultiMap.php b/Stdlib/Map/MultiMap.php index f7c4883d1..3a68b58b3 100644 --- a/Stdlib/Map/MultiMap.php +++ b/Stdlib/Map/MultiMap.php @@ -404,7 +404,11 @@ class MultiMap implements \Countable $removed = false; foreach ($keys as $key => $value) { - $removed |= $this->removeKey(implode(':', $value)); + $removed = $this->removeKey(implode(':', $value)); + + if (!$removed) { + return false; + } } return $removed; diff --git a/Utils/Barcode/C128Abstract.php b/Utils/Barcode/C128Abstract.php index 7fe2cba92..2bd7a1ffc 100644 --- a/Utils/Barcode/C128Abstract.php +++ b/Utils/Barcode/C128Abstract.php @@ -92,15 +92,15 @@ abstract class C128Abstract /** * Content to encrypt. * - * @var string|int + * @var string * @since 1.0.0 */ - protected $content = 0; + protected $content = ''; /** * Show text below barcode. * - * @var string + * @var bool * @since 1.0.0 */ protected $showText = true; diff --git a/Utils/Encoding/Huffman/Huffman.php b/Utils/Encoding/Huffman/Huffman.php index b0dc4f889..aeac7aab4 100644 --- a/Utils/Encoding/Huffman/Huffman.php +++ b/Utils/Encoding/Huffman/Huffman.php @@ -32,18 +32,6 @@ final class Huffman */ private $dictionary = null; - /** - * Remove dictionary - * - * @return void - * - * @since 1.0.0 - */ - public function removeDictionary() : void - { - $this->dictionary = null; - } - /** * Get dictionary * diff --git a/Utils/Git/Commit.php b/Utils/Git/Commit.php index e3df8709b..ff5e1df4f 100644 --- a/Utils/Git/Commit.php +++ b/Utils/Git/Commit.php @@ -83,7 +83,7 @@ class Commit /** * Files. * - * @var string[] + * @var array * @since 1.0.0 */ private $files = []; diff --git a/Utils/Git/Repository.php b/Utils/Git/Repository.php index beca1c11b..0f22f22f9 100644 --- a/Utils/Git/Repository.php +++ b/Utils/Git/Repository.php @@ -234,23 +234,27 @@ class Repository * * @param string $source Create repository from source (optional, can be remote) * - * @return string + * @return void * * @throws \Exception * * @since 1.0.0 */ - public function create(string $source = null) + public function create(string $source = null) : void { if (!is_dir($this->path) || file_exists($this->path . '/.git')) { throw new \Exception('Already repository'); } if ($source !== null) { - return stripos($source, '//') !== false ? $this->cloneRemote($source) : $this->cloneFrom($source); + stripos($source, '//') !== false ? $this->cloneRemote($source) : $this->cloneFrom($source); + + return; } - return $this->run('init'); + $this->run('init'); + + return; } /** @@ -491,7 +495,7 @@ class Repository public function checkout(Branch $branch) : string { $result = implode("\n", $this->run('checkout ' . $branch->getName())); - $this->branch = null; + $this->branch = $branch; return $result; } diff --git a/Utils/IO/Zip/ArchiveInterface.php b/Utils/IO/Zip/ArchiveInterface.php index ea9020f06..7c39aba0e 100644 --- a/Utils/IO/Zip/ArchiveInterface.php +++ b/Utils/IO/Zip/ArchiveInterface.php @@ -27,7 +27,7 @@ interface ArchiveInterface /** * Create archive. * - * @param string $sources Files and directories to compress + * @param mixed $sources Files and directories to compress * @param string $destination Output destination * @param bool $overwrite Overwrite if destination is existing * diff --git a/Utils/RnG/LinearCongruentialGenerator.php b/Utils/RnG/LinearCongruentialGenerator.php index db62ab2a4..8723af822 100644 --- a/Utils/RnG/LinearCongruentialGenerator.php +++ b/Utils/RnG/LinearCongruentialGenerator.php @@ -45,11 +45,11 @@ class LinearCongruentialGenerator * * @param int $seed Starting seed * - * @return \Closure + * @return int * * @since 1.0.0 */ - public static function bsd(int $seed = 0) + public static function bsd(int $seed = 0) : int { if ($seed !== 0) { self::$bsdSeed = $seed; @@ -63,11 +63,11 @@ class LinearCongruentialGenerator * * @param int $seed Starting seed * - * @return \Closure + * @return int * * @since 1.0.0 */ - public static function msvcrt(int $seed = 0) + public static function msvcrt(int $seed = 0) : int { if ($seed !== 0) { self::$msvcrtSeed = $seed; diff --git a/Utils/TaskSchedule/TaskFactory.php b/Utils/TaskSchedule/TaskFactory.php index 3d448b612..7d3e63499 100644 --- a/Utils/TaskSchedule/TaskFactory.php +++ b/Utils/TaskSchedule/TaskFactory.php @@ -39,7 +39,7 @@ final class TaskFactory * * @since 1.0.0 */ - public static function create(string $id = null, string $cmd = '') : TaskAbstract + public static function create(string $id = '', string $cmd = '') : TaskAbstract { switch (OperatingSystem::getSystem()) { case SystemType::WIN: diff --git a/tests/Asset/AssetManagerTest.php b/tests/Asset/AssetManagerTest.php index 71c8b031b..6e379a259 100644 --- a/tests/Asset/AssetManagerTest.php +++ b/tests/Asset/AssetManagerTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Account; +namespace phpOMS\tests\Asset; use phpOMS\Asset\AssetManager; diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index 0e94e8aa3..7a03d4f89 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Account; +namespace phpOMS\tests\Auth; use phpOMS\Auth\Auth; use phpOMS\Auth\LoginReturnType; diff --git a/tests/DataStorage/Cache/CachePoolTest.php b/tests/DataStorage/Cache/CachePoolTest.php index 84947066c..d77d879fb 100644 --- a/tests/DataStorage/Cache/CachePoolTest.php +++ b/tests/DataStorage/Cache/CachePoolTest.php @@ -23,7 +23,7 @@ class CachePoolTest extends \PHPUnit\Framework\TestCase $pool = new CachePool(); self::assertFalse($pool->remove('core')); - self::assertEquals(null, $pool->get()); + self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\NullCache', $pool->get()); } public function testGetSet() @@ -38,7 +38,7 @@ class CachePoolTest extends \PHPUnit\Framework\TestCase self::assertFalse($pool->create('abc', ['type' => 'file', 'path' => __DIR__])); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('abc')); self::assertTrue($pool->remove('abc')); - self::assertEquals(null, $pool->get('abc')); + self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\NullCache', $pool->get('abc')); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('test')); self::assertFalse($pool->remove('abc')); } diff --git a/tests/DataStorage/Cache/Connection/CacheTypeTest.php b/tests/DataStorage/Cache/Connection/CacheValueTypeTest.php similarity index 100% rename from tests/DataStorage/Cache/Connection/CacheTypeTest.php rename to tests/DataStorage/Cache/Connection/CacheValueTypeTest.php diff --git a/tests/Math/Geometry/Shape/D2/CircleTest.php b/tests/Math/Geometry/Shape/D2/CircleTest.php index ac38393bb..7ae7d1b4b 100644 --- a/tests/Math/Geometry/Shape/D2/CircleTest.php +++ b/tests/Math/Geometry/Shape/D2/CircleTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Circle; diff --git a/tests/Math/Geometry/Shape/D2/EllipseTest.php b/tests/Math/Geometry/Shape/D2/EllipseTest.php index 48fd32f7e..64443bf90 100644 --- a/tests/Math/Geometry/Shape/D2/EllipseTest.php +++ b/tests/Math/Geometry/Shape/D2/EllipseTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Ellipse; diff --git a/tests/Math/Geometry/Shape/D2/PolygonTest.php b/tests/Math/Geometry/Shape/D2/PolygonTest.php index aac84ee29..6d9afb0c9 100644 --- a/tests/Math/Geometry/Shape/D2/PolygonTest.php +++ b/tests/Math/Geometry/Shape/D2/PolygonTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Polygon; diff --git a/tests/Math/Geometry/Shape/D2/QuadrilateralTest.php b/tests/Math/Geometry/Shape/D2/QuadrilateralTest.php index 461542649..d5c951b07 100644 --- a/tests/Math/Geometry/Shape/D2/QuadrilateralTest.php +++ b/tests/Math/Geometry/Shape/D2/QuadrilateralTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Quadrilateral; diff --git a/tests/Math/Geometry/Shape/D2/RectangleTest.php b/tests/Math/Geometry/Shape/D2/RectangleTest.php index 314eb6e85..4f86d0006 100644 --- a/tests/Math/Geometry/Shape/D2/RectangleTest.php +++ b/tests/Math/Geometry/Shape/D2/RectangleTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Rectangle; diff --git a/tests/Math/Geometry/Shape/D2/TrapezoidTest.php b/tests/Math/Geometry/Shape/D2/TrapezoidTest.php index 0a75d9b2c..f46c14ec7 100644 --- a/tests/Math/Geometry/Shape/D2/TrapezoidTest.php +++ b/tests/Math/Geometry/Shape/D2/TrapezoidTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Trapezoid; diff --git a/tests/Math/Geometry/Shape/D2/TriangleTest.php b/tests/Math/Geometry/Shape/D2/TriangleTest.php index 71dd3b732..0be4b4cf0 100644 --- a/tests/Math/Geometry/Shape/D2/TriangleTest.php +++ b/tests/Math/Geometry/Shape/D2/TriangleTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Math\Shape\D2; +namespace phpOMS\tests\Math\Geometry\Shape\D2; use phpOMS\Math\Geometry\Shape\D2\Triangle; diff --git a/tests/Stdlib/Map/MultiMapTest.php b/tests/Stdlib/Map/MultiMapTest.php index 9d832cc47..1bc4397ae 100644 --- a/tests/Stdlib/Map/MultiMapTest.php +++ b/tests/Stdlib/Map/MultiMapTest.php @@ -11,7 +11,7 @@ * @link http://website.orange-management.de */ -namespace phpOMS\tests\Utils; +namespace phpOMS\tests\Stdlib\Map; use phpOMS\Stdlib\Map\MultiMap; diff --git a/tests/Utils/Encoding/Huffman/HuffmanTest.php b/tests/Utils/Encoding/Huffman/HuffmanTest.php index b07d3b176..02ddbe160 100644 --- a/tests/Utils/Encoding/Huffman/HuffmanTest.php +++ b/tests/Utils/Encoding/Huffman/HuffmanTest.php @@ -38,8 +38,5 @@ class HuffmanTest extends \PHPUnit\Framework\TestCase ); self::assertEquals('', $man->decode('')); - - $huff->removeDictionary(); - self::assertEquals(null, $huff->getDictionary()); } }