diff --git a/ci/apiv2/test_task.py b/ci/apiv2/test_task.py index 27d8596b3..63a929987 100644 --- a/ci/apiv2/test_task.py +++ b/ci/apiv2/test_task.py @@ -51,9 +51,15 @@ def test_patch_color_null(self): obj = Task.objects.get(taskId=task.id) self.assertIsNone(obj.color) - def test_runtime(self): + def test_runtime_preprocessor(self): task = self.create_test_object(file_id='002') + obj = Task.objects.get(taskId=task.id) + self.assertEqual(obj.useNewBench, 1) + + def test_runtime(self): + task = self.create_test_object(file_id='004') + obj = Task.objects.get(taskId=task.id) self.assertEqual(obj.useNewBench, 0) diff --git a/ci/apiv2/testfiles/task/create_task_004.json b/ci/apiv2/testfiles/task/create_task_004.json new file mode 100644 index 000000000..175435480 --- /dev/null +++ b/ci/apiv2/testfiles/task/create_task_004.json @@ -0,0 +1,22 @@ +{ + "attackCmd": "#HL# -a 0 ad a1", + "chunkSize": 1000, + "chunkTime": 600, + "color": "7C6EFF", + "crackerBinaryId": 1, + "forcePipe": true, + "files": [], + "isArchived": false, + "isCpuTask": false, + "isSmall": false, + "maxAgents": 112, + "notes": "example-note", + "preprocessorCommand": "", + "priority": 10, + "skipKeyspace": 500, + "staticChunks": 2, + "statusTimer": 5, + "taskName": "Example - runtime", + "useNewBench": false, + "preprocessorId": 0 +} diff --git a/ci/phpunit/dba/AbstractModelFactoryTest.php b/ci/phpunit/dba/AbstractModelFactoryTest.php index 132edc28f..24b58f277 100644 --- a/ci/phpunit/dba/AbstractModelFactoryTest.php +++ b/ci/phpunit/dba/AbstractModelFactoryTest.php @@ -216,6 +216,7 @@ public function testUpdateModelSuccessMultipleChanges(): void { */ public function testMsetSuccess(): void { $hashType = $this->createDatabaseObject(Factory::getHashTypeFactory(), new HashType(null, 'placeholder', 0, 0)); + $this->assertInstanceOf(HashType::class, $hashType); Factory::getHashTypeFactory()->mset($hashType, [HashType::IS_SALTED => 1, HashType::IS_SLOW_HASH => 1]); $hashTypeUpdated = Factory::getHashTypeFactory()->get($hashType->getId()); $this->assertEquals(1, $hashTypeUpdated->getIsSalted()); @@ -259,6 +260,7 @@ public function testMsetSuccessTwoObjects(): void { */ public function testSetSuccess(): void { $hashType = $this->createDatabaseObject(Factory::getHashTypeFactory(), new HashType(null, 'placeholder', 0, 0)); + $this->assertTrue($hashType instanceof HashType); Factory::getHashTypeFactory()->set($hashType, HashType::IS_SALTED, 1); $hashTypeUpdated = Factory::getHashTypeFactory()->get($hashType->getId()); $this->assertEquals(1, $hashTypeUpdated->getIsSalted()); @@ -294,6 +296,38 @@ public function testSetSuccessTwoObjects(): void { $this->assertEquals('something else', $hashTypeUpdated->getDescription()); } + /** + * Tests that set() replaces the by-ref model with a new instance of the correct concrete type + * + * @return void + * @throws Exception + */ + public function testSetRefreshesModel(): void { + $hashType = $this->createDatabaseObject(Factory::getHashTypeFactory(), new HashType(null, 'placeholder', 0, 0)); + $this->assertInstanceOf(HashType::class, $hashType); + $originalObject = $hashType; + $hashType = Factory::getHashTypeFactory()->set($hashType, HashType::IS_SALTED, 1); + $this->assertNotSame($originalObject, $hashType); + $this->assertEquals(1, $hashType->getIsSalted()); + $this->assertEquals(0, $hashType->getIsSlowHash()); + } + + /** + * Tests that mset() replaces the by-ref model with a new instance of the correct concrete type + * + * @return void + * @throws Exception + */ + public function testMsetRefreshesModel(): void { + $hashType = $this->createDatabaseObject(Factory::getHashTypeFactory(), new HashType(null, 'placeholder', 0, 0)); + $this->assertInstanceOf(HashType::class, $hashType); + $originalObject = $hashType; + $hashType = Factory::getHashTypeFactory()->mset($hashType, [HashType::IS_SALTED => 1, HashType::IS_SLOW_HASH => 1]); + $this->assertNotSame($originalObject, $hashType); + $this->assertEquals(1, $hashType->getIsSalted()); + $this->assertEquals(1, $hashType->getIsSlowHash()); + } + /** * Tests if values with inc() are set properly * @@ -333,11 +367,13 @@ public function testIncSuccessTwoObjects(): void { Factory::getHashTypeFactory()->inc($hashType1, HashType::IS_SALTED, 2); + $this->assertTrue($hashType1 instanceof HashType); $this->assertEquals(3, $hashType1->getIsSalted()); $this->assertEquals(1, $hashType2->getIsSalted()); Factory::getHashTypeFactory()->inc($hashType2, HashType::IS_SALTED, 20); + $this->assertTrue($hashType2 instanceof HashType); $this->assertEquals(23, $hashType2->getIsSalted()); $hashTypeUpdated = Factory::getHashTypeFactory()->get($hashType1->getId()); @@ -407,11 +443,13 @@ public function testDecSuccessTwoObjects(): void { Factory::getHashTypeFactory()->dec($hashType1, HashType::IS_SALTED, 2); + $this->assertTrue($hashType1 instanceof HashType); $this->assertEquals(48, $hashType1->getIsSalted()); $this->assertEquals(50, $hashType2->getIsSalted()); Factory::getHashTypeFactory()->dec($hashType2, HashType::IS_SALTED, 20); + $this->assertTrue($hashType2 instanceof HashType); $this->assertEquals(28, $hashType2->getIsSalted()); $hashTypeUpdated = Factory::getHashTypeFactory()->get($hashType1->getId()); @@ -1315,6 +1353,7 @@ public function testFilterWithJoinOverrideOwnFactory(): void { $accessGroup = $this->createDatabaseObject(Factory::getAccessGroupFactory(), new AccessGroup(null, 'ag_' . $testId)); $this->createDatabaseObject(Factory::getFileFactory(), new File(null, 'file_' . $testId, 1, 0, 0, $accessGroup->getId(), 1)); + $this->assertTrue($accessGroup instanceof AccessGroup); $qF = new QueryFilter(AccessGroup::GROUP_NAME, $accessGroup->getGroupName(), '=', Factory::getAccessGroupFactory()); $jF = new JoinFilter( @@ -1341,6 +1380,7 @@ public function testFilterWithJoinQueryFilters(): void { $accessGroup = $this->createDatabaseObject(Factory::getAccessGroupFactory(), new AccessGroup(null, 'ag_' . $testId)); $this->createDatabaseObject(Factory::getFileFactory(), new File(null, 'file1_' . $testId, 1, 0, 0, $accessGroup->getId(), 1)); $this->createDatabaseObject(Factory::getFileFactory(), new File(null, 'file2_' . $testId, 2, 0, 0, $accessGroup->getId(), 1)); + $this->assertTrue($accessGroup instanceof AccessGroup); $qF = new QueryFilter(AccessGroup::GROUP_NAME, $accessGroup->getGroupName(), '=', Factory::getAccessGroupFactory()); $jF = new JoinFilter( diff --git a/ci/phpunit/inc/UtilTest.php b/ci/phpunit/inc/UtilTest.php index 8cb976216..0a33763a5 100644 --- a/ci/phpunit/inc/UtilTest.php +++ b/ci/phpunit/inc/UtilTest.php @@ -762,7 +762,7 @@ public function testGetUsernameById(): void { */ public function testGetUsernameByIdNotFound(): void { $result = Util::getUsernameById(99999999); - $this->assertEquals("-99999999", $result); + $this->assertEquals("Unknown-99999999", $result); } /** diff --git a/ci/phpunit/inc/utils/ChunkUtilsTest.php b/ci/phpunit/inc/utils/ChunkUtilsTest.php index 946ba2215..7ad6f88ac 100644 --- a/ci/phpunit/inc/utils/ChunkUtilsTest.php +++ b/ci/phpunit/inc/utils/ChunkUtilsTest.php @@ -97,13 +97,6 @@ public static function invalidBenchmarkCases(): array { ]; } - // Verifies that a benchmark string with no colon routes to the old-benchmark - // path and PHP 8 throws TypeError on arithmetic with a non-numeric string. - public function testOldBenchmarkNonNumericStringThrowsTypeError(): void { - $this->expectException(\TypeError::class); - ChunkUtils::calculateChunkSize(1000000, 'invalid', 60); - } - // Verifies the safety floor: when the formula produces a size <= 0 the result // is clamped to 1 so dispatching never stalls on an infinite zero-size loop. // $QUERY must be set because the clamp path calls Util::createLogEntry which diff --git a/phpstan.neon b/phpstan.neon index 2be365de4..d76f06f9c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,12 +1,12 @@ parameters: paths: - src/inc/apiv2 - - ci/phpunit - level: 4 - treatPhpDocTypesAsCertain: false - scanDirectories: - src/dba - src/inc + - ci/phpunit + level: 4 + treatPhpDocTypesAsCertain: false excludePaths: - # Exclude the DBA tests due PHPStan doing weird complaints - - ci/phpunit/dba/AbstractModelFactoryTest.php \ No newline at end of file + # this is deprecated/legacy and will not be touched until remove + - src/inc/Auth_Yubico.php + - src/inc/Login.php \ No newline at end of file diff --git a/src/dba/AbstractModel.php b/src/dba/AbstractModel.php index 6b4b7072a..271dbc313 100755 --- a/src/dba/AbstractModel.php +++ b/src/dba/AbstractModel.php @@ -22,7 +22,7 @@ abstract function getPrimaryKeyValue(); /** * This function is used to set the id to the real database value * @param $id string - * @return + * @return void */ abstract function setId(string $id): void; @@ -30,4 +30,9 @@ abstract function setId(string $id): void; * this function returns the models id */ abstract function getId(); + + /** + * The function is used to retrieve information about the attributes of the model + */ + abstract static function getFeatures(); } diff --git a/src/dba/AbstractModelFactory.php b/src/dba/AbstractModelFactory.php index 8c05d0bcf..108da152c 100755 --- a/src/dba/AbstractModelFactory.php +++ b/src/dba/AbstractModelFactory.php @@ -102,7 +102,7 @@ private static function isBinaryColumn(AbstractModel $model, string $key): bool $features = $model->getFeatures(); return isset($features[$key]['type']) && $features[$key]['type'] === 'binary'; } - + /** * @param AbstractModel $model * @param string $key unmapped column name @@ -115,7 +115,7 @@ private static function binaryPlaceholder(AbstractModel $model, string $key): st $dbType = StartupConfig::getInstance()->getDatabaseType(); return $dbType === 'mysql' ? "UNHEX(?)" : "decode(?, 'hex')"; } - + /** * Get all the attribute keys of a model prepared with the mapping prefix where needed. The returned keys are then named * exactly how they are present in the database. @@ -225,20 +225,6 @@ private function getFilters(array $arr): array { return array(); } - /** - * @param $arr array - * @return Order[] - */ - private function getOrders(array $arr): array { - if (!is_array($arr[Factory::ORDER])) { - $arr[Factory::ORDER] = array($arr[Factory::ORDER]); - } - if (isset($arr[Factory::ORDER])) { - return $arr[Factory::ORDER]; - } - return array(); - } - /** * @param $arr array * @return Join[] @@ -290,13 +276,13 @@ public function update(AbstractModel $model): PDOStatement { /** * Atomically sets the given keys of this model to the given values without setting all other values (like ->update() does) * - * Returns the return of PDO::execute() - * @param $model AbstractModel primary key of model - * @param $arr array key-value associations for update - * @return PDOStatement + * Returns the return of PDO::execute() or null if nothing was executed + * @param AbstractModel $model AbstractModel primary key of model + * @param array $arr key-value associations for update + * @return AbstractModel updated model * @throws Exception */ - public function mset(AbstractModel &$model, array $arr): PDOStatement { + public function mset(AbstractModel $model, array $arr): AbstractModel { $query = "UPDATE " . $this->getMappedModelTable() . " SET "; $elements = []; $values = []; @@ -313,20 +299,21 @@ public function mset(AbstractModel &$model, array $arr): PDOStatement { $stmt->execute($values); $model = $this->get($model->getPrimaryKeyValue()); - return $stmt; + assert($model !== null); // assert as on this update we should not get null back (unless race-condition) + return $model; } /** * Atomically sets the given key of this model to the given value without altering other values * * Returns the return of PDO::execute() - * @param $model AbstractModel primary key of model - * @param $key string key of the column to update + * @param AbstractModel $model primary key of model + * @param string $key key of the column to update * @param $value - * @return PDOStatement + * @return AbstractModel * @throws Exception */ - public function set(AbstractModel &$model, string $key, $value): PDOStatement { + public function set(AbstractModel $model, string $key, $value): AbstractModel { $query = "UPDATE " . $this->getMappedModelTable() . " SET " . self::getMappedModelKey($model, $key) . "=" . self::binaryPlaceholder($model, $key); $values = []; @@ -338,7 +325,8 @@ public function set(AbstractModel &$model, string $key, $value): PDOStatement { $stmt->execute($values); $model = $this->get($model->getPrimaryKeyValue()); - return $stmt; + assert($model !== null); // assert as on this update we should not get null back (unless race-condition) + return $model; } /** @@ -367,7 +355,9 @@ public function inc(AbstractModel &$model, string $key, int $value = 1): PDOStat $stmt = $this->getDB()->prepare($query); $stmt->execute($values); - $model = $this->get($model->getPrimaryKeyValue()); + $refreshed = $this->get($model->getPrimaryKeyValue()); + assert($refreshed instanceof AbstractModel); + $model = $refreshed; return $stmt; } @@ -397,7 +387,9 @@ public function dec(AbstractModel &$model, string $key, int $value = 1): PDOStat $stmt = $this->getDB()->prepare($query); $stmt->execute($values); - $model = $this->get($model->getPrimaryKeyValue()); + $refreshed = $this->get($model->getPrimaryKeyValue()); + assert($refreshed instanceof AbstractModel); + $model = $refreshed; return $stmt; } @@ -654,7 +646,7 @@ public function countFilter(array $options): int { * @return AbstractModel|null the with pk associated model or Null * @throws Exception */ - public function get($pk) { + public function get($pk): ?AbstractModel { return $this->getFromDB($pk); } @@ -700,10 +692,10 @@ public function getFromDB($pk): ?AbstractModel { * $options[Factory::JOIN] is an array of JoinFilter options * * @param $options array containing option settings - * @return AbstractModel[]|AbstractModel Returns a list of matching objects or Null + * @return array Returns an array of matching objects * @throws Exception */ - private function filterWithJoin(array $options): array|AbstractModel { + private function filterWithJoin(array $options): array { $vals = array(); $joins = $this->getJoins($options); $factories = array($this); @@ -734,7 +726,7 @@ private function filterWithJoin(array $options): array|AbstractModel { if (array_key_exists(Factory::FILTER, $options)) { $query .= $this->applyFilters($vals, $options[Factory::FILTER]); } - + // Apply order filter if (!array_key_exists(Factory::ORDER, $options)) { // Add a asc order on the primary keys as a standard @@ -750,7 +742,7 @@ private function filterWithJoin(array $options): array|AbstractModel { $dbh = self::getDB(); $stmt = $dbh->prepare($query); $stmt->execute($vals); - + $res = array(); $values = array(); foreach ($factories as $factory) { @@ -867,19 +859,18 @@ private function applyFilters(&$vals, Filter|array $filters, bool $isJoinFilter } return " WHERE " . implode(" AND ", $parts); } - + /** * @param $vals * @param $element - * @return array */ - private function getAllArrayValues(&$vals, $element) { + private function getAllArrayValues(&$vals, $element): void { if (!is_array($element)) { $vals[] = $element; return; } - - foreach($element as $v) { + + foreach ($element as $v) { $this->getAllArrayValues($vals, $v); } } @@ -933,21 +924,6 @@ private function applyLimit($limit): string { return " LIMIT " . $limit->getQueryString($this); } - /** - * @param $groups - * @return string - */ - private function applyGroups($groups): string { - $groupsQueries = array(); - if (!is_array($groups)) { - $groups = array($groups); - } - foreach ($groups as $group) { - $groupsQueries[] = $group->getQueryString($this, true); - } - return " GROUP BY " . implode(", ", $groupsQueries); - } - /** * Deletes the given model * diff --git a/src/dba/Join.php b/src/dba/Join.php index a464581b7..19b3cb780 100644 --- a/src/dba/Join.php +++ b/src/dba/Join.php @@ -5,6 +5,8 @@ abstract class Join { abstract function getOtherFactory(): AbstractModelFactory; + abstract function getOverrideOwnFactory(): ?AbstractModelFactory; + abstract function getMatch1(): string; abstract function getMatch2(): string; diff --git a/src/dba/JoinFilter.php b/src/dba/JoinFilter.php index f980a429c..6bf1870d9 100755 --- a/src/dba/JoinFilter.php +++ b/src/dba/JoinFilter.php @@ -3,7 +3,7 @@ namespace Hashtopolis\dba; class JoinFilter extends Join { - private ?AbstractModelFactory $otherFactory; + private AbstractModelFactory $otherFactory; private string $match1; private string $match2; diff --git a/src/dba/PaginationFilter.php b/src/dba/PaginationFilter.php index e4e3a619e..791ef19a2 100644 --- a/src/dba/PaginationFilter.php +++ b/src/dba/PaginationFilter.php @@ -9,9 +9,7 @@ class PaginationFilter extends Filter { private $tieBreakerKey; private $tieBreakerValue; private $filters; - /** - * @var - */ + private ?AbstractModelFactory $overrideFactory; function __construct($key, $value, $operator, $tieBreakerKey, $tieBreakerValue, $filters = [], $overrideFactory = null) { diff --git a/src/dba/models/AbstractModelFactory.template.txt b/src/dba/models/AbstractModelFactory.template.txt index 5ee16a9c1..bbc131f60 100644 --- a/src/dba/models/AbstractModelFactory.template.txt +++ b/src/dba/models/AbstractModelFactory.template.txt @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class __MODEL_NAME__Factory extends AbstractModelFactory { @@ -50,7 +53,8 @@ class __MODEL_NAME__Factory extends AbstractModelFactory { /** * @param array $options * @param bool $single - * @return __MODEL_NAME__|__MODEL_NAME__[] + * @return __MODEL_NAME__|array|null + * @throws Exception */ function filter(array $options, bool $single = false): __MODEL_NAME__|array|null { $join = false; @@ -77,6 +81,7 @@ class __MODEL_NAME__Factory extends AbstractModelFactory { /** * @param string $pk * @return ?__MODEL_NAME__ + * @throws Exception */ function get($pk): ?__MODEL_NAME__ { return Util::cast(parent::get($pk), __MODEL_NAME__::class); @@ -84,9 +89,31 @@ class __MODEL_NAME__Factory extends AbstractModelFactory { /** * @param __MODEL_NAME__ $model - * @return __MODEL_NAME__ + * @return ?__MODEL_NAME__ + * @throws Exception */ - function save($model): __MODEL_NAME__ { + function save($model): ?__MODEL_NAME__ { return Util::cast(parent::save($model), __MODEL_NAME__::class); } + + /** + * @param __MODEL_NAME__ $model + * @param array $arr key-value associations for update + * @return __MODEL_NAME__ + * @throws Exception + */ + function mset($model, array $arr): __MODEL_NAME__ { + return Util::cast(parent::mset($model, $arr), __MODEL_NAME__::class); + } + + /** + * @param __MODEL_NAME__ $model + * @param string $key key of the column to update + * @param $value + * @return __MODEL_NAME__ + * @throws Exception + */ + function set($model, string $key, $value): __MODEL_NAME__ { + return Util::cast(parent::set($model, $key, $value), __MODEL_NAME__::class); + } } diff --git a/src/dba/models/AccessGroupAgentFactory.php b/src/dba/models/AccessGroupAgentFactory.php index bc7720a23..23e77dc73 100644 --- a/src/dba/models/AccessGroupAgentFactory.php +++ b/src/dba/models/AccessGroupAgentFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AccessGroupAgentFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AccessGroupAgent { /** * @param array $options * @param bool $single - * @return AccessGroupAgent|AccessGroupAgent[] + * @return AccessGroupAgent|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AccessGroupAgent|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AccessGroupAgent|array|nu /** * @param string $pk * @return ?AccessGroupAgent + * @throws Exception */ function get($pk): ?AccessGroupAgent { return Util::cast(parent::get($pk), AccessGroupAgent::class); @@ -84,9 +89,31 @@ function get($pk): ?AccessGroupAgent { /** * @param AccessGroupAgent $model - * @return AccessGroupAgent + * @return ?AccessGroupAgent + * @throws Exception */ - function save($model): AccessGroupAgent { + function save($model): ?AccessGroupAgent { return Util::cast(parent::save($model), AccessGroupAgent::class); } + + /** + * @param AccessGroupAgent $model + * @param array $arr key-value associations for update + * @return AccessGroupAgent + * @throws Exception + */ + function mset($model, array $arr): AccessGroupAgent { + return Util::cast(parent::mset($model, $arr), AccessGroupAgent::class); + } + + /** + * @param AccessGroupAgent $model + * @param string $key key of the column to update + * @param $value + * @return AccessGroupAgent + * @throws Exception + */ + function set($model, string $key, $value): AccessGroupAgent { + return Util::cast(parent::set($model, $key, $value), AccessGroupAgent::class); + } } diff --git a/src/dba/models/AccessGroupFactory.php b/src/dba/models/AccessGroupFactory.php index 9e839ec01..a493b106d 100644 --- a/src/dba/models/AccessGroupFactory.php +++ b/src/dba/models/AccessGroupFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AccessGroupFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AccessGroup { /** * @param array $options * @param bool $single - * @return AccessGroup|AccessGroup[] + * @return AccessGroup|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AccessGroup|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AccessGroup|array|null { /** * @param string $pk * @return ?AccessGroup + * @throws Exception */ function get($pk): ?AccessGroup { return Util::cast(parent::get($pk), AccessGroup::class); @@ -84,9 +89,31 @@ function get($pk): ?AccessGroup { /** * @param AccessGroup $model - * @return AccessGroup + * @return ?AccessGroup + * @throws Exception */ - function save($model): AccessGroup { + function save($model): ?AccessGroup { return Util::cast(parent::save($model), AccessGroup::class); } + + /** + * @param AccessGroup $model + * @param array $arr key-value associations for update + * @return AccessGroup + * @throws Exception + */ + function mset($model, array $arr): AccessGroup { + return Util::cast(parent::mset($model, $arr), AccessGroup::class); + } + + /** + * @param AccessGroup $model + * @param string $key key of the column to update + * @param $value + * @return AccessGroup + * @throws Exception + */ + function set($model, string $key, $value): AccessGroup { + return Util::cast(parent::set($model, $key, $value), AccessGroup::class); + } } diff --git a/src/dba/models/AccessGroupUserFactory.php b/src/dba/models/AccessGroupUserFactory.php index 3ba0d1aa7..f74582457 100644 --- a/src/dba/models/AccessGroupUserFactory.php +++ b/src/dba/models/AccessGroupUserFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AccessGroupUserFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AccessGroupUser { /** * @param array $options * @param bool $single - * @return AccessGroupUser|AccessGroupUser[] + * @return AccessGroupUser|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AccessGroupUser|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AccessGroupUser|array|nul /** * @param string $pk * @return ?AccessGroupUser + * @throws Exception */ function get($pk): ?AccessGroupUser { return Util::cast(parent::get($pk), AccessGroupUser::class); @@ -84,9 +89,31 @@ function get($pk): ?AccessGroupUser { /** * @param AccessGroupUser $model - * @return AccessGroupUser + * @return ?AccessGroupUser + * @throws Exception */ - function save($model): AccessGroupUser { + function save($model): ?AccessGroupUser { return Util::cast(parent::save($model), AccessGroupUser::class); } + + /** + * @param AccessGroupUser $model + * @param array $arr key-value associations for update + * @return AccessGroupUser + * @throws Exception + */ + function mset($model, array $arr): AccessGroupUser { + return Util::cast(parent::mset($model, $arr), AccessGroupUser::class); + } + + /** + * @param AccessGroupUser $model + * @param string $key key of the column to update + * @param $value + * @return AccessGroupUser + * @throws Exception + */ + function set($model, string $key, $value): AccessGroupUser { + return Util::cast(parent::set($model, $key, $value), AccessGroupUser::class); + } } diff --git a/src/dba/models/AgentBinaryFactory.php b/src/dba/models/AgentBinaryFactory.php index 24e719480..9d4860608 100644 --- a/src/dba/models/AgentBinaryFactory.php +++ b/src/dba/models/AgentBinaryFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AgentBinaryFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AgentBinary { /** * @param array $options * @param bool $single - * @return AgentBinary|AgentBinary[] + * @return AgentBinary|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AgentBinary|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AgentBinary|array|null { /** * @param string $pk * @return ?AgentBinary + * @throws Exception */ function get($pk): ?AgentBinary { return Util::cast(parent::get($pk), AgentBinary::class); @@ -84,9 +89,31 @@ function get($pk): ?AgentBinary { /** * @param AgentBinary $model - * @return AgentBinary + * @return ?AgentBinary + * @throws Exception */ - function save($model): AgentBinary { + function save($model): ?AgentBinary { return Util::cast(parent::save($model), AgentBinary::class); } + + /** + * @param AgentBinary $model + * @param array $arr key-value associations for update + * @return AgentBinary + * @throws Exception + */ + function mset($model, array $arr): AgentBinary { + return Util::cast(parent::mset($model, $arr), AgentBinary::class); + } + + /** + * @param AgentBinary $model + * @param string $key key of the column to update + * @param $value + * @return AgentBinary + * @throws Exception + */ + function set($model, string $key, $value): AgentBinary { + return Util::cast(parent::set($model, $key, $value), AgentBinary::class); + } } diff --git a/src/dba/models/AgentErrorFactory.php b/src/dba/models/AgentErrorFactory.php index 8c2588120..83ea3028c 100644 --- a/src/dba/models/AgentErrorFactory.php +++ b/src/dba/models/AgentErrorFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AgentErrorFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AgentError { /** * @param array $options * @param bool $single - * @return AgentError|AgentError[] + * @return AgentError|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AgentError|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AgentError|array|null { /** * @param string $pk * @return ?AgentError + * @throws Exception */ function get($pk): ?AgentError { return Util::cast(parent::get($pk), AgentError::class); @@ -84,9 +89,31 @@ function get($pk): ?AgentError { /** * @param AgentError $model - * @return AgentError + * @return ?AgentError + * @throws Exception */ - function save($model): AgentError { + function save($model): ?AgentError { return Util::cast(parent::save($model), AgentError::class); } + + /** + * @param AgentError $model + * @param array $arr key-value associations for update + * @return AgentError + * @throws Exception + */ + function mset($model, array $arr): AgentError { + return Util::cast(parent::mset($model, $arr), AgentError::class); + } + + /** + * @param AgentError $model + * @param string $key key of the column to update + * @param $value + * @return AgentError + * @throws Exception + */ + function set($model, string $key, $value): AgentError { + return Util::cast(parent::set($model, $key, $value), AgentError::class); + } } diff --git a/src/dba/models/AgentFactory.php b/src/dba/models/AgentFactory.php index 5bd4a2378..9910f23b7 100644 --- a/src/dba/models/AgentFactory.php +++ b/src/dba/models/AgentFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AgentFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Agent { /** * @param array $options * @param bool $single - * @return Agent|Agent[] + * @return Agent|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Agent|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Agent|array|null { /** * @param string $pk * @return ?Agent + * @throws Exception */ function get($pk): ?Agent { return Util::cast(parent::get($pk), Agent::class); @@ -84,9 +89,31 @@ function get($pk): ?Agent { /** * @param Agent $model - * @return Agent + * @return ?Agent + * @throws Exception */ - function save($model): Agent { + function save($model): ?Agent { return Util::cast(parent::save($model), Agent::class); } + + /** + * @param Agent $model + * @param array $arr key-value associations for update + * @return Agent + * @throws Exception + */ + function mset($model, array $arr): Agent { + return Util::cast(parent::mset($model, $arr), Agent::class); + } + + /** + * @param Agent $model + * @param string $key key of the column to update + * @param $value + * @return Agent + * @throws Exception + */ + function set($model, string $key, $value): Agent { + return Util::cast(parent::set($model, $key, $value), Agent::class); + } } diff --git a/src/dba/models/AgentStatFactory.php b/src/dba/models/AgentStatFactory.php index 885709e38..2e391a18e 100644 --- a/src/dba/models/AgentStatFactory.php +++ b/src/dba/models/AgentStatFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AgentStatFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AgentStat { /** * @param array $options * @param bool $single - * @return AgentStat|AgentStat[] + * @return AgentStat|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AgentStat|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AgentStat|array|null { /** * @param string $pk * @return ?AgentStat + * @throws Exception */ function get($pk): ?AgentStat { return Util::cast(parent::get($pk), AgentStat::class); @@ -84,9 +89,31 @@ function get($pk): ?AgentStat { /** * @param AgentStat $model - * @return AgentStat + * @return ?AgentStat + * @throws Exception */ - function save($model): AgentStat { + function save($model): ?AgentStat { return Util::cast(parent::save($model), AgentStat::class); } + + /** + * @param AgentStat $model + * @param array $arr key-value associations for update + * @return AgentStat + * @throws Exception + */ + function mset($model, array $arr): AgentStat { + return Util::cast(parent::mset($model, $arr), AgentStat::class); + } + + /** + * @param AgentStat $model + * @param string $key key of the column to update + * @param $value + * @return AgentStat + * @throws Exception + */ + function set($model, string $key, $value): AgentStat { + return Util::cast(parent::set($model, $key, $value), AgentStat::class); + } } diff --git a/src/dba/models/AgentZapFactory.php b/src/dba/models/AgentZapFactory.php index 733672c98..839f7909f 100644 --- a/src/dba/models/AgentZapFactory.php +++ b/src/dba/models/AgentZapFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AgentZapFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): AgentZap { /** * @param array $options * @param bool $single - * @return AgentZap|AgentZap[] + * @return AgentZap|array|null + * @throws Exception */ function filter(array $options, bool $single = false): AgentZap|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): AgentZap|array|null { /** * @param string $pk * @return ?AgentZap + * @throws Exception */ function get($pk): ?AgentZap { return Util::cast(parent::get($pk), AgentZap::class); @@ -84,9 +89,31 @@ function get($pk): ?AgentZap { /** * @param AgentZap $model - * @return AgentZap + * @return ?AgentZap + * @throws Exception */ - function save($model): AgentZap { + function save($model): ?AgentZap { return Util::cast(parent::save($model), AgentZap::class); } + + /** + * @param AgentZap $model + * @param array $arr key-value associations for update + * @return AgentZap + * @throws Exception + */ + function mset($model, array $arr): AgentZap { + return Util::cast(parent::mset($model, $arr), AgentZap::class); + } + + /** + * @param AgentZap $model + * @param string $key key of the column to update + * @param $value + * @return AgentZap + * @throws Exception + */ + function set($model, string $key, $value): AgentZap { + return Util::cast(parent::set($model, $key, $value), AgentZap::class); + } } diff --git a/src/dba/models/ApiGroupFactory.php b/src/dba/models/ApiGroupFactory.php index abb121e19..8349ec3d4 100644 --- a/src/dba/models/ApiGroupFactory.php +++ b/src/dba/models/ApiGroupFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ApiGroupFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): ApiGroup { /** * @param array $options * @param bool $single - * @return ApiGroup|ApiGroup[] + * @return ApiGroup|array|null + * @throws Exception */ function filter(array $options, bool $single = false): ApiGroup|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): ApiGroup|array|null { /** * @param string $pk * @return ?ApiGroup + * @throws Exception */ function get($pk): ?ApiGroup { return Util::cast(parent::get($pk), ApiGroup::class); @@ -84,9 +89,31 @@ function get($pk): ?ApiGroup { /** * @param ApiGroup $model - * @return ApiGroup + * @return ?ApiGroup + * @throws Exception */ - function save($model): ApiGroup { + function save($model): ?ApiGroup { return Util::cast(parent::save($model), ApiGroup::class); } + + /** + * @param ApiGroup $model + * @param array $arr key-value associations for update + * @return ApiGroup + * @throws Exception + */ + function mset($model, array $arr): ApiGroup { + return Util::cast(parent::mset($model, $arr), ApiGroup::class); + } + + /** + * @param ApiGroup $model + * @param string $key key of the column to update + * @param $value + * @return ApiGroup + * @throws Exception + */ + function set($model, string $key, $value): ApiGroup { + return Util::cast(parent::set($model, $key, $value), ApiGroup::class); + } } diff --git a/src/dba/models/ApiKeyFactory.php b/src/dba/models/ApiKeyFactory.php index e25395ace..4eb56b15e 100644 --- a/src/dba/models/ApiKeyFactory.php +++ b/src/dba/models/ApiKeyFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ApiKeyFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): ApiKey { /** * @param array $options * @param bool $single - * @return ApiKey|ApiKey[] + * @return ApiKey|array|null + * @throws Exception */ function filter(array $options, bool $single = false): ApiKey|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): ApiKey|array|null { /** * @param string $pk * @return ?ApiKey + * @throws Exception */ function get($pk): ?ApiKey { return Util::cast(parent::get($pk), ApiKey::class); @@ -84,9 +89,31 @@ function get($pk): ?ApiKey { /** * @param ApiKey $model - * @return ApiKey + * @return ?ApiKey + * @throws Exception */ - function save($model): ApiKey { + function save($model): ?ApiKey { return Util::cast(parent::save($model), ApiKey::class); } + + /** + * @param ApiKey $model + * @param array $arr key-value associations for update + * @return ApiKey + * @throws Exception + */ + function mset($model, array $arr): ApiKey { + return Util::cast(parent::mset($model, $arr), ApiKey::class); + } + + /** + * @param ApiKey $model + * @param string $key key of the column to update + * @param $value + * @return ApiKey + * @throws Exception + */ + function set($model, string $key, $value): ApiKey { + return Util::cast(parent::set($model, $key, $value), ApiKey::class); + } } diff --git a/src/dba/models/AssignmentFactory.php b/src/dba/models/AssignmentFactory.php index 577c4a848..dc1fc0f2b 100644 --- a/src/dba/models/AssignmentFactory.php +++ b/src/dba/models/AssignmentFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class AssignmentFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Assignment { /** * @param array $options * @param bool $single - * @return Assignment|Assignment[] + * @return Assignment|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Assignment|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Assignment|array|null { /** * @param string $pk * @return ?Assignment + * @throws Exception */ function get($pk): ?Assignment { return Util::cast(parent::get($pk), Assignment::class); @@ -84,9 +89,31 @@ function get($pk): ?Assignment { /** * @param Assignment $model - * @return Assignment + * @return ?Assignment + * @throws Exception */ - function save($model): Assignment { + function save($model): ?Assignment { return Util::cast(parent::save($model), Assignment::class); } + + /** + * @param Assignment $model + * @param array $arr key-value associations for update + * @return Assignment + * @throws Exception + */ + function mset($model, array $arr): Assignment { + return Util::cast(parent::mset($model, $arr), Assignment::class); + } + + /** + * @param Assignment $model + * @param string $key key of the column to update + * @param $value + * @return Assignment + * @throws Exception + */ + function set($model, string $key, $value): Assignment { + return Util::cast(parent::set($model, $key, $value), Assignment::class); + } } diff --git a/src/dba/models/ChunkFactory.php b/src/dba/models/ChunkFactory.php index e5cd3fc91..bcbc5e585 100644 --- a/src/dba/models/ChunkFactory.php +++ b/src/dba/models/ChunkFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ChunkFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Chunk { /** * @param array $options * @param bool $single - * @return Chunk|Chunk[] + * @return Chunk|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Chunk|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Chunk|array|null { /** * @param string $pk * @return ?Chunk + * @throws Exception */ function get($pk): ?Chunk { return Util::cast(parent::get($pk), Chunk::class); @@ -84,9 +89,31 @@ function get($pk): ?Chunk { /** * @param Chunk $model - * @return Chunk + * @return ?Chunk + * @throws Exception */ - function save($model): Chunk { + function save($model): ?Chunk { return Util::cast(parent::save($model), Chunk::class); } + + /** + * @param Chunk $model + * @param array $arr key-value associations for update + * @return Chunk + * @throws Exception + */ + function mset($model, array $arr): Chunk { + return Util::cast(parent::mset($model, $arr), Chunk::class); + } + + /** + * @param Chunk $model + * @param string $key key of the column to update + * @param $value + * @return Chunk + * @throws Exception + */ + function set($model, string $key, $value): Chunk { + return Util::cast(parent::set($model, $key, $value), Chunk::class); + } } diff --git a/src/dba/models/ConfigFactory.php b/src/dba/models/ConfigFactory.php index 7cbe8a640..2cdd5c928 100644 --- a/src/dba/models/ConfigFactory.php +++ b/src/dba/models/ConfigFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ConfigFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Config { /** * @param array $options * @param bool $single - * @return Config|Config[] + * @return Config|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Config|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Config|array|null { /** * @param string $pk * @return ?Config + * @throws Exception */ function get($pk): ?Config { return Util::cast(parent::get($pk), Config::class); @@ -84,9 +89,31 @@ function get($pk): ?Config { /** * @param Config $model - * @return Config + * @return ?Config + * @throws Exception */ - function save($model): Config { + function save($model): ?Config { return Util::cast(parent::save($model), Config::class); } + + /** + * @param Config $model + * @param array $arr key-value associations for update + * @return Config + * @throws Exception + */ + function mset($model, array $arr): Config { + return Util::cast(parent::mset($model, $arr), Config::class); + } + + /** + * @param Config $model + * @param string $key key of the column to update + * @param $value + * @return Config + * @throws Exception + */ + function set($model, string $key, $value): Config { + return Util::cast(parent::set($model, $key, $value), Config::class); + } } diff --git a/src/dba/models/ConfigSectionFactory.php b/src/dba/models/ConfigSectionFactory.php index ba9f2b137..33a4da170 100644 --- a/src/dba/models/ConfigSectionFactory.php +++ b/src/dba/models/ConfigSectionFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ConfigSectionFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): ConfigSection { /** * @param array $options * @param bool $single - * @return ConfigSection|ConfigSection[] + * @return ConfigSection|array|null + * @throws Exception */ function filter(array $options, bool $single = false): ConfigSection|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): ConfigSection|array|null /** * @param string $pk * @return ?ConfigSection + * @throws Exception */ function get($pk): ?ConfigSection { return Util::cast(parent::get($pk), ConfigSection::class); @@ -84,9 +89,31 @@ function get($pk): ?ConfigSection { /** * @param ConfigSection $model - * @return ConfigSection + * @return ?ConfigSection + * @throws Exception */ - function save($model): ConfigSection { + function save($model): ?ConfigSection { return Util::cast(parent::save($model), ConfigSection::class); } + + /** + * @param ConfigSection $model + * @param array $arr key-value associations for update + * @return ConfigSection + * @throws Exception + */ + function mset($model, array $arr): ConfigSection { + return Util::cast(parent::mset($model, $arr), ConfigSection::class); + } + + /** + * @param ConfigSection $model + * @param string $key key of the column to update + * @param $value + * @return ConfigSection + * @throws Exception + */ + function set($model, string $key, $value): ConfigSection { + return Util::cast(parent::set($model, $key, $value), ConfigSection::class); + } } diff --git a/src/dba/models/CrackerBinaryFactory.php b/src/dba/models/CrackerBinaryFactory.php index 3a7f905f8..7d9e805ca 100644 --- a/src/dba/models/CrackerBinaryFactory.php +++ b/src/dba/models/CrackerBinaryFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class CrackerBinaryFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): CrackerBinary { /** * @param array $options * @param bool $single - * @return CrackerBinary|CrackerBinary[] + * @return CrackerBinary|array|null + * @throws Exception */ function filter(array $options, bool $single = false): CrackerBinary|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): CrackerBinary|array|null /** * @param string $pk * @return ?CrackerBinary + * @throws Exception */ function get($pk): ?CrackerBinary { return Util::cast(parent::get($pk), CrackerBinary::class); @@ -84,9 +89,31 @@ function get($pk): ?CrackerBinary { /** * @param CrackerBinary $model - * @return CrackerBinary + * @return ?CrackerBinary + * @throws Exception */ - function save($model): CrackerBinary { + function save($model): ?CrackerBinary { return Util::cast(parent::save($model), CrackerBinary::class); } + + /** + * @param CrackerBinary $model + * @param array $arr key-value associations for update + * @return CrackerBinary + * @throws Exception + */ + function mset($model, array $arr): CrackerBinary { + return Util::cast(parent::mset($model, $arr), CrackerBinary::class); + } + + /** + * @param CrackerBinary $model + * @param string $key key of the column to update + * @param $value + * @return CrackerBinary + * @throws Exception + */ + function set($model, string $key, $value): CrackerBinary { + return Util::cast(parent::set($model, $key, $value), CrackerBinary::class); + } } diff --git a/src/dba/models/CrackerBinaryTypeFactory.php b/src/dba/models/CrackerBinaryTypeFactory.php index 40a04fe95..210287580 100644 --- a/src/dba/models/CrackerBinaryTypeFactory.php +++ b/src/dba/models/CrackerBinaryTypeFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class CrackerBinaryTypeFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): CrackerBinaryType { /** * @param array $options * @param bool $single - * @return CrackerBinaryType|CrackerBinaryType[] + * @return CrackerBinaryType|array|null + * @throws Exception */ function filter(array $options, bool $single = false): CrackerBinaryType|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): CrackerBinaryType|array|n /** * @param string $pk * @return ?CrackerBinaryType + * @throws Exception */ function get($pk): ?CrackerBinaryType { return Util::cast(parent::get($pk), CrackerBinaryType::class); @@ -84,9 +89,31 @@ function get($pk): ?CrackerBinaryType { /** * @param CrackerBinaryType $model - * @return CrackerBinaryType + * @return ?CrackerBinaryType + * @throws Exception */ - function save($model): CrackerBinaryType { + function save($model): ?CrackerBinaryType { return Util::cast(parent::save($model), CrackerBinaryType::class); } + + /** + * @param CrackerBinaryType $model + * @param array $arr key-value associations for update + * @return CrackerBinaryType + * @throws Exception + */ + function mset($model, array $arr): CrackerBinaryType { + return Util::cast(parent::mset($model, $arr), CrackerBinaryType::class); + } + + /** + * @param CrackerBinaryType $model + * @param string $key key of the column to update + * @param $value + * @return CrackerBinaryType + * @throws Exception + */ + function set($model, string $key, $value): CrackerBinaryType { + return Util::cast(parent::set($model, $key, $value), CrackerBinaryType::class); + } } diff --git a/src/dba/models/FileDeleteFactory.php b/src/dba/models/FileDeleteFactory.php index e8e7e69e0..0315fd23e 100644 --- a/src/dba/models/FileDeleteFactory.php +++ b/src/dba/models/FileDeleteFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class FileDeleteFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): FileDelete { /** * @param array $options * @param bool $single - * @return FileDelete|FileDelete[] + * @return FileDelete|array|null + * @throws Exception */ function filter(array $options, bool $single = false): FileDelete|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): FileDelete|array|null { /** * @param string $pk * @return ?FileDelete + * @throws Exception */ function get($pk): ?FileDelete { return Util::cast(parent::get($pk), FileDelete::class); @@ -84,9 +89,31 @@ function get($pk): ?FileDelete { /** * @param FileDelete $model - * @return FileDelete + * @return ?FileDelete + * @throws Exception */ - function save($model): FileDelete { + function save($model): ?FileDelete { return Util::cast(parent::save($model), FileDelete::class); } + + /** + * @param FileDelete $model + * @param array $arr key-value associations for update + * @return FileDelete + * @throws Exception + */ + function mset($model, array $arr): FileDelete { + return Util::cast(parent::mset($model, $arr), FileDelete::class); + } + + /** + * @param FileDelete $model + * @param string $key key of the column to update + * @param $value + * @return FileDelete + * @throws Exception + */ + function set($model, string $key, $value): FileDelete { + return Util::cast(parent::set($model, $key, $value), FileDelete::class); + } } diff --git a/src/dba/models/FileDownloadFactory.php b/src/dba/models/FileDownloadFactory.php index b249fbfc0..97b216a27 100644 --- a/src/dba/models/FileDownloadFactory.php +++ b/src/dba/models/FileDownloadFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class FileDownloadFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): FileDownload { /** * @param array $options * @param bool $single - * @return FileDownload|FileDownload[] + * @return FileDownload|array|null + * @throws Exception */ function filter(array $options, bool $single = false): FileDownload|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): FileDownload|array|null { /** * @param string $pk * @return ?FileDownload + * @throws Exception */ function get($pk): ?FileDownload { return Util::cast(parent::get($pk), FileDownload::class); @@ -84,9 +89,31 @@ function get($pk): ?FileDownload { /** * @param FileDownload $model - * @return FileDownload + * @return ?FileDownload + * @throws Exception */ - function save($model): FileDownload { + function save($model): ?FileDownload { return Util::cast(parent::save($model), FileDownload::class); } + + /** + * @param FileDownload $model + * @param array $arr key-value associations for update + * @return FileDownload + * @throws Exception + */ + function mset($model, array $arr): FileDownload { + return Util::cast(parent::mset($model, $arr), FileDownload::class); + } + + /** + * @param FileDownload $model + * @param string $key key of the column to update + * @param $value + * @return FileDownload + * @throws Exception + */ + function set($model, string $key, $value): FileDownload { + return Util::cast(parent::set($model, $key, $value), FileDownload::class); + } } diff --git a/src/dba/models/FileFactory.php b/src/dba/models/FileFactory.php index 847e9da5f..1c45a9686 100644 --- a/src/dba/models/FileFactory.php +++ b/src/dba/models/FileFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class FileFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): File { /** * @param array $options * @param bool $single - * @return File|File[] + * @return File|array|null + * @throws Exception */ function filter(array $options, bool $single = false): File|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): File|array|null { /** * @param string $pk * @return ?File + * @throws Exception */ function get($pk): ?File { return Util::cast(parent::get($pk), File::class); @@ -84,9 +89,31 @@ function get($pk): ?File { /** * @param File $model - * @return File + * @return ?File + * @throws Exception */ - function save($model): File { + function save($model): ?File { return Util::cast(parent::save($model), File::class); } + + /** + * @param File $model + * @param array $arr key-value associations for update + * @return File + * @throws Exception + */ + function mset($model, array $arr): File { + return Util::cast(parent::mset($model, $arr), File::class); + } + + /** + * @param File $model + * @param string $key key of the column to update + * @param $value + * @return File + * @throws Exception + */ + function set($model, string $key, $value): File { + return Util::cast(parent::set($model, $key, $value), File::class); + } } diff --git a/src/dba/models/FilePretaskFactory.php b/src/dba/models/FilePretaskFactory.php index a75a13eeb..dbfb39cb7 100644 --- a/src/dba/models/FilePretaskFactory.php +++ b/src/dba/models/FilePretaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class FilePretaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): FilePretask { /** * @param array $options * @param bool $single - * @return FilePretask|FilePretask[] + * @return FilePretask|array|null + * @throws Exception */ function filter(array $options, bool $single = false): FilePretask|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): FilePretask|array|null { /** * @param string $pk * @return ?FilePretask + * @throws Exception */ function get($pk): ?FilePretask { return Util::cast(parent::get($pk), FilePretask::class); @@ -84,9 +89,31 @@ function get($pk): ?FilePretask { /** * @param FilePretask $model - * @return FilePretask + * @return ?FilePretask + * @throws Exception */ - function save($model): FilePretask { + function save($model): ?FilePretask { return Util::cast(parent::save($model), FilePretask::class); } + + /** + * @param FilePretask $model + * @param array $arr key-value associations for update + * @return FilePretask + * @throws Exception + */ + function mset($model, array $arr): FilePretask { + return Util::cast(parent::mset($model, $arr), FilePretask::class); + } + + /** + * @param FilePretask $model + * @param string $key key of the column to update + * @param $value + * @return FilePretask + * @throws Exception + */ + function set($model, string $key, $value): FilePretask { + return Util::cast(parent::set($model, $key, $value), FilePretask::class); + } } diff --git a/src/dba/models/FileTaskFactory.php b/src/dba/models/FileTaskFactory.php index 7a3e1a97e..a0a7a3e29 100644 --- a/src/dba/models/FileTaskFactory.php +++ b/src/dba/models/FileTaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class FileTaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): FileTask { /** * @param array $options * @param bool $single - * @return FileTask|FileTask[] + * @return FileTask|array|null + * @throws Exception */ function filter(array $options, bool $single = false): FileTask|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): FileTask|array|null { /** * @param string $pk * @return ?FileTask + * @throws Exception */ function get($pk): ?FileTask { return Util::cast(parent::get($pk), FileTask::class); @@ -84,9 +89,31 @@ function get($pk): ?FileTask { /** * @param FileTask $model - * @return FileTask + * @return ?FileTask + * @throws Exception */ - function save($model): FileTask { + function save($model): ?FileTask { return Util::cast(parent::save($model), FileTask::class); } + + /** + * @param FileTask $model + * @param array $arr key-value associations for update + * @return FileTask + * @throws Exception + */ + function mset($model, array $arr): FileTask { + return Util::cast(parent::mset($model, $arr), FileTask::class); + } + + /** + * @param FileTask $model + * @param string $key key of the column to update + * @param $value + * @return FileTask + * @throws Exception + */ + function set($model, string $key, $value): FileTask { + return Util::cast(parent::set($model, $key, $value), FileTask::class); + } } diff --git a/src/dba/models/HashBinaryFactory.php b/src/dba/models/HashBinaryFactory.php index d4358abd0..3a4ed6276 100644 --- a/src/dba/models/HashBinaryFactory.php +++ b/src/dba/models/HashBinaryFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HashBinaryFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): HashBinary { /** * @param array $options * @param bool $single - * @return HashBinary|HashBinary[] + * @return HashBinary|array|null + * @throws Exception */ function filter(array $options, bool $single = false): HashBinary|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): HashBinary|array|null { /** * @param string $pk * @return ?HashBinary + * @throws Exception */ function get($pk): ?HashBinary { return Util::cast(parent::get($pk), HashBinary::class); @@ -84,9 +89,31 @@ function get($pk): ?HashBinary { /** * @param HashBinary $model - * @return HashBinary + * @return ?HashBinary + * @throws Exception */ - function save($model): HashBinary { + function save($model): ?HashBinary { return Util::cast(parent::save($model), HashBinary::class); } + + /** + * @param HashBinary $model + * @param array $arr key-value associations for update + * @return HashBinary + * @throws Exception + */ + function mset($model, array $arr): HashBinary { + return Util::cast(parent::mset($model, $arr), HashBinary::class); + } + + /** + * @param HashBinary $model + * @param string $key key of the column to update + * @param $value + * @return HashBinary + * @throws Exception + */ + function set($model, string $key, $value): HashBinary { + return Util::cast(parent::set($model, $key, $value), HashBinary::class); + } } diff --git a/src/dba/models/HashFactory.php b/src/dba/models/HashFactory.php index f30fc0eef..aa9dead38 100644 --- a/src/dba/models/HashFactory.php +++ b/src/dba/models/HashFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HashFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Hash { /** * @param array $options * @param bool $single - * @return Hash|Hash[] + * @return Hash|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Hash|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Hash|array|null { /** * @param string $pk * @return ?Hash + * @throws Exception */ function get($pk): ?Hash { return Util::cast(parent::get($pk), Hash::class); @@ -84,9 +89,31 @@ function get($pk): ?Hash { /** * @param Hash $model - * @return Hash + * @return ?Hash + * @throws Exception */ - function save($model): Hash { + function save($model): ?Hash { return Util::cast(parent::save($model), Hash::class); } + + /** + * @param Hash $model + * @param array $arr key-value associations for update + * @return Hash + * @throws Exception + */ + function mset($model, array $arr): Hash { + return Util::cast(parent::mset($model, $arr), Hash::class); + } + + /** + * @param Hash $model + * @param string $key key of the column to update + * @param $value + * @return Hash + * @throws Exception + */ + function set($model, string $key, $value): Hash { + return Util::cast(parent::set($model, $key, $value), Hash::class); + } } diff --git a/src/dba/models/HashTypeFactory.php b/src/dba/models/HashTypeFactory.php index afe6886b9..8149c12da 100644 --- a/src/dba/models/HashTypeFactory.php +++ b/src/dba/models/HashTypeFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HashTypeFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): HashType { /** * @param array $options * @param bool $single - * @return HashType|HashType[] + * @return HashType|array|null + * @throws Exception */ function filter(array $options, bool $single = false): HashType|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): HashType|array|null { /** * @param string $pk * @return ?HashType + * @throws Exception */ function get($pk): ?HashType { return Util::cast(parent::get($pk), HashType::class); @@ -84,9 +89,31 @@ function get($pk): ?HashType { /** * @param HashType $model - * @return HashType + * @return ?HashType + * @throws Exception */ - function save($model): HashType { + function save($model): ?HashType { return Util::cast(parent::save($model), HashType::class); } + + /** + * @param HashType $model + * @param array $arr key-value associations for update + * @return HashType + * @throws Exception + */ + function mset($model, array $arr): HashType { + return Util::cast(parent::mset($model, $arr), HashType::class); + } + + /** + * @param HashType $model + * @param string $key key of the column to update + * @param $value + * @return HashType + * @throws Exception + */ + function set($model, string $key, $value): HashType { + return Util::cast(parent::set($model, $key, $value), HashType::class); + } } diff --git a/src/dba/models/HashlistFactory.php b/src/dba/models/HashlistFactory.php index 56e567f0a..363977f73 100644 --- a/src/dba/models/HashlistFactory.php +++ b/src/dba/models/HashlistFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HashlistFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Hashlist { /** * @param array $options * @param bool $single - * @return Hashlist|Hashlist[] + * @return Hashlist|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Hashlist|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Hashlist|array|null { /** * @param string $pk * @return ?Hashlist + * @throws Exception */ function get($pk): ?Hashlist { return Util::cast(parent::get($pk), Hashlist::class); @@ -84,9 +89,31 @@ function get($pk): ?Hashlist { /** * @param Hashlist $model - * @return Hashlist + * @return ?Hashlist + * @throws Exception */ - function save($model): Hashlist { + function save($model): ?Hashlist { return Util::cast(parent::save($model), Hashlist::class); } + + /** + * @param Hashlist $model + * @param array $arr key-value associations for update + * @return Hashlist + * @throws Exception + */ + function mset($model, array $arr): Hashlist { + return Util::cast(parent::mset($model, $arr), Hashlist::class); + } + + /** + * @param Hashlist $model + * @param string $key key of the column to update + * @param $value + * @return Hashlist + * @throws Exception + */ + function set($model, string $key, $value): Hashlist { + return Util::cast(parent::set($model, $key, $value), Hashlist::class); + } } diff --git a/src/dba/models/HashlistHashlistFactory.php b/src/dba/models/HashlistHashlistFactory.php index 379458f92..ee013d808 100644 --- a/src/dba/models/HashlistHashlistFactory.php +++ b/src/dba/models/HashlistHashlistFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HashlistHashlistFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): HashlistHashlist { /** * @param array $options * @param bool $single - * @return HashlistHashlist|HashlistHashlist[] + * @return HashlistHashlist|array|null + * @throws Exception */ function filter(array $options, bool $single = false): HashlistHashlist|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): HashlistHashlist|array|nu /** * @param string $pk * @return ?HashlistHashlist + * @throws Exception */ function get($pk): ?HashlistHashlist { return Util::cast(parent::get($pk), HashlistHashlist::class); @@ -84,9 +89,31 @@ function get($pk): ?HashlistHashlist { /** * @param HashlistHashlist $model - * @return HashlistHashlist + * @return ?HashlistHashlist + * @throws Exception */ - function save($model): HashlistHashlist { + function save($model): ?HashlistHashlist { return Util::cast(parent::save($model), HashlistHashlist::class); } + + /** + * @param HashlistHashlist $model + * @param array $arr key-value associations for update + * @return HashlistHashlist + * @throws Exception + */ + function mset($model, array $arr): HashlistHashlist { + return Util::cast(parent::mset($model, $arr), HashlistHashlist::class); + } + + /** + * @param HashlistHashlist $model + * @param string $key key of the column to update + * @param $value + * @return HashlistHashlist + * @throws Exception + */ + function set($model, string $key, $value): HashlistHashlist { + return Util::cast(parent::set($model, $key, $value), HashlistHashlist::class); + } } diff --git a/src/dba/models/HealthCheckAgentFactory.php b/src/dba/models/HealthCheckAgentFactory.php index d7f04abf0..84a424441 100644 --- a/src/dba/models/HealthCheckAgentFactory.php +++ b/src/dba/models/HealthCheckAgentFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HealthCheckAgentFactory extends AbstractModelFactory { @@ -51,7 +54,8 @@ function createObjectFromDict($pk, $dict): HealthCheckAgent { /** * @param array $options * @param bool $single - * @return HealthCheckAgent|HealthCheckAgent[] + * @return HealthCheckAgent|array|null + * @throws Exception */ function filter(array $options, bool $single = false): HealthCheckAgent|array|null { $join = false; @@ -78,6 +82,7 @@ function filter(array $options, bool $single = false): HealthCheckAgent|array|nu /** * @param string $pk * @return ?HealthCheckAgent + * @throws Exception */ function get($pk): ?HealthCheckAgent { return Util::cast(parent::get($pk), HealthCheckAgent::class); @@ -85,9 +90,31 @@ function get($pk): ?HealthCheckAgent { /** * @param HealthCheckAgent $model - * @return HealthCheckAgent + * @return ?HealthCheckAgent + * @throws Exception */ - function save($model): HealthCheckAgent { + function save($model): ?HealthCheckAgent { return Util::cast(parent::save($model), HealthCheckAgent::class); } + + /** + * @param HealthCheckAgent $model + * @param array $arr key-value associations for update + * @return HealthCheckAgent + * @throws Exception + */ + function mset($model, array $arr): HealthCheckAgent { + return Util::cast(parent::mset($model, $arr), HealthCheckAgent::class); + } + + /** + * @param HealthCheckAgent $model + * @param string $key key of the column to update + * @param $value + * @return HealthCheckAgent + * @throws Exception + */ + function set($model, string $key, $value): HealthCheckAgent { + return Util::cast(parent::set($model, $key, $value), HealthCheckAgent::class); + } } diff --git a/src/dba/models/HealthCheckFactory.php b/src/dba/models/HealthCheckFactory.php index 817302082..4a8aa8afa 100644 --- a/src/dba/models/HealthCheckFactory.php +++ b/src/dba/models/HealthCheckFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class HealthCheckFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): HealthCheck { /** * @param array $options * @param bool $single - * @return HealthCheck|HealthCheck[] + * @return HealthCheck|array|null + * @throws Exception */ function filter(array $options, bool $single = false): HealthCheck|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): HealthCheck|array|null { /** * @param string $pk * @return ?HealthCheck + * @throws Exception */ function get($pk): ?HealthCheck { return Util::cast(parent::get($pk), HealthCheck::class); @@ -84,9 +89,31 @@ function get($pk): ?HealthCheck { /** * @param HealthCheck $model - * @return HealthCheck + * @return ?HealthCheck + * @throws Exception */ - function save($model): HealthCheck { + function save($model): ?HealthCheck { return Util::cast(parent::save($model), HealthCheck::class); } + + /** + * @param HealthCheck $model + * @param array $arr key-value associations for update + * @return HealthCheck + * @throws Exception + */ + function mset($model, array $arr): HealthCheck { + return Util::cast(parent::mset($model, $arr), HealthCheck::class); + } + + /** + * @param HealthCheck $model + * @param string $key key of the column to update + * @param $value + * @return HealthCheck + * @throws Exception + */ + function set($model, string $key, $value): HealthCheck { + return Util::cast(parent::set($model, $key, $value), HealthCheck::class); + } } diff --git a/src/dba/models/JwtApiKeyFactory.php b/src/dba/models/JwtApiKeyFactory.php index 8ba88d68e..420f1dafa 100644 --- a/src/dba/models/JwtApiKeyFactory.php +++ b/src/dba/models/JwtApiKeyFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class JwtApiKeyFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): JwtApiKey { /** * @param array $options * @param bool $single - * @return JwtApiKey|JwtApiKey[] + * @return JwtApiKey|array|null + * @throws Exception */ function filter(array $options, bool $single = false): JwtApiKey|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): JwtApiKey|array|null { /** * @param string $pk * @return ?JwtApiKey + * @throws Exception */ function get($pk): ?JwtApiKey { return Util::cast(parent::get($pk), JwtApiKey::class); @@ -84,9 +89,31 @@ function get($pk): ?JwtApiKey { /** * @param JwtApiKey $model - * @return JwtApiKey + * @return ?JwtApiKey + * @throws Exception */ - function save($model): JwtApiKey { + function save($model): ?JwtApiKey { return Util::cast(parent::save($model), JwtApiKey::class); } + + /** + * @param JwtApiKey $model + * @param array $arr key-value associations for update + * @return JwtApiKey + * @throws Exception + */ + function mset($model, array $arr): JwtApiKey { + return Util::cast(parent::mset($model, $arr), JwtApiKey::class); + } + + /** + * @param JwtApiKey $model + * @param string $key key of the column to update + * @param $value + * @return JwtApiKey + * @throws Exception + */ + function set($model, string $key, $value): JwtApiKey { + return Util::cast(parent::set($model, $key, $value), JwtApiKey::class); + } } diff --git a/src/dba/models/LogEntryFactory.php b/src/dba/models/LogEntryFactory.php index ddcb4d849..caab53abd 100644 --- a/src/dba/models/LogEntryFactory.php +++ b/src/dba/models/LogEntryFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class LogEntryFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): LogEntry { /** * @param array $options * @param bool $single - * @return LogEntry|LogEntry[] + * @return LogEntry|array|null + * @throws Exception */ function filter(array $options, bool $single = false): LogEntry|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): LogEntry|array|null { /** * @param string $pk * @return ?LogEntry + * @throws Exception */ function get($pk): ?LogEntry { return Util::cast(parent::get($pk), LogEntry::class); @@ -84,9 +89,31 @@ function get($pk): ?LogEntry { /** * @param LogEntry $model - * @return LogEntry + * @return ?LogEntry + * @throws Exception */ - function save($model): LogEntry { + function save($model): ?LogEntry { return Util::cast(parent::save($model), LogEntry::class); } + + /** + * @param LogEntry $model + * @param array $arr key-value associations for update + * @return LogEntry + * @throws Exception + */ + function mset($model, array $arr): LogEntry { + return Util::cast(parent::mset($model, $arr), LogEntry::class); + } + + /** + * @param LogEntry $model + * @param string $key key of the column to update + * @param $value + * @return LogEntry + * @throws Exception + */ + function set($model, string $key, $value): LogEntry { + return Util::cast(parent::set($model, $key, $value), LogEntry::class); + } } diff --git a/src/dba/models/NotificationSettingFactory.php b/src/dba/models/NotificationSettingFactory.php index d51485078..c488c81b0 100644 --- a/src/dba/models/NotificationSettingFactory.php +++ b/src/dba/models/NotificationSettingFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class NotificationSettingFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): NotificationSetting { /** * @param array $options * @param bool $single - * @return NotificationSetting|NotificationSetting[] + * @return NotificationSetting|array|null + * @throws Exception */ function filter(array $options, bool $single = false): NotificationSetting|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): NotificationSetting|array /** * @param string $pk * @return ?NotificationSetting + * @throws Exception */ function get($pk): ?NotificationSetting { return Util::cast(parent::get($pk), NotificationSetting::class); @@ -84,9 +89,31 @@ function get($pk): ?NotificationSetting { /** * @param NotificationSetting $model - * @return NotificationSetting + * @return ?NotificationSetting + * @throws Exception */ - function save($model): NotificationSetting { + function save($model): ?NotificationSetting { return Util::cast(parent::save($model), NotificationSetting::class); } + + /** + * @param NotificationSetting $model + * @param array $arr key-value associations for update + * @return NotificationSetting + * @throws Exception + */ + function mset($model, array $arr): NotificationSetting { + return Util::cast(parent::mset($model, $arr), NotificationSetting::class); + } + + /** + * @param NotificationSetting $model + * @param string $key key of the column to update + * @param $value + * @return NotificationSetting + * @throws Exception + */ + function set($model, string $key, $value): NotificationSetting { + return Util::cast(parent::set($model, $key, $value), NotificationSetting::class); + } } diff --git a/src/dba/models/PreprocessorFactory.php b/src/dba/models/PreprocessorFactory.php index 097ab22d7..d235e02bd 100644 --- a/src/dba/models/PreprocessorFactory.php +++ b/src/dba/models/PreprocessorFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class PreprocessorFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Preprocessor { /** * @param array $options * @param bool $single - * @return Preprocessor|Preprocessor[] + * @return Preprocessor|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Preprocessor|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Preprocessor|array|null { /** * @param string $pk * @return ?Preprocessor + * @throws Exception */ function get($pk): ?Preprocessor { return Util::cast(parent::get($pk), Preprocessor::class); @@ -84,9 +89,31 @@ function get($pk): ?Preprocessor { /** * @param Preprocessor $model - * @return Preprocessor + * @return ?Preprocessor + * @throws Exception */ - function save($model): Preprocessor { + function save($model): ?Preprocessor { return Util::cast(parent::save($model), Preprocessor::class); } + + /** + * @param Preprocessor $model + * @param array $arr key-value associations for update + * @return Preprocessor + * @throws Exception + */ + function mset($model, array $arr): Preprocessor { + return Util::cast(parent::mset($model, $arr), Preprocessor::class); + } + + /** + * @param Preprocessor $model + * @param string $key key of the column to update + * @param $value + * @return Preprocessor + * @throws Exception + */ + function set($model, string $key, $value): Preprocessor { + return Util::cast(parent::set($model, $key, $value), Preprocessor::class); + } } diff --git a/src/dba/models/PretaskFactory.php b/src/dba/models/PretaskFactory.php index 07e37e930..d49ef45ac 100644 --- a/src/dba/models/PretaskFactory.php +++ b/src/dba/models/PretaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class PretaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Pretask { /** * @param array $options * @param bool $single - * @return Pretask|Pretask[] + * @return Pretask|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Pretask|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Pretask|array|null { /** * @param string $pk * @return ?Pretask + * @throws Exception */ function get($pk): ?Pretask { return Util::cast(parent::get($pk), Pretask::class); @@ -84,9 +89,31 @@ function get($pk): ?Pretask { /** * @param Pretask $model - * @return Pretask + * @return ?Pretask + * @throws Exception */ - function save($model): Pretask { + function save($model): ?Pretask { return Util::cast(parent::save($model), Pretask::class); } + + /** + * @param Pretask $model + * @param array $arr key-value associations for update + * @return Pretask + * @throws Exception + */ + function mset($model, array $arr): Pretask { + return Util::cast(parent::mset($model, $arr), Pretask::class); + } + + /** + * @param Pretask $model + * @param string $key key of the column to update + * @param $value + * @return Pretask + * @throws Exception + */ + function set($model, string $key, $value): Pretask { + return Util::cast(parent::set($model, $key, $value), Pretask::class); + } } diff --git a/src/dba/models/RegVoucherFactory.php b/src/dba/models/RegVoucherFactory.php index 476ddf92f..57c3f7f7b 100644 --- a/src/dba/models/RegVoucherFactory.php +++ b/src/dba/models/RegVoucherFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class RegVoucherFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): RegVoucher { /** * @param array $options * @param bool $single - * @return RegVoucher|RegVoucher[] + * @return RegVoucher|array|null + * @throws Exception */ function filter(array $options, bool $single = false): RegVoucher|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): RegVoucher|array|null { /** * @param string $pk * @return ?RegVoucher + * @throws Exception */ function get($pk): ?RegVoucher { return Util::cast(parent::get($pk), RegVoucher::class); @@ -84,9 +89,31 @@ function get($pk): ?RegVoucher { /** * @param RegVoucher $model - * @return RegVoucher + * @return ?RegVoucher + * @throws Exception */ - function save($model): RegVoucher { + function save($model): ?RegVoucher { return Util::cast(parent::save($model), RegVoucher::class); } + + /** + * @param RegVoucher $model + * @param array $arr key-value associations for update + * @return RegVoucher + * @throws Exception + */ + function mset($model, array $arr): RegVoucher { + return Util::cast(parent::mset($model, $arr), RegVoucher::class); + } + + /** + * @param RegVoucher $model + * @param string $key key of the column to update + * @param $value + * @return RegVoucher + * @throws Exception + */ + function set($model, string $key, $value): RegVoucher { + return Util::cast(parent::set($model, $key, $value), RegVoucher::class); + } } diff --git a/src/dba/models/RightGroupFactory.php b/src/dba/models/RightGroupFactory.php index 8ba2132ed..b38a9569f 100644 --- a/src/dba/models/RightGroupFactory.php +++ b/src/dba/models/RightGroupFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class RightGroupFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): RightGroup { /** * @param array $options * @param bool $single - * @return RightGroup|RightGroup[] + * @return RightGroup|array|null + * @throws Exception */ function filter(array $options, bool $single = false): RightGroup|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): RightGroup|array|null { /** * @param string $pk * @return ?RightGroup + * @throws Exception */ function get($pk): ?RightGroup { return Util::cast(parent::get($pk), RightGroup::class); @@ -84,9 +89,31 @@ function get($pk): ?RightGroup { /** * @param RightGroup $model - * @return RightGroup + * @return ?RightGroup + * @throws Exception */ - function save($model): RightGroup { + function save($model): ?RightGroup { return Util::cast(parent::save($model), RightGroup::class); } + + /** + * @param RightGroup $model + * @param array $arr key-value associations for update + * @return RightGroup + * @throws Exception + */ + function mset($model, array $arr): RightGroup { + return Util::cast(parent::mset($model, $arr), RightGroup::class); + } + + /** + * @param RightGroup $model + * @param string $key key of the column to update + * @param $value + * @return RightGroup + * @throws Exception + */ + function set($model, string $key, $value): RightGroup { + return Util::cast(parent::set($model, $key, $value), RightGroup::class); + } } diff --git a/src/dba/models/SessionFactory.php b/src/dba/models/SessionFactory.php index 9132e5a19..bc5769625 100644 --- a/src/dba/models/SessionFactory.php +++ b/src/dba/models/SessionFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class SessionFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Session { /** * @param array $options * @param bool $single - * @return Session|Session[] + * @return Session|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Session|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Session|array|null { /** * @param string $pk * @return ?Session + * @throws Exception */ function get($pk): ?Session { return Util::cast(parent::get($pk), Session::class); @@ -84,9 +89,31 @@ function get($pk): ?Session { /** * @param Session $model - * @return Session + * @return ?Session + * @throws Exception */ - function save($model): Session { + function save($model): ?Session { return Util::cast(parent::save($model), Session::class); } + + /** + * @param Session $model + * @param array $arr key-value associations for update + * @return Session + * @throws Exception + */ + function mset($model, array $arr): Session { + return Util::cast(parent::mset($model, $arr), Session::class); + } + + /** + * @param Session $model + * @param string $key key of the column to update + * @param $value + * @return Session + * @throws Exception + */ + function set($model, string $key, $value): Session { + return Util::cast(parent::set($model, $key, $value), Session::class); + } } diff --git a/src/dba/models/SpeedFactory.php b/src/dba/models/SpeedFactory.php index 4c9ccebdd..63fec7a64 100644 --- a/src/dba/models/SpeedFactory.php +++ b/src/dba/models/SpeedFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class SpeedFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Speed { /** * @param array $options * @param bool $single - * @return Speed|Speed[] + * @return Speed|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Speed|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Speed|array|null { /** * @param string $pk * @return ?Speed + * @throws Exception */ function get($pk): ?Speed { return Util::cast(parent::get($pk), Speed::class); @@ -84,9 +89,31 @@ function get($pk): ?Speed { /** * @param Speed $model - * @return Speed + * @return ?Speed + * @throws Exception */ - function save($model): Speed { + function save($model): ?Speed { return Util::cast(parent::save($model), Speed::class); } + + /** + * @param Speed $model + * @param array $arr key-value associations for update + * @return Speed + * @throws Exception + */ + function mset($model, array $arr): Speed { + return Util::cast(parent::mset($model, $arr), Speed::class); + } + + /** + * @param Speed $model + * @param string $key key of the column to update + * @param $value + * @return Speed + * @throws Exception + */ + function set($model, string $key, $value): Speed { + return Util::cast(parent::set($model, $key, $value), Speed::class); + } } diff --git a/src/dba/models/StoredValueFactory.php b/src/dba/models/StoredValueFactory.php index df42fc923..518f5d2df 100644 --- a/src/dba/models/StoredValueFactory.php +++ b/src/dba/models/StoredValueFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class StoredValueFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): StoredValue { /** * @param array $options * @param bool $single - * @return StoredValue|StoredValue[] + * @return StoredValue|array|null + * @throws Exception */ function filter(array $options, bool $single = false): StoredValue|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): StoredValue|array|null { /** * @param string $pk * @return ?StoredValue + * @throws Exception */ function get($pk): ?StoredValue { return Util::cast(parent::get($pk), StoredValue::class); @@ -84,9 +89,31 @@ function get($pk): ?StoredValue { /** * @param StoredValue $model - * @return StoredValue + * @return ?StoredValue + * @throws Exception */ - function save($model): StoredValue { + function save($model): ?StoredValue { return Util::cast(parent::save($model), StoredValue::class); } + + /** + * @param StoredValue $model + * @param array $arr key-value associations for update + * @return StoredValue + * @throws Exception + */ + function mset($model, array $arr): StoredValue { + return Util::cast(parent::mset($model, $arr), StoredValue::class); + } + + /** + * @param StoredValue $model + * @param string $key key of the column to update + * @param $value + * @return StoredValue + * @throws Exception + */ + function set($model, string $key, $value): StoredValue { + return Util::cast(parent::set($model, $key, $value), StoredValue::class); + } } diff --git a/src/dba/models/SupertaskFactory.php b/src/dba/models/SupertaskFactory.php index ff6fa36a5..5f7c94f3e 100644 --- a/src/dba/models/SupertaskFactory.php +++ b/src/dba/models/SupertaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class SupertaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Supertask { /** * @param array $options * @param bool $single - * @return Supertask|Supertask[] + * @return Supertask|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Supertask|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Supertask|array|null { /** * @param string $pk * @return ?Supertask + * @throws Exception */ function get($pk): ?Supertask { return Util::cast(parent::get($pk), Supertask::class); @@ -84,9 +89,31 @@ function get($pk): ?Supertask { /** * @param Supertask $model - * @return Supertask + * @return ?Supertask + * @throws Exception */ - function save($model): Supertask { + function save($model): ?Supertask { return Util::cast(parent::save($model), Supertask::class); } + + /** + * @param Supertask $model + * @param array $arr key-value associations for update + * @return Supertask + * @throws Exception + */ + function mset($model, array $arr): Supertask { + return Util::cast(parent::mset($model, $arr), Supertask::class); + } + + /** + * @param Supertask $model + * @param string $key key of the column to update + * @param $value + * @return Supertask + * @throws Exception + */ + function set($model, string $key, $value): Supertask { + return Util::cast(parent::set($model, $key, $value), Supertask::class); + } } diff --git a/src/dba/models/SupertaskPretaskFactory.php b/src/dba/models/SupertaskPretaskFactory.php index c1bb9298d..23076a9e7 100644 --- a/src/dba/models/SupertaskPretaskFactory.php +++ b/src/dba/models/SupertaskPretaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class SupertaskPretaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): SupertaskPretask { /** * @param array $options * @param bool $single - * @return SupertaskPretask|SupertaskPretask[] + * @return SupertaskPretask|array|null + * @throws Exception */ function filter(array $options, bool $single = false): SupertaskPretask|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): SupertaskPretask|array|nu /** * @param string $pk * @return ?SupertaskPretask + * @throws Exception */ function get($pk): ?SupertaskPretask { return Util::cast(parent::get($pk), SupertaskPretask::class); @@ -84,9 +89,31 @@ function get($pk): ?SupertaskPretask { /** * @param SupertaskPretask $model - * @return SupertaskPretask + * @return ?SupertaskPretask + * @throws Exception */ - function save($model): SupertaskPretask { + function save($model): ?SupertaskPretask { return Util::cast(parent::save($model), SupertaskPretask::class); } + + /** + * @param SupertaskPretask $model + * @param array $arr key-value associations for update + * @return SupertaskPretask + * @throws Exception + */ + function mset($model, array $arr): SupertaskPretask { + return Util::cast(parent::mset($model, $arr), SupertaskPretask::class); + } + + /** + * @param SupertaskPretask $model + * @param string $key key of the column to update + * @param $value + * @return SupertaskPretask + * @throws Exception + */ + function set($model, string $key, $value): SupertaskPretask { + return Util::cast(parent::set($model, $key, $value), SupertaskPretask::class); + } } diff --git a/src/dba/models/TaskDebugOutputFactory.php b/src/dba/models/TaskDebugOutputFactory.php index c10274a70..5b5173566 100644 --- a/src/dba/models/TaskDebugOutputFactory.php +++ b/src/dba/models/TaskDebugOutputFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class TaskDebugOutputFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): TaskDebugOutput { /** * @param array $options * @param bool $single - * @return TaskDebugOutput|TaskDebugOutput[] + * @return TaskDebugOutput|array|null + * @throws Exception */ function filter(array $options, bool $single = false): TaskDebugOutput|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): TaskDebugOutput|array|nul /** * @param string $pk * @return ?TaskDebugOutput + * @throws Exception */ function get($pk): ?TaskDebugOutput { return Util::cast(parent::get($pk), TaskDebugOutput::class); @@ -84,9 +89,31 @@ function get($pk): ?TaskDebugOutput { /** * @param TaskDebugOutput $model - * @return TaskDebugOutput + * @return ?TaskDebugOutput + * @throws Exception */ - function save($model): TaskDebugOutput { + function save($model): ?TaskDebugOutput { return Util::cast(parent::save($model), TaskDebugOutput::class); } + + /** + * @param TaskDebugOutput $model + * @param array $arr key-value associations for update + * @return TaskDebugOutput + * @throws Exception + */ + function mset($model, array $arr): TaskDebugOutput { + return Util::cast(parent::mset($model, $arr), TaskDebugOutput::class); + } + + /** + * @param TaskDebugOutput $model + * @param string $key key of the column to update + * @param $value + * @return TaskDebugOutput + * @throws Exception + */ + function set($model, string $key, $value): TaskDebugOutput { + return Util::cast(parent::set($model, $key, $value), TaskDebugOutput::class); + } } diff --git a/src/dba/models/TaskFactory.php b/src/dba/models/TaskFactory.php index b0e4b6ce8..9887c02b6 100644 --- a/src/dba/models/TaskFactory.php +++ b/src/dba/models/TaskFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class TaskFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Task { /** * @param array $options * @param bool $single - * @return Task|Task[] + * @return Task|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Task|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Task|array|null { /** * @param string $pk * @return ?Task + * @throws Exception */ function get($pk): ?Task { return Util::cast(parent::get($pk), Task::class); @@ -84,9 +89,31 @@ function get($pk): ?Task { /** * @param Task $model - * @return Task + * @return ?Task + * @throws Exception */ - function save($model): Task { + function save($model): ?Task { return Util::cast(parent::save($model), Task::class); } + + /** + * @param Task $model + * @param array $arr key-value associations for update + * @return Task + * @throws Exception + */ + function mset($model, array $arr): Task { + return Util::cast(parent::mset($model, $arr), Task::class); + } + + /** + * @param Task $model + * @param string $key key of the column to update + * @param $value + * @return Task + * @throws Exception + */ + function set($model, string $key, $value): Task { + return Util::cast(parent::set($model, $key, $value), Task::class); + } } diff --git a/src/dba/models/TaskWrapperDisplayFactory.php b/src/dba/models/TaskWrapperDisplayFactory.php index b32d0250f..ef31548a9 100644 --- a/src/dba/models/TaskWrapperDisplayFactory.php +++ b/src/dba/models/TaskWrapperDisplayFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class TaskWrapperDisplayFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): TaskWrapperDisplay { /** * @param array $options * @param bool $single - * @return TaskWrapperDisplay|TaskWrapperDisplay[] + * @return TaskWrapperDisplay|array|null + * @throws Exception */ function filter(array $options, bool $single = false): TaskWrapperDisplay|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): TaskWrapperDisplay|array| /** * @param string $pk * @return ?TaskWrapperDisplay + * @throws Exception */ function get($pk): ?TaskWrapperDisplay { return Util::cast(parent::get($pk), TaskWrapperDisplay::class); @@ -84,9 +89,31 @@ function get($pk): ?TaskWrapperDisplay { /** * @param TaskWrapperDisplay $model - * @return TaskWrapperDisplay + * @return ?TaskWrapperDisplay + * @throws Exception */ - function save($model): TaskWrapperDisplay { + function save($model): ?TaskWrapperDisplay { return Util::cast(parent::save($model), TaskWrapperDisplay::class); } + + /** + * @param TaskWrapperDisplay $model + * @param array $arr key-value associations for update + * @return TaskWrapperDisplay + * @throws Exception + */ + function mset($model, array $arr): TaskWrapperDisplay { + return Util::cast(parent::mset($model, $arr), TaskWrapperDisplay::class); + } + + /** + * @param TaskWrapperDisplay $model + * @param string $key key of the column to update + * @param $value + * @return TaskWrapperDisplay + * @throws Exception + */ + function set($model, string $key, $value): TaskWrapperDisplay { + return Util::cast(parent::set($model, $key, $value), TaskWrapperDisplay::class); + } } diff --git a/src/dba/models/TaskWrapperFactory.php b/src/dba/models/TaskWrapperFactory.php index c546d049f..a6ac47d5f 100644 --- a/src/dba/models/TaskWrapperFactory.php +++ b/src/dba/models/TaskWrapperFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class TaskWrapperFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): TaskWrapper { /** * @param array $options * @param bool $single - * @return TaskWrapper|TaskWrapper[] + * @return TaskWrapper|array|null + * @throws Exception */ function filter(array $options, bool $single = false): TaskWrapper|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): TaskWrapper|array|null { /** * @param string $pk * @return ?TaskWrapper + * @throws Exception */ function get($pk): ?TaskWrapper { return Util::cast(parent::get($pk), TaskWrapper::class); @@ -84,9 +89,31 @@ function get($pk): ?TaskWrapper { /** * @param TaskWrapper $model - * @return TaskWrapper + * @return ?TaskWrapper + * @throws Exception */ - function save($model): TaskWrapper { + function save($model): ?TaskWrapper { return Util::cast(parent::save($model), TaskWrapper::class); } + + /** + * @param TaskWrapper $model + * @param array $arr key-value associations for update + * @return TaskWrapper + * @throws Exception + */ + function mset($model, array $arr): TaskWrapper { + return Util::cast(parent::mset($model, $arr), TaskWrapper::class); + } + + /** + * @param TaskWrapper $model + * @param string $key key of the column to update + * @param $value + * @return TaskWrapper + * @throws Exception + */ + function set($model, string $key, $value): TaskWrapper { + return Util::cast(parent::set($model, $key, $value), TaskWrapper::class); + } } diff --git a/src/dba/models/UserFactory.php b/src/dba/models/UserFactory.php index 2dd6722e9..7bdd2217e 100644 --- a/src/dba/models/UserFactory.php +++ b/src/dba/models/UserFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class UserFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): User { /** * @param array $options * @param bool $single - * @return User|User[] + * @return User|array|null + * @throws Exception */ function filter(array $options, bool $single = false): User|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): User|array|null { /** * @param string $pk * @return ?User + * @throws Exception */ function get($pk): ?User { return Util::cast(parent::get($pk), User::class); @@ -84,9 +89,31 @@ function get($pk): ?User { /** * @param User $model - * @return User + * @return ?User + * @throws Exception */ - function save($model): User { + function save($model): ?User { return Util::cast(parent::save($model), User::class); } + + /** + * @param User $model + * @param array $arr key-value associations for update + * @return User + * @throws Exception + */ + function mset($model, array $arr): User { + return Util::cast(parent::mset($model, $arr), User::class); + } + + /** + * @param User $model + * @param string $key key of the column to update + * @param $value + * @return User + * @throws Exception + */ + function set($model, string $key, $value): User { + return Util::cast(parent::set($model, $key, $value), User::class); + } } diff --git a/src/dba/models/ZapFactory.php b/src/dba/models/ZapFactory.php index c8654fd22..6df221673 100644 --- a/src/dba/models/ZapFactory.php +++ b/src/dba/models/ZapFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class ZapFactory extends AbstractModelFactory { @@ -50,7 +53,8 @@ function createObjectFromDict($pk, $dict): Zap { /** * @param array $options * @param bool $single - * @return Zap|Zap[] + * @return Zap|array|null + * @throws Exception */ function filter(array $options, bool $single = false): Zap|array|null { $join = false; @@ -77,6 +81,7 @@ function filter(array $options, bool $single = false): Zap|array|null { /** * @param string $pk * @return ?Zap + * @throws Exception */ function get($pk): ?Zap { return Util::cast(parent::get($pk), Zap::class); @@ -84,9 +89,31 @@ function get($pk): ?Zap { /** * @param Zap $model - * @return Zap + * @return ?Zap + * @throws Exception */ - function save($model): Zap { + function save($model): ?Zap { return Util::cast(parent::save($model), Zap::class); } + + /** + * @param Zap $model + * @param array $arr key-value associations for update + * @return Zap + * @throws Exception + */ + function mset($model, array $arr): Zap { + return Util::cast(parent::mset($model, $arr), Zap::class); + } + + /** + * @param Zap $model + * @param string $key key of the column to update + * @param $value + * @return Zap + * @throws Exception + */ + function set($model, string $key, $value): Zap { + return Util::cast(parent::set($model, $key, $value), Zap::class); + } } diff --git a/src/dba/models/_sqlx_migrationsFactory.php b/src/dba/models/_sqlx_migrationsFactory.php index d2f7037b9..c4d8b79e2 100644 --- a/src/dba/models/_sqlx_migrationsFactory.php +++ b/src/dba/models/_sqlx_migrationsFactory.php @@ -2,7 +2,10 @@ namespace Hashtopolis\dba\models; +use Exception; +use PDOStatement; use Hashtopolis\dba\AbstractModelFactory; +use Hashtopolis\dba\AbstractModel; use Hashtopolis\dba\Util; class _sqlx_migrationsFactory extends AbstractModelFactory { @@ -55,7 +58,8 @@ function createObjectFromDict($pk, $dict): _sqlx_migrations { /** * @param array $options * @param bool $single - * @return _sqlx_migrations|_sqlx_migrations[] + * @return _sqlx_migrations|array|null + * @throws Exception */ function filter(array $options, bool $single = false): _sqlx_migrations|array|null { $join = false; @@ -82,6 +86,7 @@ function filter(array $options, bool $single = false): _sqlx_migrations|array|nu /** * @param string $pk * @return ?_sqlx_migrations + * @throws Exception */ function get($pk): ?_sqlx_migrations { return Util::cast(parent::get($pk), _sqlx_migrations::class); @@ -89,9 +94,31 @@ function get($pk): ?_sqlx_migrations { /** * @param _sqlx_migrations $model - * @return _sqlx_migrations + * @return ?_sqlx_migrations + * @throws Exception */ - function save($model): _sqlx_migrations { + function save($model): ?_sqlx_migrations { return Util::cast(parent::save($model), _sqlx_migrations::class); } + + /** + * @param _sqlx_migrations $model + * @param array $arr key-value associations for update + * @return _sqlx_migrations + * @throws Exception + */ + function mset($model, array $arr): _sqlx_migrations { + return Util::cast(parent::mset($model, $arr), _sqlx_migrations::class); + } + + /** + * @param _sqlx_migrations $model + * @param string $key key of the column to update + * @param $value + * @return _sqlx_migrations + * @throws Exception + */ + function set($model, string $key, $value): _sqlx_migrations { + return Util::cast(parent::set($model, $key, $value), _sqlx_migrations::class); + } } diff --git a/src/inc/HTMessages.php b/src/inc/HTMessages.php index 7ff9e6547..7f2233704 100644 --- a/src/inc/HTMessages.php +++ b/src/inc/HTMessages.php @@ -10,7 +10,7 @@ class HTMessages extends Exception { public function __construct($message = "", $code = 0, ?Throwable $previous = NULL) { $this->arr = $message; - $this->message = implode("\n", $this->arr); + parent::__construct(implode("\n", $this->arr), $code, $previous); } public function getHTMLMessage() { diff --git a/src/inc/Lang.php b/src/inc/Lang.php index cf70795b9..841721484 100755 --- a/src/inc/Lang.php +++ b/src/inc/Lang.php @@ -126,7 +126,7 @@ public function getNumAvailableLanguages() { * Get the written name of a given language name. * * @param string $name name identifier of language - * @return string containing the name, false if language is not found + * @return string|bool containing the name, false if language is not found */ public function getLanguageName($name) { if (isset($this->langArr[$name]['name'])) { diff --git a/src/inc/Login.php b/src/inc/Login.php index fe84d2a49..5f62765db 100755 --- a/src/inc/Login.php +++ b/src/inc/Login.php @@ -15,6 +15,7 @@ use Hashtopolis\inc\handlers\NotificationHandler; use Hashtopolis\inc\SConfig; use Hashtopolis\inc\Util; +use function PHPUnit\Framework\assertNotNull; /** * Handles the login sessions @@ -24,8 +25,7 @@ class Login { private $user = null; private $valid = false; - /** @var Session $session */ - private $session = null; + private ?Session $session = null; private static $instance = null; @@ -68,7 +68,7 @@ private function __construct() { } $this->valid = true; $this->session = $session; - Factory::getSessionFactory()->set($session, Session::LAST_ACTION_DATE, time()); + $session = Factory::getSessionFactory()->set($session, Session::LAST_ACTION_DATE, time()); setcookie("session", $session->getSessionKey(), time() + $this->user->getSessionLifetime(), "", "", false, true); } } @@ -85,6 +85,7 @@ public function isLoggedin() { * Logs the current user out and closes his session */ public function logout() { + assertNotNull($this->session); Factory::getSessionFactory()->set($this->session, Session::IS_OPEN, 0); $this->session = null; $this->user = null; @@ -194,7 +195,7 @@ public function login(string $username, string $password, $otp = NULL): bool { } $sessionKey = Encryption::sessionHash($session->getId(), $startTime, $user->getEmail()); Factory::getSessionFactory()->set($session, Session::SESSION_KEY, $sessionKey); - Factory::getUserFactory()->set($this->user, User::LAST_LOGIN_DATE, time()); + $this->user = Factory::getUserFactory()->set($this->user, User::LAST_LOGIN_DATE, time()); $this->valid = true; Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "Successful login!"); diff --git a/src/inc/StartupConfig.php b/src/inc/StartupConfig.php index 0465f9e1d..d8f97f751 100644 --- a/src/inc/StartupConfig.php +++ b/src/inc/StartupConfig.php @@ -149,6 +149,7 @@ private function loadLegacyConfig(): void { // this is either an existing setup, or a new setup without docker include(dirname(__FILE__) . "/conf.php"); + /** @var array{user: string, pass: string, db: string, server: string, port: string} $CONN */ // check if directories is set, otherwise set the defaults for it if (!isset($DIRECTORIES)) { diff --git a/src/inc/UI.php b/src/inc/UI.php index 6e04fd9a0..cd70130c9 100644 --- a/src/inc/UI.php +++ b/src/inc/UI.php @@ -50,7 +50,7 @@ public static function addMessage($type, $message): void { public static function getNumMessages($type = "ALL"): int { $count = 0; foreach (self::$objects['messages'] as $message) { - /** @var $message DataSet */ + /** @var DataSet $message */ if ($message->getVal('type') == $type || $type == "ALL") { $count++; } diff --git a/src/inc/Util.php b/src/inc/Util.php index 9e1835e17..db4b490c5 100755 --- a/src/inc/Util.php +++ b/src/inc/Util.php @@ -143,7 +143,7 @@ public static function getSpeedDataSet($taskId, $limit = 50, $agentId = 0, $delt $first = $entries[0]->getTime(); foreach ($entries as $entry) { - $pos = $limit - 1 - floor(($first - $entry->getTime()) / $delta); + $pos = intval($limit - 1 - floor(($first - $entry->getTime()) / $delta)); if ($pos < 0) { continue; // too old entry } @@ -155,7 +155,7 @@ public static function getSpeedDataSet($taskId, $limit = 50, $agentId = 0, $delt } // prepare with timestamps - $first = round($first, -log10($delta)); + $first = intval(round($first, -log10($delta))); $timestampData = []; foreach ($data as $key => $val) { $timestampData[$first - ($limit - 1 - $key) * $delta] = $val; @@ -484,7 +484,7 @@ public static function getFileInfo($task, $accessGroups) { $qF = new QueryFilter(FileTask::TASK_ID, $task->getId(), "=", Factory::getFileTaskFactory()); $jF = new JoinFilter(Factory::getFileTaskFactory(), FileTask::FILE_ID, File::FILE_ID); $joinedFiles = Factory::getFileFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $files File[] */ + /** @var File[] $files */ $files = $joinedFiles[Factory::getFileFactory()->getModelName()]; $sizeFiles = 0; $fileSecret = false; @@ -528,7 +528,7 @@ public static function getAccessGroupIds($userId) { $qF = new QueryFilter(AccessGroupUser::USER_ID, $userId, "=", Factory::getAccessGroupUserFactory()); $jF = new JoinFilter(Factory::getAccessGroupUserFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupUser::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroups AccessGroup[] */ + /** @var AccessGroup[] $accessGroups */ $accessGroups = $joined[Factory::getAccessGroupFactory()->getModelName()]; return Util::arrayOfIds($accessGroups); } @@ -929,7 +929,7 @@ public static function tickdone($prog, $total) { public static function getUsernameById($id) { $user = Factory::getUserFactory()->get($id); if ($user === null) { - return "Unknown" . (strlen($id) > 0) ? "-$id" : ""; + return "Unknown" . ((strlen("" . $id) > 0) ? "-$id" : ""); } return $user->getUsername(); } diff --git a/src/inc/api/APIBasic.php b/src/inc/api/APIBasic.php index b863d6d0b..8595f5c27 100644 --- a/src/inc/api/APIBasic.php +++ b/src/inc/api/APIBasic.php @@ -2,6 +2,7 @@ namespace Hashtopolis\inc\api; +use Exception; use Hashtopolis\inc\agent\PResponseErrorMessage; use Hashtopolis\inc\agent\PValues; use Hashtopolis\inc\defines\DServerLog; @@ -13,23 +14,25 @@ use Hashtopolis\inc\Util; abstract class APIBasic { - /** @var Agent */ - protected $agent = null; + protected ?Agent $agent = null; /** * @param array $QUERY input query sent to the API * @throws HTException */ - public abstract function execute($QUERY = array()); + public abstract function execute(array $QUERY = []); - protected function sendResponse($RESPONSE) { + protected function sendResponse($RESPONSE): void { header("Content-Type: application/json"); echo json_encode($RESPONSE); die(); } + /** + * @throws Exception + */ protected function updateAgent($action): void { - Factory::getAgentFactory()->mset($this->agent, [Agent::LAST_IP => Util::getIP(), Agent::LAST_ACT => $action, Agent::LAST_TIME => time()]); + $this->agent = Factory::getAgentFactory()->mset($this->agent, [Agent::LAST_IP => Util::getIP(), Agent::LAST_ACT => $action, Agent::LAST_TIME => time()]); } public function sendErrorResponse($action, $msg): void { diff --git a/src/inc/api/APICheckClientVersion.php b/src/inc/api/APICheckClientVersion.php index f7017b92a..3e55b2c1e 100644 --- a/src/inc/api/APICheckClientVersion.php +++ b/src/inc/api/APICheckClientVersion.php @@ -17,7 +17,7 @@ use Hashtopolis\inc\Util; class APICheckClientVersion extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { // check if provided hash is the same as script and send file contents if not if (!PQueryCheckClientVersion::isValid($QUERY)) { $this->sendErrorResponse(PActions::CHECK_CLIENT_VERSION, 'Invalid version check query!'); diff --git a/src/inc/api/APIClientError.php b/src/inc/api/APIClientError.php index 614540b59..44bd2eee9 100644 --- a/src/inc/api/APIClientError.php +++ b/src/inc/api/APIClientError.php @@ -21,7 +21,7 @@ use Hashtopolis\inc\SConfig; class APIClientError extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryClientError::isValid($QUERY)) { $this->sendErrorResponse(PActions::CLIENT_ERROR, "Invalid error query!"); @@ -74,7 +74,7 @@ public function execute($QUERY = array()) { if ($this->agent->getIgnoreErrors() == DAgentIgnoreErrors::NO) { //deactivate agent - Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); } $this->updateAgent(PActions::CLIENT_ERROR); diff --git a/src/inc/api/APIDeRegisterAgent.php b/src/inc/api/APIDeRegisterAgent.php index 14e92dc9e..83a939cef 100644 --- a/src/inc/api/APIDeRegisterAgent.php +++ b/src/inc/api/APIDeRegisterAgent.php @@ -12,7 +12,7 @@ use Hashtopolis\inc\SConfig; class APIDeRegisterAgent extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryDeRegister::isValid($QUERY)) { $this->sendErrorResponse(PActions::DEREGISTER, "Invalid de-registering query!"); diff --git a/src/inc/api/APIDownloadBinary.php b/src/inc/api/APIDownloadBinary.php index 278a1f4fc..ff4cd7558 100644 --- a/src/inc/api/APIDownloadBinary.php +++ b/src/inc/api/APIDownloadBinary.php @@ -14,7 +14,7 @@ use Hashtopolis\inc\Util; class APIDownloadBinary extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQueryDownloadBinary::isValid($QUERY)) { $this->sendErrorResponse(PActions::DOWNLOAD_BINARY, "Invalid download query!"); } diff --git a/src/inc/api/APIGetChunk.php b/src/inc/api/APIGetChunk.php index 614fb12c0..cdf0f5fcf 100644 --- a/src/inc/api/APIGetChunk.php +++ b/src/inc/api/APIGetChunk.php @@ -32,7 +32,7 @@ class APIGetChunk extends APIBasic { * @throws HTException * @throws Exception */ - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQueryGetChunk::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_CHUNK, "Invalid chunk query!"); } @@ -154,7 +154,7 @@ public function execute($QUERY = array()) { $oF = new OrderFilter(Chunk::SKIP, "ASC"); $chunks = Factory::getChunkFactory()->filter([Factory::FILTER => [$qF1, $qF2], Factory::ORDER => $oF]); $qF1 = new QueryFilter(Chunk::PROGRESS, null, "="); - /** @var $chunks Chunk[] */ + /** @var Chunk[] $chunks */ $chunks = array_merge($chunks, Factory::getChunkFactory()->filter([Factory::FILTER => [$qF1, $qF2], Factory::ORDER => $oF])); foreach ($chunks as $chunk) { if ($chunk->getAgentId() == $this->agent->getId()) { diff --git a/src/inc/api/APIGetFile.php b/src/inc/api/APIGetFile.php index 6bffb5bc0..d69d624ca 100644 --- a/src/inc/api/APIGetFile.php +++ b/src/inc/api/APIGetFile.php @@ -14,7 +14,7 @@ use Hashtopolis\dba\Factory; class APIGetFile extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryGetFile::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_FILE, "Invalid file query!"); diff --git a/src/inc/api/APIGetFileStatus.php b/src/inc/api/APIGetFileStatus.php index 185092295..6683a7e4e 100644 --- a/src/inc/api/APIGetFileStatus.php +++ b/src/inc/api/APIGetFileStatus.php @@ -8,7 +8,7 @@ use Hashtopolis\inc\agent\PValues; class APIGetFileStatus extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { $deleteRequests = Factory::getFileDeleteFactory()->filter([]); $files = []; foreach ($deleteRequests as $deleteRequest) { diff --git a/src/inc/api/APIGetFound.php b/src/inc/api/APIGetFound.php index bcb54c8e9..942f8b03e 100644 --- a/src/inc/api/APIGetFound.php +++ b/src/inc/api/APIGetFound.php @@ -13,7 +13,7 @@ use Hashtopolis\inc\Util; class APIGetFound extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryGetFound::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_FOUND, "Invalid found query!"); diff --git a/src/inc/api/APIGetHashlist.php b/src/inc/api/APIGetHashlist.php index 7aadfa235..8958ca7cc 100644 --- a/src/inc/api/APIGetHashlist.php +++ b/src/inc/api/APIGetHashlist.php @@ -13,7 +13,7 @@ use Hashtopolis\inc\Util; class APIGetHashlist extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryGetHashlist::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_HASHLIST, "Invalid hashlist query!"); diff --git a/src/inc/api/APIGetHealthCheck.php b/src/inc/api/APIGetHealthCheck.php index 1f7e76801..92026aeb3 100644 --- a/src/inc/api/APIGetHealthCheck.php +++ b/src/inc/api/APIGetHealthCheck.php @@ -13,7 +13,7 @@ use Hashtopolis\inc\SConfig; class APIGetHealthCheck extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQueryGetHealthCheck::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_HEALTH_CHECK, "Invalid get health check query!"); } diff --git a/src/inc/api/APIGetTask.php b/src/inc/api/APIGetTask.php index 4c0b85eff..735b90ef6 100644 --- a/src/inc/api/APIGetTask.php +++ b/src/inc/api/APIGetTask.php @@ -21,7 +21,7 @@ use Hashtopolis\inc\utils\TaskUtils; class APIGetTask extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQueryGetTask::isValid($QUERY)) { $this->sendErrorResponse(PActions::GET_TASK, "Invalid task query!"); } @@ -158,7 +158,7 @@ private function sendTask($task, $assignment) { $qF = new QueryFilter(FileTask::TASK_ID, $task->getId(), "=", Factory::getFileTaskFactory()); $jF = new JoinFilter(Factory::getFileTaskFactory(), File::FILE_ID, FileTask::FILE_ID); $joined = Factory::getFileFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $files File[] */ + /** @var File[] $files */ $files = $joined[Factory::getFileFactory()->getModelName()]; foreach ($files as $file) { $taskFiles[] = $file->getFilename(); diff --git a/src/inc/api/APILogin.php b/src/inc/api/APILogin.php index 8289c929f..7ef1f4f7e 100644 --- a/src/inc/api/APILogin.php +++ b/src/inc/api/APILogin.php @@ -15,12 +15,12 @@ use Hashtopolis\inc\Util; class APILogin extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQueryLogin::isValid($QUERY)) { $this->sendErrorResponse(PActions::LOGIN, "Invalid login query!"); } $this->checkToken(PActions::LOGIN, $QUERY); - Factory::getAgentFactory()->set($this->agent, Agent::CLIENT_SIGNATURE, htmlentities($QUERY[PQueryLogin::CLIENT_SIGNATURE], ENT_QUOTES, "UTF-8")); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::CLIENT_SIGNATURE, htmlentities($QUERY[PQueryLogin::CLIENT_SIGNATURE], ENT_QUOTES, "UTF-8")); $this->updateAgent(PActions::LOGIN); DServerLog::log(DServerLog::DEBUG, "Agent logged in", [$this->agent]); diff --git a/src/inc/api/APIRegisterAgent.php b/src/inc/api/APIRegisterAgent.php index 3b3aed3f2..51d199f27 100644 --- a/src/inc/api/APIRegisterAgent.php +++ b/src/inc/api/APIRegisterAgent.php @@ -22,7 +22,7 @@ use Hashtopolis\inc\Util; class APIRegisterAgent extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { //check required values if (!PQueryRegister::isValid($QUERY)) { $this->sendErrorResponse(PActions::REGISTER, "Invalid registering query!"); diff --git a/src/inc/api/APISendBenchmark.php b/src/inc/api/APISendBenchmark.php index e63a479f3..ddd4b45ab 100644 --- a/src/inc/api/APISendBenchmark.php +++ b/src/inc/api/APISendBenchmark.php @@ -16,7 +16,7 @@ use Hashtopolis\inc\SConfig; class APISendBenchmark extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQuerySendBenchmark::isValid($QUERY)) { $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid benchmark query!"); } @@ -44,14 +44,14 @@ public function execute($QUERY = array()) { case PValuesBenchmarkType::SPEED_TEST: $split = explode(":", $benchmark); if (sizeof($split) != 2 || !is_numeric($split[0]) || !is_numeric($split[1]) || $split[0] <= 0 || $split[1] <= 0) { - Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); DServerLog::log(DServerLog::ERROR, "Invalid speed test benchmark result!", [$this->agent, $benchmark]); $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid benchmark result!"); } break; case PValuesBenchmarkType::RUN_TIME: if (!is_numeric($benchmark) || $benchmark <= 0) { - Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); DServerLog::log(DServerLog::ERROR, "Invalid benchmark results for runtime benchmark", [$this->agent, $task, $benchmark]); $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid benchmark result!"); } @@ -60,7 +60,7 @@ public function execute($QUERY = array()) { DServerLog::log(DServerLog::TRACE, "Saving normalized runtime benchmark", [$this->agent, $task, $benchmark]); break; default: - Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::IS_ACTIVE, 0); $this->sendErrorResponse(PActions::SEND_BENCHMARK, "Invalid benchmark type!"); } diff --git a/src/inc/api/APISendHealthCheck.php b/src/inc/api/APISendHealthCheck.php index 06987e7d6..698c37908 100644 --- a/src/inc/api/APISendHealthCheck.php +++ b/src/inc/api/APISendHealthCheck.php @@ -15,7 +15,7 @@ use Hashtopolis\inc\utils\HealthUtils; class APISendHealthCheck extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQuerySendHealthCheck::isValid($QUERY)) { $this->sendErrorResponse(PActions::SEND_HEALTH_CHECK, "Invalid send health check query!"); } diff --git a/src/inc/api/APISendKeyspace.php b/src/inc/api/APISendKeyspace.php index 9f71f1f2d..82a6aa060 100644 --- a/src/inc/api/APISendKeyspace.php +++ b/src/inc/api/APISendKeyspace.php @@ -17,7 +17,7 @@ use Hashtopolis\inc\Util; class APISendKeyspace extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQuerySendKeyspace::isValid($QUERY)) { $this->sendErrorResponse(PActions::SEND_KEYSPACE, "Invalid keyspace query!"); } @@ -53,7 +53,7 @@ public function execute($QUERY = array()) { $this->sendErrorResponse(PActions::SEND_KEYSPACE, "Server parsed a negative keyspace, it's very likely that the number was too big to be handled by the server system!"); } - Factory::getTaskFactory()->set($task, Task::KEYSPACE, $keyspace); + $task = Factory::getTaskFactory()->set($task, Task::KEYSPACE, $keyspace); DServerLog::log(DServerLog::TRACE, "Keyspace saved", [$this->agent, $task]); } @@ -61,7 +61,7 @@ public function execute($QUERY = array()) { if ($task->getSkipKeyspace() > $task->getKeyspace() && $task->getKeyspace() != DPrince::PRINCE_KEYSPACE) { // skip is too high DServerLog::log(DServerLog::ERROR, "Task skip value is too high, putting task inactive!", [$this->agent, $task]); - Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); + $task = Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); $qF = new QueryFilter(Assignment::TASK_ID, $task->getId(), "="); Factory::getAssignmentFactory()->massDeletion([Factory::FILTER => $qF]); Util::createLogEntry(DLogEntryIssuer::API, $this->agent->getToken(), DLogEntry::ERROR, "Task with ID " . $task->getId() . " has set a skip value which is too high for its keyspace!"); diff --git a/src/inc/api/APISendProgress.php b/src/inc/api/APISendProgress.php index ef3073d43..dde1c4d65 100644 --- a/src/inc/api/APISendProgress.php +++ b/src/inc/api/APISendProgress.php @@ -44,7 +44,7 @@ use Hashtopolis\inc\Util; class APISendProgress extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { if (!PQuerySendProgress::isValid($QUERY)) { $this->sendErrorResponse(PActions::SEND_PROGRESS, "Invalid progress query!"); } @@ -67,7 +67,7 @@ public function execute($QUERY = array()) { $this->sendErrorResponse(PActions::SEND_PROGRESS, "You are not assigned to this chunk"); } else if ($this->agent->getIsActive() == 0) { - Factory::getChunkFactory()->set($chunk, Chunk::SPEED, 0); + $chunk = Factory::getChunkFactory()->set($chunk, Chunk::SPEED, 0); $this->sendErrorResponse(PActions::SEND_PROGRESS, "Agent is marked inactive!"); } @@ -183,7 +183,7 @@ public function execute($QUERY = array()) { DServerLog::log(DServerLog::TRACE, "Chunk was aborted, we need to stop afterwards", [$this->agent]); $aborting = true; } - Factory::getChunkFactory()->mset($chunk, [ + $chunk = Factory::getChunkFactory()->mset($chunk, [ Chunk::PROGRESS => $relativeProgress, Chunk::CHECKPOINT => $keyspaceProgress, Chunk::SOLVE_TIME => time(), @@ -242,6 +242,10 @@ public function execute($QUERY = array()) { $split[3] = Util::strToHex($split[3]); $identifier = "WPA*%*" . implode("*", $split) . "%"; } + else{ + $skipped++; + break; + } $qF1 = new LikeFilterInsensitive(Hash::HASH, $identifier); } else { // we use the exact match for all other hashes to avoid performance loss @@ -322,6 +326,7 @@ public function execute($QUERY = array()) { else { // this format is used for -m 16801 $mac_ap = $split[0]; $mac_cli = $split[1]; + $essid = ""; } if (Util::startsWith($essid, '$HEX[') && Util::endsWith($essid, "]") && strlen($essid) % 2 == 0) { $essid = substr($essid, 5, strlen($essid) - 6); @@ -423,9 +428,10 @@ public function execute($QUERY = array()) { DServerLog::log(DServerLog::TRACE, "Updated with received cracks", [$this->agent, $chunk]); + assert($chunk instanceof Chunk); if ($chunk->getState() == DHashcatStatus::STATUS_ABORTED_RUNTIME) { // the chunk was manually interrupted - Factory::getChunkFactory()->set($chunk, Chunk::STATE, DHashcatStatus::ABORTED); + $chunk = Factory::getChunkFactory()->set($chunk, Chunk::STATE, DHashcatStatus::ABORTED); DServerLog::log(DServerLog::TRACE, "Chunk was manually interrupted", [$this->agent]); $this->sendErrorResponse(PActions::SEND_PROGRESS, "Chunk was manually interrupted."); } @@ -447,16 +453,16 @@ public function execute($QUERY = array()) { if ($taskdone) { // task is fully dispatched and this last chunk is done, deprioritize it - Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); + $task = Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); if ($taskWrapper->getTaskType() == DTaskTypes::SUPERTASK) { // check if the task wrapper is a supertask and is completed if (Util::checkTaskWrapperCompleted($taskWrapper)) { - Factory::getTaskWrapperFactory()->set($taskWrapper, TaskWrapper::PRIORITY, 0); + $taskWrapper = Factory::getTaskWrapperFactory()->set($taskWrapper, TaskWrapper::PRIORITY, 0); } } else { - Factory::getTaskWrapperFactory()->set($taskWrapper, TaskWrapper::PRIORITY, 0); + $taskWrapper = Factory::getTaskWrapperFactory()->set($taskWrapper, TaskWrapper::PRIORITY, 0); } DServerLog::log(DServerLog::TRACE, "As task is done, finished it and updated taskWrapper", [$this->agent, $task, $taskWrapper]); @@ -474,7 +480,7 @@ public function execute($QUERY = array()) { } if ($aborting) { - Factory::getChunkFactory()->mset($chunk, [Chunk::SPEED => 0, Chunk::STATE => DHashcatStatus::ABORTED]); + $chunk = Factory::getChunkFactory()->mset($chunk, [Chunk::SPEED => 0, Chunk::STATE => DHashcatStatus::ABORTED]); DServerLog::log(DServerLog::TRACE, "From earlier setting, chunk needed to be aborted.", [$this->agent, $chunk]); $this->sendErrorResponse(PActions::SEND_PROGRESS, "Chunk was aborted!"); } @@ -482,13 +488,13 @@ public function execute($QUERY = array()) { switch ($state) { case DHashcatStatus::EXHAUSTED: // the chunk has finished (exhausted) - Factory::getChunkFactory()->mset($chunk, [Chunk::SPEED => 0, Chunk::PROGRESS => 10000, Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength()]); + $chunk = Factory::getChunkFactory()->mset($chunk, [Chunk::SPEED => 0, Chunk::PROGRESS => 10000, Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength()]); DServerLog::log(DServerLog::TRACE, "Chunk is exhausted (cracker status)", [$this->agent, $chunk]); break; case DHashcatStatus::CRACKED: // the chunk has finished (cracked whole hashList) // de-prioritize all tasks and un-assign all agents - Factory::getChunkFactory()->mset($chunk, [Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength(), Chunk::PROGRESS => 10000, Chunk::SPEED => 0]); + $chunk = Factory::getChunkFactory()->mset($chunk, [Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength(), Chunk::PROGRESS => 10000, Chunk::SPEED => 0]); DServerLog::log(DServerLog::TRACE, "Last hash was cracked (cracker status)", [$this->agent, $chunk]); TaskUtils::depriorizeAllTasks($hashlists); @@ -501,9 +507,8 @@ public function execute($QUERY = array()) { case DHashcatStatus::ABORTED: case DHashcatStatus::QUIT: // the chunk was aborted or quit - Factory::getChunkFactory()->set($chunk, Chunk::SPEED, 0); + $chunk = Factory::getChunkFactory()->set($chunk, Chunk::SPEED, 0); $this->sendErrorResponse(PActions::SEND_PROGRESS, "Chunk was aborted!"); - break; case DHashcatStatus::RUNNING: default: // the chunk isn't finished yet, we will send zaps @@ -515,13 +520,13 @@ public function execute($QUERY = array()) { NotificationHandler::checkNotifications(DNotificationType::HASHLIST_ALL_CRACKED, $payload); DServerLog::log(DServerLog::TRACE, "Agent still is running, but all hashes got cracked (all agents together), stop it", [$this->agent]); - Factory::getChunkFactory()->mset($chunk, [Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength(), Chunk::PROGRESS => 10000, Chunk::SPEED => 0]); + $chunk = Factory::getChunkFactory()->mset($chunk, [Chunk::CHECKPOINT => $chunk->getSkip() + $chunk->getLength(), Chunk::PROGRESS => 10000, Chunk::SPEED => 0]); TaskUtils::depriorizeAllTasks($hashlists); $qF = new QueryFilter(Assignment::TASK_ID, $task->getId(), "="); Factory::getAssignmentFactory()->massDeletion([Factory::FILTER => $qF]); - Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); + $task = Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); DServerLog::log(DServerLog::TRACE, "Depriorized all tasks and updated", [$this->agent, $task, $chunk, $totalHashlist]); //stop agent @@ -534,7 +539,7 @@ public function execute($QUERY = array()) { ) ); } - Factory::getChunkFactory()->set($chunk, Chunk::SPEED, $speed); + $chunk = Factory::getChunkFactory()->set($chunk, Chunk::SPEED, $speed); // save speed in history if ($speed > 0) { @@ -559,7 +564,7 @@ public function execute($QUERY = array()) { } $toZap[] = $zap->getHash(); } - Factory::getAgentFactory()->set($this->agent, Agent::LAST_TIME, time()); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::LAST_TIME, time()); if ($agentZap->getLastZapId() > 0) { Factory::getAgentZapFactory()->update($agentZap); } diff --git a/src/inc/api/APITestConnection.php b/src/inc/api/APITestConnection.php index 1dcda9c44..1f7dc38cf 100644 --- a/src/inc/api/APITestConnection.php +++ b/src/inc/api/APITestConnection.php @@ -8,7 +8,7 @@ use Hashtopolis\inc\agent\PValues; class APITestConnection extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { $this->sendResponse(array( PResponse::ACTION => PActions::TEST_CONNECTION, PResponse::RESPONSE => PValues::SUCCESS diff --git a/src/inc/api/APIUpdateClientInformation.php b/src/inc/api/APIUpdateClientInformation.php index 373fe12e8..55328e4ef 100644 --- a/src/inc/api/APIUpdateClientInformation.php +++ b/src/inc/api/APIUpdateClientInformation.php @@ -11,7 +11,7 @@ use Hashtopolis\dba\Factory; class APIUpdateClientInformation extends APIBasic { - public function execute($QUERY = array()) { + public function execute(array $QUERY = array()) { // check required values and token if (!PQueryUpdateInformation::isValid($QUERY)) { $this->sendErrorResponse(PActions::UPDATE_CLIENT_INFORMATION, "Invalid update query!"); @@ -34,9 +34,9 @@ public function execute($QUERY = array()) { // save agent details if (strlen($this->agent->getUid()) == 0 && $this->agent->getCpuOnly() == 0) { // we only update this variable on the first time, otherwise we would overwrite manual changes - Factory::getAgentFactory()->set($this->agent, Agent::CPU_ONLY, $cpuOnly); + $this->agent = Factory::getAgentFactory()->set($this->agent, Agent::CPU_ONLY, $cpuOnly); } - Factory::getAgentFactory()->mset($this->agent, [ + $this->agent = Factory::getAgentFactory()->mset($this->agent, [ Agent::DEVICES => htmlentities(implode("\n", $devices), ENT_QUOTES, "UTF-8"), Agent::UID => $uid, Agent::OS => $os diff --git a/src/inc/defines/DAccessControl.php b/src/inc/defines/DAccessControl.php index c563c93f7..5a0b32e58 100644 --- a/src/inc/defines/DAccessControl.php +++ b/src/inc/defines/DAccessControl.php @@ -37,12 +37,7 @@ class DAccessControl { const LOGIN_ACCESS = "loginAccess"; static function getConstants() { - try { - $oClass = new ReflectionClass(__CLASS__); - } - catch (ReflectionException $e) { - die("Exception: " . $e->getMessage()); - } + $oClass = new ReflectionClass(__CLASS__); return $oClass->getConstants(); } diff --git a/src/inc/defines/DConfig.php b/src/inc/defines/DConfig.php index 8dac65937..cc9892440 100644 --- a/src/inc/defines/DConfig.php +++ b/src/inc/defines/DConfig.php @@ -83,12 +83,7 @@ class DConfig { const NOTIFICATIONS_PROXY_TYPE = "notificationsProxyType"; static function getConstants() { - try { - $oClass = new ReflectionClass(__CLASS__); - } - catch (ReflectionException $e) { - die("Exception: " . $e->getMessage()); - } + $oClass = new ReflectionClass(__CLASS__); return $oClass->getConstants(); } diff --git a/src/inc/defines/UApi.php b/src/inc/defines/UApi.php index d506a5ef4..f6786f8f1 100644 --- a/src/inc/defines/UApi.php +++ b/src/inc/defines/UApi.php @@ -9,12 +9,7 @@ abstract class UApi { abstract function describe($constant); static function getConstants() { - try { - $oClass = new ReflectionClass(static::class); - } - catch (ReflectionException $e) { - die("Exception: " . $e->getMessage()); - } + $oClass = new ReflectionClass(static::class); return $oClass->getConstants(); } diff --git a/src/inc/handlers/ApiHandler.php b/src/inc/handlers/ApiHandler.php index b0289b2ad..f2f31c32e 100644 --- a/src/inc/handlers/ApiHandler.php +++ b/src/inc/handlers/ApiHandler.php @@ -8,8 +8,6 @@ use Hashtopolis\inc\UI; class ApiHandler implements Handler { - private $user; - public function __construct($id = null) { // nothing } diff --git a/src/inc/handlers/HashlistHandler.php b/src/inc/handlers/HashlistHandler.php index d53bd33af..b79b69df3 100644 --- a/src/inc/handlers/HashlistHandler.php +++ b/src/inc/handlers/HashlistHandler.php @@ -16,10 +16,7 @@ use Hashtopolis\inc\Util; class HashlistHandler implements Handler { - /** - * @var Hashlist $hashlist - */ - private $hashlist; + private ?Hashlist $hashlist; public function __construct($hashlistId = null) { if ($hashlistId == null) { diff --git a/src/inc/handlers/SearchHandler.php b/src/inc/handlers/SearchHandler.php index 4f5a31d43..e12b98938 100644 --- a/src/inc/handlers/SearchHandler.php +++ b/src/inc/handlers/SearchHandler.php @@ -86,7 +86,7 @@ private function search() { $qF1 = new LikeFilterInsensitive(Hash::PLAINTEXT, "%" . $queryEntry . "%"); $qF2 = new ContainFilter(Hash::HASHLIST_ID, Util::arrayOfIds($userHashlists), Factory::getHashFactory()); $joined2 = Factory::getHashFactory()->filter([Factory::FILTER => [$qF1, $qF2], Factory::JOIN => $jF]); - /** @var $hashes Hash[] */ + /** @var Hash[] $hashes */ $hashes = $joined2[Factory::getHashFactory()->getModelName()]; for ($i = 0; $i < sizeof($hashes); $i++) { $joined[Factory::getHashFactory()->getModelName()][] = $joined2[Factory::getHashFactory()->getModelName()][$i]; @@ -94,7 +94,7 @@ private function search() { } $resultEntry = new DataSet(); - /** @var $hashes Hash[] */ + /** @var Hash[] $hashes */ $hashes = $joined[Factory::getHashFactory()->getModelName()]; if (sizeof($hashes) == 0) { $resultEntry->addValue("found", false); @@ -105,7 +105,7 @@ private function search() { $resultEntry->addValue("query", $queryEntry); $matches = array(); for ($i = 0; $i < sizeof($hashes); $i++) { - /** @var $hash Hash */ + /** @var Hash $hash */ $hash = $joined[Factory::getHashFactory()->getModelName()][$i]; $matches[] = $hash; if ($hashlists->getVal($hash->getHashlistId()) == false) { diff --git a/src/inc/notifications/HashtopolisNotification.php b/src/inc/notifications/HashtopolisNotification.php index d0a53c04f..99423bdef 100644 --- a/src/inc/notifications/HashtopolisNotification.php +++ b/src/inc/notifications/HashtopolisNotification.php @@ -16,8 +16,7 @@ abstract class HashtopolisNotification { public static $name; protected $receiver; - /** @var $notification NotificationSetting */ - protected $notification; + protected NotificationSetting $notification; private static $instances = []; diff --git a/src/inc/templating/Template.php b/src/inc/templating/Template.php index 4e7a6814f..3e40c7ce5 100644 --- a/src/inc/templating/Template.php +++ b/src/inc/templating/Template.php @@ -32,7 +32,7 @@ public function __construct($template, $direct = false) { if (ini_get("display_errors") == 1) { echo "ERROR: Template $template not found!\n"; } - return false; + return; } } $this->content = file_get_contents($path); @@ -42,7 +42,6 @@ public function __construct($template, $direct = false) { $this->resolveDependencies(); $parsed = $this->parse($this->content); $this->statements = $parsed[0]; - return true; } public function getContent() { @@ -324,9 +323,6 @@ private function resolveDependencies() { switch ($command[0]) { case "TEMPLATE": $tmp = new Template($command[1]); - if ($tmp === false) { - return false; - } $tmp->resolveDependencies(); $render = $tmp->getContent(); if ($render === false) { diff --git a/src/inc/user_api/UserAPIAccess.php b/src/inc/user_api/UserAPIAccess.php index f13e26fdf..50e25c12e 100644 --- a/src/inc/user_api/UserAPIAccess.php +++ b/src/inc/user_api/UserAPIAccess.php @@ -4,8 +4,8 @@ use Hashtopolis\inc\utils\AccessControlUtils; use Throwable; -use Hashtopolis\inc\apiv2\common\error\HttpConflict; -use Hashtopolis\inc\apiv2\common\error\HttpError; +use Hashtopolis\inc\apiv2\error\HttpConflict; +use Hashtopolis\inc\apiv2\error\HttpError; use Hashtopolis\inc\defines\UQuery; use Hashtopolis\inc\defines\UQueryAccess; use Hashtopolis\inc\defines\UQueryTask; diff --git a/src/inc/user_api/UserAPIBasic.php b/src/inc/user_api/UserAPIBasic.php index d544bc5a8..7b8af0c69 100644 --- a/src/inc/user_api/UserAPIBasic.php +++ b/src/inc/user_api/UserAPIBasic.php @@ -6,6 +6,7 @@ use Hashtopolis\dba\models\ApiKey; use Hashtopolis\dba\QueryFilter; use Hashtopolis\dba\Factory; +use Hashtopolis\inc\agent\PValues; use Hashtopolis\inc\defines\UQuery; use Hashtopolis\inc\defines\UQueryTask; use Hashtopolis\inc\defines\UResponse; diff --git a/src/inc/user_api/UserAPIHashlist.php b/src/inc/user_api/UserAPIHashlist.php index 22083e5a5..7a54be0a4 100644 --- a/src/inc/user_api/UserAPIHashlist.php +++ b/src/inc/user_api/UserAPIHashlist.php @@ -149,7 +149,7 @@ private function generateWordlist($QUERY) { throw new HTException("Invalid query!"); } $arr = HashlistUtils::createWordlists($QUERY[UQueryHashlist::HASHLIST_ID], $this->user); - /** @var $file File */ + /** @var File $file */ $file = $arr[2]; $response = [ UResponseHashlist::SECTION => $QUERY[UQueryHashlist::SECTION], diff --git a/src/inc/user_api/UserAPIPretask.php b/src/inc/user_api/UserAPIPretask.php index 4528fb43d..df17b4d95 100644 --- a/src/inc/user_api/UserAPIPretask.php +++ b/src/inc/user_api/UserAPIPretask.php @@ -150,7 +150,7 @@ private function setPretaskMaxAgents($QUERY) { if (!isset($QUERY[UQueryTask::PRETASK_ID]) || !isset($QUERY[UQueryTask::PRETASK_MAX_AGENTS])) { throw new HTException("Invalid query!"); } - PretaskUtils::setMaxAgents($QUERY[UQueryTask::PRETASK_ID], $QUERY[UQueryTask::PRETASK_MAX_AGENTS], $this->user); + PretaskUtils::setMaxAgents($QUERY[UQueryTask::PRETASK_ID], $QUERY[UQueryTask::PRETASK_MAX_AGENTS]); $this->sendSuccessResponse($QUERY); } diff --git a/src/inc/user_api/UserAPISupertask.php b/src/inc/user_api/UserAPISupertask.php index 9bbc9d952..53352a153 100644 --- a/src/inc/user_api/UserAPISupertask.php +++ b/src/inc/user_api/UserAPISupertask.php @@ -93,6 +93,7 @@ private function bulkSupertask($QUERY) { $QUERY[UQueryTask::SUPERTASK_NAME], $QUERY[UQueryTask::TASK_ATTACKCMD], $QUERY[UQueryTask::TASK_CPU_ONLY], + 0, $QUERY[UQueryTask::TASK_SMALL], $QUERY[UQueryTask::TASK_CRACKER_TYPE], $QUERY[UQueryTask::TASK_BENCHTYPE], @@ -125,6 +126,7 @@ private function importSupertask($QUERY) { SupertaskUtils::importSupertask( $QUERY[UQueryTask::SUPERTASK_NAME], $QUERY[UQueryTask::TASK_CPU_ONLY], + 0, $QUERY[UQueryTask::TASK_SMALL], $QUERY[UQueryTask::TASK_OPTIMIZED], $QUERY[UQueryTask::TASK_CRACKER_TYPE], diff --git a/src/inc/utils/AccessControlUtils.php b/src/inc/utils/AccessControlUtils.php index 0af5f35f3..386cd51bb 100644 --- a/src/inc/utils/AccessControlUtils.php +++ b/src/inc/utils/AccessControlUtils.php @@ -68,17 +68,17 @@ public static function updateGroupPermissions(int $groupId, array $perm): bool { $constant = $constant[0]; } if ($split[0] == $constant) { - $newArr[$constant] = ($split[1] == "1") ? true : false; + $newArr[$constant] = $split[1] == "1"; } } } - Factory::getRightGroupFactory()->set($group, RightGroup::PERMISSIONS, json_encode($newArr)); + $group = Factory::getRightGroupFactory()->set($group, RightGroup::PERMISSIONS, json_encode($newArr)); $acl = AccessControl::getInstance(null, $group->getId()); $arr = $newArr; $changes = false; foreach ($newArr as $constant => $set) { - if ($set == true) { + if ($set) { continue; } else if ($acl->givenByDependency($constant)) { diff --git a/src/inc/utils/AccessUtils.php b/src/inc/utils/AccessUtils.php index 81929d40a..ae6fb18a0 100644 --- a/src/inc/utils/AccessUtils.php +++ b/src/inc/utils/AccessUtils.php @@ -78,13 +78,13 @@ public static function userCanAccessAgent(Agent $agent, User $user): bool { $qF = new QueryFilter(AccessGroupAgent::AGENT_ID, $agent->getId(), "=", Factory::getAccessGroupAgentFactory()); $jF = new JoinFilter(Factory::getAccessGroupAgentFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupAgent::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroupsAgent AccessGroup[] */ + /** @var AccessGroup[] $accessGroupsAgent */ $accessGroupsAgent = $joined[Factory::getAccessGroupFactory()->getModelName()]; $qF = new QueryFilter(AccessGroupUser::USER_ID, $user->getId(), "=", Factory::getAccessGroupUserFactory()); $jF = new JoinFilter(Factory::getAccessGroupUserFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupUser::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroupsUser AccessGroup[] */ + /** @var AccessGroup[] $accessGroupsUser */ $accessGroupsUser = $joined[Factory::getAccessGroupFactory()->getModelName()]; return sizeof(AccessUtils::intersection($accessGroupsAgent, $accessGroupsUser)) > 0; @@ -145,7 +145,6 @@ public static function getAccessGroupsOfUser(User $user): array { $qF = new QueryFilter(AccessGroupUser::USER_ID, $user->getId(), "=", Factory::getAccessGroupUserFactory()); $jF = new JoinFilter(Factory::getAccessGroupUserFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupUser::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroupsUser AccessGroup[] */ return $joined[Factory::getAccessGroupFactory()->getModelName()]; } @@ -157,7 +156,6 @@ public static function getAccessGroupsOfAgent(Agent $agent): array { $qF = new QueryFilter(AccessGroupAgent::AGENT_ID, $agent->getId(), "=", Factory::getAccessGroupAgentFactory()); $jF = new JoinFilter(Factory::getAccessGroupAgentFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupAgent::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroupsUser AccessGroup[] */ return $joined[Factory::getAccessGroupFactory()->getModelName()]; } diff --git a/src/inc/utils/AccountUtils.php b/src/inc/utils/AccountUtils.php index 6ddc8ac42..77158f834 100644 --- a/src/inc/utils/AccountUtils.php +++ b/src/inc/utils/AccountUtils.php @@ -109,7 +109,7 @@ public static function setEmail(string $email, User $user): void { throw new HTException("Invalid email address!"); } - Factory::getUserFactory()->set($user, User::EMAIL, $email); + $user = Factory::getUserFactory()->set($user, User::EMAIL, $email); Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "User changed email!"); } @@ -151,7 +151,7 @@ public static function changePassword(string $oldPassword, string $newPassword, $newSalt = Util::randomString(20); $newHash = Encryption::passwordHash($newPassword, $newSalt); - Factory::getUserFactory()->mset($user, [User::PASSWORD_HASH => $newHash, User::PASSWORD_SALT => $newSalt, USer::IS_COMPUTED_PASSWORD => 0]); + $user = Factory::getUserFactory()->mset($user, [User::PASSWORD_HASH => $newHash, User::PASSWORD_SALT => $newSalt, USer::IS_COMPUTED_PASSWORD => 0]); Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "User changed password!"); } diff --git a/src/inc/utils/AgentBinaryUtils.php b/src/inc/utils/AgentBinaryUtils.php index 1c9631e56..d0f06c1fb 100644 --- a/src/inc/utils/AgentBinaryUtils.php +++ b/src/inc/utils/AgentBinaryUtils.php @@ -70,9 +70,9 @@ public static function editBinary($binaryId, $type, $os, $filename, $version, $u } if ($updateTrack != $agentBinary->getUpdateTrack()) { - Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::UPDATE_AVAILABLE, ''); + $agentBinary = Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::UPDATE_AVAILABLE, ''); } - Factory::getAgentBinaryFactory()->mset($agentBinary, [ + $agentBinary = Factory::getAgentBinaryFactory()->mset($agentBinary, [ AgentBinary::BINARY_TYPE => $type, AgentBinary::OPERATING_SYSTEMS => $os, AgentBinary::FILENAME => $filename, @@ -87,14 +87,14 @@ public static function editBinary($binaryId, $type, $os, $filename, $version, $u public static function editUpdateTracker($binaryId, $updateTracker, $user) { $binary = AgentBinaryUtils::getBinary($binaryId); if ($updateTracker != $binary->getUpdateTrack()) { - Factory::getAgentBinaryFactory()->mset($binary, [ + $binary = Factory::getAgentBinaryFactory()->mset($binary, [ AgentBinary::UPDATE_AVAILABLE => '', AgentBinary::UPDATE_TRACK => $updateTracker ] ); } else { - Factory::getAgentBinaryFactory()->set($binary, AgentBinary::UPDATE_TRACK, $updateTracker); + $binary = Factory::getAgentBinaryFactory()->set($binary, AgentBinary::UPDATE_TRACK, $updateTracker); } Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "Binary " . $binary->getFilename() . " was updated!"); } @@ -104,7 +104,7 @@ public static function editName($binaryId, $filename, $user) { throw new HTException("Provided filename does not exist!"); } $agentBinary = AgentBinaryUtils::getBinary($binaryId); - Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::FILENAME, $filename); + $agentBinary = Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::FILENAME, $filename); Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "Binary " . $agentBinary->getFilename() . " was updated!"); } @@ -117,7 +117,7 @@ public static function editType($binaryId, $type, $user) { if ($result != null) { throw new HTException("You cannot have two binaries with the same type!"); } - Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::BINARY_TYPE, $type); + $agentBinary = Factory::getAgentBinaryFactory()->set($agentBinary, AgentBinary::BINARY_TYPE, $type); Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "Binary " . $agentBinary->getFilename() . " was updated!"); } @@ -179,7 +179,7 @@ public static function executeUpgrade($binaryId) { } // update version number of agent and reset flag - Factory::getAgentBinaryFactory()->mset($agentBinary, [AgentBinary::VERSION => $agentBinary->getUpdateAvailable(), AgentBinary::UPDATE_AVAILABLE => '']); + $agentBinary = Factory::getAgentBinaryFactory()->mset($agentBinary, [AgentBinary::VERSION => $agentBinary->getUpdateAvailable(), AgentBinary::UPDATE_AVAILABLE => '']); } /** diff --git a/src/inc/utils/AgentUtils.php b/src/inc/utils/AgentUtils.php index d407ae12b..d4c2266fe 100644 --- a/src/inc/utils/AgentUtils.php +++ b/src/inc/utils/AgentUtils.php @@ -390,7 +390,7 @@ public static function deleteDependencies($agent) { public static function assign(int $agentId, int $taskId, User $user): ?Assignment { $agent = AgentUtils::getAgent($agentId, $user); - if ($taskId == 0 || empty($taskId)) { // unassign + if ($taskId == 0) { // unassign $qF = new QueryFilter(Agent::AGENT_ID, $agent->getId(), "="); Factory::getAssignmentFactory()->massDeletion([Factory::FILTER => $qF]); if (isset($_GET['task'])) { @@ -431,10 +431,7 @@ public static function assign(int $agentId, int $taskId, User $user): ?Assignmen Factory::getAssignmentFactory()->delete($assignments[$i]); } $assignment = $assignments[0]; - Factory::getAssignmentFactory()->mset($assignment, [Assignment::TASK_ID => $task->getId(), Assignment::BENCHMARK => $benchmark]); - $assignment->setTaskId($task->getId()); - $assignment->setAgentId($agent->getId()); - $assignment->setBenchmark($benchmark); + $assignment = Factory::getAssignmentFactory()->mset($assignment, [Assignment::TASK_ID => $task->getId(), Assignment::BENCHMARK => $benchmark]); } else { $assignment = new Assignment(null, $task->getId(), $agent->getId(), $benchmark); @@ -500,7 +497,7 @@ public static function changeOwner($agentId, $ownerId, $user) { $agent = AgentUtils::getAgent($agentId, $user); if ($ownerId == 0) { $username = "NONE"; - Factory::getAgentFactory()->set($agent, Agent::USER_ID, null); + $agent = Factory::getAgentFactory()->set($agent, Agent::USER_ID, null); } else { if (is_numeric($ownerId)) { @@ -514,7 +511,7 @@ public static function changeOwner($agentId, $ownerId, $user) { throw new HTException("Invalid user selected!"); } $username = $user->getUsername(); - Factory::getAgentFactory()->set($agent, Agent::USER_ID, $owner->getId()); + $agent = Factory::getAgentFactory()->set($agent, Agent::USER_ID, $owner->getId()); } Util::createLogEntry(DLogEntryIssuer::USER, $user->getId(), DLogEntry::INFO, "Owner for agent " . $agent->getAgentName() . " was changed to " . $username); } diff --git a/src/inc/utils/ApiUtils.php b/src/inc/utils/ApiUtils.php index 10f69e04f..89dbe67f4 100644 --- a/src/inc/utils/ApiUtils.php +++ b/src/inc/utils/ApiUtils.php @@ -67,11 +67,11 @@ public static function editKey($keyId, $userId, $groupId, $startValid, $endValid else if ($group == null) { throw new HTException("Invalid API group selected!"); } - else if (MASK_API_KEYS && ($key->getUserId() != $userId)) { + else if (($key->getUserId() != $userId)) { throw new HTException("Can't change key owner!"); } - Factory::getApiKeyFactory()->mset($key, [ + $key = Factory::getApiKeyFactory()->mset($key, [ ApiKey::USER_ID => $user->getId(), ApiKey::API_GROUP_ID => $group->getId(), ApiKey::START_VALID => strtotime($startValid), diff --git a/src/inc/utils/ChunkUtils.php b/src/inc/utils/ChunkUtils.php index f1eb893a6..4530014d9 100644 --- a/src/inc/utils/ChunkUtils.php +++ b/src/inc/utils/ChunkUtils.php @@ -37,7 +37,7 @@ public static function handleExistingChunk($chunk, $task, $assignment) { if (($chunk->getCheckpoint() == $chunk->getSkip() || SConfig::getInstance()->getVal(DConfig::DISABLE_TRIMMING)) && $agentChunkSizeMax >= $chunk->getLength()) { //chunk has not started yet DServerLog::log(DServerLog::TRACE, "Chunk did not start yet and is small enough to give it to agent", [$task, $chunk, $assignment]); - Factory::getChunkFactory()->mset($chunk, [ + return Factory::getChunkFactory()->mset($chunk, [ Chunk::PROGRESS => $initialProgress, Chunk::DISPATCH_TIME => time(), Chunk::SOLVE_TIME => 0, @@ -46,14 +46,13 @@ public static function handleExistingChunk($chunk, $task, $assignment) { Chunk::SPEED => 0 ] ); - return $chunk; } else if ($chunk->getCheckpoint() == $chunk->getSkip() || SConfig::getInstance()->getVal(DConfig::DISABLE_TRIMMING)) { //split chunk into two parts DServerLog::log(DServerLog::TRACE, "Chunk has not started, but needs to be split", [$task, $chunk, $assignment]); $originalLength = $chunk->getLength(); $firstPart = $chunk; - Factory::getChunkFactory()->mset($firstPart, [ + $firstPart = Factory::getChunkFactory()->mset($firstPart, [ Chunk::LENGTH => $agentChunkSize, Chunk::AGENT_ID => $assignment->getAgentId(), Chunk::DISPATCH_TIME => time(), @@ -72,7 +71,7 @@ public static function handleExistingChunk($chunk, $task, $assignment) { DServerLog::log(DServerLog::TRACE, "Chunk was started and reached a checkpoint", [$task, $chunk, $assignment]); if ($chunk->getLength() + $chunk->getSkip() - $chunk->getCheckpoint() == 0) { // special case when remaining chunk length gets 0 - Factory::getChunkFactory()->mset($chunk, [ + $chunk = Factory::getChunkFactory()->mset($chunk, [ Chunk::PROGRESS => 10000, Chunk::STATE => DHashcatStatus::ABORTED_CHECKPOINT, Chunk::SPEED => 0 @@ -96,7 +95,7 @@ public static function handleExistingChunk($chunk, $task, $assignment) { 0 ); $newChunk = Factory::getChunkFactory()->save($newChunk); - Factory::getChunkFactory()->mset($chunk, [ + $chunk = Factory::getChunkFactory()->mset($chunk, [ Chunk::LENGTH => $chunk->getCheckpoint() - $chunk->getSkip(), Chunk::PROGRESS => 10000, Chunk::STATE => DHashcatStatus::ABORTED_CHECKPOINT, @@ -119,7 +118,7 @@ public static function createNewChunk($task, $assignment) { // if we have set a skip keyspace we set the the current progress to the skip which was set initially if ($task->getSkipKeyspace() > $task->getKeyspaceProgress()) { - Factory::getTaskFactory()->set($task, Task::KEYSPACE_PROGRESS, $task->getSkipKeyspace()); + $task = Factory::getTaskFactory()->set($task, Task::KEYSPACE_PROGRESS, $task->getSkipKeyspace()); } $remaining = $task->getKeyspace() - $task->getKeyspaceProgress(); @@ -133,6 +132,7 @@ public static function createNewChunk($task, $assignment) { $length = $remaining; } Factory::getTaskFactory()->inc($task, Task::KEYSPACE_PROGRESS, $length); + assert($task instanceof Task); $initialProgress = ($task->getUsePreprocessor() || $task->getForcePipe()) ? null : 0; $chunk = new Chunk(null, $task->getId(), $start, $length, $assignment->getAgentId(), time(), 0, $start, $initialProgress, DHashcatStatus::INIT, 0, 0); $chunk = Factory::getChunkFactory()->save($chunk); @@ -170,7 +170,7 @@ public static function calculateChunkSize($keyspace, $benchmark, $chunkTime, $to else if ($chunkSize > 10000) { // just protection to avoid millions or whatever chunk number throw new HTException("Too large number of static chunks, most likely because of misconfiguration!"); } - return ceil($keyspace / $chunkSize); + return intval(ceil($keyspace / $chunkSize)); default: throw new HTException("Unknown static chunking method!"); } @@ -183,7 +183,7 @@ public static function calculateChunkSize($keyspace, $benchmark, $chunkTime, $to return $keyspace; } - $size = floor($keyspace * $benchmark * $chunkTime / 100); + $size = floor($keyspace * floatval($benchmark) * $chunkTime / 100); } else { // new benchmarking method @@ -194,8 +194,8 @@ public static function calculateChunkSize($keyspace, $benchmark, $chunkTime, $to } // NEW VARIANT - $factor = $chunkTime / $benchmark[1] * 1000; - $size = floor($factor * $benchmark[0]); + $factor = $chunkTime / floatval($benchmark[1]) * 1000; + $size = floor($factor * floatval($benchmark[0])); } $chunkSize = $size * $tolerance; @@ -208,6 +208,6 @@ public static function calculateChunkSize($keyspace, $benchmark, $chunkTime, $to Util::createLogEntry("API", $QUERY[PQuery::TOKEN], DLogEntry::WARN, "Calculated chunk size was 0 on benchmark $benchmark!"); } - return $chunkSize; + return intval($chunkSize); } } \ No newline at end of file diff --git a/src/inc/utils/ConfigUtils.php b/src/inc/utils/ConfigUtils.php index 002dc55da..6f436e572 100644 --- a/src/inc/utils/ConfigUtils.php +++ b/src/inc/utils/ConfigUtils.php @@ -181,7 +181,7 @@ public static function rebuildCache(): array { $jF = new JoinFilter(Factory::getTaskFactory(), Task::TASK_ID, Chunk::TASK_ID, Factory::getChunkFactory()); $qF = new QueryFilter(Task::TASK_WRAPPER_ID, $taskWrapper->getId(), "=", Factory::getTaskFactory()); $joined = Factory::getChunkFactory()->filter([Factory::JOIN => $jF, Factory::FILTER => $qF]); - /** @var $chunks Chunk[] */ + /** @var Chunk[] $chunks */ $chunks = $joined[Factory::getChunkFactory()->getModelName()]; $total_cracked = 0; @@ -193,7 +193,7 @@ public static function rebuildCache(): array { $total_cracked += $count; if ($count != $chunk->getCracked()) { $correctedChunks++; - Factory::getChunkFactory()->set($chunk, Chunk::CRACKED, $count); + $chunk = Factory::getChunkFactory()->set($chunk, Chunk::CRACKED, $count); } } if ($total_cracked != $taskWrapper->getCracked()) { @@ -218,7 +218,7 @@ public static function rebuildCache(): array { if ($count != $hashlist->getCracked()) { $correctedHashlists++; $counted = true; - Factory::getHashlistFactory()->set($hashlist, Hashlist::CRACKED, $count); + $hashlist = Factory::getHashlistFactory()->set($hashlist, Hashlist::CRACKED, $count); } $count = $hashFactory->countFilter([Factory::FILTER => $qF1]); if ($count != $hashlist->getHashCount()) { diff --git a/src/inc/utils/CrackerBinaryUtils.php b/src/inc/utils/CrackerBinaryUtils.php index 721ffb80f..b6306ec0f 100644 --- a/src/inc/utils/CrackerBinaryUtils.php +++ b/src/inc/utils/CrackerBinaryUtils.php @@ -18,7 +18,7 @@ class CrackerBinaryUtils { public static function getNewestVersion($crackerBinaryTypeId) { $qF = new QueryFilter(CrackerBinary::CRACKER_BINARY_TYPE_ID, $crackerBinaryTypeId, "="); $binaries = Factory::getCrackerBinaryFactory()->filter([Factory::FILTER => $qF]); - /** @var $newest CrackerBinary */ + /** @var ?CrackerBinary $newest */ $newest = null; foreach ($binaries as $binary) { if ($newest == null || Comparator::greaterThan($binary->getVersion(), $newest->getVersion())) { diff --git a/src/inc/utils/CrackerUtils.php b/src/inc/utils/CrackerUtils.php index 2ef945112..0b1fa3b46 100644 --- a/src/inc/utils/CrackerUtils.php +++ b/src/inc/utils/CrackerUtils.php @@ -125,7 +125,7 @@ public static function updateBinary($version, $name, $url, $binaryId) { if (strlen($version) == 0 || strlen($name) == 0 || strlen($url) == 0) { throw new HTException("Please provide all information!"); } - Factory::getCrackerBinaryFactory()->mset($binary, [ + $binary = Factory::getCrackerBinaryFactory()->mset($binary, [ CrackerBinary::BINARY_NAME => htmlentities($name, ENT_QUOTES, "UTF-8"), CrackerBinary::DOWNLOAD_URL => $url, CrackerBinary::VERSION => $version diff --git a/src/inc/utils/FileUtils.php b/src/inc/utils/FileUtils.php index 3d307e0e2..ddd7224a7 100644 --- a/src/inc/utils/FileUtils.php +++ b/src/inc/utils/FileUtils.php @@ -285,7 +285,7 @@ public static function saveChanges($fileId, $filename, $accessGroupId, $user) { if ($accessGroup == null) { throw new HTException("Invalid access group Id!"); } - Factory::getFileFactory()->set($file, File::ACCESS_GROUP_ID, $accessGroup->getId()); + $file = Factory::getFileFactory()->set($file, File::ACCESS_GROUP_ID, $accessGroup->getId()); } if ($file->getFilename() == $newName) { diff --git a/src/inc/utils/HashlistUtils.php b/src/inc/utils/HashlistUtils.php index 2a497d081..601d1d916 100644 --- a/src/inc/utils/HashlistUtils.php +++ b/src/inc/utils/HashlistUtils.php @@ -60,7 +60,7 @@ public static function editNotes($hashlistId, $notes, $user) { /** * @param string $hash * @param User $user - * @return Hash + * @return ?Hash * @throws HTException */ public static function getHash($hash, $user) { @@ -258,10 +258,10 @@ public static function setSecret($hashlistId, $isSecret, $user) { $jF2 = new JoinFilter(Factory::getTaskWrapperFactory(), Task::TASK_WRAPPER_ID, TaskWrapper::TASK_WRAPPER_ID, Factory::getTaskWrapperFactory()); $jF3 = new JoinFilter(Factory::getHashlistFactory(), Hashlist::HASHLIST_ID, TaskWrapper::HASHLIST_ID, Factory::getTaskWrapperFactory()); $joined = Factory::getAssignmentFactory()->filter([Factory::JOIN => [$jF1, $jF2, $jF3]]); - /** @var $assignments Assignment[] */ + /** @var Assignment[] $assignments */ $assignments = $joined[Factory::getAssignmentFactory()->getModelName()]; for ($x = 0; $x < sizeof($assignments); $x++) { - /** @var $hashlist Hashlist */ + /** @var Hashlist $hashlist */ $hashlist = $joined[Factory::getHashlistFactory()->getModelName()][$x]; if ($hashlist->getId() == $hashlist->getId()) { Factory::getAssignmentFactory()->delete($joined[Factory::getAssignmentFactory()->getModelName()][$x]); @@ -272,7 +272,7 @@ public static function setSecret($hashlistId, $isSecret, $user) { /** * @param int $hashlistId - * @param int $isSecret + * @param $isArchived * @param User $user * @throws HTException */ @@ -463,7 +463,7 @@ public static function processZap($hashlistId, $separator, $source, $post, $file $crackedIn[$hashEntry->getHashlistId()]++; } - $hashFactory->mset($hashEntry, [Hash::PLAINTEXT => $plain, Hash::IS_CRACKED => 1, Hash::TIME_CRACKED => time()]); + $hashEntry = $hashFactory->mset($hashEntry, [Hash::PLAINTEXT => $plain, Hash::IS_CRACKED => 1, Hash::TIME_CRACKED => time()]); if ($hashlist->getFormat() == DHashlistFormat::PLAIN) { $zaps[] = new Zap(null, $hashEntry->getHash(), time(), null, $hashlist->getId()); @@ -514,7 +514,7 @@ public static function processZap($hashlistId, $separator, $source, $post, $file $crackedIn[$hashEntry->getHashlistId()]++; } - $hashFactory->mset($hashEntry, [Hash::PLAINTEXT => $plain, Hash::IS_CRACKED => 1, Hash::TIME_CRACKED => time()]); + $hashEntry = $hashFactory->mset($hashEntry, [Hash::PLAINTEXT => $plain, Hash::IS_CRACKED => 1, Hash::TIME_CRACKED => time()]); if ($hashlist->getFormat() == DHashlistFormat::PLAIN) { $zaps[] = new Zap(null, $hashEntry->getHash(), time(), null, $hashlist->getId()); @@ -588,13 +588,13 @@ public static function delete($hashlistId, $user) { $qF = new QueryFilter(HashlistHashlist::HASHLIST_ID, $hashlist->getId(), "=", Factory::getHashlistHashlistFactory()); $jF = new JoinFilter(Factory::getHashlistFactory(), HashlistHashlist::PARENT_HASHLIST_ID, Hashlist::HASHLIST_ID, Factory::getHashlistHashlistFactory()); $joined = Factory::getHashlistHashlistFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $superHashlists Hashlist[] */ $superHashlists = $joined[Factory::getHashlistFactory()->getModelName()]; $toDelete = []; foreach ($superHashlists as $superHashlist) { Factory::getHashlistFactory()->dec($superHashlist, Hashlist::HASH_COUNT, $hashlist->getHashCount()); Factory::getHashlistFactory()->dec($superHashlist, Hashlist::CRACKED, $hashlist->getCracked()); + /** @var Hashlist $superHashlist */ if ($superHashlist->getHashCount() <= 0) { // this superhashlist has no hashlist which belongs to it anymore -> delete it $toDelete[] = $superHashlist; @@ -931,7 +931,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted, } fclose($file); unlink($tmpfile); - Factory::getHashlistFactory()->mset($hashlist, [Hashlist::HASH_COUNT => $added, Hashlist::CRACKED => $preFound]); + $hashlist = Factory::getHashlistFactory()->mset($hashlist, [Hashlist::HASH_COUNT => $added, Hashlist::CRACKED => $preFound]); Util::createLogEntry("User", $user->getId(), DLogEntry::INFO, "New Hashlist created: " . $hashlist->getHashlistName()); NotificationHandler::checkNotifications(DNotificationType::NEW_HASHLIST, new DataSet(array(DPayloadKeys::HASHLIST => $hashlist))); @@ -1002,7 +1002,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted, fclose($file); unlink($tmpfile); - Factory::getHashlistFactory()->set($hashlist, Hashlist::HASH_COUNT, $added); + $hashlist = Factory::getHashlistFactory()->set($hashlist, Hashlist::HASH_COUNT, $added); Util::createLogEntry("User", $user->getId(), DLogEntry::INFO, "New Hashlist created: " . $hashlist->getHashlistName()); NotificationHandler::checkNotifications(DNotificationType::NEW_HASHLIST, new DataSet(array(DPayloadKeys::HASHLIST => $hashlist))); @@ -1015,7 +1015,7 @@ public static function createHashlist($name, $isSalted, $isSecret, $isHexSalted, } fclose($file); unlink($tmpfile); - Factory::getHashlistFactory()->set($hashlist, Hashlist::HASH_COUNT, 1); + $hashlist = Factory::getHashlistFactory()->set($hashlist, Hashlist::HASH_COUNT, 1); Util::createLogEntry("User", $user->getId(), DLogEntry::INFO, "New Hashlist created: " . $hashlist->getHashlistName()); NotificationHandler::checkNotifications(DNotificationType::NEW_HASHLIST, new DataSet(array(DPayloadKeys::HASHLIST => $hashlist))); @@ -1197,7 +1197,7 @@ public static function changeAccessGroup($hashlistId, $accessGroupId, $user) { } $qF = new QueryFilter(Hashlist::HASHLIST_ID, $hashlist->getId(), "="); - $uS = new UpdateSet(Hashlist::ACCESS_GROUP_ID, $accessGroup->getId(), "="); + $uS = new UpdateSet(Hashlist::ACCESS_GROUP_ID, $accessGroup->getId()); Factory::getHashlistFactory()->massUpdate([Factory::FILTER => $qF, Factory::UPDATE => $uS]); $qF = new QueryFilter(TaskWrapper::HASHLIST_ID, $hashlist->getId(), "="); diff --git a/src/inc/utils/LockUtils.php b/src/inc/utils/LockUtils.php index 3da4fb669..06e19cac4 100644 --- a/src/inc/utils/LockUtils.php +++ b/src/inc/utils/LockUtils.php @@ -5,7 +5,7 @@ use Exception; class LockUtils { - /** @var $locks Lock[] */ + /** @var Lock[] $locks */ private static $locks = array(); /** diff --git a/src/inc/utils/PreprocessorUtils.php b/src/inc/utils/PreprocessorUtils.php index 3dab2b497..18759a693 100644 --- a/src/inc/utils/PreprocessorUtils.php +++ b/src/inc/utils/PreprocessorUtils.php @@ -138,7 +138,7 @@ public static function editBinaryName($preprocessorId, $binaryName) { public static function editKeyspaceCommand($preprocessorId, $keyspaceCommand) { if (strlen($keyspaceCommand) == 0) { - $keyspaceCommand == null; + $keyspaceCommand = null; } else if (Util::containsBlacklistedChars($keyspaceCommand)) { throw new HTException("The keyspace command must contain no blacklisted characters!"); @@ -156,7 +156,7 @@ public static function editKeyspaceCommand($preprocessorId, $keyspaceCommand) { public static function editSkipCommand($preprocessorId, $skipCommand) { if (strlen($skipCommand) == 0) { - $skipCommand == null; + $skipCommand = null; } else if (Util::containsBlacklistedChars($skipCommand)) { throw new HTException("The skip command must contain no blacklisted characters!"); @@ -174,7 +174,7 @@ public static function editSkipCommand($preprocessorId, $skipCommand) { public static function editLimitCommand($preprocessorId, $limitCommand) { if (strlen($limitCommand) == 0) { - $limitCommand == null; + $limitCommand = null; } else if (Util::containsBlacklistedChars($limitCommand)) { throw new HTException("The limit command must contain no blacklisted characters!"); diff --git a/src/inc/utils/SupertaskUtils.php b/src/inc/utils/SupertaskUtils.php index baad0c265..e77f7841a 100644 --- a/src/inc/utils/SupertaskUtils.php +++ b/src/inc/utils/SupertaskUtils.php @@ -170,7 +170,7 @@ public static function deleteSupertask($supertaskId) { $joinedTasks = Factory::getPretaskFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); Factory::getSupertaskPretaskFactory()->massDeletion([Factory::FILTER => $qF]); - /** @var $pretasks Pretask[] */ + /** @var Pretask[] $pretasks */ $pretasks = $joinedTasks[Factory::getPretaskFactory()->getModelName()]; foreach ($pretasks as $pretask) { @@ -268,7 +268,7 @@ public static function runSupertask($supertaskId, $hashlistId, $crackerId) { $qF = new QueryFilter(SupertaskPretask::SUPERTASK_ID, $supertask->getId(), "=", Factory::getSupertaskPretaskFactory()); $jF = new JoinFilter(Factory::getSupertaskPretaskFactory(), Pretask::PRETASK_ID, SupertaskPretask::PRETASK_ID); $joined = Factory::getPretaskFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $pretasks Pretask[] */ + /** @var Pretask[] $pretasks */ $pretasks = $joined[Factory::getPretaskFactory()->getModelName()]; Factory::getAgentFactory()->getDB()->beginTransaction(); diff --git a/src/inc/utils/TaskUtils.php b/src/inc/utils/TaskUtils.php index 9bb3a9643..5fad03e14 100644 --- a/src/inc/utils/TaskUtils.php +++ b/src/inc/utils/TaskUtils.php @@ -497,7 +497,7 @@ public static function changeChunkTime($taskId, $chunkTime, $user) { $qF = new QueryFilter(Assignment::TASK_ID, $task->getId(), "=", Factory::getTaskFactory()); $jF = new JoinFilter(Factory::getTaskFactory(), Task::TASK_ID, Assignment::TASK_ID); $join = Factory::getAssignmentFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $assignments Assignment[] */ + /** @var Assignment[] $assignments */ $assignments = $join[Factory::getAssignmentFactory()->getModelName()]; foreach ($assignments as $assignment) { if ($task->getUseNewBench() == 0) { @@ -743,7 +743,7 @@ public static function updateStatusTimer($taskId, $statusTimer, $user) { } $statusTimer = intval($statusTimer); - if ($statusTimer <= 0 || !is_numeric($statusTimer)) { + if ($statusTimer <= 0) { throw new HTException("Invalid status interval!"); } if ($statusTimer > $task->getChunkTime()) { @@ -757,7 +757,7 @@ public static function updateStatusTimer($taskId, $statusTimer, $user) { * @param int $taskId * @param int $priority * @param User $user - * @param bool $top + * @param bool $topPriority * @throws HTException */ public static function updatePriority($taskId, $priority, $user, $topPriority = false) { @@ -894,9 +894,9 @@ public static function createTask($hashlistId, $name, $attackCmd, $chunkTime, $s if ($priority < 0) { $priority = 0; } - if ($usePreprocessor && $benchtype == 'runtime') { - // enforce speed benchmark type when using PRINCE - $benchtype = 'speed'; + if ($usePreprocessor && $benchtype == 0) { + // enforce speed benchmark type when using preprocessor + $benchtype = 1; } Factory::getAgentFactory()->getDB()->beginTransaction(); @@ -948,7 +948,7 @@ public static function createTask($hashlistId, $name, $attackCmd, $chunkTime, $s /** * @param $agent Agent * @param bool $all set true to get all matching tasks for this agent - * @return Task|Task[] + * @return Task|Task[]|null */ public static function getBestTask($agent, $all = false) { $allTasks = array(); @@ -957,7 +957,7 @@ public static function getBestTask($agent, $all = false) { $qF = new QueryFilter(AccessGroupAgent::AGENT_ID, $agent->getId(), "=", Factory::getAccessGroupAgentFactory()); $jF = new JoinFilter(Factory::getAccessGroupAgentFactory(), AccessGroup::ACCESS_GROUP_ID, AccessGroupAgent::ACCESS_GROUP_ID); $joined = Factory::getAccessGroupFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $accessGroupAgent AccessGroup[] */ + /** @var AccessGroup[] $accessGroupAgent */ $accessGroupAgent = $joined[Factory::getAccessGroupFactory()->getModelName()]; $accessGroups = Util::arrayOfIds($accessGroupAgent); @@ -1095,7 +1095,7 @@ public static function deleteTask($task) { $files = $joined[Factory::getFileFactory()->getModelName()]; $toDelete = []; foreach ($files as $file) { - /** @var $file File */ + /** @var File $file */ if ($file->getFileType() == DFileType::TEMPORARY) { unlink(Factory::getStoredValueFactory()->get(DDirectories::FILES)->getVal() . "/" . $file->getFilename()); $toDelete[] = $file; @@ -1147,7 +1147,7 @@ public static function getChunk($chunkId, $user) { * * @param $task Task * @param $agent Agent - * @return Task null if the task is completed or fully dispatched + * @return Task|null null if the task is completed or fully dispatched */ public static function checkTask($task, $agent = null) { if ($task->getIsArchived() == 1) { @@ -1190,7 +1190,7 @@ public static function checkTask($task, $agent = null) { } if ($completed >= $task->getKeyspace()) { // task is completed, set priority to 0 - Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); + $task = Factory::getTaskFactory()->set($task, Task::PRIORITY, 0); $taskWrapper = Factory::getTaskWrapperFactory()->get($task->getTaskWrapperId()); if ($taskWrapper->getTaskType() != DTaskTypes::SUPERTASK) { Factory::getTaskWrapperFactory()->set($taskWrapper, TaskWrapper::PRIORITY, 0); @@ -1267,7 +1267,6 @@ public static function getFilesOfTask($task) { $qF = new QueryFilter(FileTask::TASK_ID, $task->getId(), "=", Factory::getFileTaskFactory()); $jF = new JoinFilter(Factory::getFileTaskFactory(), File::FILE_ID, FileTask::FILE_ID); $joined = Factory::getFileFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $files File[] */ return $joined[Factory::getFileFactory()->getModelName()]; } @@ -1279,7 +1278,6 @@ public static function getFilesOfPretask($pretask) { $qF = new QueryFilter(FilePretask::PRETASK_ID, $pretask->getId(), "=", Factory::getFilePretaskFactory()); $jF = new JoinFilter(Factory::getFilePretaskFactory(), File::FILE_ID, FilePretask::FILE_ID); $joined = Factory::getFileFactory()->filter([Factory::FILTER => $qF, Factory::JOIN => $jF]); - /** @var $files File[] */ return $joined[Factory::getFileFactory()->getModelName()]; } diff --git a/src/inc/utils/TaskWrapperUtils.php b/src/inc/utils/TaskWrapperUtils.php index fb7095298..5f7490eca 100644 --- a/src/inc/utils/TaskWrapperUtils.php +++ b/src/inc/utils/TaskWrapperUtils.php @@ -47,7 +47,7 @@ public static function updatePriority($taskWrapperId, $priority, $user) { TaskUtils::setSupertaskPriority($taskWrapperId, $priority, $user); break; default: - assert(False, "Internal Error: taskType not recognized"); + throw new HttpError("Internal Error: taskType not recognized"); } } }