diff --git a/app/modules/api/Controllers/AccountController.php b/app/modules/api/Controllers/AccountController.php index 6b09fd8c..f7fa6c44 100644 --- a/app/modules/api/Controllers/AccountController.php +++ b/app/modules/api/Controllers/AccountController.php @@ -24,10 +24,14 @@ namespace SP\Modules\Api\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Crypt\Crypt; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\Modules\Api\Controllers\Help\AccountHelp; use SP\Mvc\Model\QueryCondition; use SP\Services\Account\AccountPresetService; @@ -74,7 +78,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($accountDetails, $id)); - } catch (\Exception $e) { + } catch (Exception $e) { $this->returnResponseException($e); processException($e); @@ -106,7 +110,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess(["password" => $password], $id)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -142,7 +146,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($accountDetails, $accountRequest->id, __('Password updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -192,7 +196,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($accountDetails, $accountId, __('Account created'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -243,7 +247,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($accountDetails, $accountRequest->id, __('Account updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -288,7 +292,7 @@ final class AccountController extends ControllerBase $this->returnResponse( ApiResponse::makeSuccess( $this->accountService->getByFilter($accountSearchFilter)->getDataAsArray())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -318,7 +322,7 @@ final class AccountController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($accountDetails, $id, __('Account removed'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -326,9 +330,9 @@ final class AccountController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Controllers/CategoryController.php b/app/modules/api/Controllers/CategoryController.php index 38756e6d..795f977d 100644 --- a/app/modules/api/Controllers/CategoryController.php +++ b/app/modules/api/Controllers/CategoryController.php @@ -24,9 +24,13 @@ namespace SP\Modules\Api\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; use SP\Modules\Api\Controllers\Help\CategoryHelp; @@ -65,7 +69,7 @@ final class CategoryController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($categoryData, $id)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -94,7 +98,7 @@ final class CategoryController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($categoryData, $id, __('Category added'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -124,7 +128,7 @@ final class CategoryController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($categoryData, $categoryData->getId(), __('Category updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -153,7 +157,7 @@ final class CategoryController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($categoryData, $id, __('Category deleted'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -175,7 +179,7 @@ final class CategoryController extends ControllerBase $this->eventDispatcher->notifyEvent('search.category', new Event($this)); $this->returnResponse(ApiResponse::makeSuccess($this->categoryService->search($itemSearchData)->getDataAsArray())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -185,9 +189,9 @@ final class CategoryController extends ControllerBase /** * initialize * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Controllers/ClientController.php b/app/modules/api/Controllers/ClientController.php index 8f8cdacf..d888787a 100644 --- a/app/modules/api/Controllers/ClientController.php +++ b/app/modules/api/Controllers/ClientController.php @@ -24,9 +24,13 @@ namespace SP\Modules\Api\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\DataModel\ClientData; use SP\DataModel\ItemSearchData; use SP\Modules\Api\Controllers\Help\ClientHelp; @@ -66,7 +70,7 @@ final class ClientController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($clientData, $id)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -96,7 +100,7 @@ final class ClientController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($clientData, $id, __('Client added'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -127,7 +131,7 @@ final class ClientController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($clientData, $clientData->getId(), __('Client updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -156,7 +160,7 @@ final class ClientController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($clientData, $id, __('Client deleted'))); - } catch (\Exception $e) { + } catch (Exception $e) { $this->returnResponseException($e); processException($e); @@ -178,7 +182,7 @@ final class ClientController extends ControllerBase $this->eventDispatcher->notifyEvent('search.client', new Event($this)); $this->returnResponse(ApiResponse::makeSuccess($this->clientService->search($itemSearchData)->getDataAsArray())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -186,9 +190,9 @@ final class ClientController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Controllers/ConfigController.php b/app/modules/api/Controllers/ConfigController.php index 53217642..e4e1779f 100644 --- a/app/modules/api/Controllers/ConfigController.php +++ b/app/modules/api/Controllers/ConfigController.php @@ -24,9 +24,11 @@ namespace SP\Modules\Api\Controllers; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\Modules\Api\Controllers\Help\ConfigHelp; use SP\Services\Api\ApiResponse; use SP\Services\Backup\FileBackupService; @@ -59,7 +61,7 @@ final class ConfigController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($path, null, __('Backup process finished'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -92,7 +94,7 @@ final class ConfigController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($path, null, __('Export process finished'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -100,7 +102,7 @@ final class ConfigController extends ControllerBase } /** - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Controllers/ControllerBase.php b/app/modules/api/Controllers/ControllerBase.php index a5b50352..13bdb683 100644 --- a/app/modules/api/Controllers/ControllerBase.php +++ b/app/modules/api/Controllers/ControllerBase.php @@ -25,6 +25,9 @@ namespace SP\Modules\Api\Controllers; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use Klein\Klein; use Psr\Container\ContainerInterface; use SP\Core\Context\StatelessContext; @@ -34,6 +37,7 @@ use SP\Http\Json; use SP\Services\Api\ApiResponse; use SP\Services\Api\ApiService; use SP\Services\Api\JsonRpcResponse; +use SP\Services\ServiceException; /** * Class ControllerBase @@ -82,8 +86,8 @@ abstract class ControllerBase * @param Container $container * @param string $actionName * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public final function __construct(Container $container, $actionName) { @@ -123,7 +127,7 @@ abstract class ControllerBase * @param int $actionId * * @throws SPException - * @throws \SP\Services\ServiceException + * @throws ServiceException */ final protected function setupApi($actionId) { @@ -137,7 +141,7 @@ abstract class ControllerBase * * {"jsonrpc": "2.0", "result": 19, "id": 3} * - * @param \SP\Services\Api\ApiResponse $apiResponse + * @param ApiResponse $apiResponse */ final protected function returnResponse(ApiResponse $apiResponse) { @@ -166,9 +170,9 @@ abstract class ControllerBase } /** - * @param \Exception $e + * @param Exception $e */ - final protected function returnResponseException(\Exception $e) + final protected function returnResponseException(Exception $e) { $this->sendJsonResponse(JsonRpcResponse::getResponseException($e, $this->apiService->getRequestId())); } diff --git a/app/modules/api/Controllers/Help/ClientHelp.php b/app/modules/api/Controllers/Help/ClientHelp.php index f79c5ce8..8c95c6f6 100644 --- a/app/modules/api/Controllers/Help/ClientHelp.php +++ b/app/modules/api/Controllers/Help/ClientHelp.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/app/modules/api/Controllers/TagController.php b/app/modules/api/Controllers/TagController.php index 202a5a38..b891a4a3 100644 --- a/app/modules/api/Controllers/TagController.php +++ b/app/modules/api/Controllers/TagController.php @@ -24,9 +24,13 @@ namespace SP\Modules\Api\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\DataModel\ItemSearchData; use SP\DataModel\TagData; use SP\Modules\Api\Controllers\Help\TagHelp; @@ -64,7 +68,7 @@ final class TagController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($tagData, $id)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -92,7 +96,7 @@ final class TagController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($tagData, $id, __('Tag added'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -121,7 +125,7 @@ final class TagController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($tagData, $tagData->getId(), __('Tag updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -150,7 +154,7 @@ final class TagController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($tagData, $id, __('Tag removed'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -172,7 +176,7 @@ final class TagController extends ControllerBase $this->eventDispatcher->notifyEvent('search.tag', new Event($this)); $this->returnResponse(ApiResponse::makeSuccess($this->tagService->search($itemSearchData)->getDataAsArray())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -180,9 +184,9 @@ final class TagController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Controllers/UserGroupController.php b/app/modules/api/Controllers/UserGroupController.php index 463507f2..1f89b22a 100644 --- a/app/modules/api/Controllers/UserGroupController.php +++ b/app/modules/api/Controllers/UserGroupController.php @@ -24,9 +24,13 @@ namespace SP\Modules\Api\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidClassException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserGroupData; use SP\Modules\Api\Controllers\Help\TagHelp; @@ -64,7 +68,7 @@ final class UserGroupController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($userGroupData, $id)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -94,7 +98,7 @@ final class UserGroupController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($userGroupData, $id, __('Group added'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -126,7 +130,7 @@ final class UserGroupController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($userGroupData, $userGroupData->getId(), __('Group updated'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -156,7 +160,7 @@ final class UserGroupController extends ControllerBase ); $this->returnResponse(ApiResponse::makeSuccess($userGroupData, $id, __('Group deleted'))); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -178,7 +182,7 @@ final class UserGroupController extends ControllerBase $this->eventDispatcher->notifyEvent('search.userGroup', new Event($this)); $this->returnResponse(ApiResponse::makeSuccess($this->userGroupService->search($itemSearchData)->getDataAsArray())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->returnResponseException($e); @@ -186,9 +190,9 @@ final class UserGroupController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidClassException */ protected function initialize() { diff --git a/app/modules/api/Init.php b/app/modules/api/Init.php index cf3150e5..bc2947ee 100644 --- a/app/modules/api/Init.php +++ b/app/modules/api/Init.php @@ -24,6 +24,9 @@ namespace SP\Modules\Api; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; use Psr\Container\ContainerInterface; use SP\Core\Context\ContextException; use SP\Core\Context\StatelessContext; @@ -34,6 +37,7 @@ use SP\Services\Upgrade\UpgradeAppService; use SP\Services\Upgrade\UpgradeDatabaseService; use SP\Services\Upgrade\UpgradeUtil; use SP\Storage\Database\DatabaseUtil; +use SP\Storage\File\FileException; use SP\Util\HttpUtil; /** @@ -70,10 +74,10 @@ final class Init extends ModuleBase * * @throws ContextException * @throws InitializationException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public function initialize($controller) { @@ -134,10 +138,10 @@ final class Init extends ModuleBase * Comprobar si es necesario actualizar componentes * * @throws InitializationException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws FileException */ private function checkUpgrade() { diff --git a/app/modules/api/module.php b/app/modules/api/module.php index a03472e5..6cd156ca 100644 --- a/app/modules/api/module.php +++ b/app/modules/api/module.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/app/modules/web/Controllers/AccessManagerController.php b/app/modules/web/Controllers/AccessManagerController.php index bd85ec58..6fe217d7 100644 --- a/app/modules/web/Controllers/AccessManagerController.php +++ b/app/modules/web/Controllers/AccessManagerController.php @@ -24,15 +24,23 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; +use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\AuthTokenGrid; use SP\Modules\Web\Controllers\Helpers\Grid\PublicLinkGrid; use SP\Modules\Web\Controllers\Helpers\Grid\UserGrid; use SP\Modules\Web\Controllers\Helpers\Grid\UserGroupGrid; use SP\Modules\Web\Controllers\Helpers\Grid\UserProfileGrid; use SP\Modules\Web\Controllers\Helpers\TabsGridHelper; +use SP\Services\Auth\AuthException; use SP\Services\AuthToken\AuthTokenService; use SP\Services\PublicLink\PublicLinkService; use SP\Services\User\UserService; @@ -56,10 +64,10 @@ final class AccessManagerController extends ControllerBase protected $tabsGridHelper; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ public function indexAction() { @@ -69,10 +77,10 @@ final class AccessManagerController extends ControllerBase /** * Returns a tabbed grid with items * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getGridTabs() { @@ -111,11 +119,11 @@ final class AccessManagerController extends ControllerBase /** * Returns users' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getUsersList() { @@ -127,11 +135,11 @@ final class AccessManagerController extends ControllerBase /** * Returns users group data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getUsersGroupList() { @@ -143,11 +151,11 @@ final class AccessManagerController extends ControllerBase /** * Returns users profile data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getUsersProfileList() { @@ -159,11 +167,11 @@ final class AccessManagerController extends ControllerBase /** * Returns API tokens data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getAuthTokensList() { @@ -175,11 +183,11 @@ final class AccessManagerController extends ControllerBase /** * Returns public links data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getPublicLinksList() { @@ -197,9 +205,9 @@ final class AccessManagerController extends ControllerBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountController.php b/app/modules/web/Controllers/AccountController.php index 5411bf6d..09359559 100644 --- a/app/modules/web/Controllers/AccountController.php +++ b/app/modules/web/Controllers/AccountController.php @@ -24,6 +24,10 @@ namespace SP\Modules\Web\Controllers; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; @@ -33,6 +37,11 @@ use SP\Core\Context\SessionContext; use SP\Core\Crypt\Vault; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SessionTimeout; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\Core\UI\ThemeIcons; use SP\DataModel\AccountExtData; @@ -48,6 +57,7 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\AccountForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountAclService; use SP\Services\Account\AccountHistoryService; use SP\Services\Account\AccountService; @@ -55,6 +65,7 @@ use SP\Services\Auth\AuthException; use SP\Services\ItemPreset\ItemPresetInterface; use SP\Services\ItemPreset\ItemPresetService; use SP\Services\PublicLink\PublicLinkService; +use SP\Services\ServiceException; use SP\Services\User\UserService; use SP\Util\ErrorUtil; use SP\Util\ImageUtil; @@ -81,7 +92,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn /** * Index action * - * @throws \Psr\Container\ContainerExceptionInterface + * @throws ContainerExceptionInterface */ public function indexAction() { @@ -93,7 +104,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn $this->eventDispatcher->notifyEvent('show.account.search', new Event($this)); $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -118,7 +129,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn return $this->returnJsonResponseData([ 'html' => $this->render() ]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -132,8 +143,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function viewAction($id) { @@ -169,7 +180,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -189,8 +200,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param string $hash Link's hash * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function viewLinkAction($hash) { @@ -263,7 +274,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -300,7 +311,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); if ($this->isAjax === false @@ -318,8 +329,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function copyAction($id) { @@ -352,7 +363,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -372,8 +383,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function editAction($id) { @@ -408,7 +419,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -428,8 +439,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function deleteAction($id = null) { @@ -461,7 +472,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -481,8 +492,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function editPassAction($id) { @@ -514,7 +525,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -534,8 +545,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function viewHistoryAction($id) { @@ -567,7 +578,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -587,8 +598,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @param int $id Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function requestAccessAction($id) { @@ -609,7 +620,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn } $this->view(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -658,7 +669,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); return $this->returnJsonResponseData($data); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -669,11 +680,11 @@ final class AccountController extends ControllerBase implements CrudControllerIn /** * @return Password - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException */ private function getPasswordPreset() { @@ -718,7 +729,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); return $this->returnJsonResponseData($data); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -734,14 +745,14 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @return bool * @throws Helpers\HelperException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException + * @throws SPException */ public function copyPassAction($id) { @@ -771,14 +782,14 @@ final class AccountController extends ControllerBase implements CrudControllerIn * * @return bool * @throws Helpers\HelperException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException + * @throws SPException */ public function copyPassHistoryAction($id) { @@ -843,7 +854,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -892,7 +903,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -937,7 +948,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -978,7 +989,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn JsonResponse::JSON_SUCCESS, __u('Account restored') ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -1025,7 +1036,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Account removed')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -1089,7 +1100,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn ); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -1104,7 +1115,7 @@ final class AccountController extends ControllerBase implements CrudControllerIn * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @throws AuthException - * @throws \SP\Core\Exceptions\SessionTimeout + * @throws SessionTimeout */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountFavoriteController.php b/app/modules/web/Controllers/AccountFavoriteController.php index 0f2c3f7f..89c6ccbe 100644 --- a/app/modules/web/Controllers/AccountFavoriteController.php +++ b/app/modules/web/Controllers/AccountFavoriteController.php @@ -24,6 +24,7 @@ namespace SP\Modules\Web\Controllers; +use Exception; use SP\Core\Events\Event; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -54,7 +55,7 @@ final class AccountFavoriteController extends SimpleControllerBase $this->accountFavoriteService->add($accountId, $this->session->getUserData()->getId()); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorite added')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -74,7 +75,7 @@ final class AccountFavoriteController extends SimpleControllerBase $this->accountFavoriteService->delete($accountId, $this->session->getUserData()->getId()); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Favorite deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/AccountFileController.php b/app/modules/web/Controllers/AccountFileController.php index 264c902f..df6369a9 100644 --- a/app/modules/web/Controllers/AccountFileController.php +++ b/app/modules/web/Controllers/AccountFileController.php @@ -24,9 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use RuntimeException; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\FileData; use SP\Html\Html; @@ -37,6 +45,7 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Mvc\Controller\CrudControllerInterface; use SP\Services\Account\AccountFileService; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; use SP\Storage\File\FileException; use SP\Storage\File\FileHandler; use SP\Util\ErrorUtil; @@ -106,7 +115,7 @@ final class AccountFileController extends ControllerBase implements CrudControll return $this->returnJsonResponseData(['html' => $this->render()]); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -161,7 +170,7 @@ final class AccountFileController extends ControllerBase implements CrudControll $response->body($fileData->getContent()); $response->send(true); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -256,7 +265,7 @@ final class AccountFileController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('exception', new Event($e)); return $this->returnJsonResponse(1, $e->getMessage(), [$e->getHint()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -272,7 +281,7 @@ final class AccountFileController extends ControllerBase implements CrudControll * * @return string * @throws SPException - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function checkAllowedMimeType(FileData $fileData, FileHandler $fileHandler) { @@ -293,10 +302,10 @@ final class AccountFileController extends ControllerBase implements CrudControll * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException * @throws SPException */ public function searchAction() @@ -318,10 +327,10 @@ final class AccountFileController extends ControllerBase implements CrudControll * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -337,7 +346,7 @@ final class AccountFileController extends ControllerBase implements CrudControll */ public function createAction() { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -347,7 +356,7 @@ final class AccountFileController extends ControllerBase implements CrudControll */ public function editAction($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -382,7 +391,7 @@ final class AccountFileController extends ControllerBase implements CrudControll $this->accountFileService->delete($id); return $this->returnJsonResponse(0, __u('File Deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -396,7 +405,7 @@ final class AccountFileController extends ControllerBase implements CrudControll */ public function saveCreateAction() { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -406,7 +415,7 @@ final class AccountFileController extends ControllerBase implements CrudControll */ public function saveEditAction($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -414,7 +423,7 @@ final class AccountFileController extends ControllerBase implements CrudControll * * @param int $accountId Account's ID * - * @throws \Psr\Container\ContainerExceptionInterface + * @throws ContainerExceptionInterface */ public function listAction($accountId) { @@ -446,7 +455,7 @@ final class AccountFileController extends ControllerBase implements CrudControll } $this->eventDispatcher->notifyEvent('list.accountFile', new Event($this)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION, true, 'files-list'); @@ -458,9 +467,9 @@ final class AccountFileController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountHistoryManagerController.php b/app/modules/web/Controllers/AccountHistoryManagerController.php index 0d0cc363..433e8056 100644 --- a/app/modules/web/Controllers/AccountHistoryManagerController.php +++ b/app/modules/web/Controllers/AccountHistoryManagerController.php @@ -24,15 +24,22 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\AccountHistoryGrid; use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Services\Account\AccountHistoryService; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; /** * Class AccountHistoryManagerController @@ -50,11 +57,11 @@ final class AccountHistoryManagerController extends ControllerBase /** * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -75,10 +82,10 @@ final class AccountHistoryManagerController extends ControllerBase * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -122,7 +129,7 @@ final class AccountHistoryManagerController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Account removed')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -161,7 +168,7 @@ final class AccountHistoryManagerController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Account restored')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -173,9 +180,9 @@ final class AccountHistoryManagerController extends ControllerBase /** * Initialize class * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/AccountManagerController.php b/app/modules/web/Controllers/AccountManagerController.php index 60e99b50..b4f14dd9 100644 --- a/app/modules/web/Controllers/AccountManagerController.php +++ b/app/modules/web/Controllers/AccountManagerController.php @@ -24,9 +24,15 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\AccountGrid; use SP\Modules\Web\Controllers\Traits\ItemTrait; @@ -38,6 +44,7 @@ use SP\Services\Account\AccountHistoryService; use SP\Services\Account\AccountSearchFilter; use SP\Services\Account\AccountSearchService; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\Tag\TagService; @@ -65,11 +72,11 @@ final class AccountManagerController extends ControllerBase /** * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -90,11 +97,11 @@ final class AccountManagerController extends ControllerBase * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ protected function getSearchGrid() { @@ -103,10 +110,10 @@ final class AccountManagerController extends ControllerBase $accountGrid = $this->dic->get(AccountGrid::class); $filter = new AccountSearchFilter(); - $filter->setTxtSearch($itemSearchData->getSeachString()); $filter->setLimitCount($itemSearchData->getLimitCount()); $filter->setLimitStart($itemSearchData->getLimitStart()); $filter->setStringFilters($this->accountSearchService->analyzeQueryFilters($itemSearchData->getSeachString())); + $filter->setCleanTxtSearch($this->accountSearchService->getCleanString()); return $accountGrid->updatePager( $accountGrid->getGrid( @@ -152,7 +159,7 @@ final class AccountManagerController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Account removed')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); @@ -192,7 +199,7 @@ final class AccountManagerController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Accounts updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); @@ -223,7 +230,7 @@ final class AccountManagerController extends ControllerBase $this->eventDispatcher->notifyEvent('show.account.bulkEdit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); @@ -265,9 +272,9 @@ final class AccountManagerController extends ControllerBase /** * Initialize class * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/AuthTokenController.php b/app/modules/web/Controllers/AuthTokenController.php index a3b7efea..7483f2af 100644 --- a/app/modules/web/Controllers/AuthTokenController.php +++ b/app/modules/web/Controllers/AuthTokenController.php @@ -24,9 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\AuthTokenData; use SP\Http\JsonResponse; @@ -36,7 +44,9 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\AuthTokenForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Services\Auth\AuthException; use SP\Services\AuthToken\AuthTokenService; +use SP\Services\ServiceException; use SP\Services\User\UserService; /** @@ -57,11 +67,11 @@ final class AuthTokenController extends ControllerBase implements CrudController * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -82,10 +92,10 @@ final class AuthTokenController extends ControllerBase implements CrudController * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -120,7 +130,7 @@ final class AuthTokenController extends ControllerBase implements CrudController $this->eventDispatcher->notifyEvent('show.authToken.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -134,9 +144,9 @@ final class AuthTokenController extends ControllerBase implements CrudController * * @param $authTokenId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ protected function setViewData($authTokenId = null) { @@ -188,7 +198,7 @@ final class AuthTokenController extends ControllerBase implements CrudController $this->eventDispatcher->notifyEvent('show.authToken.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -239,7 +249,7 @@ final class AuthTokenController extends ControllerBase implements CrudController ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Authorization deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -275,7 +285,7 @@ final class AuthTokenController extends ControllerBase implements CrudController return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Authorization added')); } catch (ValidationException $e) { return $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -329,7 +339,7 @@ final class AuthTokenController extends ControllerBase implements CrudController return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Authorization updated')); } catch (ValidationException $e) { return $this->returnJsonResponse(JsonResponse::JSON_ERROR, $e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -367,7 +377,7 @@ final class AuthTokenController extends ControllerBase implements CrudController ); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -379,9 +389,9 @@ final class AuthTokenController extends ControllerBase implements CrudController /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/BootstrapController.php b/app/modules/web/Controllers/BootstrapController.php index 1867b370..87dbbf81 100644 --- a/app/modules/web/Controllers/BootstrapController.php +++ b/app/modules/web/Controllers/BootstrapController.php @@ -24,6 +24,9 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Bootstrap; use SP\Core\Crypt\CryptPKI; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -45,8 +48,8 @@ final class BootstrapController extends SimpleControllerBase * Returns environment data * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function getEnvironmentAction() { @@ -112,7 +115,7 @@ final class BootstrapController extends SimpleControllerBase { try { return $this->dic->get(PluginManager::class)->getEnabledPlugins(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } @@ -121,8 +124,8 @@ final class BootstrapController extends SimpleControllerBase /** * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private function getAuthBasicAutologinEnabled() { @@ -132,8 +135,8 @@ final class BootstrapController extends SimpleControllerBase /** * @return string - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private function getPublicKey() { diff --git a/app/modules/web/Controllers/CategoryController.php b/app/modules/web/Controllers/CategoryController.php index d03af2e5..022511f6 100644 --- a/app/modules/web/Controllers/CategoryController.php +++ b/app/modules/web/Controllers/CategoryController.php @@ -24,9 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\CategoryData; use SP\Http\JsonResponse; @@ -35,7 +43,10 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\CategoryForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\Category\CategoryService; +use SP\Services\ServiceException; /** * Class CategoryController @@ -55,11 +66,11 @@ final class CategoryController extends ControllerBase implements CrudControllerI * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -80,10 +91,10 @@ final class CategoryController extends ControllerBase implements CrudControllerI * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -115,7 +126,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI $this->eventDispatcher->notifyEvent('show.category.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -129,10 +140,10 @@ final class CategoryController extends ControllerBase implements CrudControllerI * * @param $categoryId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException + * @throws NoSuchItemException */ protected function setViewData($categoryId = null) { @@ -182,7 +193,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI $this->eventDispatcher->notifyEvent('show.category.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -233,7 +244,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Category deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -273,7 +284,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Category added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -317,7 +328,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Category updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -350,7 +361,7 @@ final class CategoryController extends ControllerBase implements CrudControllerI $this->eventDispatcher->notifyEvent('show.category', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -362,9 +373,9 @@ final class CategoryController extends ControllerBase implements CrudControllerI /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ClientController.php b/app/modules/web/Controllers/ClientController.php index 8fafe724..863fd39d 100644 --- a/app/modules/web/Controllers/ClientController.php +++ b/app/modules/web/Controllers/ClientController.php @@ -25,9 +25,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ClientData; use SP\Http\JsonResponse; @@ -36,7 +44,10 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\ClientForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\Client\ClientService; +use SP\Services\ServiceException; /** * Class ClientController @@ -56,11 +67,11 @@ final class ClientController extends ControllerBase implements CrudControllerInt * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -81,10 +92,10 @@ final class ClientController extends ControllerBase implements CrudControllerInt * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -116,7 +127,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt $this->eventDispatcher->notifyEvent('show.client.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -130,10 +141,10 @@ final class ClientController extends ControllerBase implements CrudControllerInt * * @param $clientId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException + * @throws NoSuchItemException */ protected function setViewData($clientId = null) { @@ -182,7 +193,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt $this->eventDispatcher->notifyEvent('show.client.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -230,7 +241,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Client deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -268,7 +279,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Client added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -308,7 +319,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Client updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -341,7 +352,7 @@ final class ClientController extends ControllerBase implements CrudControllerInt $this->eventDispatcher->notifyEvent('show.client', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -353,9 +364,9 @@ final class ClientController extends ControllerBase implements CrudControllerInt /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigAccountController.php b/app/modules/web/Controllers/ConfigAccountController.php index c01d3cbc..09a1a6fe 100644 --- a/app/modules/web/Controllers/ConfigAccountController.php +++ b/app/modules/web/Controllers/ConfigAccountController.php @@ -28,6 +28,7 @@ use SP\Core\Acl\ActionsInterface; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -43,7 +44,7 @@ final class ConfigAccountController extends SimpleControllerBase /** * saveAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function saveAction() { diff --git a/app/modules/web/Controllers/ConfigBackupController.php b/app/modules/web/Controllers/ConfigBackupController.php index 01d96d09..02e37d73 100644 --- a/app/modules/web/Controllers/ConfigBackupController.php +++ b/app/modules/web/Controllers/ConfigBackupController.php @@ -24,11 +24,13 @@ namespace SP\Modules\Web\Controllers; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; use SP\Services\Backup\FileBackupService; @@ -47,7 +49,7 @@ final class ConfigBackupController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function fileBackupAction() { @@ -69,7 +71,7 @@ final class ConfigBackupController extends SimpleControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Backup process finished')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -132,7 +134,7 @@ final class ConfigBackupController extends SimpleControllerBase $export->createArchive(); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Export process finished')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -143,7 +145,7 @@ final class ConfigBackupController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function downloadExportAction() { @@ -174,7 +176,7 @@ final class ConfigBackupController extends SimpleControllerBase $response->send(); $file->readChunked(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -185,7 +187,7 @@ final class ConfigBackupController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function downloadBackupAppAction() { @@ -220,7 +222,7 @@ final class ConfigBackupController extends SimpleControllerBase $response->send(); $file->readChunked(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -231,7 +233,7 @@ final class ConfigBackupController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function downloadBackupDbAction() { @@ -266,7 +268,7 @@ final class ConfigBackupController extends SimpleControllerBase $response->send(); $file->readChunked(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/ConfigDokuWikiController.php b/app/modules/web/Controllers/ConfigDokuWikiController.php index 7208f458..8bc669ab 100644 --- a/app/modules/web/Controllers/ConfigDokuWikiController.php +++ b/app/modules/web/Controllers/ConfigDokuWikiController.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -28,6 +28,7 @@ use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -43,7 +44,7 @@ final class ConfigDokuWikiController extends SimpleControllerBase /** * saveAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function saveAction() { diff --git a/app/modules/web/Controllers/ConfigEncryptionController.php b/app/modules/web/Controllers/ConfigEncryptionController.php index caafe807..d5e50b61 100644 --- a/app/modules/web/Controllers/ConfigEncryptionController.php +++ b/app/modules/web/Controllers/ConfigEncryptionController.php @@ -24,18 +24,24 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Crypt\Hash; use SP\Core\Crypt\Session as CryptSession; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Repositories\NoSuchItemException; use SP\Services\Config\ConfigService; use SP\Services\Crypt\MasterPassService; use SP\Services\Crypt\TemporaryMasterPassService; use SP\Services\Crypt\UpdateMasterPassRequest; +use SP\Services\ServiceException; use SP\Services\Task\TaskFactory; /** @@ -49,11 +55,11 @@ final class ConfigEncryptionController extends SimpleControllerBase /** * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws NoSuchItemException + * @throws ServiceException + * @throws SPException */ public function saveAction() { @@ -144,7 +150,7 @@ final class ConfigEncryptionController extends SimpleControllerBase $mastePassService->changeMasterPassword($request); $this->eventDispatcher->notifyEvent('update.masterPassword.end', new Event($this)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -160,7 +166,7 @@ final class ConfigEncryptionController extends SimpleControllerBase $this->eventDispatcher->notifyEvent('update.masterPassword.hash', new Event($this)); $mastePassService->updateConfig(Hash::hashKey($newMasterPass)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -195,7 +201,7 @@ final class ConfigEncryptionController extends SimpleControllerBase new Event($this, EventMessage::factory()->addDescription(__u('Master password hash updated')))); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Master password hash updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -233,7 +239,7 @@ final class ConfigEncryptionController extends SimpleControllerBase __u('Temporary password generated'), [__u('Email sent')] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -247,7 +253,7 @@ final class ConfigEncryptionController extends SimpleControllerBase } return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Temporary password generated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/ConfigGeneralController.php b/app/modules/web/Controllers/ConfigGeneralController.php index 216ef7b3..3de6c4b3 100644 --- a/app/modules/web/Controllers/ConfigGeneralController.php +++ b/app/modules/web/Controllers/ConfigGeneralController.php @@ -24,12 +24,15 @@ namespace SP\Modules\Web\Controllers; +use Exception; +use RuntimeException; use SP\Config\ConfigUtil; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; use SP\Services\Config\ConfigBackupService; @@ -48,7 +51,7 @@ final class ConfigGeneralController extends SimpleControllerBase /** * saveAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function saveAction() { @@ -187,7 +190,7 @@ final class ConfigGeneralController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function downloadLogAction() { @@ -220,7 +223,7 @@ final class ConfigGeneralController extends SimpleControllerBase $response->send(); $file->readChunked(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -233,7 +236,7 @@ final class ConfigGeneralController extends SimpleControllerBase * @param string $type * * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function downloadConfigBackupAction($type) { @@ -257,7 +260,7 @@ final class ConfigGeneralController extends SimpleControllerBase $data = ConfigBackupService::configToJson($configBackupService->getBackup()); break; default: - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } $response = $this->router->response(); @@ -273,7 +276,7 @@ final class ConfigGeneralController extends SimpleControllerBase $response->body($data); $response->send(true); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/ConfigImportController.php b/app/modules/web/Controllers/ConfigImportController.php index 20dbcc10..972b0fe7 100644 --- a/app/modules/web/Controllers/ConfigImportController.php +++ b/app/modules/web/Controllers/ConfigImportController.php @@ -24,6 +24,7 @@ namespace SP\Modules\Web\Controllers; +use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; @@ -31,6 +32,7 @@ use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Services\Import\FileImport; @@ -49,7 +51,7 @@ final class ConfigImportController extends SimpleControllerBase /** * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function importAction() { @@ -91,7 +93,7 @@ final class ConfigImportController extends SimpleControllerBase __u('No accounts were imported'), [__u('Please check out the event log for more details')] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/ConfigLdapController.php b/app/modules/web/Controllers/ConfigLdapController.php index 9ee9c92f..a52bd1fd 100644 --- a/app/modules/web/Controllers/ConfigLdapController.php +++ b/app/modules/web/Controllers/ConfigLdapController.php @@ -24,6 +24,9 @@ namespace SP\Modules\Web\Controllers; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; @@ -101,7 +104,7 @@ final class ConfigLdapController extends SimpleControllerBase return $this->saveConfig($configData, $this->config, function () use ($eventMessage) { $this->eventDispatcher->notifyEvent('save.config.ldap', new Event($this, $eventMessage)); }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -163,7 +166,7 @@ final class ConfigLdapController extends SimpleControllerBase __u('LDAP connection OK'), [sprintf(__('Objects found: %d'), $data['count'])] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -209,7 +212,7 @@ final class ConfigLdapController extends SimpleControllerBase __u('LDAP connection OK'), [sprintf(__('Objects found: %d'), $data['count'])] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -221,8 +224,8 @@ final class ConfigLdapController extends SimpleControllerBase /** * importAction * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function importAction() { @@ -288,7 +291,7 @@ final class ConfigLdapController extends SimpleControllerBase ] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/app/modules/web/Controllers/ConfigMailController.php b/app/modules/web/Controllers/ConfigMailController.php index 44bf5495..3be877f1 100644 --- a/app/modules/web/Controllers/ConfigMailController.php +++ b/app/modules/web/Controllers/ConfigMailController.php @@ -24,11 +24,14 @@ namespace SP\Modules\Web\Controllers; +use Exception; use SP\Config\ConfigUtil; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SessionTimeout; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; use SP\Providers\Mail\MailParams; @@ -46,7 +49,7 @@ final class ConfigMailController extends SimpleControllerBase /** * saveAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function saveAction() { @@ -126,7 +129,7 @@ final class ConfigMailController extends SimpleControllerBase /** * checkAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function checkAction() { @@ -167,7 +170,7 @@ final class ConfigMailController extends SimpleControllerBase __u('Email sent'), [__u('Please, check your inbox')] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -178,7 +181,7 @@ final class ConfigMailController extends SimpleControllerBase /** * @return bool - * @throws \SP\Core\Exceptions\SessionTimeout + * @throws SessionTimeout */ protected function initialize() diff --git a/app/modules/web/Controllers/ConfigManagerController.php b/app/modules/web/Controllers/ConfigManagerController.php index 14bc097a..1c446f5c 100644 --- a/app/modules/web/Controllers/ConfigManagerController.php +++ b/app/modules/web/Controllers/ConfigManagerController.php @@ -24,10 +24,18 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\AppInfoInterface; use SP\Core\Crypt\CryptSessionHandler; use SP\Core\Events\Event; +use SP\Core\Exceptions\CheckException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\Core\MimeTypes; use SP\Modules\Web\Controllers\Helpers\TabsHelper; @@ -37,11 +45,14 @@ use SP\Plugin\PluginManager; use SP\Providers\Auth\Ldap\LdapTypeInterface; use SP\Providers\Log\LogInterface; use SP\Providers\Mail\MailHandler; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; use SP\Services\Backup\FileBackupService; use SP\Services\Config\ConfigService; use SP\Services\Crypt\TemporaryMasterPassService; use SP\Services\Export\XmlExportService; +use SP\Services\ServiceException; use SP\Services\Task\Task; use SP\Services\User\UserService; use SP\Services\UserGroup\UserGroupService; @@ -64,9 +75,9 @@ final class ConfigManagerController extends ControllerBase protected $tabsHelper; /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\SPException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws SPException */ public function indexAction() { @@ -76,9 +87,9 @@ final class ConfigManagerController extends ControllerBase /** * Returns a tabbed grid with items * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\SPException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws SPException */ protected function getTabs() { @@ -130,9 +141,9 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\CheckException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws CheckException */ protected function getConfigGeneral() { @@ -164,10 +175,10 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws CheckException + * @throws SPException */ protected function getAccountConfig() { @@ -194,7 +205,7 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \SP\Core\Exceptions\CheckException + * @throws CheckException */ protected function getWikiConfig() { @@ -209,9 +220,9 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\CheckException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws CheckException */ protected function getLdapConfig() { @@ -236,8 +247,8 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function getMailConfig() { @@ -262,12 +273,12 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException */ protected function getEncryptionConfig() { @@ -303,7 +314,7 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \SP\Core\Exceptions\CheckException + * @throws CheckException */ protected function getBackupConfig() { @@ -344,8 +355,8 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function getImportConfig() { @@ -367,10 +378,10 @@ final class ConfigManagerController extends ControllerBase /** * @return DataTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws NoSuchItemException + * @throws ServiceException */ protected function getInfo() { @@ -406,9 +417,9 @@ final class ConfigManagerController extends ControllerBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ConfigWikiController.php b/app/modules/web/Controllers/ConfigWikiController.php index 45b0fc29..c431fa59 100644 --- a/app/modules/web/Controllers/ConfigWikiController.php +++ b/app/modules/web/Controllers/ConfigWikiController.php @@ -28,6 +28,7 @@ use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\ConfigTrait; @@ -43,7 +44,7 @@ final class ConfigWikiController extends SimpleControllerBase /** * saveAction * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function saveAction() { diff --git a/app/modules/web/Controllers/ControllerBase.php b/app/modules/web/Controllers/ControllerBase.php index d8199c30..de9f16c9 100644 --- a/app/modules/web/Controllers/ControllerBase.php +++ b/app/modules/web/Controllers/ControllerBase.php @@ -27,7 +27,12 @@ namespace SP\Modules\Web\Controllers; defined('APP_ROOT') || die(); use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Hash; use SP\Core\Exceptions\FileNotFoundException; use SP\Core\Exceptions\SessionTimeout; @@ -87,8 +92,8 @@ abstract class ControllerBase * @param Container $container * @param $actionName * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface * @throws SessionTimeout */ public final function __construct(Container $container, $actionName) @@ -218,7 +223,7 @@ abstract class ControllerBase try { $this->dic->get(LayoutHelper::class)->getFullLayout('main', $this->acl); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -243,9 +248,9 @@ abstract class ControllerBase * @param bool $requireAuthCompleted * * @throws AuthException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\SessionTimeout + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout */ protected function checkLoggedIn($requireAuthCompleted = true) { diff --git a/app/modules/web/Controllers/CustomFieldController.php b/app/modules/web/Controllers/CustomFieldController.php index da43788b..578bc131 100644 --- a/app/modules/web/Controllers/CustomFieldController.php +++ b/app/modules/web/Controllers/CustomFieldController.php @@ -24,9 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\CustomFieldDefinitionData; use SP\Http\JsonResponse; @@ -36,6 +44,8 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\CustomFieldDefForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\CustomField\CustomFieldDefService; use SP\Services\CustomField\CustomFieldTypeService; @@ -57,11 +67,11 @@ final class CustomFieldController extends ControllerBase implements CrudControll * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -82,10 +92,10 @@ final class CustomFieldController extends ControllerBase implements CrudControll * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -117,7 +127,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('show.customField.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -131,9 +141,9 @@ final class CustomFieldController extends ControllerBase implements CrudControll * * @param $customFieldId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ protected function setViewData($customFieldId = null) { @@ -181,7 +191,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('show.customField.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -221,7 +231,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Field deleted')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -258,7 +268,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Field added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -299,7 +309,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Field updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -330,7 +340,7 @@ final class CustomFieldController extends ControllerBase implements CrudControll $this->setViewData($id); $this->eventDispatcher->notifyEvent('show.customField', new Event($this)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -344,9 +354,9 @@ final class CustomFieldController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ErrorController.php b/app/modules/web/Controllers/ErrorController.php index 8f04203f..e1c9a7c1 100644 --- a/app/modules/web/Controllers/ErrorController.php +++ b/app/modules/web/Controllers/ErrorController.php @@ -25,6 +25,8 @@ namespace SP\Modules\Web\Controllers; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; use Klein\Klein; use SP\Core\Exceptions\FileNotFoundException; use SP\Core\Exceptions\SPException; @@ -57,8 +59,8 @@ final class ErrorController * @param Container $container * @param string $actionName * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function __construct(Container $container, $actionName) { diff --git a/app/modules/web/Controllers/EventlogController.php b/app/modules/web/Controllers/EventlogController.php index 230d9049..6ff30b70 100644 --- a/app/modules/web/Controllers/EventlogController.php +++ b/app/modules/web/Controllers/EventlogController.php @@ -24,13 +24,20 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\EventlogGrid; use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Services\Auth\AuthException; use SP\Services\EventLog\EventlogService; /** @@ -50,11 +57,11 @@ final class EventlogController extends ControllerBase /** * indexAction * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function indexAction() { @@ -75,10 +82,10 @@ final class EventlogController extends ControllerBase * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -93,11 +100,11 @@ final class EventlogController extends ControllerBase * searchAction * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -128,7 +135,7 @@ final class EventlogController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Event log cleared')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); @@ -136,9 +143,9 @@ final class EventlogController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php index a1405c76..26b46fa1 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountActionsHelper.php @@ -50,7 +50,7 @@ final class AccountActionsHelper extends HelperBase protected $sk; /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getViewAction() { @@ -166,7 +166,7 @@ final class AccountActionsHelper extends HelperBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getEditAction() { @@ -187,7 +187,7 @@ final class AccountActionsHelper extends HelperBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getRequestAction() { @@ -252,7 +252,7 @@ final class AccountActionsHelper extends HelperBase * @param AccountAcl $accountAcl * @param AccountActionsDto $accountActionsDto * - * @return \SP\Html\DataGrid\Action\DataGridAction[] + * @return DataGridAction[] */ public function getActionsGrouppedForAccount(AccountAcl $accountAcl, AccountActionsDto $accountActionsDto) { @@ -388,7 +388,7 @@ final class AccountActionsHelper extends HelperBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getPublicLinkAction() { diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php index 6951d76c..7255a079 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountHelper.php @@ -24,11 +24,18 @@ namespace SP\Modules\Web\Controllers\Helpers\Account; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; use SP\Core\Acl\AccountPermissionException; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\Acl\UnauthorizedPageException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\Dto\AccountAclDto; use SP\DataModel\Dto\AccountDetailsResponse; @@ -49,6 +56,7 @@ use SP\Services\Crypt\MasterPassService; use SP\Services\ItemPreset\ItemPresetInterface; use SP\Services\ItemPreset\ItemPresetService; use SP\Services\PublicLink\PublicLinkService; +use SP\Services\ServiceException; use SP\Services\Tag\TagService; use SP\Services\User\UpdatedMasterPassException; use SP\Services\User\UserService; @@ -110,8 +118,8 @@ final class AccountHelper extends HelperBase * @throws SPException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function setViewForAccount(AccountDetailsResponse $accountDetailsResponse, $actionId) { @@ -222,9 +230,9 @@ final class AccountHelper extends HelperBase * @throws NoSuchItemException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ServiceException */ public function checkActionAccess() { @@ -246,10 +254,10 @@ final class AccountHelper extends HelperBase * * @return AccountAcl * @throws AccountPermissionException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function checkAccess(AccountDetailsResponse $accountDetailsResponse) { @@ -266,11 +274,11 @@ final class AccountHelper extends HelperBase /** * Sets account's view common data * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ protected function setViewCommon() { @@ -342,12 +350,12 @@ final class AccountHelper extends HelperBase * @throws NoSuchItemException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function setViewForBlank($actionId) { @@ -412,9 +420,9 @@ final class AccountHelper extends HelperBase * @throws NoSuchItemException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ServiceException */ public function setViewForRequest(AccountDetailsResponse $accountDetailsResponse, $actionId) { @@ -445,8 +453,8 @@ final class AccountHelper extends HelperBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php index 048de2bf..fc7a1058 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountHistoryHelper.php @@ -24,20 +24,28 @@ namespace SP\Modules\Web\Controllers\Helpers\Account; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\AccountPermissionException; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedPageException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AccountHistoryData; use SP\DataModel\Dto\AccountAclDto; use SP\Modules\Web\Controllers\Helpers\HelperBase; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountAcl; use SP\Services\Account\AccountAclService; use SP\Services\Account\AccountHistoryService; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\Crypt\MasterPassService; +use SP\Services\ServiceException; use SP\Services\User\UpdatedMasterPassException; /** @@ -79,12 +87,12 @@ final class AccountHistoryHelper extends HelperBase * @throws AccountPermissionException * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException */ public function setView(AccountHistoryData $accountHistoryData, $actionId) { @@ -129,10 +137,10 @@ final class AccountHistoryHelper extends HelperBase /** * @throws UnauthorizedPageException * @throws UpdatedMasterPassException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws NoSuchItemException + * @throws ServiceException */ protected function checkActionAccess() { @@ -153,10 +161,10 @@ final class AccountHistoryHelper extends HelperBase * @param AccountHistoryData $accountHistoryData * * @throws AccountPermissionException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function checkAccess(AccountHistoryData $accountHistoryData) { @@ -179,8 +187,8 @@ final class AccountHistoryHelper extends HelperBase /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/app/modules/web/Controllers/Helpers/Account/AccountPasswordHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountPasswordHelper.php index c68e3539..522d5902 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountPasswordHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountPasswordHelper.php @@ -24,14 +24,20 @@ namespace SP\Modules\Web\Controllers\Helpers\Account; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Session as CryptSession; +use SP\Core\Exceptions\FileNotFoundException; use SP\DataModel\AccountPassData; use SP\Modules\Web\Controllers\Helpers\HelperBase; use SP\Modules\Web\Controllers\Helpers\HelperException; +use SP\Repositories\NoSuchItemException; use SP\Services\Crypt\MasterPassService; +use SP\Services\ServiceException; use SP\Util\ImageUtil; /** @@ -53,12 +59,12 @@ final class AccountPasswordHelper extends HelperBase * * @return array * @throws HelperException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\FileNotFoundException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws FileNotFoundException + * @throws NoSuchItemException + * @throws ServiceException */ public function getPasswordView(AccountPassData $accountData, bool $useImage) { @@ -104,11 +110,11 @@ final class AccountPasswordHelper extends HelperBase * * @return string * @throws HelperException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws NoSuchItemException + * @throws ServiceException */ public function getPasswordClear(AccountPassData $accountData) { @@ -122,8 +128,8 @@ final class AccountPasswordHelper extends HelperBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize() { diff --git a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php index b20bf974..8029d5b6 100644 --- a/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php +++ b/app/modules/web/Controllers/Helpers/Account/AccountSearchHelper.php @@ -24,8 +24,13 @@ namespace SP\Modules\Web\Controllers\Helpers\Account; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Html\DataGrid\Action\DataGridAction; use SP\Html\DataGrid\Action\DataGridActionSearch; use SP\Html\DataGrid\DataGrid; @@ -85,10 +90,10 @@ final class AccountSearchHelper extends HelperBase /** * Obtener los datos para la caja de búsqueda * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ public function getSearchBox() { @@ -111,11 +116,11 @@ final class AccountSearchHelper extends HelperBase /** * Obtener los resultados de una búsqueda * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function getAccountSearch() { @@ -169,8 +174,8 @@ final class AccountSearchHelper extends HelperBase * Devuelve la matriz a utilizar en la vista * * @return DataGrid - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private function getGrid() { @@ -227,7 +232,7 @@ final class AccountSearchHelper extends HelperBase /** * Devolver la cabecera con los campos de ordenación * - * @return \SP\Html\DataGrid\Layout\DataGridHeaderSort + * @return DataGridHeaderSort */ private function getHeaderSort() { diff --git a/app/modules/web/Controllers/Helpers/Grid/AccountGrid.php b/app/modules/web/Controllers/Helpers/Grid/AccountGrid.php index 59ba6c83..4c090f6c 100644 --- a/app/modules/web/Controllers/Helpers/Grid/AccountGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/AccountGrid.php @@ -104,7 +104,7 @@ final class AccountGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -154,7 +154,7 @@ final class AccountGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getViewAction() { @@ -188,7 +188,7 @@ final class AccountGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ public function getBulkEditAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/AccountHistoryGrid.php b/app/modules/web/Controllers/Helpers/Grid/AccountHistoryGrid.php index ae12ba23..660651cd 100644 --- a/app/modules/web/Controllers/Helpers/Grid/AccountHistoryGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/AccountHistoryGrid.php @@ -95,7 +95,7 @@ final class AccountHistoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -150,7 +150,7 @@ final class AccountHistoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getRestoreAction() { @@ -167,7 +167,7 @@ final class AccountHistoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/AuthTokenGrid.php b/app/modules/web/Controllers/Helpers/Grid/AuthTokenGrid.php index 302d11b5..0c289ace 100644 --- a/app/modules/web/Controllers/Helpers/Grid/AuthTokenGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/AuthTokenGrid.php @@ -98,7 +98,7 @@ final class AuthTokenGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -128,7 +128,7 @@ final class AuthTokenGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -163,7 +163,7 @@ final class AuthTokenGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getViewAction() { @@ -180,7 +180,7 @@ final class AuthTokenGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/CategoryGrid.php b/app/modules/web/Controllers/Helpers/Grid/CategoryGrid.php index 79f31baa..08440141 100644 --- a/app/modules/web/Controllers/Helpers/Grid/CategoryGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/CategoryGrid.php @@ -97,7 +97,7 @@ final class CategoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -125,7 +125,7 @@ final class CategoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -160,7 +160,7 @@ final class CategoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditAction() { @@ -177,7 +177,7 @@ final class CategoryGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/ClientGrid.php b/app/modules/web/Controllers/Helpers/Grid/ClientGrid.php index ac611a0e..62ea3136 100644 --- a/app/modules/web/Controllers/Helpers/Grid/ClientGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/ClientGrid.php @@ -128,7 +128,7 @@ final class ClientGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -145,7 +145,7 @@ final class ClientGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCreateAction() { @@ -163,7 +163,7 @@ final class ClientGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/CustomFieldGrid.php b/app/modules/web/Controllers/Helpers/Grid/CustomFieldGrid.php index c50f0ab6..63b97131 100644 --- a/app/modules/web/Controllers/Helpers/Grid/CustomFieldGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/CustomFieldGrid.php @@ -98,7 +98,7 @@ final class CustomFieldGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -132,7 +132,7 @@ final class CustomFieldGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -149,7 +149,7 @@ final class CustomFieldGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCreateAction() { @@ -167,7 +167,7 @@ final class CustomFieldGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditAction() { @@ -184,7 +184,7 @@ final class CustomFieldGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/EventlogGrid.php b/app/modules/web/Controllers/Helpers/Grid/EventlogGrid.php index 912ad933..ecb5c858 100644 --- a/app/modules/web/Controllers/Helpers/Grid/EventlogGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/EventlogGrid.php @@ -153,7 +153,7 @@ final class EventlogGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -170,7 +170,7 @@ final class EventlogGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getRefrestAction() { @@ -189,7 +189,7 @@ final class EventlogGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getClearAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/FileGrid.php b/app/modules/web/Controllers/Helpers/Grid/FileGrid.php index 1419b050..38c40e1c 100644 --- a/app/modules/web/Controllers/Helpers/Grid/FileGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/FileGrid.php @@ -97,7 +97,7 @@ final class FileGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { diff --git a/app/modules/web/Controllers/Helpers/Grid/GridBase.php b/app/modules/web/Controllers/Helpers/Grid/GridBase.php index 588dc72e..ef1d973f 100644 --- a/app/modules/web/Controllers/Helpers/Grid/GridBase.php +++ b/app/modules/web/Controllers/Helpers/Grid/GridBase.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers\Helpers\Grid; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\UI\ThemeIcons; use SP\DataModel\ItemSearchData; @@ -50,7 +52,7 @@ abstract class GridBase extends HelperBase implements GridInterface */ protected $icons; /** - * @var \SP\Core\Acl\Acl + * @var Acl */ protected $acl; @@ -77,9 +79,9 @@ abstract class GridBase extends HelperBase implements GridInterface /** * Devolver el paginador por defecto * - * @param \SP\Html\DataGrid\Action\DataGridActionSearch $sourceAction + * @param DataGridActionSearch $sourceAction * - * @return \SP\Html\DataGrid\Layout\DataGridPager + * @return DataGridPager */ final protected function getPager(DataGridActionSearch $sourceAction) { @@ -97,8 +99,8 @@ abstract class GridBase extends HelperBase implements GridInterface } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ final protected function initialize() { @@ -113,7 +115,7 @@ abstract class GridBase extends HelperBase implements GridInterface protected abstract function getGridLayout(): DataGridInterface; /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected abstract function getHeader(): DataGridHeader; diff --git a/app/modules/web/Controllers/Helpers/Grid/ItemPresetGrid.php b/app/modules/web/Controllers/Helpers/Grid/ItemPresetGrid.php index 65fcaefe..2e9c9958 100644 --- a/app/modules/web/Controllers/Helpers/Grid/ItemPresetGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/ItemPresetGrid.php @@ -100,7 +100,7 @@ final class ItemPresetGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { diff --git a/app/modules/web/Controllers/Helpers/Grid/NotificationGrid.php b/app/modules/web/Controllers/Helpers/Grid/NotificationGrid.php index ebdaee2d..bb52a63b 100644 --- a/app/modules/web/Controllers/Helpers/Grid/NotificationGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/NotificationGrid.php @@ -118,7 +118,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -159,7 +159,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -176,7 +176,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCreateAction() { @@ -194,7 +194,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getViewAction() { @@ -225,7 +225,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCheckAction() { @@ -243,7 +243,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditAction() { @@ -259,7 +259,7 @@ final class NotificationGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/PluginGrid.php b/app/modules/web/Controllers/Helpers/Grid/PluginGrid.php index 886da57f..4a108dde 100644 --- a/app/modules/web/Controllers/Helpers/Grid/PluginGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/PluginGrid.php @@ -129,7 +129,7 @@ final class PluginGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -183,7 +183,7 @@ final class PluginGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDisableAction() { @@ -221,7 +221,7 @@ final class PluginGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/PublicLinkGrid.php b/app/modules/web/Controllers/Helpers/Grid/PublicLinkGrid.php index 64faf13c..12c6a59b 100644 --- a/app/modules/web/Controllers/Helpers/Grid/PublicLinkGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/PublicLinkGrid.php @@ -99,7 +99,7 @@ final class PublicLinkGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { @@ -139,7 +139,7 @@ final class PublicLinkGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -174,7 +174,7 @@ final class PublicLinkGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getViewAction() { @@ -207,7 +207,7 @@ final class PublicLinkGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/TagGrid.php b/app/modules/web/Controllers/Helpers/Grid/TagGrid.php index a879dbe5..82473625 100644 --- a/app/modules/web/Controllers/Helpers/Grid/TagGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/TagGrid.php @@ -140,7 +140,7 @@ final class TagGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCreateAction() { @@ -175,7 +175,7 @@ final class TagGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/TrackGrid.php b/app/modules/web/Controllers/Helpers/Grid/TrackGrid.php index 0acdfaa2..1583efeb 100644 --- a/app/modules/web/Controllers/Helpers/Grid/TrackGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/TrackGrid.php @@ -150,7 +150,7 @@ final class TrackGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridActionSearch + * @return DataGridActionSearch */ private function getSearchAction() { @@ -167,7 +167,7 @@ final class TrackGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getRefrestAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/UserGrid.php b/app/modules/web/Controllers/Helpers/Grid/UserGrid.php index 89ddb658..ec8e2865 100644 --- a/app/modules/web/Controllers/Helpers/Grid/UserGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/UserGrid.php @@ -153,7 +153,7 @@ final class UserGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getCreateAction() { @@ -188,7 +188,7 @@ final class UserGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getDeleteAction() { @@ -205,7 +205,7 @@ final class UserGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getViewAction() { @@ -222,7 +222,7 @@ final class UserGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Action\DataGridAction + * @return DataGridAction */ private function getEditPassAction() { diff --git a/app/modules/web/Controllers/Helpers/Grid/UserGroupGrid.php b/app/modules/web/Controllers/Helpers/Grid/UserGroupGrid.php index c70d863d..494d5648 100644 --- a/app/modules/web/Controllers/Helpers/Grid/UserGroupGrid.php +++ b/app/modules/web/Controllers/Helpers/Grid/UserGroupGrid.php @@ -98,7 +98,7 @@ final class UserGroupGrid extends GridBase } /** - * @return \SP\Html\DataGrid\Layout\DataGridHeader + * @return DataGridHeader */ protected function getHeader(): DataGridHeader { diff --git a/app/modules/web/Controllers/Helpers/HelperBase.php b/app/modules/web/Controllers/Helpers/HelperBase.php index c127b583..1cac9036 100644 --- a/app/modules/web/Controllers/Helpers/HelperBase.php +++ b/app/modules/web/Controllers/Helpers/HelperBase.php @@ -25,6 +25,8 @@ namespace SP\Modules\Web\Controllers\Helpers; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; use Psr\Container\ContainerInterface; use SP\Config\Config; use SP\Config\ConfigData; @@ -42,7 +44,7 @@ use SP\Mvc\View\Template; abstract class HelperBase { /** - * @var \SP\Mvc\View\Template + * @var Template */ protected $view; /** @@ -73,14 +75,14 @@ abstract class HelperBase /** * Constructor * - * @param \SP\Mvc\View\Template $template - * @param Config $config - * @param ContextInterface $context - * @param EventDispatcher $eventDispatcher - * @param Container $container + * @param Template $template + * @param Config $config + * @param ContextInterface $context + * @param EventDispatcher $eventDispatcher + * @param Container $container * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ final public function __construct(Template $template, Config $config, ContextInterface $context, EventDispatcher $eventDispatcher, Container $container) { diff --git a/app/modules/web/Controllers/Helpers/ItemPresetHelper.php b/app/modules/web/Controllers/Helpers/ItemPresetHelper.php index 60f250e5..9d19031c 100644 --- a/app/modules/web/Controllers/Helpers/ItemPresetHelper.php +++ b/app/modules/web/Controllers/Helpers/ItemPresetHelper.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers\Helpers; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\NoSuchPropertyException; use SP\DataModel\ItemPreset\AccountPermission; use SP\DataModel\ItemPreset\AccountPrivate; use SP\DataModel\ItemPreset\Password; @@ -57,7 +59,7 @@ final class ItemPresetHelper extends HelperBase /** * @param ItemPresetData $itemPresetData * - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws NoSuchPropertyException */ public function makeAccountPermissionView(ItemPresetData $itemPresetData) { @@ -77,7 +79,7 @@ final class ItemPresetHelper extends HelperBase /** * @param ItemPresetData $itemPresetData * - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws NoSuchPropertyException */ public function makeAccountPrivateView(ItemPresetData $itemPresetData) { @@ -92,8 +94,8 @@ final class ItemPresetHelper extends HelperBase /** * @param ItemPresetData $itemPresetData * - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws NoSuchPropertyException + * @throws InvalidArgumentException */ public function makeSessionTimeoutView(ItemPresetData $itemPresetData) { @@ -108,7 +110,7 @@ final class ItemPresetHelper extends HelperBase /** * @param ItemPresetData $itemPresetData * - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws NoSuchPropertyException */ public function makeAccountPasswordView(ItemPresetData $itemPresetData) { diff --git a/app/modules/web/Controllers/Helpers/LayoutHelper.php b/app/modules/web/Controllers/Helpers/LayoutHelper.php index 6e2d850f..7937bbd9 100644 --- a/app/modules/web/Controllers/Helpers/LayoutHelper.php +++ b/app/modules/web/Controllers/Helpers/LayoutHelper.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers\Helpers; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; @@ -396,8 +398,8 @@ final class LayoutHelper extends HelperBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/app/modules/web/Controllers/IndexController.php b/app/modules/web/Controllers/IndexController.php index dff147aa..fde6f617 100644 --- a/app/modules/web/Controllers/IndexController.php +++ b/app/modules/web/Controllers/IndexController.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Modules\Web\Controllers\Helpers\LayoutHelper; /** @@ -36,8 +38,8 @@ final class IndexController extends ControllerBase /** * Index action * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function indexAction() { diff --git a/app/modules/web/Controllers/InstallController.php b/app/modules/web/Controllers/InstallController.php index db50d41f..8acc9c43 100644 --- a/app/modules/web/Controllers/InstallController.php +++ b/app/modules/web/Controllers/InstallController.php @@ -24,6 +24,7 @@ namespace SP\Modules\Web\Controllers; +use Exception; use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\Core\PhpExtensionChecker; @@ -87,7 +88,7 @@ final class InstallController extends ControllerBase $this->dic->get(Installer::class)->run($installData); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Installation finished')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); diff --git a/app/modules/web/Controllers/ItemManagerController.php b/app/modules/web/Controllers/ItemManagerController.php index 8b9ba999..f73f1fa4 100644 --- a/app/modules/web/Controllers/ItemManagerController.php +++ b/app/modules/web/Controllers/ItemManagerController.php @@ -24,9 +24,16 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; +use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\AccountGrid; use SP\Modules\Web\Controllers\Helpers\Grid\AccountHistoryGrid; use SP\Modules\Web\Controllers\Helpers\Grid\CategoryGrid; @@ -39,6 +46,7 @@ use SP\Modules\Web\Controllers\Helpers\TabsGridHelper; use SP\Services\Account\AccountFileService; use SP\Services\Account\AccountHistoryService; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\CustomField\CustomFieldDefService; @@ -62,10 +70,10 @@ final class ItemManagerController extends ControllerBase protected $tabsGridHelper; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ public function indexAction() { @@ -75,10 +83,10 @@ final class ItemManagerController extends ControllerBase /** * Returns a tabbed grid with items * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getGridTabs() { @@ -129,11 +137,11 @@ final class ItemManagerController extends ControllerBase /** * Returns categories' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getCategoriesList() { @@ -145,11 +153,11 @@ final class ItemManagerController extends ControllerBase /** * Returns tags' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getTagsList() { @@ -161,11 +169,11 @@ final class ItemManagerController extends ControllerBase /** * Returns clients' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getClientsList() { @@ -177,11 +185,11 @@ final class ItemManagerController extends ControllerBase /** * Returns custom fields' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getCustomFieldsList() { @@ -193,11 +201,11 @@ final class ItemManagerController extends ControllerBase /** * Returns account files' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getAccountFilesList() { @@ -209,11 +217,11 @@ final class ItemManagerController extends ControllerBase /** * Returns accounts' data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getAccountsList() { @@ -225,11 +233,11 @@ final class ItemManagerController extends ControllerBase /** * Returns accounts' history data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getAccountsHistoryList() { @@ -241,11 +249,11 @@ final class ItemManagerController extends ControllerBase /** * Returns API tokens data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getItemPresetList() { @@ -263,9 +271,9 @@ final class ItemManagerController extends ControllerBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ItemPresetController.php b/app/modules/web/Controllers/ItemPresetController.php index ef72ff92..3bd2d648 100644 --- a/app/modules/web/Controllers/ItemPresetController.php +++ b/app/modules/web/Controllers/ItemPresetController.php @@ -24,9 +24,19 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ItemPresetData; use SP\Http\JsonResponse; @@ -36,6 +46,8 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\ItemsPresetForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\ItemPreset\ItemPresetInterface; use SP\Services\ItemPreset\ItemPresetService; use SP\Util\Filter; @@ -78,7 +90,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.itemPreset', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -93,13 +105,13 @@ final class ItemPresetController extends ControllerBase implements CrudControlle * @param int $id * @param string $type * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws NoSuchItemException */ protected function setViewData(int $id = null, string $type = null) { @@ -145,11 +157,11 @@ final class ItemPresetController extends ControllerBase implements CrudControlle * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -170,10 +182,10 @@ final class ItemPresetController extends ControllerBase implements CrudControlle * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -215,7 +227,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.itemPreset.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -249,7 +261,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.itemPreset.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -296,7 +308,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Value deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -335,7 +347,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Value created')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -378,7 +390,7 @@ final class ItemPresetController extends ControllerBase implements CrudControlle return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Value updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -390,9 +402,9 @@ final class ItemPresetController extends ControllerBase implements CrudControlle /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ItemsController.php b/app/modules/web/Controllers/ItemsController.php index 9e099c4a..b536f0c9 100644 --- a/app/modules/web/Controllers/ItemsController.php +++ b/app/modules/web/Controllers/ItemsController.php @@ -24,6 +24,11 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\DataModelInterface; use SP\DataModel\NotificationData; use SP\Html\Html; @@ -35,6 +40,7 @@ use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\Notification\NotificationService; use SP\Services\Tag\TagService; +use stdClass; /** * Class ItemsController @@ -48,17 +54,17 @@ final class ItemsController extends SimpleControllerBase * * @param int $accountId * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ public function accountsUserAction($accountId = null) { $outItems = []; foreach ($this->dic->get(AccountService::class)->getForUser($accountId) as $account) { - $obj = new \stdClass(); + $obj = new stdClass(); $obj->id = $account->id; $obj->name = $account->clientName . ' - ' . $account->name; @@ -74,11 +80,11 @@ final class ItemsController extends SimpleControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function clientsAction() { @@ -90,11 +96,11 @@ final class ItemsController extends SimpleControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function categoriesAction() { @@ -106,11 +112,11 @@ final class ItemsController extends SimpleControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function notificationsAction() { @@ -143,11 +149,11 @@ final class ItemsController extends SimpleControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function tagsAction() { @@ -179,7 +185,7 @@ final class ItemsController extends SimpleControllerBase /** @var DataModelInterface $item */ foreach ($items as $item) { - $obj = new \stdClass(); + $obj = new stdClass(); $obj->id = $item->getId(); $obj->name = $item->getName(); diff --git a/app/modules/web/Controllers/LoginController.php b/app/modules/web/Controllers/LoginController.php index 57205d0f..ccfc2f16 100644 --- a/app/modules/web/Controllers/LoginController.php +++ b/app/modules/web/Controllers/LoginController.php @@ -24,6 +24,9 @@ namespace SP\Modules\Web\Controllers; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; use SP\Core\Context\SessionContext; use SP\Core\Events\Event; @@ -46,8 +49,8 @@ final class LoginController extends ControllerBase /** * Login action * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function loginAction() { @@ -84,7 +87,7 @@ final class LoginController extends ControllerBase return $this->returnJsonResponseData([ 'url' => $this->session->getTrasientKey('redirect') ?: $loginResponmse->getRedirect() ]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -141,8 +144,8 @@ final class LoginController extends ControllerBase /** * Index action * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function indexAction() { diff --git a/app/modules/web/Controllers/NotificationController.php b/app/modules/web/Controllers/NotificationController.php index adca9e20..6ade8861 100644 --- a/app/modules/web/Controllers/NotificationController.php +++ b/app/modules/web/Controllers/NotificationController.php @@ -24,9 +24,15 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\NotificationData; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\NotificationGrid; @@ -35,6 +41,8 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\NotificationForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\Notification\NotificationService; use SP\Services\User\UserService; @@ -55,11 +63,11 @@ final class NotificationController extends ControllerBase implements CrudControl /** * indexAction * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function indexAction() { @@ -80,10 +88,10 @@ final class NotificationController extends ControllerBase implements CrudControl * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -118,7 +126,7 @@ final class NotificationController extends ControllerBase implements CrudControl $this->eventDispatcher->notifyEvent('show.notification', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -132,9 +140,9 @@ final class NotificationController extends ControllerBase implements CrudControl * * @param $notificationId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ protected function setViewData($notificationId = null) { @@ -161,11 +169,11 @@ final class NotificationController extends ControllerBase implements CrudControl /** * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -202,7 +210,7 @@ final class NotificationController extends ControllerBase implements CrudControl $this->eventDispatcher->notifyEvent('show.notification.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -236,7 +244,7 @@ final class NotificationController extends ControllerBase implements CrudControl $this->eventDispatcher->notifyEvent('show.notification.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -287,7 +295,7 @@ final class NotificationController extends ControllerBase implements CrudControl ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notification deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -322,7 +330,7 @@ final class NotificationController extends ControllerBase implements CrudControl ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notification read')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -355,7 +363,7 @@ final class NotificationController extends ControllerBase implements CrudControl ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notification created')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -392,7 +400,7 @@ final class NotificationController extends ControllerBase implements CrudControl ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Notification updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -402,9 +410,9 @@ final class NotificationController extends ControllerBase implements CrudControl } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/PluginController.php b/app/modules/web/Controllers/PluginController.php index b6ad3d3f..7c494314 100644 --- a/app/modules/web/Controllers/PluginController.php +++ b/app/modules/web/Controllers/PluginController.php @@ -24,17 +24,25 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\PluginGrid; use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Plugin\PluginManager; +use SP\Repositories\NoSuchItemException; use SP\Repositories\Plugin\PluginModel; +use SP\Services\Auth\AuthException; use SP\Services\Plugin\PluginDataService; use SP\Services\Plugin\PluginService; @@ -59,11 +67,11 @@ final class PluginController extends ControllerBase /** * indexAction * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function indexAction() { @@ -84,10 +92,10 @@ final class PluginController extends ControllerBase * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -102,11 +110,11 @@ final class PluginController extends ControllerBase * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -146,7 +154,7 @@ final class PluginController extends ControllerBase $this->eventDispatcher->notifyEvent('show.plugin', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -160,11 +168,11 @@ final class PluginController extends ControllerBase * * @param $pluginId * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ protected function setViewData($pluginId = null) { @@ -207,7 +215,7 @@ final class PluginController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin enabled')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -236,7 +244,7 @@ final class PluginController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin disabled')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -266,7 +274,7 @@ final class PluginController extends ControllerBase ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin reset')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -304,7 +312,7 @@ final class PluginController extends ControllerBase return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Plugin deleted')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -316,7 +324,7 @@ final class PluginController extends ControllerBase /** * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/PublicLinkController.php b/app/modules/web/Controllers/PublicLinkController.php index 3a450042..ac43839d 100644 --- a/app/modules/web/Controllers/PublicLinkController.php +++ b/app/modules/web/Controllers/PublicLinkController.php @@ -24,10 +24,18 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use RuntimeException; use SP\Bootstrap; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\PublicLinkData; @@ -40,6 +48,7 @@ use SP\Modules\Web\Forms\PublicLinkForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; use SP\Services\Account\AccountService; +use SP\Services\Auth\AuthException; use SP\Services\PublicLink\PublicLinkService; use SP\Util\PasswordUtil; @@ -61,10 +70,10 @@ final class PublicLinkController extends ControllerBase implements CrudControlle * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException * @throws SPException */ public function searchAction() @@ -86,10 +95,10 @@ final class PublicLinkController extends ControllerBase implements CrudControlle * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -121,7 +130,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.publicLink.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -135,7 +144,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle * * @param $publicLinkId * - * @throws \Psr\Container\ContainerExceptionInterface + * @throws ContainerExceptionInterface * @throws SPException */ protected function setViewData($publicLinkId = null) @@ -183,7 +192,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('edit.publicLink.refresh', new Event($this)); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Link updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -217,7 +226,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.publicLink.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -266,7 +275,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Link deleted')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -297,7 +306,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Link created')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -334,7 +343,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('create.publicLink.account', new Event($this)); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Link created')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -350,7 +359,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle */ public function saveEditAction($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -377,7 +386,7 @@ final class PublicLinkController extends ControllerBase implements CrudControlle $this->eventDispatcher->notifyEvent('show.publicLink', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -389,9 +398,9 @@ final class PublicLinkController extends ControllerBase implements CrudControlle /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/ResourceController.php b/app/modules/web/Controllers/ResourceController.php index eb74dad9..41541989 100644 --- a/app/modules/web/Controllers/ResourceController.php +++ b/app/modules/web/Controllers/ResourceController.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Exceptions\SPException; use SP\Html\Minify; @@ -124,8 +126,8 @@ final class ResourceController extends SimpleControllerBase /** * @throws SPException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize() { diff --git a/app/modules/web/Controllers/SecurityManagerController.php b/app/modules/web/Controllers/SecurityManagerController.php index 56339f18..3a3015f9 100644 --- a/app/modules/web/Controllers/SecurityManagerController.php +++ b/app/modules/web/Controllers/SecurityManagerController.php @@ -24,12 +24,20 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; +use SP\Html\DataGrid\DataGridTab; use SP\Modules\Web\Controllers\Helpers\Grid\EventlogGrid; use SP\Modules\Web\Controllers\Helpers\Grid\TrackGrid; use SP\Modules\Web\Controllers\Helpers\TabsGridHelper; +use SP\Services\Auth\AuthException; use SP\Services\EventLog\EventlogService; use SP\Services\Track\TrackService; @@ -50,10 +58,10 @@ final class SecurityManagerController extends ControllerBase protected $tabsGridHelper; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ public function indexAction() { @@ -63,10 +71,10 @@ final class SecurityManagerController extends ControllerBase /** * Returns a tabbed grid with items * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getGridTabs() { @@ -95,11 +103,11 @@ final class SecurityManagerController extends ControllerBase /** * Returns eventlog data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getEventlogList() { @@ -111,11 +119,11 @@ final class SecurityManagerController extends ControllerBase /** * Returns tracks data tab * - * @return \SP\Html\DataGrid\DataGridTab - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return DataGridTab + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getTracksList() { @@ -133,9 +141,9 @@ final class SecurityManagerController extends ControllerBase } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/StatusController.php b/app/modules/web/Controllers/StatusController.php index 8aa9c109..32f955f4 100644 --- a/app/modules/web/Controllers/StatusController.php +++ b/app/modules/web/Controllers/StatusController.php @@ -24,6 +24,8 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use SP\Core\AppInfoInterface; @@ -45,8 +47,8 @@ final class StatusController extends SimpleControllerBase * checkReleaseAction * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function checkReleaseAction() { @@ -104,8 +106,8 @@ final class StatusController extends SimpleControllerBase * checkNoticesAction * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function checkNoticesAction() { diff --git a/app/modules/web/Controllers/TagController.php b/app/modules/web/Controllers/TagController.php index e8da64ac..b98f4ba2 100644 --- a/app/modules/web/Controllers/TagController.php +++ b/app/modules/web/Controllers/TagController.php @@ -24,8 +24,16 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\TagData; use SP\Http\JsonResponse; @@ -34,6 +42,8 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\TagForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; use SP\Services\Tag\TagService; /** @@ -54,11 +64,11 @@ final class TagController extends ControllerBase implements CrudControllerInterf * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -79,10 +89,10 @@ final class TagController extends ControllerBase implements CrudControllerInterf * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -114,7 +124,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf $this->eventDispatcher->notifyEvent('show.tag.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -128,9 +138,9 @@ final class TagController extends ControllerBase implements CrudControllerInterf * * @param $tagId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ protected function setViewData($tagId = null) { @@ -176,7 +186,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf $this->eventDispatcher->notifyEvent('show.tag.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -218,7 +228,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Tag removed')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -249,7 +259,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Tag added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -284,7 +294,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Tag updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -317,7 +327,7 @@ final class TagController extends ControllerBase implements CrudControllerInterf $this->eventDispatcher->notifyEvent('show.tag', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -329,9 +339,9 @@ final class TagController extends ControllerBase implements CrudControllerInterf /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/TaskController.php b/app/modules/web/Controllers/TaskController.php index 765b9a79..15d755e7 100644 --- a/app/modules/web/Controllers/TaskController.php +++ b/app/modules/web/Controllers/TaskController.php @@ -29,6 +29,7 @@ use Psr\Container\ContainerInterface; use SP\Services\ServiceException; use SP\Services\Task\TaskFactory; use SP\Services\Task\TaskService; +use SP\Storage\File\FileException; /** * Class TaskController @@ -86,7 +87,7 @@ final class TaskController /** * @param $taskId * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testTaskAction($taskId) { diff --git a/app/modules/web/Controllers/TrackController.php b/app/modules/web/Controllers/TrackController.php index a34e547c..e11d7230 100644 --- a/app/modules/web/Controllers/TrackController.php +++ b/app/modules/web/Controllers/TrackController.php @@ -24,13 +24,20 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Acl; use SP\Core\Acl\UnauthorizedActionException; use SP\Core\Events\Event; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\Grid\TrackGrid; use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; +use SP\Services\Auth\AuthException; use SP\Services\Track\TrackService; /** @@ -51,12 +58,12 @@ final class TrackController extends ControllerBase * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException * @throws UnauthorizedActionException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function searchAction() { @@ -77,10 +84,10 @@ final class TrackController extends ControllerBase * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -112,7 +119,7 @@ final class TrackController extends ControllerBase $this->eventDispatcher->notifyEvent('unlock.track', new Event($this)); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Track unlocked')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -140,7 +147,7 @@ final class TrackController extends ControllerBase $this->eventDispatcher->notifyEvent('clear.track', new Event($this)); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Tracks cleared out')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -150,9 +157,9 @@ final class TrackController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/Traits/ConfigTrait.php b/app/modules/web/Controllers/Traits/ConfigTrait.php index 30fed2ce..ae1ae933 100644 --- a/app/modules/web/Controllers/Traits/ConfigTrait.php +++ b/app/modules/web/Controllers/Traits/ConfigTrait.php @@ -24,6 +24,7 @@ namespace SP\Modules\Web\Controllers\Traits; +use Exception; use SP\Bootstrap; use SP\Config\Config; use SP\Config\ConfigData; @@ -66,7 +67,7 @@ trait ConfigTrait } return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Configuration updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Error while saving the configuration')); diff --git a/app/modules/web/Controllers/Traits/ItemTrait.php b/app/modules/web/Controllers/Traits/ItemTrait.php index 109ef22e..dc3bd49a 100644 --- a/app/modules/web/Controllers/Traits/ItemTrait.php +++ b/app/modules/web/Controllers/Traits/ItemTrait.php @@ -25,13 +25,19 @@ namespace SP\Modules\Web\Controllers\Traits; use Defuse\Crypto\Exception\CryptoException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldData; use SP\DataModel\ItemSearchData; use SP\Http\Request; +use SP\Repositories\NoSuchItemException; use SP\Services\CustomField\CustomFieldItem; use SP\Services\CustomField\CustomFieldService; +use SP\Services\ServiceException; use SP\Util\Filter; /** @@ -48,9 +54,9 @@ trait ItemTrait * @param int $itemId * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ protected function getCustomFieldsForItem($moduleId, $itemId) { @@ -99,10 +105,10 @@ trait ItemTrait * @param Request $request * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException */ protected function addCustomFieldsForItem($moduleId, $itemId, Request $request) { @@ -138,8 +144,8 @@ trait ItemTrait * @param int|int[] $itemId * * @throws SPException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function deleteCustomFieldsForItem($moduleId, $itemId) { @@ -160,8 +166,8 @@ trait ItemTrait * @param Request $request * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ protected function updateCustomFieldsForItem($moduleId, $itemId, Request $request) { diff --git a/app/modules/web/Controllers/Traits/JsonTrait.php b/app/modules/web/Controllers/Traits/JsonTrait.php index 22920800..0d02e72d 100644 --- a/app/modules/web/Controllers/Traits/JsonTrait.php +++ b/app/modules/web/Controllers/Traits/JsonTrait.php @@ -24,6 +24,7 @@ namespace SP\Modules\Web\Controllers\Traits; +use Exception; use SP\Core\Context\SessionContext; use SP\Core\Exceptions\SPException; use SP\Http\Json; @@ -97,12 +98,12 @@ trait JsonTrait /** * Returns JSON response * - * @param \Exception $exception + * @param Exception $exception * @param int $status Status code * * @return bool */ - protected function returnJsonResponseException(\Exception $exception, $status = JsonResponse::JSON_ERROR) + protected function returnJsonResponseException(Exception $exception, $status = JsonResponse::JSON_ERROR) { $jsonResponse = new JsonResponse(); $jsonResponse->setStatus($status); diff --git a/app/modules/web/Controllers/UpgradeController.php b/app/modules/web/Controllers/UpgradeController.php index a0e52b27..ab69b8cf 100644 --- a/app/modules/web/Controllers/UpgradeController.php +++ b/app/modules/web/Controllers/UpgradeController.php @@ -24,12 +24,16 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\Actions; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Helpers\LayoutHelper; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Services\Upgrade\UpgradeAppService; use SP\Services\Upgrade\UpgradeDatabaseService; +use SP\Storage\File\FileException; /** * Class UpgradeController @@ -43,9 +47,9 @@ final class UpgradeController extends ControllerBase /** * indexAction * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws FileException */ public function indexAction() { @@ -101,7 +105,7 @@ final class UpgradeController extends ControllerBase __u('Application successfully updated'), [__u('You will be redirected to log in within 5 seconds')] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $this->returnJsonResponseException($e); diff --git a/app/modules/web/Controllers/UserController.php b/app/modules/web/Controllers/UserController.php index 64a1153f..9a465f1a 100644 --- a/app/modules/web/Controllers/UserController.php +++ b/app/modules/web/Controllers/UserController.php @@ -24,9 +24,18 @@ namespace SP\Modules\Web\Controllers; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\UserData; use SP\Http\JsonResponse; @@ -36,7 +45,9 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\UserForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Services\Auth\AuthException; use SP\Services\Mail\MailService; +use SP\Services\ServiceException; use SP\Services\User\UserService; use SP\Services\UserGroup\UserGroupService; use SP\Services\UserPassRecover\UserPassRecoverService; @@ -61,11 +72,11 @@ final class UserController extends ControllerBase implements CrudControllerInter * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -86,10 +97,10 @@ final class UserController extends ControllerBase implements CrudControllerInter * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -121,7 +132,7 @@ final class UserController extends ControllerBase implements CrudControllerInter $this->eventDispatcher->notifyEvent('show.user.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -135,8 +146,8 @@ final class UserController extends ControllerBase implements CrudControllerInter * * @param $userId * - * @throws \SP\Core\Exceptions\SPException - * @throws \Psr\Container\ContainerExceptionInterface + * @throws SPException + * @throws ContainerExceptionInterface */ protected function setViewData($userId = null) { @@ -208,7 +219,7 @@ final class UserController extends ControllerBase implements CrudControllerInter $this->eventDispatcher->notifyEvent('show.user.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -247,7 +258,7 @@ final class UserController extends ControllerBase implements CrudControllerInter $this->eventDispatcher->notifyEvent('show.user.editPass', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -299,7 +310,7 @@ final class UserController extends ControllerBase implements CrudControllerInter return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('User deleted')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -340,7 +351,7 @@ final class UserController extends ControllerBase implements CrudControllerInter return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('User added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -353,12 +364,12 @@ final class UserController extends ControllerBase implements CrudControllerInter * @param int $userId * @param UserData $userData * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ protected function checkChangeUserPass(int $userId, UserData $userData) { @@ -408,7 +419,7 @@ final class UserController extends ControllerBase implements CrudControllerInter return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('User updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -449,7 +460,7 @@ final class UserController extends ControllerBase implements CrudControllerInter return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Password updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -482,7 +493,7 @@ final class UserController extends ControllerBase implements CrudControllerInter $this->eventDispatcher->notifyEvent('show.user', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -492,9 +503,9 @@ final class UserController extends ControllerBase implements CrudControllerInter } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserGroupController.php b/app/modules/web/Controllers/UserGroupController.php index aea5b443..2ff420a3 100644 --- a/app/modules/web/Controllers/UserGroupController.php +++ b/app/modules/web/Controllers/UserGroupController.php @@ -24,10 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\UserGroupData; use SP\Http\JsonResponse; @@ -37,6 +44,9 @@ use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\UserGroupForm; use SP\Mvc\Controller\CrudControllerInterface; use SP\Mvc\View\Components\SelectItemAdapter; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; +use SP\Services\ServiceException; use SP\Services\User\UserService; use SP\Services\UserGroup\UserGroupService; use SP\Services\UserGroup\UserToUserGroupService; @@ -64,10 +74,10 @@ final class UserGroupController extends ControllerBase implements CrudController * * @return bool * @throws ConstraintException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -88,10 +98,10 @@ final class UserGroupController extends ControllerBase implements CrudController * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ protected function getSearchGrid() { @@ -123,7 +133,7 @@ final class UserGroupController extends ControllerBase implements CrudController $this->eventDispatcher->notifyEvent('show.userGroup.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -138,9 +148,9 @@ final class UserGroupController extends ControllerBase implements CrudController * @param $userGroupId * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws QueryException + * @throws ServiceException + * @throws NoSuchItemException */ protected function setViewData($userGroupId = null) { @@ -196,7 +206,7 @@ final class UserGroupController extends ControllerBase implements CrudController $this->eventDispatcher->notifyEvent('show.userGroup.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -245,7 +255,7 @@ final class UserGroupController extends ControllerBase implements CrudController return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group deleted')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -284,7 +294,7 @@ final class UserGroupController extends ControllerBase implements CrudController return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -328,7 +338,7 @@ final class UserGroupController extends ControllerBase implements CrudController return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Group updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -361,7 +371,7 @@ final class UserGroupController extends ControllerBase implements CrudController $this->eventDispatcher->notifyEvent('show.userGroup', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -373,9 +383,9 @@ final class UserGroupController extends ControllerBase implements CrudController /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserPassResetController.php b/app/modules/web/Controllers/UserPassResetController.php index fc8eaeb9..9be5c67a 100644 --- a/app/modules/web/Controllers/UserPassResetController.php +++ b/app/modules/web/Controllers/UserPassResetController.php @@ -24,8 +24,14 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\InvalidArgumentException; use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\Http\JsonResponse; @@ -58,8 +64,8 @@ final class UserPassResetController extends ControllerBase /** * Password reset action * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function indexAction() { @@ -119,7 +125,7 @@ final class UserPassResetController extends ControllerBase __u('Request sent'), [__u('You will receive an email to complete the request shortly.')] ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->addTracking(); @@ -135,7 +141,7 @@ final class UserPassResetController extends ControllerBase /** * @throws SPException - * @throws \Exception + * @throws Exception */ protected function checkTracking() { @@ -151,7 +157,7 @@ final class UserPassResetController extends ControllerBase { try { $this->trackService->add($this->trackRequest); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -159,8 +165,8 @@ final class UserPassResetController extends ControllerBase /** * @param null $hash * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function resetAction($hash = null) { @@ -221,7 +227,7 @@ final class UserPassResetController extends ControllerBase JsonResponse::JSON_SUCCESS, __u('Password updated') ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->addTracking(); @@ -233,9 +239,9 @@ final class UserPassResetController extends ControllerBase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws DependencyException + * @throws NotFoundException + * @throws InvalidArgumentException */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserProfileController.php b/app/modules/web/Controllers/UserProfileController.php index 628d85c6..38a48a7b 100644 --- a/app/modules/web/Controllers/UserProfileController.php +++ b/app/modules/web/Controllers/UserProfileController.php @@ -24,9 +24,17 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ProfileData; use SP\DataModel\UserProfileData; @@ -36,6 +44,9 @@ use SP\Modules\Web\Controllers\Traits\ItemTrait; use SP\Modules\Web\Controllers\Traits\JsonTrait; use SP\Modules\Web\Forms\UserProfileForm; use SP\Mvc\Controller\CrudControllerInterface; +use SP\Repositories\NoSuchItemException; +use SP\Services\Auth\AuthException; +use SP\Services\ServiceException; use SP\Services\UserProfile\UserProfileService; /** @@ -56,11 +67,11 @@ final class UserProfileController extends ControllerBase implements CrudControll * Search action * * @return bool - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function searchAction() { @@ -81,10 +92,10 @@ final class UserProfileController extends ControllerBase implements CrudControll * getSearchGrid * * @return $this - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws DependencyException + * @throws NotFoundException + * @throws ConstraintException + * @throws QueryException */ protected function getSearchGrid() { @@ -116,7 +127,7 @@ final class UserProfileController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('show.userProfile.create', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -130,10 +141,10 @@ final class UserProfileController extends ControllerBase implements CrudControll * * @param $profileId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException + * @throws NoSuchItemException */ protected function setViewData($profileId = null) { @@ -185,7 +196,7 @@ final class UserProfileController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('show.userProfile.edit', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -234,7 +245,7 @@ final class UserProfileController extends ControllerBase implements CrudControll ); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile deleted')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -275,7 +286,7 @@ final class UserProfileController extends ControllerBase implements CrudControll return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile added')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -319,7 +330,7 @@ final class UserProfileController extends ControllerBase implements CrudControll return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Profile updated')); } catch (ValidationException $e) { return $this->returnJsonResponseException($e); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -352,7 +363,7 @@ final class UserProfileController extends ControllerBase implements CrudControll $this->eventDispatcher->notifyEvent('show.userProfile', new Event($this)); return $this->returnJsonResponseData(['html' => $this->render()]); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -364,9 +375,9 @@ final class UserProfileController extends ControllerBase implements CrudControll /** * Initialize class * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Services\Auth\AuthException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws AuthException */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserSettingsGeneralController.php b/app/modules/web/Controllers/UserSettingsGeneralController.php index 47372d90..f8f6d63f 100644 --- a/app/modules/web/Controllers/UserSettingsGeneralController.php +++ b/app/modules/web/Controllers/UserSettingsGeneralController.php @@ -24,6 +24,9 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Events\Event; use SP\Http\JsonResponse; use SP\Modules\Web\Controllers\Traits\JsonTrait; @@ -73,7 +76,7 @@ final class UserSettingsGeneralController extends SimpleControllerBase $userData->setPreferences($userPreferencesData); return $this->returnJsonResponse(JsonResponse::JSON_SUCCESS, __u('Preferences updated')); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -85,8 +88,8 @@ final class UserSettingsGeneralController extends SimpleControllerBase /** * initialize * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize() { diff --git a/app/modules/web/Controllers/UserSettingsManagerController.php b/app/modules/web/Controllers/UserSettingsManagerController.php index ebf4a200..7dc57c7c 100644 --- a/app/modules/web/Controllers/UserSettingsManagerController.php +++ b/app/modules/web/Controllers/UserSettingsManagerController.php @@ -24,15 +24,19 @@ namespace SP\Modules\Web\Controllers; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\Acl; use SP\Core\Events\Event; use SP\Core\Events\EventDispatcherInterface; +use SP\Core\Exceptions\SessionTimeout; use SP\Core\Language; use SP\Modules\Web\Controllers\Helpers\TabsHelper; use SP\Mvc\Controller\ExtensibleTabControllerInterface; use SP\Mvc\View\Components\DataTab; use SP\Mvc\View\Components\SelectItemAdapter; use SP\Mvc\View\Template; +use SP\Services\Auth\AuthException; /** * Class UserSettingsManagerController @@ -47,8 +51,8 @@ final class UserSettingsManagerController extends ControllerBase implements Exte protected $tabsHelper; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function indexAction() { @@ -58,8 +62,8 @@ final class UserSettingsManagerController extends ControllerBase implements Exte /** * Returns a tabbed grid with items * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function getTabs() { @@ -127,10 +131,10 @@ final class UserSettingsManagerController extends ControllerBase implements Exte } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Exceptions\SessionTimeout - * @throws \SP\Services\Auth\AuthException + * @throws DependencyException + * @throws NotFoundException + * @throws SessionTimeout + * @throws AuthException */ protected function initialize() { diff --git a/lib/SP/Bootstrap.php b/lib/SP/Bootstrap.php index 63e3558b..9c638e12 100644 --- a/lib/SP/Bootstrap.php +++ b/lib/SP/Bootstrap.php @@ -25,6 +25,8 @@ namespace SP; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; use Klein\Klein; use Klein\Response; use PHPMailer\PHPMailer\Exception; @@ -50,6 +52,7 @@ use SP\Util\Checks; use SP\Util\Filter; use SP\Util\VersionUtil; use Symfony\Component\Debug\Debug; +use Throwable; defined('APP_ROOT') || die(); @@ -110,8 +113,8 @@ final class Bootstrap * * @param Container $container * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private final function __construct(Container $container) { @@ -139,7 +142,7 @@ final class Bootstrap $this->router->onError(function ($router, $err_msg, $type, $err) { logger('Routing error: ' . $err_msg); - /** @var Exception|\Throwable $err */ + /** @var Exception|Throwable $err */ logger('Routing error: ' . $err->getTraceAsString()); /** @var Klein $router */ @@ -264,8 +267,8 @@ final class Bootstrap * @throws Core\Exceptions\CheckException * @throws InitializationException * @throws Services\Upgrade\UpgradeException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException * @throws Storage\File\FileException */ protected function initializeCommon() @@ -386,8 +389,8 @@ final class Bootstrap * @throws ConfigException * @throws Services\Upgrade\UpgradeException * @throws Storage\File\FileException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private function initConfig() { @@ -401,8 +404,8 @@ final class Bootstrap * * @throws Services\Upgrade\UpgradeException * @throws Storage\File\FileException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ private function checkConfigVersion() { @@ -446,8 +449,8 @@ final class Bootstrap * @param string $module * * @throws InitializationException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public static function run(Container $container, $module = APP_MODULE) { diff --git a/lib/SP/Config/Config.php b/lib/SP/Config/Config.php index 88b478ed..a6af6e2a 100644 --- a/lib/SP/Config/Config.php +++ b/lib/SP/Config/Config.php @@ -24,6 +24,8 @@ namespace SP\Config; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Exception; use Psr\Container\ContainerInterface; use ReflectionObject; use SP\Core\Context\ContextInterface; @@ -127,7 +129,7 @@ final class Config self::$timeUpdated = $this->configData->getConfigDate(); $this->configLoaded = true; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new ConfigException($e->getMessage(), @@ -275,7 +277,7 @@ final class Config /** * @return Config * @throws FileException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function generateUpgradeKey() { diff --git a/lib/SP/Config/ConfigUtil.php b/lib/SP/Config/ConfigUtil.php index 4d3f56db..124175a4 100644 --- a/lib/SP/Config/ConfigUtil.php +++ b/lib/SP/Config/ConfigUtil.php @@ -92,7 +92,7 @@ final class ConfigUtil * Comprobar el archivo de configuración. * Esta función comprueba que el archivo de configuración exista y los permisos sean correctos. * - * @throws \SP\Core\Exceptions\ConfigException + * @throws ConfigException */ public static function checkConfigDir() { diff --git a/lib/SP/Core/Acl/AccountPermissionException.php b/lib/SP/Core/Acl/AccountPermissionException.php index 40313dad..b7407684 100644 --- a/lib/SP/Core/Acl/AccountPermissionException.php +++ b/lib/SP/Core/Acl/AccountPermissionException.php @@ -24,6 +24,7 @@ namespace SP\Core\Acl; +use Exception; use SP\Core\Exceptions\SPException; /** @@ -38,9 +39,9 @@ final class AccountPermissionException extends SPException * * @param string $type * @param int $code - * @param \Exception|null $previous + * @param Exception|null $previous */ - public function __construct($type, $code = 0, \Exception $previous = null) + public function __construct($type, $code = 0, Exception $previous = null) { parent::__construct(__u('You don\'t have permission to access this account'), $type, __u('Please contact to the administrator'), $code, $previous); } diff --git a/lib/SP/Core/Acl/Actions.php b/lib/SP/Core/Acl/Actions.php index 8dd67e4f..81555235 100644 --- a/lib/SP/Core/Acl/Actions.php +++ b/lib/SP/Core/Acl/Actions.php @@ -24,6 +24,7 @@ namespace SP\Core\Acl; +use RuntimeException; use SP\DataModel\ActionData; use SP\Storage\File\FileCacheInterface; use SP\Storage\File\FileException; @@ -53,7 +54,7 @@ final class Actions */ protected $actions; /** - * @var \SP\Storage\File\XmlFileStorageInterface + * @var XmlFileStorageInterface */ protected $xmlFileStorage; /** @@ -64,8 +65,8 @@ final class Actions /** * Action constructor. * - * @param FileCacheInterface $fileCache - * @param \SP\Storage\File\XmlFileStorageInterface $xmlFileStorage + * @param FileCacheInterface $fileCache + * @param XmlFileStorageInterface $xmlFileStorage * * @throws FileException */ @@ -124,7 +125,7 @@ final class Actions foreach ($this->load() as $a) { if (isset($this->actions[$a['id']])) { - throw new \RuntimeException('Duplicated action id: ' . $a['id']); + throw new RuntimeException('Duplicated action id: ' . $a['id']); } $action = new ActionData(); diff --git a/lib/SP/Core/Acl/UnauthorizedActionException.php b/lib/SP/Core/Acl/UnauthorizedActionException.php index fa84bc9c..b460d800 100644 --- a/lib/SP/Core/Acl/UnauthorizedActionException.php +++ b/lib/SP/Core/Acl/UnauthorizedActionException.php @@ -25,6 +25,7 @@ namespace SP\Core\Acl; +use Exception; use SP\Core\Exceptions\SPException; /** @@ -39,9 +40,9 @@ final class UnauthorizedActionException extends SPException * * @param string $type * @param int $code - * @param \Exception|null $previous + * @param Exception|null $previous */ - public function __construct($type, $code = 0, \Exception $previous = null) + public function __construct($type, $code = 0, Exception $previous = null) { parent::__construct(__u('You don\'t have permission to do this operation'), $type, __u('Please contact to the administrator'), $code, $previous); } diff --git a/lib/SP/Core/Acl/UnauthorizedPageException.php b/lib/SP/Core/Acl/UnauthorizedPageException.php index 9364687f..bb76c35d 100644 --- a/lib/SP/Core/Acl/UnauthorizedPageException.php +++ b/lib/SP/Core/Acl/UnauthorizedPageException.php @@ -24,6 +24,7 @@ namespace SP\Core\Acl; +use Exception; use SP\Core\Exceptions\SPException; /** @@ -38,9 +39,9 @@ final class UnauthorizedPageException extends SPException * * @param string $type * @param int $code - * @param \Exception|null $previous + * @param Exception|null $previous */ - public function __construct($type, $code = 0, \Exception $previous = null) + public function __construct($type, $code = 0, Exception $previous = null) { parent::__construct(__u('You don\'t have permission to access this page'), $type, __u('Please contact to the administrator'), $code, $previous); } diff --git a/lib/SP/Core/Crypt/CryptPKI.php b/lib/SP/Core/Crypt/CryptPKI.php index b60537c1..5abd044b 100644 --- a/lib/SP/Core/Crypt/CryptPKI.php +++ b/lib/SP/Core/Crypt/CryptPKI.php @@ -117,7 +117,7 @@ final class CryptPKI * @param string $data los datos a encriptar * * @return string - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function encryptRSA($data) { @@ -131,7 +131,7 @@ final class CryptPKI * Devuelve la clave pública desde el archivo * * @return string - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function getPublicKey() { @@ -146,7 +146,7 @@ final class CryptPKI * @param string $data los datos a desencriptar * * @return string - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function decryptRSA($data) { @@ -160,7 +160,7 @@ final class CryptPKI * Devuelve la clave privada desde el archivo * * @return string - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function getPrivateKey() { diff --git a/lib/SP/Core/Crypt/CryptSessionHandler.php b/lib/SP/Core/Crypt/CryptSessionHandler.php index 7f64c9a1..2adaf5d4 100644 --- a/lib/SP/Core/Crypt/CryptSessionHandler.php +++ b/lib/SP/Core/Crypt/CryptSessionHandler.php @@ -26,13 +26,14 @@ namespace SP\Core\Crypt; use Defuse\Crypto\Exception\CryptoException; use Defuse\Crypto\Key; +use SessionHandler; /** * Class CryptSessionHandler * * @package SP\Core\Crypt */ -final class CryptSessionHandler extends \SessionHandler +final class CryptSessionHandler extends SessionHandler { /** * @var bool Indica si la sesión está encriptada diff --git a/lib/SP/Core/Crypt/SecureKeyCookie.php b/lib/SP/Core/Crypt/SecureKeyCookie.php index 675318bc..669f9d3f 100644 --- a/lib/SP/Core/Crypt/SecureKeyCookie.php +++ b/lib/SP/Core/Crypt/SecureKeyCookie.php @@ -25,6 +25,7 @@ namespace SP\Core\Crypt; use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use Defuse\Crypto\Key; use SP\Http\Request; @@ -141,7 +142,7 @@ final class SecureKeyCookie extends Cookie /** * @return Vault * @throws CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function generateSecuredData() { diff --git a/lib/SP/Core/Crypt/Session.php b/lib/SP/Core/Crypt/Session.php index fb97da8e..c3814e72 100644 --- a/lib/SP/Core/Crypt/Session.php +++ b/lib/SP/Core/Crypt/Session.php @@ -24,6 +24,7 @@ namespace SP\Core\Crypt; +use Defuse\Crypto\Exception\CryptoException; use SP\Core\Context\SessionContext; /** @@ -39,7 +40,7 @@ final class Session * @param SessionContext $sessionContext * * @return string - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public static function getSessionKey(SessionContext $sessionContext) { @@ -62,7 +63,7 @@ final class Session * @param $data * @param SessionContext $sessionContext * - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public static function saveSessionKey($data, SessionContext $sessionContext) { @@ -74,7 +75,7 @@ final class Session * * @param SessionContext $sessionContext * - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public static function reKey(SessionContext $sessionContext) { diff --git a/lib/SP/Core/Crypt/Vault.php b/lib/SP/Core/Crypt/Vault.php index 8a94788e..61f14098 100644 --- a/lib/SP/Core/Crypt/Vault.php +++ b/lib/SP/Core/Crypt/Vault.php @@ -24,6 +24,8 @@ namespace SP\Core\Crypt; +use Defuse\Crypto\Exception\CryptoException; + /** * Class Vault * @@ -63,7 +65,7 @@ final class Vault * @param string $oldSeed * * @return Vault - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function reKey($newSeed, $oldSeed) { @@ -78,10 +80,10 @@ final class Vault /** * Devolver la clave maestra de la sesión * - * @param string $key + * @param string $key * * @return string - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function getData($key) { @@ -91,11 +93,11 @@ final class Vault /** * Guardar la clave maestra en la sesión * - * @param mixed $data - * @param string $key + * @param mixed $data + * @param string $key * * @return $this - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function saveData($data, $key) { diff --git a/lib/SP/Core/DataCollection.php b/lib/SP/Core/DataCollection.php index aa1d7a8f..44f6dcce 100644 --- a/lib/SP/Core/DataCollection.php +++ b/lib/SP/Core/DataCollection.php @@ -247,11 +247,11 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab * Allows the ability to arbitrarily request an attribute from * this instance while treating it as an instance property * - * @see get() - * * @param string $key The name of the parameter to return * * @return mixed + * @see get() + * */ public function __get($key) { @@ -264,12 +264,12 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab * Allows the ability to arbitrarily set an attribute from * this instance while treating it as an instance property * - * @see set() - * * @param string $key The name of the parameter to set * @param mixed $value The value of the parameter to set * * @return void + * @see set() + * */ public function __set($key, $value) { @@ -282,11 +282,11 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab * Allows the ability to arbitrarily check the existence of an attribute * from this instance while treating it as an instance property * - * @see exists() - * * @param string $key The name of the parameter * * @return boolean + * @see exists() + * */ public function __isset($key) { @@ -299,11 +299,11 @@ abstract class DataCollection implements IteratorAggregate, ArrayAccess, Countab * Allows the ability to arbitrarily remove an attribute from * this instance while treating it as an instance property * - * @see remove() - * * @param string $key The name of the parameter * * @return void + * @see remove() + * */ public function __unset($key) { diff --git a/lib/SP/Core/Events/EventDispatcherInterface.php b/lib/SP/Core/Events/EventDispatcherInterface.php index eadf4230..50a69d84 100644 --- a/lib/SP/Core/Events/EventDispatcherInterface.php +++ b/lib/SP/Core/Events/EventDispatcherInterface.php @@ -24,12 +24,14 @@ namespace SP\Core\Events; +use SplSubject; + /** * Interface EventDispatcherInterface * * @package SP\Core\EventDispatcher */ -interface EventDispatcherInterface extends \SplSubject +interface EventDispatcherInterface extends SplSubject { /** * Notificar a los observadores y establecer el estado diff --git a/lib/SP/Core/Exceptions/CheckException.php b/lib/SP/Core/Exceptions/CheckException.php index f0ccfee1..7e80470e 100644 --- a/lib/SP/Core/Exceptions/CheckException.php +++ b/lib/SP/Core/Exceptions/CheckException.php @@ -26,6 +26,7 @@ namespace SP\Core\Exceptions; /** * Class CheckException + * * @package SP\Core\Exceptions */ class CheckException extends SPException diff --git a/lib/SP/Core/Exceptions/ItemException.php b/lib/SP/Core/Exceptions/ItemException.php index c20a23f1..e6fb668a 100644 --- a/lib/SP/Core/Exceptions/ItemException.php +++ b/lib/SP/Core/Exceptions/ItemException.php @@ -25,12 +25,14 @@ namespace SP\Core\Exceptions; +use Exception; + /** * Class ItemException * * @package SP\Core\Exceptions */ -final class ItemException extends \Exception +final class ItemException extends Exception { } \ No newline at end of file diff --git a/lib/SP/Core/Exceptions/NoSuchPropertyException.php b/lib/SP/Core/Exceptions/NoSuchPropertyException.php index d1b03e24..0276b832 100644 --- a/lib/SP/Core/Exceptions/NoSuchPropertyException.php +++ b/lib/SP/Core/Exceptions/NoSuchPropertyException.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,12 +24,14 @@ namespace SP\Core\Exceptions; +use Exception; + /** * Class NoSuchPropertyException * * @package SP\Core\Exceptions */ -class NoSuchPropertyException extends \Exception +class NoSuchPropertyException extends Exception { } \ No newline at end of file diff --git a/lib/SP/Core/Exceptions/SPException.php b/lib/SP/Core/Exceptions/SPException.php index a2882649..4c5569a4 100644 --- a/lib/SP/Core/Exceptions/SPException.php +++ b/lib/SP/Core/Exceptions/SPException.php @@ -31,7 +31,7 @@ defined('APP_ROOT') || die(); /** * Extender la clase Exception para mostrar ayuda en los mensajes */ -class SPException extends \Exception +class SPException extends Exception { /** * Constantes para tipos de excepción @@ -59,7 +59,7 @@ class SPException extends \Exception * @param int $code * @param Exception|null $previous */ - public function __construct($message, $type = self::ERROR, $hint = null, $code = 0, \Exception $previous = null) + public function __construct($message, $type = self::ERROR, $hint = null, $code = 0, Exception $previous = null) { $this->type = $type; $this->hint = $hint; diff --git a/lib/SP/Core/Exceptions/SessionTimeout.php b/lib/SP/Core/Exceptions/SessionTimeout.php index 8b2dcfc9..09233bc1 100644 --- a/lib/SP/Core/Exceptions/SessionTimeout.php +++ b/lib/SP/Core/Exceptions/SessionTimeout.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,12 +24,14 @@ namespace SP\Core\Exceptions; +use Exception; + /** * Class SessionTimeout * * @package SP\Core\Exceptions */ -final class SessionTimeout extends \Exception +final class SessionTimeout extends Exception { } \ No newline at end of file diff --git a/lib/SP/Core/ModuleBase.php b/lib/SP/Core/ModuleBase.php index d234c57b..44657579 100644 --- a/lib/SP/Core/ModuleBase.php +++ b/lib/SP/Core/ModuleBase.php @@ -25,10 +25,13 @@ namespace SP\Core; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; use Klein\Klein; use Psr\Container\ContainerInterface; use SP\Bootstrap; use SP\Config\Config; +use SP\Config\ConfigData; use SP\Core\Context\ContextInterface; use SP\Core\Events\EventDispatcher; use SP\Http\Request; @@ -49,7 +52,7 @@ use SP\Util\Util; abstract class ModuleBase { /** - * @var \SP\Config\ConfigData + * @var ConfigData */ protected $configData; /** @@ -116,8 +119,8 @@ abstract class ModuleBase /** * Initializes event handlers * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initEventHandlers() { diff --git a/lib/SP/DataModel/EncryptedModel.php b/lib/SP/DataModel/EncryptedModel.php index 108f52ad..2fc23364 100644 --- a/lib/SP/DataModel/EncryptedModel.php +++ b/lib/SP/DataModel/EncryptedModel.php @@ -25,6 +25,7 @@ namespace SP\DataModel; +use Defuse\Crypto\Exception\CryptoException; use SP\Core\Crypt\Crypt; use SP\Core\Exceptions\NoSuchPropertyException; @@ -46,7 +47,7 @@ trait EncryptedModel * * @return static|null * @throws NoSuchPropertyException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function encrypt(string $key, string $property = 'data') { @@ -71,7 +72,7 @@ trait EncryptedModel * * @return static|null * @throws NoSuchPropertyException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function decrypt(string $key, string $property = 'data') { diff --git a/lib/SP/DataModel/HydratableInterface.php b/lib/SP/DataModel/HydratableInterface.php index f96c8949..a8ed8b0c 100644 --- a/lib/SP/DataModel/HydratableInterface.php +++ b/lib/SP/DataModel/HydratableInterface.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/DataModel/ItemPreset/AccountPermission.php b/lib/SP/DataModel/ItemPreset/AccountPermission.php index 84c31973..336cea74 100644 --- a/lib/SP/DataModel/ItemPreset/AccountPermission.php +++ b/lib/SP/DataModel/ItemPreset/AccountPermission.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/DataModel/ItemPreset/SessionTimeout.php b/lib/SP/DataModel/ItemPreset/SessionTimeout.php index 3d5726d2..913702f7 100644 --- a/lib/SP/DataModel/ItemPreset/SessionTimeout.php +++ b/lib/SP/DataModel/ItemPreset/SessionTimeout.php @@ -24,6 +24,7 @@ namespace SP\DataModel\ItemPreset; +use SP\Core\Exceptions\InvalidArgumentException; use SP\Http\Address; /** @@ -52,7 +53,7 @@ class SessionTimeout * @param string $address IP address and/or mask * @param int $timeout Timeout in seconds * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct(string $address, int $timeout) { diff --git a/lib/SP/DataModel/TrackData.php b/lib/SP/DataModel/TrackData.php index 65807cec..2fcdc86b 100644 --- a/lib/SP/DataModel/TrackData.php +++ b/lib/SP/DataModel/TrackData.php @@ -24,6 +24,7 @@ namespace SP\DataModel; +use SP\Core\Exceptions\InvalidArgumentException; use SP\Http\Address; /** @@ -128,7 +129,7 @@ class TrackData extends DataModelBase /** * @return string|null - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function getIpv4() { @@ -142,7 +143,7 @@ class TrackData extends DataModelBase /** * @param string $ipv4 * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function setIpv4($ipv4) { @@ -152,7 +153,7 @@ class TrackData extends DataModelBase /** * @param string $track_ip * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function setTrackIp($track_ip) { @@ -175,7 +176,7 @@ class TrackData extends DataModelBase /** * @return string|null - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function getIpv6() { @@ -189,7 +190,7 @@ class TrackData extends DataModelBase /** * @param string $ipv6 * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function setIpv6($ipv6) { diff --git a/lib/SP/Html/DataGrid/Action/DataGridAction.php b/lib/SP/Html/DataGrid/Action/DataGridAction.php index 575d778a..c5185bab 100644 --- a/lib/SP/Html/DataGrid/Action/DataGridAction.php +++ b/lib/SP/Html/DataGrid/Action/DataGridAction.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Action/DataGridActionBase.php b/lib/SP/Html/DataGrid/Action/DataGridActionBase.php index 1a0ead18..02868251 100644 --- a/lib/SP/Html/DataGrid/Action/DataGridActionBase.php +++ b/lib/SP/Html/DataGrid/Action/DataGridActionBase.php @@ -24,6 +24,7 @@ namespace SP\Html\DataGrid\Action; +use RuntimeException; use SP\Html\Assets\IconInterface; defined('APP_ROOT') || die(); @@ -158,8 +159,8 @@ abstract class DataGridActionBase implements DataGridActionInterface * @param string $class * @param string $method * - * @throws \RuntimeException * @return $this + * @throws RuntimeException */ public function setRuntimeFilter($class, $method) { @@ -169,7 +170,7 @@ abstract class DataGridActionBase implements DataGridActionInterface return $filter->{$method}(); }; } else { - throw new \RuntimeException('Method does not exist'); + throw new RuntimeException('Method does not exist'); } return $this; diff --git a/lib/SP/Html/DataGrid/Action/DataGridActionSearch.php b/lib/SP/Html/DataGrid/Action/DataGridActionSearch.php index 07b76f88..6940d473 100644 --- a/lib/SP/Html/DataGrid/Action/DataGridActionSearch.php +++ b/lib/SP/Html/DataGrid/Action/DataGridActionSearch.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/DataGridBase.php b/lib/SP/Html/DataGrid/DataGridBase.php index 00c39db0..ce92b237 100644 --- a/lib/SP/Html/DataGrid/DataGridBase.php +++ b/lib/SP/Html/DataGrid/DataGridBase.php @@ -153,7 +153,7 @@ abstract class DataGridBase implements DataGridInterface } /** - * @param \SP\Core\Acl\ActionsInterface $action + * @param ActionsInterface $action * * @return $this */ diff --git a/lib/SP/Html/DataGrid/Layout/DataGridHeader.php b/lib/SP/Html/DataGrid/Layout/DataGridHeader.php index f65c7bb4..8d5381dc 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridHeader.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridHeader.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Layout/DataGridHeaderBase.php b/lib/SP/Html/DataGrid/Layout/DataGridHeaderBase.php index a04d3cc5..3bcd372b 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridHeaderBase.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridHeaderBase.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Layout/DataGridHeaderSort.php b/lib/SP/Html/DataGrid/Layout/DataGridHeaderSort.php index b080e745..eeb21519 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridHeaderSort.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridHeaderSort.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Layout/DataGridPager.php b/lib/SP/Html/DataGrid/Layout/DataGridPager.php index 672f1e3a..9134f708 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridPager.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridPager.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Layout/DataGridPagerBase.php b/lib/SP/Html/DataGrid/Layout/DataGridPagerBase.php index dae2e69a..a7ca9414 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridPagerBase.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridPagerBase.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/DataGrid/Layout/DataGridPagerInterface.php b/lib/SP/Html/DataGrid/Layout/DataGridPagerInterface.php index 8eab7112..8e2947e7 100644 --- a/lib/SP/Html/DataGrid/Layout/DataGridPagerInterface.php +++ b/lib/SP/Html/DataGrid/Layout/DataGridPagerInterface.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Html/Minify.php b/lib/SP/Html/Minify.php index 243579e9..a26d84d4 100644 --- a/lib/SP/Html/Minify.php +++ b/lib/SP/Html/Minify.php @@ -25,6 +25,8 @@ namespace SP\Html; use Klein\Klein; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Http\Request; defined('APP_ROOT') || die(); @@ -96,8 +98,8 @@ final class Minify * * @param bool $disableMinify Deshabilitar minimizar * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function getMinified($disableMinify = false) { diff --git a/lib/SP/Http/JsonResponse.php b/lib/SP/Http/JsonResponse.php index 714807ea..b506b9f2 100644 --- a/lib/SP/Http/JsonResponse.php +++ b/lib/SP/Http/JsonResponse.php @@ -24,12 +24,15 @@ namespace SP\Http; +use JsonSerializable; +use stdClass; + /** * Class Json para definir la estructura de una respuesta en formato JSON * * @package SP\Http */ -final class JsonResponse implements \JsonSerializable +final class JsonResponse implements JsonSerializable { const JSON_SUCCESS = 0; const JSON_SUCCESS_STICKY = 100; @@ -147,7 +150,7 @@ final class JsonResponse implements \JsonSerializable } /** - * @param array|\stdClass $data + * @param array|stdClass $data * * @return JsonResponse */ diff --git a/lib/SP/Http/Request.php b/lib/SP/Http/Request.php index 50bf754d..b33de165 100644 --- a/lib/SP/Http/Request.php +++ b/lib/SP/Http/Request.php @@ -24,7 +24,9 @@ namespace SP\Http; +use Exception; use Klein\DataCollection\DataCollection; +use Klein\DataCollection\HeaderDataCollection; use SP\Bootstrap; use SP\Core\Crypt\CryptPKI; use SP\Core\Crypt\Hash; @@ -44,7 +46,7 @@ final class Request */ const SECURE_DIRS = ['css', 'js']; /** - * @var \Klein\DataCollection\HeaderDataCollection + * @var HeaderDataCollection */ private $headers; /** @@ -247,7 +249,7 @@ final class Request } return $clearData; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return $encryptedData; diff --git a/lib/SP/Http/XMLRPCResponseParse.php b/lib/SP/Http/XMLRPCResponseParse.php index 6d0c427c..511dfe9f 100644 --- a/lib/SP/Http/XMLRPCResponseParse.php +++ b/lib/SP/Http/XMLRPCResponseParse.php @@ -26,6 +26,7 @@ namespace SP\Http; use DOMDocument; use DOMElement; +use DOMException; use DOMNode; use DOMNodeList; use InvalidArgumentException; @@ -55,7 +56,7 @@ abstract class XMLRPCResponseParse * * @param string $xml El documento XML * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct($xml) { @@ -66,11 +67,11 @@ abstract class XMLRPCResponseParse $dom->loadXML($xml); if ($dom->getElementsByTagName('methodResponse')->length === 0) { - throw new \DOMException(__u('Invalid XML-RPC response')); + throw new DOMException(__u('Invalid XML-RPC response')); } $this->root = $dom->documentElement; - } catch (\DOMException $e) { + } catch (DOMException $e) { throw new InvalidArgumentException($e->getMessage(), $e->getCode()); } } diff --git a/lib/SP/Mvc/Controller/ControllerTrait.php b/lib/SP/Mvc/Controller/ControllerTrait.php index 696c3d94..36e5f75c 100644 --- a/lib/SP/Mvc/Controller/ControllerTrait.php +++ b/lib/SP/Mvc/Controller/ControllerTrait.php @@ -24,6 +24,7 @@ namespace SP\Mvc\Controller; +use Closure; use SP\Bootstrap; use SP\Config\ConfigData; use SP\Core\Exceptions\SPException; @@ -57,9 +58,9 @@ trait ControllerTrait * * @param Request $request * @param ConfigData $configData - * @param \Closure $onRedirect + * @param Closure $onRedirect */ - protected function sessionLogout(Request $request, ConfigData $configData, \Closure $onRedirect) + protected function sessionLogout(Request $request, ConfigData $configData, Closure $onRedirect) { if ($request->isJson()) { $jsonResponse = new JsonResponse(__u('Session not started or timed out')); diff --git a/lib/SP/Mvc/Controller/ExtensibleTabControllerInterface.php b/lib/SP/Mvc/Controller/ExtensibleTabControllerInterface.php index 38ec2977..82a8cc8f 100644 --- a/lib/SP/Mvc/Controller/ExtensibleTabControllerInterface.php +++ b/lib/SP/Mvc/Controller/ExtensibleTabControllerInterface.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Mvc/Model/QueryCondition.php b/lib/SP/Mvc/Model/QueryCondition.php index a4fa3556..9797fc2f 100644 --- a/lib/SP/Mvc/Model/QueryCondition.php +++ b/lib/SP/Mvc/Model/QueryCondition.php @@ -24,6 +24,8 @@ namespace SP\Mvc\Model; +use RuntimeException; + /** * Class QueryCondition * @@ -68,7 +70,7 @@ final class QueryCondition public function getFilters($type = self::CONDITION_AND) { if ($type !== self::CONDITION_AND && $type !== self::CONDITION_OR) { - throw new \RuntimeException(__u('Invalid filter type')); + throw new RuntimeException(__u('Invalid filter type')); } return $this->hasFilters() ? '(' . implode($type, $this->query) . ')' : null; diff --git a/lib/SP/Mvc/View/Components/SelectItemAdapter.php b/lib/SP/Mvc/View/Components/SelectItemAdapter.php index 4dc41a60..92651a7e 100644 --- a/lib/SP/Mvc/View/Components/SelectItemAdapter.php +++ b/lib/SP/Mvc/View/Components/SelectItemAdapter.php @@ -25,6 +25,7 @@ namespace SP\Mvc\View\Components; use RuntimeException; +use SP\Core\Exceptions\SPException; use SP\DataModel\DataModelInterface; use SP\Http\Json; @@ -84,7 +85,7 @@ final class SelectItemAdapter implements ItemAdapterInterface * Returns a JSON like collection of items for a select component * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getJsonItemsFromModel() { @@ -105,7 +106,7 @@ final class SelectItemAdapter implements ItemAdapterInterface * Returns a collection of items for a select component * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getJsonItemsFromArray() { diff --git a/lib/SP/Mvc/View/Template.php b/lib/SP/Mvc/View/Template.php index 6bcf57a7..898ccb9c 100644 --- a/lib/SP/Mvc/View/Template.php +++ b/lib/SP/Mvc/View/Template.php @@ -108,7 +108,7 @@ final class Template * * @return string La ruta al archivo de la plantilla * - * @throws \SP\Core\Exceptions\FileNotFoundException + * @throws FileNotFoundException */ private function checkTemplate($template, $base = null) { diff --git a/lib/SP/Mvc/View/TemplateVarCollection.php b/lib/SP/Mvc/View/TemplateVarCollection.php index 9d4a14f6..4d1d98e0 100644 --- a/lib/SP/Mvc/View/TemplateVarCollection.php +++ b/lib/SP/Mvc/View/TemplateVarCollection.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Plugin/PluginBase.php b/lib/SP/Plugin/PluginBase.php index 6c5a63da..98e816c4 100644 --- a/lib/SP/Plugin/PluginBase.php +++ b/lib/SP/Plugin/PluginBase.php @@ -24,8 +24,13 @@ namespace SP\Plugin; +use Defuse\Crypto\Exception\CryptoException; use Psr\Container\ContainerInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Services\Plugin\PluginService; +use SP\Services\ServiceException; /** * Class PluginBase @@ -128,11 +133,11 @@ abstract class PluginBase implements PluginInterface * @param int $id * @param mixed $data * - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ final public function saveData(int $id, $data) { diff --git a/lib/SP/Plugin/PluginEventReceiver.php b/lib/SP/Plugin/PluginEventReceiver.php index fc04e8c9..e9e99c81 100644 --- a/lib/SP/Plugin/PluginEventReceiver.php +++ b/lib/SP/Plugin/PluginEventReceiver.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Plugin/PluginManager.php b/lib/SP/Plugin/PluginManager.php index 405dec4d..305bf75b 100644 --- a/lib/SP/Plugin/PluginManager.php +++ b/lib/SP/Plugin/PluginManager.php @@ -24,6 +24,7 @@ namespace SP\Plugin; +use Exception; use ReflectionClass; use SP\Bootstrap; use SP\Core\Context\ContextInterface; @@ -32,6 +33,7 @@ use SP\Core\Events\EventDispatcher; use SP\Core\Events\EventMessage; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Repositories\NoSuchItemException; use SP\Repositories\Plugin\PluginModel; use SP\Services\Install\Installer; @@ -196,7 +198,7 @@ final class PluginManager } return $plugin; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', @@ -252,7 +254,7 @@ final class PluginManager } return true; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', @@ -271,7 +273,7 @@ final class PluginManager * * @throws ConstraintException * @throws QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function loadPlugins() { @@ -410,7 +412,7 @@ final class PluginManager ->addDetail(__u('Name'), $pluginName)) ); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', @@ -426,7 +428,7 @@ final class PluginManager /** * Comprobar disponibilidad de plugins habilitados * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function checkEnabledPlugins() { @@ -446,8 +448,8 @@ final class PluginManager * Devolver los plugins habilitados * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getEnabledPlugins() { diff --git a/lib/SP/Plugin/PluginOperation.php b/lib/SP/Plugin/PluginOperation.php index 6f64359e..ca5c3832 100644 --- a/lib/SP/Plugin/PluginOperation.php +++ b/lib/SP/Plugin/PluginOperation.php @@ -66,11 +66,11 @@ final class PluginOperation * @param mixed $data * * @return int - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function create(int $itemId, $data) { @@ -87,11 +87,11 @@ final class PluginOperation * @param mixed $data * * @return int - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function update(int $itemId, $data) { @@ -106,9 +106,9 @@ final class PluginOperation /** * @param int $itemId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function delete(int $itemId) { diff --git a/lib/SP/Providers/Acl/AclHandler.php b/lib/SP/Providers/Acl/AclHandler.php index 65c5df7a..c799d091 100644 --- a/lib/SP/Providers/Acl/AclHandler.php +++ b/lib/SP/Providers/Acl/AclHandler.php @@ -25,6 +25,7 @@ namespace SP\Providers\Acl; use DI\Container; +use Exception; use Psr\Container\ContainerInterface; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; @@ -137,7 +138,7 @@ final class AclHandler extends Provider implements EventReceiver AccountAclService::clearAcl($user->id); } } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -173,7 +174,7 @@ final class AclHandler extends Provider implements EventReceiver AccountAclService::clearAcl($user->id); } } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } diff --git a/lib/SP/Providers/Auth/AuthProvider.php b/lib/SP/Providers/Auth/AuthProvider.php index a9413ee0..e47b7e40 100644 --- a/lib/SP/Providers/Auth/AuthProvider.php +++ b/lib/SP/Providers/Auth/AuthProvider.php @@ -25,6 +25,10 @@ namespace SP\Providers\Auth; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\DataModel\UserLoginData; use SP\Providers\Auth\Browser\Browser; @@ -76,11 +80,11 @@ final class AuthProvider extends Provider * * @param UserLoginData $userLoginData * - * @uses authLdap + * @return false|AuthResult[] * @uses authDatabase * @uses authBrowser * - * @return false|AuthResult[] + * @uses authLdap */ public function doAuth(UserLoginData $userLoginData) { @@ -159,8 +163,8 @@ final class AuthProvider extends Provider * se ejecuta el proceso para actualizar la clave. * * @return DatabaseAuthData - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function authDatabase() { @@ -183,8 +187,8 @@ final class AuthProvider extends Provider * @param Container $dic * * @throws AuthException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Auth/Database/Database.php b/lib/SP/Providers/Auth/Database/Database.php index 7e6c026f..158c0010 100644 --- a/lib/SP/Providers/Auth/Database/Database.php +++ b/lib/SP/Providers/Auth/Database/Database.php @@ -24,6 +24,7 @@ namespace SP\Providers\Auth\Database; +use Exception; use SP\Core\Crypt\Hash; use SP\DataModel\UserLoginData; use SP\Providers\Auth\AuthInterface; @@ -114,7 +115,7 @@ final class Database implements AuthInterface } return Hash::checkHashKey($this->userLoginData->getLoginPass(), $userLoginResponse->getPass()); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } diff --git a/lib/SP/Providers/Auth/Ldap/AttributeCollection.php b/lib/SP/Providers/Auth/Ldap/AttributeCollection.php index 1e36f645..bc4307eb 100644 --- a/lib/SP/Providers/Auth/Ldap/AttributeCollection.php +++ b/lib/SP/Providers/Auth/Ldap/AttributeCollection.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Providers/Auth/Ldap/LdapCode.php b/lib/SP/Providers/Auth/Ldap/LdapCode.php index 7d18ec38..73a104fb 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapCode.php +++ b/lib/SP/Providers/Auth/Ldap/LdapCode.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Providers/Auth/Ldap/LdapConnection.php b/lib/SP/Providers/Auth/Ldap/LdapConnection.php index df0ebe03..5ea288b0 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapConnection.php +++ b/lib/SP/Providers/Auth/Ldap/LdapConnection.php @@ -120,8 +120,8 @@ final class LdapConnection implements LdapConnectionInterface /** * Realizar la conexión al servidor de LDAP. * - * @throws LdapException * @return bool + * @throws LdapException */ public function connect(): bool { @@ -242,8 +242,8 @@ final class LdapConnection implements LdapConnectionInterface * @param string $bindDn con el DN del usuario * @param string $bindPass con la clave del usuario * - * @throws LdapException * @return bool + * @throws LdapException */ public function bind(string $bindDn = null, string $bindPass = null): bool { diff --git a/lib/SP/Providers/Auth/Ldap/LdapConnectionInterface.php b/lib/SP/Providers/Auth/Ldap/LdapConnectionInterface.php index 56cf68d1..9436c824 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapConnectionInterface.php +++ b/lib/SP/Providers/Auth/Ldap/LdapConnectionInterface.php @@ -52,8 +52,8 @@ interface LdapConnectionInterface /** * Realizar la conexión al servidor de LDAP. * - * @throws LdapException * @return bool + * @throws LdapException */ public function connect(): bool; diff --git a/lib/SP/Providers/Auth/Ldap/LdapMsAds.php b/lib/SP/Providers/Auth/Ldap/LdapMsAds.php index 2f5d0508..897cfccd 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapMsAds.php +++ b/lib/SP/Providers/Auth/Ldap/LdapMsAds.php @@ -26,6 +26,7 @@ namespace SP\Providers\Auth\Ldap; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\Address; /** @@ -46,7 +47,7 @@ final class LdapMsAds extends Ldap * Devolver el filtro para comprobar la pertenecia al grupo * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getGroupMembershipFilter(): string { diff --git a/lib/SP/Providers/Auth/Ldap/LdapMsAzureAd.php b/lib/SP/Providers/Auth/Ldap/LdapMsAzureAd.php index 96088a26..9e17bf46 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapMsAzureAd.php +++ b/lib/SP/Providers/Auth/Ldap/LdapMsAzureAd.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -26,6 +26,7 @@ namespace SP\Providers\Auth\Ldap; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\Http\Address; /** @@ -46,7 +47,7 @@ final class LdapMsAzureAd extends Ldap * Devolver el filtro para comprobar la pertenecia al grupo * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getGroupMembershipFilter(): string { diff --git a/lib/SP/Providers/Auth/Ldap/LdapStd.php b/lib/SP/Providers/Auth/Ldap/LdapStd.php index e3c79893..f8a35673 100644 --- a/lib/SP/Providers/Auth/Ldap/LdapStd.php +++ b/lib/SP/Providers/Auth/Ldap/LdapStd.php @@ -26,6 +26,7 @@ namespace SP\Providers\Auth\Ldap; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; /** * Class LdapStd @@ -55,7 +56,7 @@ final class LdapStd extends Ldap * Devolver el filtro para comprobar la pertenecia al grupo * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getGroupMembershipFilter(): string { diff --git a/lib/SP/Providers/Log/DatabaseLogHandler.php b/lib/SP/Providers/Log/DatabaseLogHandler.php index 9cbc1366..88f76474 100644 --- a/lib/SP/Providers/Log/DatabaseLogHandler.php +++ b/lib/SP/Providers/Log/DatabaseLogHandler.php @@ -25,8 +25,12 @@ namespace SP\Providers\Log; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; +use SP\Core\Exceptions\InvalidClassException; use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\DataModel\EventlogData; @@ -67,7 +71,7 @@ final class DatabaseLogHandler extends Provider implements EventReceiver *

* * @return void - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException * @since 5.1.0 */ public function update(SplSubject $subject) @@ -81,7 +85,7 @@ final class DatabaseLogHandler extends Provider implements EventReceiver * @param string $eventType Nombre del evento * @param Event $event Objeto del evento * - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException */ public function updateEvent($eventType, Event $event) { @@ -107,7 +111,7 @@ final class DatabaseLogHandler extends Provider implements EventReceiver } else { $eventlogData->setDescription(__($source->getMessage())); } - } elseif ($source instanceof \Exception) { + } elseif ($source instanceof Exception) { $eventlogData->setLevel('ERROR'); $eventlogData->setDescription(__($source->getMessage())); } elseif (($eventMessage = $event->getEventMessage()) !== null) { @@ -116,7 +120,7 @@ final class DatabaseLogHandler extends Provider implements EventReceiver try { $this->eventlogService->create($eventlogData); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } @@ -146,8 +150,8 @@ final class DatabaseLogHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Log/FileLogHandler.php b/lib/SP/Providers/Log/FileLogHandler.php index dfacaff9..65cf44b5 100644 --- a/lib/SP/Providers/Log/FileLogHandler.php +++ b/lib/SP/Providers/Log/FileLogHandler.php @@ -26,8 +26,12 @@ namespace SP\Providers\Log; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; +use SP\Core\Exceptions\InvalidClassException; use SP\Core\Language; use SP\Providers\EventsTrait; use SP\Providers\Provider; @@ -83,7 +87,7 @@ final class FileLogHandler extends Provider implements EventReceiver *

* * @return void - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException * @since 5.1.0 */ public function update(SplSubject $subject) @@ -97,13 +101,13 @@ final class FileLogHandler extends Provider implements EventReceiver * @param string $eventType Nombre del evento * @param Event $event Objeto del evento * - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException */ public function updateEvent($eventType, Event $event) { $this->language->setAppLocales(); - if (($e = $event->getSource()) instanceof \Exception) { + if (($e = $event->getSource()) instanceof Exception) { logger(sprintf(self::MESSAGE_FORMAT, $eventType, __($e->getMessage()))); } elseif (($eventMessage = $event->getEventMessage()) !== null) { logger(sprintf(self::MESSAGE_FORMAT, $eventType, $eventMessage->composeText(';'))); @@ -115,8 +119,8 @@ final class FileLogHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Log/LogInterface.php b/lib/SP/Providers/Log/LogInterface.php index d85d954a..17480cf7 100644 --- a/lib/SP/Providers/Log/LogInterface.php +++ b/lib/SP/Providers/Log/LogInterface.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. diff --git a/lib/SP/Providers/Log/RemoteSyslogHandler.php b/lib/SP/Providers/Log/RemoteSyslogHandler.php index f7c29bcb..d30718d5 100644 --- a/lib/SP/Providers/Log/RemoteSyslogHandler.php +++ b/lib/SP/Providers/Log/RemoteSyslogHandler.php @@ -25,10 +25,14 @@ namespace SP\Providers\Log; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use Monolog\Handler\SyslogUdpHandler; use Monolog\Logger; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; +use SP\Core\Exceptions\InvalidClassException; use SP\Core\Language; use SP\Http\Request; use SP\Providers\EventsTrait; @@ -92,7 +96,7 @@ final class RemoteSyslogHandler extends Provider implements EventReceiver *

* * @return void - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException * @since 5.1.0 */ public function update(SplSubject $subject) @@ -106,19 +110,19 @@ final class RemoteSyslogHandler extends Provider implements EventReceiver * @param string $eventType Nombre del evento * @param Event $event Objeto del evento * - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException */ public function updateEvent($eventType, Event $event) { $this->language->setAppLocales(); - if (($e = $event->getSource()) instanceof \Exception) { - /** @var \Exception $e */ + if (($e = $event->getSource()) instanceof Exception) { + /** @var Exception $e */ $this->logger->error( sprintf(self::MESSAGE_FORMAT, - $eventType, - __($e->getMessage()), - $this->request->getClientAddress(true))); + $eventType, + __($e->getMessage()), + $this->request->getClientAddress(true))); } elseif (($eventMessage = $event->getEventMessage()) !== null) { $this->logger->debug( sprintf(self::MESSAGE_FORMAT, @@ -133,8 +137,8 @@ final class RemoteSyslogHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Log/SyslogHandler.php b/lib/SP/Providers/Log/SyslogHandler.php index 48d3a9fc..af32a0be 100644 --- a/lib/SP/Providers/Log/SyslogHandler.php +++ b/lib/SP/Providers/Log/SyslogHandler.php @@ -25,9 +25,13 @@ namespace SP\Providers\Log; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use Monolog\Logger; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; +use SP\Core\Exceptions\InvalidClassException; use SP\Core\Language; use SP\Http\Request; use SP\Providers\EventsTrait; @@ -91,7 +95,7 @@ final class SyslogHandler extends Provider implements EventReceiver *

* * @return void - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException * @since 5.1.0 */ public function update(SplSubject $subject) @@ -105,14 +109,14 @@ final class SyslogHandler extends Provider implements EventReceiver * @param string $eventType Nombre del evento * @param Event $event Objeto del evento * - * @throws \SP\Core\Exceptions\InvalidClassException + * @throws InvalidClassException */ public function updateEvent($eventType, Event $event) { $this->language->setAppLocales(); - if (($e = $event->getSource()) instanceof \Exception) { - /** @var \Exception $e */ + if (($e = $event->getSource()) instanceof Exception) { + /** @var Exception $e */ $this->logger->error( sprintf(self::MESSAGE_FORMAT, $eventType, @@ -132,8 +136,8 @@ final class SyslogHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Mail/MailHandler.php b/lib/SP/Providers/Mail/MailHandler.php index 2e6412a3..700dafd6 100644 --- a/lib/SP/Providers/Mail/MailHandler.php +++ b/lib/SP/Providers/Mail/MailHandler.php @@ -25,6 +25,9 @@ namespace SP\Providers\Mail; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; use SP\Core\Messages\MailMessage; @@ -66,7 +69,7 @@ final class MailHandler extends Provider implements EventReceiver ]; /** - * @var \SP\Services\Mail\MailService + * @var MailService */ private $mailService; /** @@ -168,7 +171,7 @@ final class MailHandler extends Provider implements EventReceiver $recipients, $mailMessage ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -177,8 +180,8 @@ final class MailHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Mail/MailProvider.php b/lib/SP/Providers/Mail/MailProvider.php index 1a50f544..012046e7 100644 --- a/lib/SP/Providers/Mail/MailProvider.php +++ b/lib/SP/Providers/Mail/MailProvider.php @@ -25,6 +25,9 @@ namespace SP\Providers\Mail; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use PHPMailer\PHPMailer\PHPMailer; use SP\Core\AppInfoInterface; use SP\Providers\Provider; @@ -84,7 +87,7 @@ final class MailProvider extends Provider $this->mailer->WordWrap = 100; return $this->mailer; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new MailProviderException( @@ -116,8 +119,8 @@ final class MailProvider extends Provider /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Providers/Notification/NotificationHandler.php b/lib/SP/Providers/Notification/NotificationHandler.php index 0e9b41e2..0a255b88 100644 --- a/lib/SP/Providers/Notification/NotificationHandler.php +++ b/lib/SP/Providers/Notification/NotificationHandler.php @@ -25,6 +25,9 @@ namespace SP\Providers\Notification; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventReceiver; use SP\DataModel\NotificationData; @@ -137,7 +140,7 @@ final class NotificationHandler extends Provider implements EventReceiver { try { $this->notificationService->create($notificationData); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -164,8 +167,8 @@ final class NotificationHandler extends Provider implements EventReceiver /** * @param Container $dic * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ protected function initialize(Container $dic) { diff --git a/lib/SP/Repositories/Account/AccountFileRepository.php b/lib/SP/Repositories/Account/AccountFileRepository.php index 542a4f03..9ca305ec 100644 --- a/lib/SP/Repositories/Account/AccountFileRepository.php +++ b/lib/SP/Repositories/Account/AccountFileRepository.php @@ -24,6 +24,9 @@ namespace SP\Repositories\Account; +use RuntimeException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\FileData; use SP\DataModel\FileExtData; use SP\DataModel\ItemSearchData; @@ -48,8 +51,8 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * @param FileData $itemData * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -88,15 +91,15 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn */ public function update($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** * @param $id * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getInfoById($id) { @@ -126,9 +129,9 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * * @param int $id * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -161,9 +164,9 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * * @param int $id * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getByAccountId($id) { @@ -191,9 +194,9 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn /** * Returns all the items * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -225,9 +228,9 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * * @param array $ids * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -265,8 +268,8 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -287,8 +290,8 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -311,7 +314,7 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -321,7 +324,7 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -331,7 +334,7 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -340,8 +343,8 @@ final class AccountFileRepository extends Repository implements RepositoryItemIn * @param ItemSearchData $itemSearchData * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { diff --git a/lib/SP/Repositories/Account/AccountHistoryRepository.php b/lib/SP/Repositories/Account/AccountHistoryRepository.php index 860ee8a4..f5c7ed3d 100644 --- a/lib/SP/Repositories/Account/AccountHistoryRepository.php +++ b/lib/SP/Repositories/Account/AccountHistoryRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Account; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -173,7 +174,7 @@ final class AccountHistoryRepository extends Repository implements RepositoryIte */ public function update($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -268,7 +269,7 @@ final class AccountHistoryRepository extends Repository implements RepositoryIte */ public function getByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -326,7 +327,7 @@ final class AccountHistoryRepository extends Repository implements RepositoryIte */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -338,7 +339,7 @@ final class AccountHistoryRepository extends Repository implements RepositoryIte */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -350,7 +351,7 @@ final class AccountHistoryRepository extends Repository implements RepositoryIte */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/Account/AccountRepository.php b/lib/SP/Repositories/Account/AccountRepository.php index 44f551f0..28393ee2 100644 --- a/lib/SP/Repositories/Account/AccountRepository.php +++ b/lib/SP/Repositories/Account/AccountRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Account; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -45,6 +46,7 @@ use SP\Services\Account\AccountRequest; use SP\Services\Account\AccountSearchFilter; use SP\Storage\Database\QueryData; use SP\Storage\Database\QueryResult; +use stdClass; /** * Class AccountRepository @@ -58,7 +60,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf /** * Devolver el número total de cuentas * - * @return \stdClass + * @return stdClass * @throws QueryException * @throws ConstraintException */ @@ -326,7 +328,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf /** * Updates an item * - * @param \SP\Services\Account\AccountRequest $itemData + * @param AccountRequest $itemData * * @return mixed * @throws SPException @@ -387,7 +389,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf /** * Updates an item for bulk action * - * @param \SP\Services\Account\AccountRequest $itemData + * @param AccountRequest $itemData * * @return mixed * @throws SPException @@ -476,7 +478,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf */ public function getByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -510,7 +512,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -520,7 +522,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -530,7 +532,7 @@ final class AccountRepository extends Repository implements RepositoryItemInterf */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/Account/AccountToFavoriteRepository.php b/lib/SP/Repositories/Account/AccountToFavoriteRepository.php index b89d3b9d..2e66f147 100644 --- a/lib/SP/Repositories/Account/AccountToFavoriteRepository.php +++ b/lib/SP/Repositories/Account/AccountToFavoriteRepository.php @@ -24,8 +24,11 @@ namespace SP\Repositories\Account; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Repositories\Repository; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class AccountFavoriteRepository @@ -39,9 +42,9 @@ final class AccountToFavoriteRepository extends Repository * * @param $id int El Id de usuario * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getForUserId($id) { @@ -60,8 +63,8 @@ final class AccountToFavoriteRepository extends Repository * @param $userId int El Id del usuario * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($accountId, $userId) { @@ -80,8 +83,8 @@ final class AccountToFavoriteRepository extends Repository * @param $userId int El Id del usuario * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($accountId, $userId) { diff --git a/lib/SP/Repositories/Account/AccountToTagRepository.php b/lib/SP/Repositories/Account/AccountToTagRepository.php index d012408c..7cbfcea7 100644 --- a/lib/SP/Repositories/Account/AccountToTagRepository.php +++ b/lib/SP/Repositories/Account/AccountToTagRepository.php @@ -24,11 +24,14 @@ namespace SP\Repositories\Account; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Repository; use SP\Repositories\RepositoryItemTrait; use SP\Services\Account\AccountRequest; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class AccountToTagRepository @@ -44,9 +47,9 @@ final class AccountToTagRepository extends Repository * * @param int $id * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getTagsByAccountId($id) { @@ -68,8 +71,8 @@ final class AccountToTagRepository extends Repository /** * @param AccountRequest $accountRequest * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update(AccountRequest $accountRequest) { @@ -83,8 +86,8 @@ final class AccountToTagRepository extends Repository * @param int $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByAccountId($id) { @@ -102,8 +105,8 @@ final class AccountToTagRepository extends Repository * @param AccountRequest $accountRequest * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add(AccountRequest $accountRequest) { diff --git a/lib/SP/Repositories/Account/AccountToUserGroupRepository.php b/lib/SP/Repositories/Account/AccountToUserGroupRepository.php index fca0be60..a1bc3a78 100644 --- a/lib/SP/Repositories/Account/AccountToUserGroupRepository.php +++ b/lib/SP/Repositories/Account/AccountToUserGroupRepository.php @@ -24,11 +24,14 @@ namespace SP\Repositories\Account; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Repository; use SP\Repositories\RepositoryItemTrait; use SP\Services\Account\AccountRequest; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class AccountToUserGroupRepository @@ -44,9 +47,9 @@ final class AccountToUserGroupRepository extends Repository * * @param int $id con el Id de la cuenta * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getUserGroupsByAccountId($id) { @@ -70,9 +73,9 @@ final class AccountToUserGroupRepository extends Repository * * @param $id * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getUserGroupsByUserGroupId($id) { @@ -95,8 +98,8 @@ final class AccountToUserGroupRepository extends Repository * @param $id int * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByUserGroupId($id) { @@ -113,8 +116,8 @@ final class AccountToUserGroupRepository extends Repository * @param bool $isEdit * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function updateByType(AccountRequest $accountRequest, bool $isEdit) { @@ -128,8 +131,8 @@ final class AccountToUserGroupRepository extends Repository * @param bool $isEdit * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteTypeByAccountId($id, bool $isEdit) { @@ -146,8 +149,8 @@ final class AccountToUserGroupRepository extends Repository * @param bool $isEdit * * @return int Last ID inserted - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function addByType(AccountRequest $accountRequest, bool $isEdit) { @@ -180,8 +183,8 @@ final class AccountToUserGroupRepository extends Repository * @param $id int * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByAccountId($id) { diff --git a/lib/SP/Repositories/Account/AccountToUserRepository.php b/lib/SP/Repositories/Account/AccountToUserRepository.php index c55ed5f6..545b86ae 100644 --- a/lib/SP/Repositories/Account/AccountToUserRepository.php +++ b/lib/SP/Repositories/Account/AccountToUserRepository.php @@ -24,11 +24,14 @@ namespace SP\Repositories\Account; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Repository; use SP\Repositories\RepositoryItemTrait; use SP\Services\Account\AccountRequest; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class AccountToUserRepository @@ -47,8 +50,8 @@ final class AccountToUserRepository extends Repository * @param bool $isEdit * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function updateByType(AccountRequest $accountRequest, bool $isEdit) { @@ -65,8 +68,8 @@ final class AccountToUserRepository extends Repository * @param bool $isEdit * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteTypeByAccountId($id, bool $isEdit) { @@ -85,8 +88,8 @@ final class AccountToUserRepository extends Repository * @param bool $isEdit * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function addByType(AccountRequest $accountRequest, bool $isEdit) { @@ -121,8 +124,8 @@ final class AccountToUserRepository extends Repository * @param int $id con el Id de la cuenta * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByAccountId($id) { @@ -139,9 +142,9 @@ final class AccountToUserRepository extends Repository * * @param int $id con el id de la cuenta * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getUsersByAccountId($id) { diff --git a/lib/SP/Repositories/AuthToken/AuthTokenRepository.php b/lib/SP/Repositories/AuthToken/AuthTokenRepository.php index 8a289bc5..deefe5ae 100644 --- a/lib/SP/Repositories/AuthToken/AuthTokenRepository.php +++ b/lib/SP/Repositories/AuthToken/AuthTokenRepository.php @@ -24,6 +24,9 @@ namespace SP\Repositories\AuthToken; +use RuntimeException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\AuthTokenData; use SP\DataModel\ItemSearchData; use SP\Repositories\DuplicatedItemException; @@ -48,8 +51,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -67,8 +70,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param int $id * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -97,8 +100,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * * @return QueryResult * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -130,7 +133,7 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte */ public function getByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -139,8 +142,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -165,7 +168,7 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -174,8 +177,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -212,8 +215,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * * @return int * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -252,8 +255,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param AuthTokenData $itemData * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkDuplicatedOnAdd($itemData) { @@ -279,8 +282,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param $id * * @return string - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getTokenByUserId($id) { @@ -300,8 +303,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * * @return int * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -342,8 +345,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param AuthTokenData $itemData * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkDuplicatedOnUpdate($itemData) { @@ -372,8 +375,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param string $token * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function refreshTokenByUserId($id, $token) { @@ -399,8 +402,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param $hash * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function refreshVaultByUserId($id, $vault, $hash) { @@ -425,8 +428,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param $token string El token de autorización * * @return false|int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUserIdForToken($token) { @@ -446,8 +449,8 @@ final class AuthTokenRepository extends Repository implements RepositoryItemInte * @param $token string El token de seguridad * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getTokenByToken($actionId, $token) { diff --git a/lib/SP/Repositories/Category/CategoryRepository.php b/lib/SP/Repositories/Category/CategoryRepository.php index 72f733e8..882c76a4 100644 --- a/lib/SP/Repositories/Category/CategoryRepository.php +++ b/lib/SP/Repositories/Category/CategoryRepository.php @@ -24,6 +24,9 @@ namespace SP\Repositories\Category; +use RuntimeException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; @@ -76,8 +79,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param CategoryData $itemData * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkDuplicatedOnAdd($itemData) { @@ -98,8 +101,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * * @return int * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -133,8 +136,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param CategoryData $itemData * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkDuplicatedOnUpdate($itemData) { @@ -155,8 +158,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param int $id * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -174,8 +177,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param string $name * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByName($name) { @@ -194,8 +197,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * Returns all the items * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -212,8 +215,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param array $ids * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -238,8 +241,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -261,8 +264,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -286,7 +289,7 @@ final class CategoryRepository extends Repository implements RepositoryItemInter */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -295,8 +298,8 @@ final class CategoryRepository extends Repository implements RepositoryItemInter * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { diff --git a/lib/SP/Repositories/Client/ClientRepository.php b/lib/SP/Repositories/Client/ClientRepository.php index 3935238f..29ab1798 100644 --- a/lib/SP/Repositories/Client/ClientRepository.php +++ b/lib/SP/Repositories/Client/ClientRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Client; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -294,7 +295,7 @@ final class ClientRepository extends Repository implements RepositoryItemInterfa */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/Config/ConfigRepository.php b/lib/SP/Repositories/Config/ConfigRepository.php index 34045aa6..6052c8b1 100644 --- a/lib/SP/Repositories/Config/ConfigRepository.php +++ b/lib/SP/Repositories/Config/ConfigRepository.php @@ -29,6 +29,7 @@ use SP\Core\Exceptions\QueryException; use SP\DataModel\ConfigData; use SP\Repositories\Repository; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class ConfigRepository @@ -57,8 +58,8 @@ final class ConfigRepository extends Repository * @param ConfigData $configData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(ConfigData $configData) { @@ -72,7 +73,7 @@ final class ConfigRepository extends Repository /** * Obtener un array con la configuración almacenada en la BBDD. * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException */ @@ -87,7 +88,7 @@ final class ConfigRepository extends Repository /** * @param string $param * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException */ @@ -120,8 +121,8 @@ final class ConfigRepository extends Repository * @param $param * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByParam($param) { diff --git a/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php b/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php index 210bddc8..39e4327a 100644 --- a/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php +++ b/lib/SP/Repositories/CustomField/CustomFieldDefRepository.php @@ -24,6 +24,9 @@ namespace SP\Repositories\CustomField; +use RuntimeException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldDefinitionData; use SP\DataModel\ItemSearchData; @@ -53,8 +56,8 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * @param CustomFieldDefinitionData $itemData * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -83,8 +86,8 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * @param CustomFieldDefinitionData $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -126,8 +129,8 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * @param int $id * * @return CustomFieldDefinitionData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -167,9 +170,9 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte /** * Returns all the items * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -191,8 +194,8 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * @param array $ids * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -221,8 +224,8 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * * @return int * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -247,9 +250,9 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function delete($id) { @@ -268,7 +271,7 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -278,7 +281,7 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -288,7 +291,7 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -296,9 +299,9 @@ final class CustomFieldDefRepository extends Repository implements RepositoryIte * * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { diff --git a/lib/SP/Repositories/CustomField/CustomFieldRepository.php b/lib/SP/Repositories/CustomField/CustomFieldRepository.php index 554590ed..925ef3d2 100644 --- a/lib/SP/Repositories/CustomField/CustomFieldRepository.php +++ b/lib/SP/Repositories/CustomField/CustomFieldRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\CustomField; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldData; @@ -32,6 +33,7 @@ use SP\Repositories\Repository; use SP\Repositories\RepositoryItemInterface; use SP\Repositories\RepositoryItemTrait; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class CustomFieldRepository @@ -112,7 +114,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function delete($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -270,13 +272,13 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function getById($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** * Returns all the items * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException */ @@ -292,7 +294,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn /** * Returns all the items that were encryptes * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws QueryException * @throws ConstraintException */ @@ -314,7 +316,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function getByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -326,7 +328,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function deleteByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -338,7 +340,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -350,7 +352,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function search(ItemSearchData $SearchData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -359,7 +361,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn * @param $moduleId * @param $itemId * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws QueryException * @throws ConstraintException */ @@ -400,7 +402,7 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -412,6 +414,6 @@ final class CustomFieldRepository extends Repository implements RepositoryItemIn */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } } \ No newline at end of file diff --git a/lib/SP/Repositories/CustomField/CustomFieldTypeRepository.php b/lib/SP/Repositories/CustomField/CustomFieldTypeRepository.php index 709f2ffa..47aad6a4 100644 --- a/lib/SP/Repositories/CustomField/CustomFieldTypeRepository.php +++ b/lib/SP/Repositories/CustomField/CustomFieldTypeRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\CustomField; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -33,6 +34,7 @@ use SP\Repositories\Repository; use SP\Repositories\RepositoryItemInterface; use SP\Repositories\RepositoryItemTrait; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class CustomFieldTypeRepository @@ -72,7 +74,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -108,7 +110,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -116,7 +118,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt * * @param int $id * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException */ @@ -133,7 +135,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt /** * Returns all the items * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException */ @@ -155,7 +157,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt */ public function getByIdBatch(array $ids) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -209,7 +211,7 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -221,6 +223,6 @@ final class CustomFieldTypeRepository extends Repository implements RepositoryIt */ public function search(ItemSearchData $SearchData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } } \ No newline at end of file diff --git a/lib/SP/Repositories/ItemPreset/ItemPresetRepository.php b/lib/SP/Repositories/ItemPreset/ItemPresetRepository.php index 32101fc0..561d6d23 100644 --- a/lib/SP/Repositories/ItemPreset/ItemPresetRepository.php +++ b/lib/SP/Repositories/ItemPreset/ItemPresetRepository.php @@ -24,6 +24,9 @@ namespace SP\Repositories\ItemPreset; +use RuntimeException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemPresetData; use SP\DataModel\ItemSearchData; use SP\Repositories\Repository; @@ -47,8 +50,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param ItemPresetData $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -84,8 +87,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param ItemPresetData $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -123,8 +126,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -142,8 +145,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param int $id * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -166,8 +169,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param int $userProfileId * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByFilter(string $type, int $userId, int $userGroupId, int $userProfileId) { @@ -199,8 +202,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * Returns all the items * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -219,8 +222,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param array $ids * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -244,8 +247,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -268,7 +271,7 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -278,7 +281,7 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -288,7 +291,7 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -297,8 +300,8 @@ class ItemPresetRepository extends Repository implements RepositoryItemInterface * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { diff --git a/lib/SP/Repositories/Notification/NotificationRepository.php b/lib/SP/Repositories/Notification/NotificationRepository.php index 94f86da4..7b371a3c 100644 --- a/lib/SP/Repositories/Notification/NotificationRepository.php +++ b/lib/SP/Repositories/Notification/NotificationRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Notification; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; @@ -312,7 +313,7 @@ final class NotificationRepository extends Repository implements RepositoryItemI */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -322,7 +323,7 @@ final class NotificationRepository extends Repository implements RepositoryItemI */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -332,7 +333,7 @@ final class NotificationRepository extends Repository implements RepositoryItemI */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/Plugin/PluginDataRepository.php b/lib/SP/Repositories/Plugin/PluginDataRepository.php index 3b7aeb5d..85fd5fa6 100644 --- a/lib/SP/Repositories/Plugin/PluginDataRepository.php +++ b/lib/SP/Repositories/Plugin/PluginDataRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Plugin; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; @@ -48,7 +49,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt * @param PluginDataModel $itemData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws QueryException */ public function create($itemData) @@ -75,7 +76,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt * @param PluginDataModel $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws QueryException */ public function update($itemData) @@ -104,7 +105,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt * @param $id * * @return int - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws QueryException */ public function delete($id) @@ -252,7 +253,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -264,7 +265,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -276,7 +277,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -288,7 +289,7 @@ final class PluginDataRepository extends Repository implements RepositoryItemInt */ public function search(ItemSearchData $SearchData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/Plugin/PluginRepository.php b/lib/SP/Repositories/Plugin/PluginRepository.php index c2fc7a20..6de49c85 100644 --- a/lib/SP/Repositories/Plugin/PluginRepository.php +++ b/lib/SP/Repositories/Plugin/PluginRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\Plugin; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -247,7 +248,7 @@ final class PluginRepository extends Repository implements RepositoryItemInterfa */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -259,7 +260,7 @@ final class PluginRepository extends Repository implements RepositoryItemInterfa */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -271,7 +272,7 @@ final class PluginRepository extends Repository implements RepositoryItemInterfa */ public function checkDuplicatedOnAdd($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/PublicLink/PublicLinkRepository.php b/lib/SP/Repositories/PublicLink/PublicLinkRepository.php index a64178d8..3ab9a9a7 100644 --- a/lib/SP/Repositories/PublicLink/PublicLinkRepository.php +++ b/lib/SP/Repositories/PublicLink/PublicLinkRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\PublicLink; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -109,7 +110,7 @@ final class PublicLinkRepository extends Repository implements RepositoryItemInt * * @param array $ids * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws QueryException * @throws ConstraintException */ @@ -182,7 +183,7 @@ final class PublicLinkRepository extends Repository implements RepositoryItemInt */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -190,7 +191,7 @@ final class PublicLinkRepository extends Repository implements RepositoryItemInt * * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws QueryException * @throws ConstraintException */ @@ -311,7 +312,7 @@ final class PublicLinkRepository extends Repository implements RepositoryItemInt */ public function checkDuplicatedOnUpdate($itemData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -514,7 +515,7 @@ final class PublicLinkRepository extends Repository implements RepositoryItemInt * * @param int $itemId * - * @return \SP\Storage\Database\QueryResult + * @return QueryResult * @throws ConstraintException * @throws QueryException * @todo Update tests to include userId diff --git a/lib/SP/Repositories/RepositoryItemTrait.php b/lib/SP/Repositories/RepositoryItemTrait.php index 2f9c64d3..d7d52773 100644 --- a/lib/SP/Repositories/RepositoryItemTrait.php +++ b/lib/SP/Repositories/RepositoryItemTrait.php @@ -24,6 +24,7 @@ namespace SP\Repositories; +use Exception; use SP\DataModel\DataModelInterface; use SP\Storage\Database\DatabaseUtil; use SP\Storage\Database\DBStorageInterface; @@ -51,7 +52,7 @@ trait RepositoryItemTrait foreach ($items as $key => $item) { try { $this->delete($item->getId()); - } catch (\Exception $e) { + } catch (Exception $e) { unset($items[$key]); } } diff --git a/lib/SP/Repositories/Track/TrackRepository.php b/lib/SP/Repositories/Track/TrackRepository.php index d2aa57ee..398e7139 100644 --- a/lib/SP/Repositories/Track/TrackRepository.php +++ b/lib/SP/Repositories/Track/TrackRepository.php @@ -44,8 +44,8 @@ final class TrackRepository extends Repository * @param TrackRequest $trackRequest * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add(TrackRequest $trackRequest) { @@ -74,8 +74,8 @@ final class TrackRepository extends Repository * @param $id int * * @return int - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException */ public function delete($id) { @@ -91,8 +91,8 @@ final class TrackRepository extends Repository * @param $id int * * @return int - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException */ public function unlock($id) { @@ -123,9 +123,9 @@ final class TrackRepository extends Repository /** * @param $id int * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -149,9 +149,9 @@ final class TrackRepository extends Repository } /** - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -176,9 +176,9 @@ final class TrackRepository extends Repository * * @param TrackRequest $trackRequest * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getTracksForClientFromTime(TrackRequest $trackRequest) { diff --git a/lib/SP/Repositories/User/UserPassRecoverRepository.php b/lib/SP/Repositories/User/UserPassRecoverRepository.php index 7439ef48..ee48880b 100644 --- a/lib/SP/Repositories/User/UserPassRecoverRepository.php +++ b/lib/SP/Repositories/User/UserPassRecoverRepository.php @@ -24,9 +24,12 @@ namespace SP\Repositories\User; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\Repositories\Repository; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class UserPassRecoverRepository @@ -42,8 +45,8 @@ final class UserPassRecoverRepository extends Repository * @param int $time * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAttemptsByUserId($userId, $time) { @@ -68,8 +71,8 @@ final class UserPassRecoverRepository extends Repository * @param string $hash * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($userId, $hash) { @@ -120,9 +123,9 @@ final class UserPassRecoverRepository extends Repository * @param $hash * @param $time * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getUserIdForHash($hash, $time) { diff --git a/lib/SP/Repositories/User/UserRepository.php b/lib/SP/Repositories/User/UserRepository.php index 2575b5af..e1676f8a 100644 --- a/lib/SP/Repositories/User/UserRepository.php +++ b/lib/SP/Repositories/User/UserRepository.php @@ -24,6 +24,7 @@ namespace SP\Repositories\User; +use RuntimeException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; @@ -364,7 +365,7 @@ final class UserRepository extends Repository implements RepositoryItemInterface */ public function checkInUse($id) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** diff --git a/lib/SP/Repositories/UserGroup/UserToUserGroupRepository.php b/lib/SP/Repositories/UserGroup/UserToUserGroupRepository.php index fa0a3018..7de119d7 100644 --- a/lib/SP/Repositories/UserGroup/UserToUserGroupRepository.php +++ b/lib/SP/Repositories/UserGroup/UserToUserGroupRepository.php @@ -24,10 +24,13 @@ namespace SP\Repositories\UserGroup; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\UserToUserGroupData; use SP\Repositories\Repository; use SP\Repositories\RepositoryItemTrait; use SP\Storage\Database\QueryData; +use SP\Storage\Database\QueryResult; /** * Class UserToUserGroupRepository @@ -45,8 +48,8 @@ final class UserToUserGroupRepository extends Repository * @param $userId * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkUserInGroup($groupId, $userId) { @@ -62,9 +65,9 @@ final class UserToUserGroupRepository extends Repository * * @param $userId * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getGroupsForUser($userId) { @@ -82,8 +85,8 @@ final class UserToUserGroupRepository extends Repository * @param array $users * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($id, array $users) { @@ -97,8 +100,8 @@ final class UserToUserGroupRepository extends Repository * @param $id int * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -117,8 +120,8 @@ final class UserToUserGroupRepository extends Repository * @param array $users * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($groupId, array $users) { @@ -147,9 +150,9 @@ final class UserToUserGroupRepository extends Repository * * @param $id int * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { diff --git a/lib/SP/Services/Account/AccountAclService.php b/lib/SP/Services/Account/AccountAclService.php index 12165614..1414c5ba 100644 --- a/lib/SP/Services/Account/AccountAclService.php +++ b/lib/SP/Services/Account/AccountAclService.php @@ -25,13 +25,16 @@ namespace SP\Services\Account; use SP\Core\Acl\Acl; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\FileNotFoundException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\Dto\AccountAclDto; use SP\DataModel\ProfileData; use SP\Services\Service; use SP\Services\User\UserLoginResponse; use SP\Services\UserGroup\UserToUserGroupService; use SP\Storage\File\FileCache; +use SP\Storage\File\FileCacheInterface; use SP\Storage\File\FileException; use SP\Util\FileUtil; @@ -99,8 +102,8 @@ final class AccountAclService extends Service * @param bool $isHistory * * @return AccountAcl - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAcl($actionId, AccountAclDto $accountAclDto = null, $isHistory = false) { @@ -188,8 +191,8 @@ final class AccountAclService extends Service * Actualizar la ACL * * @return AccountAcl - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function updateAcl() { @@ -215,8 +218,8 @@ final class AccountAclService extends Service /** * Crear la ACL de una cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function makeAcl() { @@ -230,8 +233,8 @@ final class AccountAclService extends Service } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function compileAccountAccess() { @@ -381,7 +384,7 @@ final class AccountAclService extends Service * * @param AccountAcl $accountAcl * - * @return null|\SP\Storage\File\FileCacheInterface + * @return null|FileCacheInterface */ public function saveAclInCache(AccountAcl $accountAcl) { diff --git a/lib/SP/Services/Account/AccountCryptService.php b/lib/SP/Services/Account/AccountCryptService.php index 58a2fbe8..ae80a366 100644 --- a/lib/SP/Services/Account/AccountCryptService.php +++ b/lib/SP/Services/Account/AccountCryptService.php @@ -25,6 +25,9 @@ namespace SP\Services\Account; use Defuse\Crypto\Exception\CryptoException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Crypt; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -84,7 +87,7 @@ final class AccountCryptService extends Service }); $this->eventDispatcher->notifyEvent('update.masterPassword.accounts.end', new Event($this, $eventMessage)); - } catch (\Exception $e) { + } catch (Exception $e) { $this->eventDispatcher->notifyEvent('exception', new Event($e)); throw new ServiceException( @@ -230,7 +233,7 @@ final class AccountCryptService extends Service }); $this->eventDispatcher->notifyEvent('update.masterPassword.accountsHistory.end', new Event($this, $eventMessage)); - } catch (\Exception $e) { + } catch (Exception $e) { $this->eventDispatcher->notifyEvent('exception', new Event($e)); throw new ServiceException( @@ -243,8 +246,8 @@ final class AccountCryptService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountFileService.php b/lib/SP/Services/Account/AccountFileService.php index f77cc4a1..e8e37aa1 100644 --- a/lib/SP/Services/Account/AccountFileService.php +++ b/lib/SP/Services/Account/AccountFileService.php @@ -24,8 +24,12 @@ namespace SP\Services\Account; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Exceptions\CheckException; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\InvalidImageException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\FileData; use SP\DataModel\FileExtData; use SP\DataModel\ItemSearchData; @@ -56,8 +60,8 @@ final class AccountFileService extends Service * * @return int * @throws InvalidImageException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -81,8 +85,8 @@ final class AccountFileService extends Service * @param $id * * @return FileExtData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getInfoById($id) { @@ -95,8 +99,8 @@ final class AccountFileService extends Service * @param int $id * * @return FileExtData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -107,8 +111,8 @@ final class AccountFileService extends Service * Returns all the items * * @return FileExtData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -121,8 +125,8 @@ final class AccountFileService extends Service * @param array $ids * * @return FileExtData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -136,8 +140,8 @@ final class AccountFileService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -155,8 +159,8 @@ final class AccountFileService extends Service * * @return AccountFileService * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -173,8 +177,8 @@ final class AccountFileService extends Service * @param ItemSearchData $searchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $searchData) { @@ -187,8 +191,8 @@ final class AccountFileService extends Service * @param int $id * * @return FileData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByAccountId($id) { @@ -196,8 +200,8 @@ final class AccountFileService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountHistoryService.php b/lib/SP/Services/Account/AccountHistoryService.php index b7ee398a..fa1f08f4 100644 --- a/lib/SP/Services/Account/AccountHistoryService.php +++ b/lib/SP/Services/Account/AccountHistoryService.php @@ -24,6 +24,9 @@ namespace SP\Services\Account; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AccountHistoryData; @@ -65,7 +68,7 @@ final class AccountHistoryService extends Service * * @return AccountHistoryData * @throws SPException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getById($id) { @@ -85,7 +88,7 @@ final class AccountHistoryService extends Service * * @return array Con los registros con id como clave y fecha - usuario como valor * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getHistoryForAccount($id) { @@ -122,7 +125,7 @@ final class AccountHistoryService extends Service * * @return ItemData[] * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getUsersByAccountId($id) { @@ -134,7 +137,7 @@ final class AccountHistoryService extends Service * * @return ItemData[] * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getUserGroupsByAccountId($id) { @@ -146,7 +149,7 @@ final class AccountHistoryService extends Service * * @return QueryResult * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function search(ItemSearchData $itemSearchData) { @@ -160,7 +163,7 @@ final class AccountHistoryService extends Service * * @return bool * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function create(AccountHistoryCreateDto $dto) { @@ -170,7 +173,7 @@ final class AccountHistoryService extends Service /** * @return array * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAccountsPassData() { @@ -184,7 +187,7 @@ final class AccountHistoryService extends Service * * @throws QueryException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function delete($id) { @@ -200,7 +203,7 @@ final class AccountHistoryService extends Service * * @return int * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function deleteByIdBatch(array $ids) { @@ -214,7 +217,7 @@ final class AccountHistoryService extends Service * * @return int * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function deleteByAccountIdBatch(array $ids) { @@ -225,7 +228,7 @@ final class AccountHistoryService extends Service * @param AccountPasswordRequest $accountRequest * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function updatePasswordMasterPass(AccountPasswordRequest $accountRequest) { @@ -239,7 +242,7 @@ final class AccountHistoryService extends Service * * @return array * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAll() { @@ -247,8 +250,8 @@ final class AccountHistoryService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountPresetService.php b/lib/SP/Services/Account/AccountPresetService.php index 51fc0e2d..b59eb750 100644 --- a/lib/SP/Services/Account/AccountPresetService.php +++ b/lib/SP/Services/Account/AccountPresetService.php @@ -25,6 +25,9 @@ namespace SP\Services\Account; use SP\Config\ConfigData; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\ValidationException; use SP\DataModel\ItemPreset\Password; use SP\Mvc\Controller\Validators\PasswordValidator; @@ -64,9 +67,9 @@ final class AccountPresetService * @param AccountRequest $accountRequest * * @throws ValidationException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException */ public function checkPasswordPreset(AccountRequest $accountRequest) { diff --git a/lib/SP/Services/Account/AccountRequest.php b/lib/SP/Services/Account/AccountRequest.php index 847ed771..d4893aca 100644 --- a/lib/SP/Services/Account/AccountRequest.php +++ b/lib/SP/Services/Account/AccountRequest.php @@ -135,14 +135,6 @@ final class AccountRequest * @var bool */ public $changePermissions = false; - /** - * @var bool - */ - public $updateUserPermissions = false; - /** - * @var bool - */ - public $updateUserGroupPermissions = false; /** * @var bool */ diff --git a/lib/SP/Services/Account/AccountSearchService.php b/lib/SP/Services/Account/AccountSearchService.php index 18e4454c..6e72f08c 100644 --- a/lib/SP/Services/Account/AccountSearchService.php +++ b/lib/SP/Services/Account/AccountSearchService.php @@ -24,8 +24,14 @@ namespace SP\Services\Account; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\Core\Acl\Acl; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountSearchVData; use SP\DataModel\Dto\AccountAclDto; use SP\DataModel\Dto\AccountCache; @@ -137,9 +143,9 @@ final class AccountSearchService extends Service * @param AccountSearchFilter $accountSearchFilter * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function processSearchResults(AccountSearchFilter $accountSearchFilter) { @@ -198,8 +204,8 @@ final class AccountSearchService extends Service * @param $string * * @return QueryCondition - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function analyzeQueryFilters($string) { @@ -328,7 +334,7 @@ final class AccountSearchService extends Service break; } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -342,8 +348,8 @@ final class AccountSearchService extends Service * @param AccountSearchVData $accountSearchData * * @return AccountCache - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ protected function getCacheForAccount(AccountSearchVData $accountSearchData) { @@ -401,8 +407,16 @@ final class AccountSearchService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @return string + */ + public function getCleanString() + { + return $this->cleanString; + } + + /** + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountService.php b/lib/SP/Services/Account/AccountService.php index 9709cb88..90689f9c 100644 --- a/lib/SP/Services/Account/AccountService.php +++ b/lib/SP/Services/Account/AccountService.php @@ -25,10 +25,16 @@ namespace SP\Services\Account; use Defuse\Crypto\Exception\CryptoException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AccountData; +use SP\DataModel\AccountExtData; use SP\DataModel\AccountHistoryData; use SP\DataModel\AccountPassData; use SP\DataModel\Dto\AccountDetailsResponse; @@ -48,6 +54,7 @@ use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; use SP\Storage\Database\QueryResult; +use stdClass; /** * Class AccountService @@ -84,7 +91,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return AccountService * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function withUsersById(AccountDetailsResponse $accountDetailsResponse) { @@ -98,7 +105,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return AccountService * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function withUserGroupsById(AccountDetailsResponse $accountDetailsResponse) { @@ -112,7 +119,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return AccountService * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function withTagsById(AccountDetailsResponse $accountDetailsResponse) { @@ -126,7 +133,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return bool * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function incrementViewCounter($id) { @@ -138,7 +145,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return bool * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function incrementDecryptCounter($id) { @@ -148,9 +155,9 @@ final class AccountService extends Service implements AccountServiceInterface /** * @param $id * - * @return \SP\DataModel\AccountPassData + * @return AccountPassData * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws NoSuchItemException */ public function getPasswordForId($id) @@ -172,8 +179,8 @@ final class AccountService extends Service implements AccountServiceInterface * @return int * @throws QueryException * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws ConstraintException + * @throws NoSuchPropertyException */ public function create(AccountRequest $accountRequest) { @@ -250,8 +257,8 @@ final class AccountService extends Service implements AccountServiceInterface * @param AccountRequest $accountRequest * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws ConstraintException + * @throws NoSuchPropertyException * @throws NoSuchItemException */ private function setPresetPrivate(AccountRequest $accountRequest) @@ -285,8 +292,8 @@ final class AccountService extends Service implements AccountServiceInterface * * @return AccountDetailsResponse * @throws QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws NoSuchItemException + * @throws ConstraintException */ public function getById($id) { @@ -348,8 +355,8 @@ final class AccountService extends Service implements AccountServiceInterface * @param int $accountId * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws ConstraintException + * @throws NoSuchPropertyException */ private function addPresetPermissions(int $accountId) { @@ -391,7 +398,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return int * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function createFromHistory(AccountHistoryData $data) { @@ -419,7 +426,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @param AccountRequest $accountRequest * - * @throws \Exception + * @throws Exception */ public function update(AccountRequest $accountRequest) { @@ -467,7 +474,7 @@ final class AccountService extends Service implements AccountServiceInterface * @throws NoSuchItemException * @throws QueryException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ private function addHistory($accountId, $isDelete = false) { @@ -489,7 +496,7 @@ final class AccountService extends Service implements AccountServiceInterface * @param AccountRequest $accountRequest * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ private function updateItems(AccountRequest $accountRequest) { @@ -561,7 +568,7 @@ final class AccountService extends Service implements AccountServiceInterface /** * @param AccountRequest $accountRequest * - * @throws \Exception + * @throws Exception */ public function editPassword(AccountRequest $accountRequest) { @@ -583,7 +590,7 @@ final class AccountService extends Service implements AccountServiceInterface * @param AccountPasswordRequest $accountRequest * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws QueryException */ public function updatePasswordMasterPass(AccountPasswordRequest $accountRequest) @@ -595,7 +602,7 @@ final class AccountService extends Service implements AccountServiceInterface * @param $historyId * @param $accountId * - * @throws \Exception + * @throws Exception */ public function editRestore($historyId, $accountId) { @@ -648,7 +655,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return array * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getForUser($accountId = null) { @@ -666,7 +673,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return array * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getLinked($accountId) { @@ -682,7 +689,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return AccountPassData * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws NoSuchItemException */ public function getPasswordHistoryForId($id) @@ -702,7 +709,7 @@ final class AccountService extends Service implements AccountServiceInterface /** * @return AccountData[] * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAllBasic() { @@ -714,7 +721,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return QueryResult * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function search(ItemSearchData $itemSearchData) { @@ -724,9 +731,9 @@ final class AccountService extends Service implements AccountServiceInterface /** * Devolver el número total de cuentas * - * @return \stdClass + * @return stdClass * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getTotalNumAccounts() { @@ -738,10 +745,10 @@ final class AccountService extends Service implements AccountServiceInterface * * @param $id * - * @return \SP\DataModel\AccountExtData + * @return AccountExtData * @throws QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws NoSuchItemException + * @throws ConstraintException */ public function getDataForLink($id) { @@ -759,7 +766,7 @@ final class AccountService extends Service implements AccountServiceInterface * * @return array Con los datos de la clave * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAccountsPassData() { @@ -774,7 +781,7 @@ final class AccountService extends Service implements AccountServiceInterface * @return QueryResult * @throws QueryException * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getByFilter(AccountSearchFilter $accountSearchFilter) { @@ -787,8 +794,8 @@ final class AccountService extends Service implements AccountServiceInterface } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountServiceInterface.php b/lib/SP/Services/Account/AccountServiceInterface.php index c5a9a22a..aaa5529e 100644 --- a/lib/SP/Services/Account/AccountServiceInterface.php +++ b/lib/SP/Services/Account/AccountServiceInterface.php @@ -24,6 +24,7 @@ namespace SP\Services\Account; +use SP\Core\Exceptions\SPException; use SP\DataModel\Dto\AccountDetailsResponse; /** @@ -37,7 +38,7 @@ interface AccountServiceInterface * @param int $id * * @return AccountDetailsResponse - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getById($id); } \ No newline at end of file diff --git a/lib/SP/Services/Account/AccountToFavoriteService.php b/lib/SP/Services/Account/AccountToFavoriteService.php index dc16fade..2eeca404 100644 --- a/lib/SP/Services/Account/AccountToFavoriteService.php +++ b/lib/SP/Services/Account/AccountToFavoriteService.php @@ -24,6 +24,10 @@ namespace SP\Services\Account; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Repositories\Account\AccountToFavoriteRepository; use SP\Services\Service; @@ -45,8 +49,8 @@ final class AccountToFavoriteService extends Service * @param $id int El Id de usuario * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getForUserId($id) { @@ -60,8 +64,8 @@ final class AccountToFavoriteService extends Service * @param $userId int El Id del usuario * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($accountId, $userId) { @@ -75,8 +79,8 @@ final class AccountToFavoriteService extends Service * @param $userId int El Id del usuario * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($accountId, $userId) { @@ -84,8 +88,8 @@ final class AccountToFavoriteService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Account/AccountToTagService.php b/lib/SP/Services/Account/AccountToTagService.php index d9e69008..ce446e07 100644 --- a/lib/SP/Services/Account/AccountToTagService.php +++ b/lib/SP/Services/Account/AccountToTagService.php @@ -24,6 +24,10 @@ namespace SP\Services\Account; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Account\AccountToTagRepository; use SP\Services\Service; @@ -44,8 +48,8 @@ final class AccountToTagService extends Service * @param $id * * @return ItemData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getTagsByAccountId($id) { @@ -53,8 +57,8 @@ final class AccountToTagService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Api/ApiService.php b/lib/SP/Services/Api/ApiService.php index 4e14571e..1b66e1b8 100644 --- a/lib/SP/Services/Api/ApiService.php +++ b/lib/SP/Services/Api/ApiService.php @@ -25,9 +25,12 @@ namespace SP\Services\Api; use Defuse\Crypto\Exception\CryptoException; +use Exception; use SP\Core\Crypt\Hash; use SP\Core\Crypt\Vault; +use SP\Core\Exceptions\InvalidArgumentException; use SP\Core\Exceptions\InvalidClassException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AuthTokenData; use SP\Modules\Api\Controllers\Help\HelpInterface; use SP\Repositories\Track\TrackRequest; @@ -81,8 +84,8 @@ final class ApiService extends Service * @param $actionId * * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException - * @throws \Exception + * @throws SPException + * @throws Exception */ public function setup($actionId) { @@ -124,7 +127,7 @@ final class ApiService extends Service { try { $this->trackService->add($this->trackRequest); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException( __u('Internal error'), ServiceException::ERROR, @@ -193,7 +196,7 @@ final class ApiService extends Service /** * Sets up user's data in context and performs some user checks * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ private function setupUser() { @@ -366,7 +369,7 @@ final class ApiService extends Service } /** - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ protected function initialize() { diff --git a/lib/SP/Services/Api/JsonRpcResponse.php b/lib/SP/Services/Api/JsonRpcResponse.php index b4a9c73d..2d54fd4f 100644 --- a/lib/SP/Services/Api/JsonRpcResponse.php +++ b/lib/SP/Services/Api/JsonRpcResponse.php @@ -24,6 +24,7 @@ namespace SP\Services\Api; +use Exception; use SP\Core\Exceptions\SPException; use SP\Http\Json; @@ -46,7 +47,7 @@ final class JsonRpcResponse * @param int $id * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public static function getResponse(ApiResponse $apiResponse, int $id) { @@ -58,12 +59,12 @@ final class JsonRpcResponse } /** - * @param \Exception $e - * @param int $id + * @param Exception $e + * @param int $id * * @return string */ - public static function getResponseException(\Exception $e, int $id) + public static function getResponseException(Exception $e, int $id) { $data = ($e instanceof SPException) ? $e->getHint() : null; diff --git a/lib/SP/Services/Auth/LoginService.php b/lib/SP/Services/Auth/LoginService.php index be13673b..dc34515e 100644 --- a/lib/SP/Services/Auth/LoginService.php +++ b/lib/SP/Services/Auth/LoginService.php @@ -27,9 +27,16 @@ namespace SP\Services\Auth; defined('APP_ROOT') || die(); use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\Core\Language; use SP\Core\UI\ThemeInterface; @@ -43,6 +50,7 @@ use SP\Providers\Auth\Database\DatabaseAuthData; use SP\Providers\Auth\Ldap\LdapAuth; use SP\Providers\Auth\Ldap\LdapAuthData; use SP\Providers\Auth\Ldap\LdapCode; +use SP\Repositories\NoSuchItemException; use SP\Repositories\Track\TrackRequest; use SP\Services\Crypt\TemporaryMasterPassService; use SP\Services\Service; @@ -113,19 +121,19 @@ final class LoginService extends Service /** * Ejecutar las acciones de login * + * @return LoginResponse + * @throws AuthException + * @throws SPException + * @throws EnvironmentIsBrokenException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException + * @throws Exception * @uses LoginService::authBrowser() * @uses LoginService::authDatabase() * @uses LoginService::authLdap() * - * @return LoginResponse - * @throws AuthException - * @throws SPException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \Exception */ public function doLogin() { @@ -195,7 +203,7 @@ final class LoginService extends Service { try { $this->trackService->add($this->trackRequest); - } catch (\Exception $e) { + } catch (Exception $e) { throw new AuthException( __u('Internal error'), AuthException::ERROR, @@ -208,13 +216,13 @@ final class LoginService extends Service /** * Comprobar estado del usuario * - * @throws AuthException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException * @return LoginResponse + * @throws EnvironmentIsBrokenException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException + * @throws AuthException */ private function checkUser() { @@ -268,8 +276,8 @@ final class LoginService extends Service * * @throws AuthException * @throws SPException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function loadMasterPass() { @@ -382,11 +390,11 @@ final class LoginService extends Service /** * Cargar la sesión del usuario * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function setUserSession() { @@ -449,9 +457,9 @@ final class LoginService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws InvalidArgumentException */ protected function initialize() { @@ -472,7 +480,7 @@ final class LoginService extends Service * @param LdapAuthData $authData * * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException * @throws AuthException */ private function authLdap(LdapAuthData $authData) @@ -578,7 +586,7 @@ final class LoginService extends Service // Creamos el usuario de LDAP en MySQL $this->userService->createOnLogin($userLoginRequest); } - } catch (\Exception $e) { + } catch (Exception $e) { throw new AuthException( __u('Internal error'), AuthException::ERROR, @@ -597,7 +605,7 @@ final class LoginService extends Service * @param DatabaseAuthData $authData * * @return bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException * @throws AuthException */ private function authDatabase(DatabaseAuthData $authData) @@ -699,7 +707,7 @@ final class LoginService extends Service ); return true; - } catch (\Exception $e) { + } catch (Exception $e) { throw new AuthException( __u('Internal error'), AuthException::ERROR, diff --git a/lib/SP/Services/AuthToken/AuthTokenService.php b/lib/SP/Services/AuthToken/AuthTokenService.php index 5010227e..8aff1477 100644 --- a/lib/SP/Services/AuthToken/AuthTokenService.php +++ b/lib/SP/Services/AuthToken/AuthTokenService.php @@ -24,10 +24,17 @@ namespace SP\Services\AuthToken; +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; use SP\Core\Crypt\Hash; use SP\Core\Crypt\Vault; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AuthTokenData; use SP\DataModel\ItemSearchData; @@ -105,8 +112,8 @@ final class AuthTokenService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -117,8 +124,8 @@ final class AuthTokenService extends Service * @param $id * * @return AuthTokenData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -129,8 +136,8 @@ final class AuthTokenService extends Service * @param $id * * @return AuthTokenService - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function delete($id) @@ -149,8 +156,8 @@ final class AuthTokenService extends Service * * @return bool * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -166,10 +173,10 @@ final class AuthTokenService extends Service * * @return mixed * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -184,10 +191,10 @@ final class AuthTokenService extends Service * * @return AuthTokenData * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ private function injectSecureData(AuthTokenData $authTokenData, $token = null) { @@ -212,7 +219,7 @@ final class AuthTokenService extends Service * Generar un token de acceso * * @return string - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ private function generateToken() { @@ -237,7 +244,7 @@ final class AuthTokenService extends Service * * @return Vault * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ private function getSecureData($token, $key) { @@ -247,7 +254,7 @@ final class AuthTokenService extends Service /** * @param AuthTokenData $itemData * - * @throws \Exception + * @throws Exception */ public function refreshAndUpdate(AuthTokenData $itemData) { @@ -267,9 +274,9 @@ final class AuthTokenService extends Service * @param string $token * * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException */ public function update(AuthTokenData $itemData, $token = null) { @@ -282,8 +289,8 @@ final class AuthTokenService extends Service * @param AuthTokenData $itemData * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function updateRaw(AuthTokenData $itemData) { @@ -299,8 +306,8 @@ final class AuthTokenService extends Service * @param $token string El token de seguridad * * @return false|AuthTokenData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws ServiceException */ public function getTokenByToken($actionId, $token) @@ -316,8 +323,8 @@ final class AuthTokenService extends Service /** * @return AuthTokenData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -325,8 +332,8 @@ final class AuthTokenService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Backup/FileBackupService.php b/lib/SP/Services/Backup/FileBackupService.php index 83cd5b9b..9e6ef00b 100644 --- a/lib/SP/Services/Backup/FileBackupService.php +++ b/lib/SP/Services/Backup/FileBackupService.php @@ -24,10 +24,17 @@ namespace SP\Services\Backup; +use Exception; +use PDO; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\Core\AppInfoInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\CheckException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\Core\PhpExtensionChecker; use SP\Services\Service; @@ -36,6 +43,7 @@ use SP\Storage\Database\Database; use SP\Storage\Database\DatabaseUtil; use SP\Storage\Database\QueryData; use SP\Storage\File\ArchiveHandler; +use SP\Storage\File\FileException; use SP\Storage\File\FileHandler; use SP\Util\Checks; @@ -111,7 +119,7 @@ final class FileBackupService extends Service $this->config->saveConfig($this->configData); } catch (ServiceException $e) { throw $e; - } catch (\Exception $e) { + } catch (Exception $e) { $this->eventDispatcher->notifyEvent('exception', new Event($e)); throw new ServiceException( @@ -127,8 +135,8 @@ final class FileBackupService extends Service /** * Comprobar y crear el directorio de backups. * - * @throws ServiceException * @return bool + * @throws ServiceException */ private function checkBackupDir() { @@ -203,13 +211,13 @@ final class FileBackupService extends Service * Backup de las tablas de la BBDD. * Utilizar '*' para toda la BBDD o 'table1 table2 table3...' * - * @param \SP\Storage\File\FileHandler $fileHandler - * @param string|array $tables + * @param FileHandler $fileHandler + * @param string|array $tables * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Storage\File\FileException - * @throws \SP\Core\Exceptions\CheckException + * @throws ConstraintException + * @throws QueryException + * @throws FileException + * @throws CheckException */ private function backupTables(FileHandler $fileHandler, $tables = '*') { @@ -291,11 +299,11 @@ final class FileBackupService extends Service $queryData->setQuery('SELECT * FROM `' . $tableName . '`'); // Consulta para obtener los registros de la tabla - $queryRes = $db->doQueryRaw($queryData, [\PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL], false); + $queryRes = $db->doQueryRaw($queryData, [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL], false); $numColumns = $queryRes->columnCount(); - while ($row = $queryRes->fetch(\PDO::FETCH_NUM, \PDO::FETCH_ORI_NEXT)) { + while ($row = $queryRes->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT)) { $fileHandler->write('INSERT INTO `' . $tableName . '` VALUES('); $field = 1; @@ -340,8 +348,8 @@ final class FileBackupService extends Service * Realizar un backup de la aplicación y comprimirlo. * * @return bool - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ private function backupApp() { @@ -389,8 +397,8 @@ final class FileBackupService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Category/CategoryService.php b/lib/SP/Services/Category/CategoryService.php index 13475527..71beafa5 100644 --- a/lib/SP/Services/Category/CategoryService.php +++ b/lib/SP/Services/Category/CategoryService.php @@ -24,6 +24,10 @@ namespace SP\Services\Category; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; @@ -53,8 +57,8 @@ final class CategoryService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -66,8 +70,8 @@ final class CategoryService extends Service * * @return CategoryData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -86,8 +90,8 @@ final class CategoryService extends Service * @param string $name * * @return CategoryData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getByName($name) @@ -105,8 +109,8 @@ final class CategoryService extends Service * @param $id * * @return $this - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function delete($id) @@ -125,8 +129,8 @@ final class CategoryService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -154,8 +158,8 @@ final class CategoryService extends Service * * @return int * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -166,8 +170,8 @@ final class CategoryService extends Service * Get all items from the service's repository * * @return CategoryData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -175,8 +179,8 @@ final class CategoryService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Client/ClientService.php b/lib/SP/Services/Client/ClientService.php index 4237f817..1adad146 100644 --- a/lib/SP/Services/Client/ClientService.php +++ b/lib/SP/Services/Client/ClientService.php @@ -24,6 +24,10 @@ namespace SP\Services\Client; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ClientData; use SP\DataModel\ItemData; @@ -35,6 +39,7 @@ use SP\Services\Account\AccountFilterUser; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; +use SP\Storage\Database\QueryResult; /** * Class ClientService @@ -53,9 +58,9 @@ final class ClientService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -67,8 +72,8 @@ final class ClientService extends Service * * @return ClientData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -85,8 +90,8 @@ final class ClientService extends Service * @param string $name * * @return ClientData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getByName($name) @@ -118,8 +123,8 @@ final class ClientService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -147,8 +152,8 @@ final class ClientService extends Service * * @return int * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -159,8 +164,8 @@ final class ClientService extends Service * Get all items from the service's repository * * @return ClientData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -171,8 +176,8 @@ final class ClientService extends Service * Returns all clients visible for a given user * * @return ItemData[] - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException */ public function getAllForUser() { @@ -180,8 +185,8 @@ final class ClientService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Config/ConfigBackupService.php b/lib/SP/Services/Config/ConfigBackupService.php index 24ca81aa..27cded90 100644 --- a/lib/SP/Services/Config/ConfigBackupService.php +++ b/lib/SP/Services/Config/ConfigBackupService.php @@ -24,11 +24,17 @@ namespace SP\Services\Config; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use RuntimeException; use SP\Config\ConfigData; +use SP\Core\Exceptions\SPException; use SP\Http\Json; use SP\Repositories\NoSuchItemException; use SP\Services\Service; use SP\Services\ServiceException; +use SP\Storage\File\FileException; use SP\Util\Util; /** @@ -47,7 +53,7 @@ final class ConfigBackupService extends Service * @param string $configData * * @return string - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public static function configToJson(string $configData): string { @@ -59,7 +65,7 @@ final class ConfigBackupService extends Service */ public static function configToXml(string $configData) { - throw new \RuntimeException('Not implemented'); + throw new RuntimeException('Not implemented'); } /** @@ -72,7 +78,7 @@ final class ConfigBackupService extends Service try { $this->configService->save('config_backup', $this->packConfigData($configData)); $this->configService->save('config_backup_date', time()); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -90,9 +96,9 @@ final class ConfigBackupService extends Service /** * @return ConfigData * @throws ServiceException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws FileException */ public function restore() { diff --git a/lib/SP/Services/Config/ConfigService.php b/lib/SP/Services/Config/ConfigService.php index 971408cb..c26a3a2d 100644 --- a/lib/SP/Services/Config/ConfigService.php +++ b/lib/SP/Services/Config/ConfigService.php @@ -24,6 +24,9 @@ namespace SP\Services\Config; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\DataModel\ConfigData; @@ -57,7 +60,7 @@ final class ConfigService extends Service { try { $result = $this->configRepository->getByParam($param); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, null, $e->getCode(), $e); } @@ -82,8 +85,8 @@ final class ConfigService extends Service * @param ConfigData $configData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(ConfigData $configData) { @@ -103,7 +106,7 @@ final class ConfigService extends Service $this->save($param, $value); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new ServiceException($e->getMessage(), ServiceException::ERROR, null, $e->getCode(), $e); @@ -115,8 +118,8 @@ final class ConfigService extends Service * @param string $value * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function save($param, $value) { @@ -155,8 +158,8 @@ final class ConfigService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Crypt/MasterPassService.php b/lib/SP/Services/Crypt/MasterPassService.php index ee8e054d..31c97708 100644 --- a/lib/SP/Services/Crypt/MasterPassService.php +++ b/lib/SP/Services/Crypt/MasterPassService.php @@ -24,7 +24,13 @@ namespace SP\Services\Crypt; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Hash; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountCryptService; use SP\Services\Config\ConfigService; use SP\Services\CustomField\CustomFieldCryptService; @@ -59,7 +65,7 @@ final class MasterPassService extends Service * * @return bool * @throws ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws NoSuchItemException */ public function checkUserUpdateMPass($userMPassTime) { @@ -72,7 +78,7 @@ final class MasterPassService extends Service * * @return bool * @throws ServiceException - * @throws \SP\Repositories\NoSuchItemException + * @throws NoSuchItemException */ public function checkMasterPassword($masterPassword) { @@ -82,7 +88,7 @@ final class MasterPassService extends Service /** * @param UpdateMasterPassRequest $request * - * @throws \Exception + * @throws Exception */ public function changeMasterPassword(UpdateMasterPassRequest $request) { @@ -100,8 +106,8 @@ final class MasterPassService extends Service /** * @param $hash * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function updateConfig($hash) { @@ -110,8 +116,8 @@ final class MasterPassService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Crypt/SecureSessionService.php b/lib/SP/Services/Crypt/SecureSessionService.php index b2471b8c..81fd6811 100644 --- a/lib/SP/Services/Crypt/SecureSessionService.php +++ b/lib/SP/Services/Crypt/SecureSessionService.php @@ -25,6 +25,7 @@ namespace SP\Services\Crypt; use Defuse\Crypto\Key; +use Exception; use SP\Core\Crypt\UUIDCookie; use SP\Core\Crypt\Vault; use SP\Http\Request; @@ -85,7 +86,7 @@ final class SecureSessionService extends Service } } catch (FileException $e) { return $this->saveKey(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } @@ -128,7 +129,7 @@ final class SecureSessionService extends Service logger('Saved session key'); return $securedKey; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } diff --git a/lib/SP/Services/Crypt/TemporaryMasterPassService.php b/lib/SP/Services/Crypt/TemporaryMasterPassService.php index d257941e..a0057997 100644 --- a/lib/SP/Services/Crypt/TemporaryMasterPassService.php +++ b/lib/SP/Services/Crypt/TemporaryMasterPassService.php @@ -24,11 +24,17 @@ namespace SP\Services\Crypt; +use Defuse\Crypto\Exception\CryptoException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\AppInfoInterface; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Messages\MailMessage; use SP\DataModel\Dto\ConfigRequest; use SP\Repositories\NoSuchItemException; @@ -104,7 +110,7 @@ final class TemporaryMasterPassService extends Service ); return $randomKey; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new ServiceException(__u('Error while generating the temporary password')); @@ -154,7 +160,7 @@ final class TemporaryMasterPassService extends Service return $isValid; } catch (NoSuchItemException $e) { return false; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new ServiceException(__u('Error while checking the temporary password')); @@ -187,8 +193,8 @@ final class TemporaryMasterPassService extends Service * @param $key * * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function sendByEmailForGroup($groupId, $key) { @@ -206,8 +212,8 @@ final class TemporaryMasterPassService extends Service * @param $key * * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function sendByEmailForAllUsers($key) { @@ -254,7 +260,7 @@ final class TemporaryMasterPassService extends Service * @return string con la clave maestra desencriptada * @throws NoSuchItemException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function getUsingKey($key) { @@ -264,8 +270,8 @@ final class TemporaryMasterPassService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/CustomField/CustomFieldCryptService.php b/lib/SP/Services/CustomField/CustomFieldCryptService.php index c77edb64..a58293ca 100644 --- a/lib/SP/Services/CustomField/CustomFieldCryptService.php +++ b/lib/SP/Services/CustomField/CustomFieldCryptService.php @@ -26,9 +26,14 @@ namespace SP\Services\CustomField; defined('APP_ROOT') || die(); +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Crypt; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldData; use SP\Services\Crypt\UpdateMasterPassRequest; use SP\Services\Service; @@ -54,8 +59,8 @@ final class CustomFieldCryptService extends Service /** * @param callable $decryptor * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ protected function processUpdateMasterPassword(callable $decryptor) { @@ -94,7 +99,7 @@ final class CustomFieldCryptService extends Service $this->customFieldService->updateMasterPass($customField, $this->request->getNewMasterPass()); $success[] = $customField->getId(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -129,7 +134,7 @@ final class CustomFieldCryptService extends Service $customFieldData->getKey(), $this->request->getCurrentMasterPass()); }); - } catch (\Exception $e) { + } catch (Exception $e) { $this->eventDispatcher->notifyEvent('exception', new Event($e)); throw new ServiceException( @@ -142,8 +147,8 @@ final class CustomFieldCryptService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/CustomField/CustomFieldDefService.php b/lib/SP/Services/CustomField/CustomFieldDefService.php index 26d61370..b7b96de5 100644 --- a/lib/SP/Services/CustomField/CustomFieldDefService.php +++ b/lib/SP/Services/CustomField/CustomFieldDefService.php @@ -24,7 +24,11 @@ namespace SP\Services\CustomField; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Acl\ActionsInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldDefinitionData; use SP\DataModel\ItemSearchData; use SP\Repositories\CustomField\CustomFieldDefRepository; @@ -32,6 +36,7 @@ use SP\Repositories\NoSuchItemException; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; +use SP\Storage\Database\QueryResult; /** * Class CustomFieldDefService @@ -84,9 +89,9 @@ final class CustomFieldDefService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -136,8 +141,8 @@ final class CustomFieldDefService extends Service * @param $itemData * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create($itemData) { @@ -170,10 +175,10 @@ final class CustomFieldDefService extends Service /** * @param $id * - * @return \SP\DataModel\CustomFieldDefinitionData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @return CustomFieldDefinitionData + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function getById($id) { @@ -184,8 +189,8 @@ final class CustomFieldDefService extends Service * @param CustomFieldDefinitionData $itemData * * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function updateRaw(CustomFieldDefinitionData $itemData) { @@ -198,8 +203,8 @@ final class CustomFieldDefService extends Service * Get all items from the service's repository * * @return CustomFieldDefinitionData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -207,8 +212,8 @@ final class CustomFieldDefService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/CustomField/CustomFieldService.php b/lib/SP/Services/CustomField/CustomFieldService.php index 5cd4c18f..e12813f7 100644 --- a/lib/SP/Services/CustomField/CustomFieldService.php +++ b/lib/SP/Services/CustomField/CustomFieldService.php @@ -25,11 +25,15 @@ namespace SP\Services\CustomField; use Defuse\Crypto\Exception\CryptoException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldData; use SP\Repositories\CustomField\CustomFieldRepository; +use SP\Repositories\NoSuchItemException; use SP\Services\Service; use SP\Services\ServiceException; @@ -104,7 +108,7 @@ final class CustomFieldService extends Service * * @return array * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getForModuleAndItemId($moduleId, $itemId) { @@ -119,7 +123,7 @@ final class CustomFieldService extends Service * @return bool * @throws CryptoException * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws SPException */ public function updateOrCreateData(CustomFieldData $customFieldData) @@ -171,8 +175,8 @@ final class CustomFieldService extends Service * @throws CryptoException * @throws QueryException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws NoSuchItemException */ public function create(CustomFieldData $customFieldData) { @@ -214,7 +218,7 @@ final class CustomFieldService extends Service * * @return int * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function deleteCustomFieldDefinitionData($definitionId) { @@ -229,7 +233,7 @@ final class CustomFieldService extends Service * * @return bool * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function deleteCustomFieldDataBatch(array $ids, $moduleId) { @@ -242,8 +246,8 @@ final class CustomFieldService extends Service * @param array $definitionIds * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteCustomFieldDefinitionDataBatch(array $definitionIds) { @@ -260,7 +264,7 @@ final class CustomFieldService extends Service * @throws CryptoException * @throws QueryException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function updateMasterPass(CustomFieldData $customFieldData, $masterPass) { @@ -272,7 +276,7 @@ final class CustomFieldService extends Service /** * @return CustomFieldData[] * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAll() { @@ -282,7 +286,7 @@ final class CustomFieldService extends Service /** * @return CustomFieldData[] * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function getAllEncrypted() { @@ -290,8 +294,8 @@ final class CustomFieldService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/CustomField/CustomFieldTypeService.php b/lib/SP/Services/CustomField/CustomFieldTypeService.php index c7f796e8..a7af1876 100644 --- a/lib/SP/Services/CustomField/CustomFieldTypeService.php +++ b/lib/SP/Services/CustomField/CustomFieldTypeService.php @@ -24,6 +24,8 @@ namespace SP\Services\CustomField; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldTypeData; use SP\Repositories\CustomField\CustomFieldTypeRepository; use SP\Repositories\NoSuchItemException; @@ -48,8 +50,8 @@ final class CustomFieldTypeService extends Service * Get all items from the service's repository * * @return CustomFieldTypeData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -60,8 +62,8 @@ final class CustomFieldTypeService extends Service * Returns all the items * * @return CustomFieldTypeData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -72,8 +74,8 @@ final class CustomFieldTypeService extends Service * @param $id * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) diff --git a/lib/SP/Services/EventLog/EventlogService.php b/lib/SP/Services/EventLog/EventlogService.php index 3eaeef63..c1492dae 100644 --- a/lib/SP/Services/EventLog/EventlogService.php +++ b/lib/SP/Services/EventLog/EventlogService.php @@ -24,6 +24,11 @@ namespace SP\Services\EventLog; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\EventlogData; use SP\DataModel\ItemSearchData; use SP\Http\Request; @@ -51,8 +56,8 @@ final class EventlogService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -61,9 +66,9 @@ final class EventlogService extends Service /** * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function clear() { @@ -74,8 +79,8 @@ final class EventlogService extends Service * @param EventlogData $eventlogData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(EventlogData $eventlogData) { @@ -89,8 +94,8 @@ final class EventlogService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Export/XmlExportService.php b/lib/SP/Services/Export/XmlExportService.php index 488bc7ab..42e49d07 100644 --- a/lib/SP/Services/Export/XmlExportService.php +++ b/lib/SP/Services/Export/XmlExportService.php @@ -24,7 +24,10 @@ namespace SP\Services\Export; +use DOMDocument; +use DOMElement; use DOMXPath; +use Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; @@ -33,6 +36,7 @@ use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\CheckException; use SP\Core\PhpExtensionChecker; use SP\DataModel\CategoryData; use SP\Services\Account\AccountService; @@ -43,6 +47,7 @@ use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\Tag\TagService; use SP\Storage\File\ArchiveHandler; +use SP\Storage\File\FileException; use SP\Storage\File\FileHandler; use SP\Util\VersionUtil; @@ -64,11 +69,11 @@ final class XmlExportService extends Service */ private $extensionChecker; /** - * @var \DOMDocument + * @var DOMDocument */ private $xml; /** - * @var \DOMElement + * @var DOMElement */ private $root; /** @@ -95,7 +100,7 @@ final class XmlExportService extends Service * @param string $pass string La clave de exportación * * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function doExport(string $exportPath, string $pass = null) { @@ -132,7 +137,7 @@ final class XmlExportService extends Service * Genera el nombre del archivo usado para la exportación. * * @return string - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function generateExportFilename(): string { @@ -194,7 +199,7 @@ final class XmlExportService extends Service $this->writeXML(); } catch (ServiceException $e) { throw $e; - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException( __u('Error while exporting'), ServiceException::ERROR, @@ -213,9 +218,9 @@ final class XmlExportService extends Service private function createRoot() { try { - $this->xml = new \DOMDocument('1.0', 'UTF-8'); + $this->xml = new DOMDocument('1.0', 'UTF-8'); $this->root = $this->xml->appendChild($this->xml->createElement('Root')); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -246,7 +251,7 @@ final class XmlExportService extends Service $nodeMeta->appendChild($metaGroup); $this->root->appendChild($nodeMeta); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -294,7 +299,7 @@ final class XmlExportService extends Service } $this->appendNode($nodeCategories); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -302,11 +307,11 @@ final class XmlExportService extends Service /** * Añadir un nuevo nodo al árbol raíz * - * @param \DOMElement $node El nodo a añadir + * @param DOMElement $node El nodo a añadir * * @throws ServiceException */ - private function appendNode(\DOMElement $node) + private function appendNode(DOMElement $node) { try { // Si se utiliza clave de encriptación los datos se encriptan en un nuevo nodo: @@ -322,7 +327,7 @@ final class XmlExportService extends Service // Buscar si existe ya un nodo para el conjunto de datos encriptados $encryptedNode = $this->root->getElementsByTagName('Encrypted')->item(0); - if (!$encryptedNode instanceof \DOMElement) { + if (!$encryptedNode instanceof DOMElement) { $encryptedNode = $this->xml->createElement('Encrypted'); $encryptedNode->setAttribute('hash', Hash::hashKey($this->exportPass)); } @@ -342,7 +347,7 @@ final class XmlExportService extends Service } else { $this->root->appendChild($node); } - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -367,8 +372,8 @@ final class XmlExportService extends Service * * @throws ServiceException * @throws ServiceException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function createClients() { @@ -404,7 +409,7 @@ final class XmlExportService extends Service } $this->appendNode($nodeClients); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -413,8 +418,8 @@ final class XmlExportService extends Service * Crear el nodo con los datos de las etiquetas * * @throws ServiceException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function createTags() { @@ -448,7 +453,7 @@ final class XmlExportService extends Service } $this->appendNode($nodeTags); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -457,8 +462,8 @@ final class XmlExportService extends Service * Crear el nodo con los datos de las cuentas * * @throws ServiceException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function createAccounts() { @@ -516,7 +521,7 @@ final class XmlExportService extends Service } $this->appendNode($nodeAccounts); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } @@ -542,17 +547,17 @@ final class XmlExportService extends Service ->getElementsByTagName('Meta') ->item(0) ->appendChild($hashNode); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } /** - * @param \DOMDocument $document + * @param DOMDocument $document * * @return string */ - public static function generateHashFromNodes(\DOMDocument $document): string + public static function generateHashFromNodes(DOMDocument $document): string { $data = ''; @@ -577,14 +582,14 @@ final class XmlExportService extends Service if (!$this->xml->save($this->exportFile)) { throw new ServiceException(__u('Error while creating the XML file')); } - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } /** - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ public function createArchive() { @@ -612,8 +617,8 @@ final class XmlExportService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { @@ -633,7 +638,7 @@ final class XmlExportService extends Service { try { return $this->xml->saveXML($this->root->getElementsByTagName($node)->item(0)); - } catch (\Exception $e) { + } catch (Exception $e) { throw new ServiceException($e->getMessage(), ServiceException::ERROR, __FUNCTION__); } } diff --git a/lib/SP/Services/Export/XmlVerifyService.php b/lib/SP/Services/Export/XmlVerifyService.php index 6374e9df..50320ae1 100644 --- a/lib/SP/Services/Export/XmlVerifyService.php +++ b/lib/SP/Services/Export/XmlVerifyService.php @@ -27,11 +27,13 @@ namespace SP\Services\Export; use Defuse\Crypto\Exception\CryptoException; use DOMDocument; +use DOMElement; use DOMXPath; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Services\Service; use SP\Services\ServiceException; +use SP\Storage\File\FileException; use SP\Storage\File\FileHandler; /** @@ -62,7 +64,7 @@ final class XmlVerifyService extends Service * * @return VerifyResult * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function verify(string $xmlFile): VerifyResult { @@ -77,7 +79,7 @@ final class XmlVerifyService extends Service /** * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function setup() { @@ -88,7 +90,7 @@ final class XmlVerifyService extends Service * Leer el archivo a un objeto XML. * * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ protected function readXmlFile() { @@ -163,7 +165,7 @@ final class XmlVerifyService extends Service * * @return VerifyResult * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException * @throws CryptoException */ public function verifyEncrypted(string $xmlFile, string $password): VerifyResult @@ -221,7 +223,7 @@ final class XmlVerifyService extends Service $xmlOut->appendChild($xmlOut->createElement('Root')); foreach ($this->xml->getElementsByTagName('Data') as $node) { - /** @var $node \DOMElement */ + /** @var $node DOMElement */ $xml = new DOMDocument(); if (!$xml->loadXML(Crypt::decrypt(base64_decode($node->nodeValue), $node->getAttribute('key'), $this->password))) { diff --git a/lib/SP/Services/Import/CsvImport.php b/lib/SP/Services/Import/CsvImport.php index b4ee8825..f5c46810 100644 --- a/lib/SP/Services/Import/CsvImport.php +++ b/lib/SP/Services/Import/CsvImport.php @@ -26,6 +26,7 @@ namespace SP\Services\Import; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Storage\File\FileException; defined('APP_ROOT') || die(); @@ -41,7 +42,7 @@ final class CsvImport extends CsvImportBase implements ImportInterface * * @return $this|ImportInterface * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function doImport() { diff --git a/lib/SP/Services/Import/CsvImportBase.php b/lib/SP/Services/Import/CsvImportBase.php index 42fe9d91..3019fe95 100644 --- a/lib/SP/Services/Import/CsvImportBase.php +++ b/lib/SP/Services/Import/CsvImportBase.php @@ -24,6 +24,7 @@ namespace SP\Services\Import; +use Exception; use Psr\Container\ContainerInterface; use SP\Core\Events\Event; use SP\Core\Events\EventDispatcher; @@ -35,6 +36,7 @@ use SP\Services\Account\AccountService; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\Tag\TagService; +use SP\Storage\File\FileException; defined('APP_ROOT') || die(); @@ -112,7 +114,7 @@ abstract class CsvImportBase * Obtener los datos de las entradas de sysPass y crearlas * * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ protected function processAccounts() { @@ -162,7 +164,7 @@ abstract class CsvImportBase ->addDetail(__u('Account imported'), $accountName) ->addDetail(__u('Client'), $clientName)) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', diff --git a/lib/SP/Services/Import/FileImport.php b/lib/SP/Services/Import/FileImport.php index 265eb0d3..10362805 100644 --- a/lib/SP/Services/Import/FileImport.php +++ b/lib/SP/Services/Import/FileImport.php @@ -40,14 +40,14 @@ defined('APP_ROOT') || die(); final class FileImport { /** - * @var \SP\Storage\File\FileHandler + * @var FileHandler */ private $fileHandler; /** * FileImport constructor. * - * @param \SP\Storage\File\FileHandler $fileHandler Datos del archivo a importar + * @param FileHandler $fileHandler Datos del archivo a importar */ private function __construct(FileHandler $fileHandler) { @@ -172,7 +172,7 @@ final class FileImport } /** - * @return \SP\Storage\File\FileHandler + * @return FileHandler */ public function getFileHandler(): FileHandler { diff --git a/lib/SP/Services/Import/ImportService.php b/lib/SP/Services/Import/ImportService.php index f2eae829..575cd60b 100644 --- a/lib/SP/Services/Import/ImportService.php +++ b/lib/SP/Services/Import/ImportService.php @@ -25,7 +25,11 @@ namespace SP\Services\Import; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Services\Service; +use SP\Storage\File\FileException; defined('APP_ROOT') || die(); @@ -59,9 +63,9 @@ final class ImportService extends Service * @param FileImport $fileImport * * @return int Returns the total number of imported items - * @throws \Exception - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws Exception + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function doImport(ImportParams $importParams, FileImport $fileImport) { @@ -78,7 +82,7 @@ final class ImportService extends Service /** * @return ImportInterface * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ protected function selectImportType() { @@ -100,8 +104,8 @@ final class ImportService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Import/ImportTrait.php b/lib/SP/Services/Import/ImportTrait.php index 59d37b6a..f6d5943c 100644 --- a/lib/SP/Services/Import/ImportTrait.php +++ b/lib/SP/Services/Import/ImportTrait.php @@ -24,8 +24,12 @@ namespace SP\Services\Import; +use Defuse\Crypto\Exception\CryptoException; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\OldCrypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ClientData; @@ -96,10 +100,10 @@ trait ImportTrait * * @throws ImportException * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException */ protected function addAccount(AccountRequest $accountRequest) { diff --git a/lib/SP/Services/Import/KeepassImport.php b/lib/SP/Services/Import/KeepassImport.php index e2c338cc..7d60f85a 100644 --- a/lib/SP/Services/Import/KeepassImport.php +++ b/lib/SP/Services/Import/KeepassImport.php @@ -26,8 +26,10 @@ namespace SP\Services\Import; use DOMElement; use DOMXPath; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ClientData; use SP\Services\Account\AccountRequest; @@ -49,7 +51,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface * Iniciar la importación desde KeePass * * @return ImportInterface - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function doImport() { @@ -66,7 +68,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface /** * Obtener los grupos y procesar lan entradas de KeePass. * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ private function process() { @@ -81,7 +83,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface $this->getEntries(); - /** @var \SP\Services\Account\AccountRequest[] $group */ + /** @var AccountRequest[] $group */ foreach ($this->items as $group => $entry) { try { $categoryId = $this->addCategory(new CategoryData(null, $group, 'KeePass')); @@ -105,7 +107,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface ); } } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -164,7 +166,7 @@ final class KeepassImport extends XmlImportBase implements ImportInterface /** * @param array $entry * - * @return \SP\Services\Account\AccountRequest + * @return AccountRequest */ private function mapEntryToAccount(array $entry) { diff --git a/lib/SP/Services/Import/SyspassImport.php b/lib/SP/Services/Import/SyspassImport.php index 2a09e061..5c7405d3 100644 --- a/lib/SP/Services/Import/SyspassImport.php +++ b/lib/SP/Services/Import/SyspassImport.php @@ -25,7 +25,11 @@ namespace SP\Services\Import; use Defuse\Crypto\Exception\CryptoException; +use DOMDocument; +use DOMElement; +use DOMNodeList; use DOMXPath; +use Exception; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Crypt\OldCrypt; @@ -48,8 +52,8 @@ final class SyspassImport extends XmlImportBase implements ImportInterface /** * Iniciar la importación desde sysPass. * - * @throws ImportException * @return ImportInterface + * @throws ImportException */ public function doImport() { @@ -89,7 +93,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface return $this; } catch (ImportException $e) { throw $e; - } catch (\Exception $e) { + } catch (Exception $e) { throw new ImportException($e->getMessage(), ImportException::CRITICAL); } } @@ -126,7 +130,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface } foreach ($this->xmlDOM->getElementsByTagName('Data') as $node) { - /** @var $node \DOMElement */ + /** @var $node DOMElement */ $data = base64_decode($node->nodeValue); try { @@ -143,7 +147,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface continue; } - $newXmlData = new \DOMDocument(); + $newXmlData = new DOMDocument(); if ($newXmlData->loadXML($xmlDecrypted) === false) { throw new ImportException(__u('Wrong encryption password')); @@ -188,7 +192,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface protected function processCategories() { $this->getNodesData('Categories', 'Category', - function (\DOMElement $category) { + function (DOMElement $category) { $categoryData = new CategoryData(); foreach ($category->childNodes as $node) { @@ -211,7 +215,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface new Event($this, EventMessage::factory() ->addDetail(__u('Category imported'), $categoryData->getName())) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -227,7 +231,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface protected function processClients() { $this->getNodesData('Clients', 'Client', - function (\DOMElement $client) { + function (DOMElement $client) { $clientData = new ClientData(); foreach ($client->childNodes as $node) { @@ -250,7 +254,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface new Event($this, EventMessage::factory() ->addDetail(__u('Client imported'), $clientData->getName())) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -267,7 +271,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface protected function processCustomers() { $this->getNodesData('Customers', 'Customer', - function (\DOMElement $client) { + function (DOMElement $client) { $clientData = new ClientData(); foreach ($client->childNodes as $node) { @@ -290,7 +294,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface new Event($this, EventMessage::factory() ->addDetail(__u('Client imported'), $clientData->getName())) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -306,7 +310,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface protected function processTags() { $this->getNodesData('Tags', 'Tag', - function (\DOMElement $tag) { + function (DOMElement $tag) { $tagData = new TagData(); foreach ($tag->childNodes as $node) { @@ -326,7 +330,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface new Event($this, EventMessage::factory() ->addDetail(__u('Tag imported'), $tagData->getName())) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -342,10 +346,10 @@ final class SyspassImport extends XmlImportBase implements ImportInterface protected function processAccounts() { $this->getNodesData('Accounts', 'Account', - function (\DOMElement $account) { + function (DOMElement $account) { $accountRequest = new AccountRequest(); - /** @var \DOMElement $node */ + /** @var DOMElement $node */ foreach ($account->childNodes as $node) { if (isset($node->tagName)) { switch ($node->tagName) { @@ -387,7 +391,7 @@ final class SyspassImport extends XmlImportBase implements ImportInterface new Event($this, EventMessage::factory() ->addDetail(__u('Account imported'), $accountRequest->name)) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -398,16 +402,16 @@ final class SyspassImport extends XmlImportBase implements ImportInterface /** * Procesar las etiquetas de la cuenta * - * @param \DOMNodeList $nodes + * @param DOMNodeList $nodes * * @return array */ - protected function processAccountTags(\DOMNodeList $nodes) + protected function processAccountTags(DOMNodeList $nodes) { $tags = []; if ($nodes->length > 0) { - /** @var \DOMElement $node */ + /** @var DOMElement $node */ foreach ($nodes as $node) { if (isset($node->tagName)) { $tags[] = $this->getWorkingItem('tag', (int)$node->getAttribute('id')); diff --git a/lib/SP/Services/Import/XmlFileImport.php b/lib/SP/Services/Import/XmlFileImport.php index 303ec2ca..3bc06848 100644 --- a/lib/SP/Services/Import/XmlFileImport.php +++ b/lib/SP/Services/Import/XmlFileImport.php @@ -24,6 +24,9 @@ namespace SP\Services\Import; +use DOMDocument; +use SP\Storage\File\FileException; + /** * Class XmlFileImport * @@ -36,7 +39,7 @@ final class XmlFileImport */ protected $fileImport; /** - * @var \DOMDocument + * @var DOMDocument */ protected $xmlDOM; @@ -46,7 +49,7 @@ final class XmlFileImport * @param FileImport $fileImport * * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function __construct(FileImport $fileImport) { @@ -59,14 +62,14 @@ final class XmlFileImport * Leer el archivo a un objeto XML. * * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ protected function readXMLFile() { libxml_use_internal_errors(true); // Cargar el XML con DOM - $this->xmlDOM = new \DOMDocument(); + $this->xmlDOM = new DOMDocument(); $this->xmlDOM->formatOutput = false; $this->xmlDOM->preserveWhiteSpace = false; @@ -109,7 +112,7 @@ final class XmlFileImport } /** - * @return \DOMDocument + * @return DOMDocument */ public function getXmlDOM() { diff --git a/lib/SP/Services/Import/XmlImport.php b/lib/SP/Services/Import/XmlImport.php index 5b16b6c2..4d25bbf4 100644 --- a/lib/SP/Services/Import/XmlImport.php +++ b/lib/SP/Services/Import/XmlImport.php @@ -25,7 +25,10 @@ namespace SP\Services\Import; use DI\Container; +use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\SPException; defined('APP_ROOT') || die(); @@ -69,7 +72,7 @@ final class XmlImport implements ImportInterface * * @return ImportInterface * @throws ImportException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function doImport() { @@ -83,8 +86,8 @@ final class XmlImport implements ImportInterface * * @return KeepassImport|SyspassImport * @throws ImportException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function selectImportType($format) { diff --git a/lib/SP/Services/Import/XmlImportBase.php b/lib/SP/Services/Import/XmlImportBase.php index e7bb2ece..c27a3f83 100644 --- a/lib/SP/Services/Import/XmlImportBase.php +++ b/lib/SP/Services/Import/XmlImportBase.php @@ -25,6 +25,10 @@ namespace SP\Services\Import; use DI\Container; +use DOMDocument; +use DOMElement; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\Core\Events\EventDispatcher; use SP\Services\Account\AccountService; @@ -47,7 +51,7 @@ abstract class XmlImportBase */ protected $xmlFileImport; /** - * @var \DOMDocument + * @var DOMDocument */ protected $xmlDOM; /** @@ -70,8 +74,8 @@ abstract class XmlImportBase * @param XmlFileImport $xmlFileImport * @param ImportParams $importParams * - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function __construct(Container $dic, XmlFileImport $xmlFileImport, ImportParams $importParams) { @@ -107,9 +111,9 @@ abstract class XmlImportBase throw new ImportException(__u('Invalid Method'), ImportException::WARNING); } - /** @var \DOMElement $nodes */ + /** @var DOMElement $nodes */ foreach ($nodeList as $nodes) { - /** @var \DOMElement $Account */ + /** @var DOMElement $Account */ foreach ($nodes->getElementsByTagName($childNodeName) as $node) { $callback($node); } diff --git a/lib/SP/Services/Import/XmlImportTrait.php b/lib/SP/Services/Import/XmlImportTrait.php index 093be002..9cdbdafd 100644 --- a/lib/SP/Services/Import/XmlImportTrait.php +++ b/lib/SP/Services/Import/XmlImportTrait.php @@ -24,6 +24,8 @@ namespace SP\Services\Import; +use DOMDocument; +use DOMElement; use SP\Core\Exceptions\SPException; defined('APP_ROOT') || die(); @@ -36,12 +38,12 @@ defined('APP_ROOT') || die(); trait XmlImportTrait { /** - * @var \DOMDocument + * @var DOMDocument */ protected $xmlDOM; /** - * @param \DOMDocument $xmlDOM + * @param DOMDocument $xmlDOM */ public function setXmlDOM($xmlDOM) { @@ -78,9 +80,9 @@ trait XmlImportTrait throw new ImportException(__u('Invalid Method'), SPException::WARNING); } - /** @var \DOMElement $nodes */ + /** @var DOMElement $nodes */ foreach ($ParentNode as $nodes) { - /** @var \DOMElement $Account */ + /** @var DOMElement $Account */ foreach ($nodes->getElementsByTagName($childNodeName) as $node) { $this->$callback($node); } diff --git a/lib/SP/Services/Install/Installer.php b/lib/SP/Services/Install/Installer.php index 969b01dd..aadf7111 100644 --- a/lib/SP/Services/Install/Installer.php +++ b/lib/SP/Services/Install/Installer.php @@ -25,10 +25,16 @@ namespace SP\Services\Install; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\ConfigData; use SP\Core\Crypt\Hash; use SP\Core\Events\EventDispatcher; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ProfileData; use SP\DataModel\UserData; @@ -81,9 +87,9 @@ final class Installer extends Service * @return static * @throws InvalidArgumentException * @throws SPException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws EnvironmentIsBrokenException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function run(InstallData $installData) { @@ -168,11 +174,11 @@ final class Installer extends Service * Iniciar instalación. * * @throws SPException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException */ private function install() { @@ -307,7 +313,7 @@ final class Installer extends Service $configService->create(new \SP\DataModel\ConfigData('masterPwd', Hash::hashKey($this->installData->getMasterPassword()))); $configService->create(new \SP\DataModel\ConfigData('lastupdatempass', time())); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->dbs->rollback(); @@ -327,8 +333,8 @@ final class Installer extends Service * Esta función crea el grupo, perfil y usuario 'admin' para utilizar sysPass. * * @throws SPException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ private function createAdminAccount() { @@ -358,7 +364,7 @@ final class Installer extends Service if ($id === 0) { throw new SPException(__u('Error while creating \'admin\' user')); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->dbs->rollback(); diff --git a/lib/SP/Services/Install/MySQL.php b/lib/SP/Services/Install/MySQL.php index ce899b11..f9edcfaa 100644 --- a/lib/SP/Services/Install/MySQL.php +++ b/lib/SP/Services/Install/MySQL.php @@ -48,7 +48,7 @@ final class MySQL implements DatabaseSetupInterface */ protected $installData; /** - * @var \SP\Storage\Database\MySQLHandler + * @var MySQLHandler */ protected $mysqlHandler; /** diff --git a/lib/SP/Services/ItemPreset/ItemPresetService.php b/lib/SP/Services/ItemPreset/ItemPresetService.php index c2209bd0..19ea938a 100644 --- a/lib/SP/Services/ItemPreset/ItemPresetService.php +++ b/lib/SP/Services/ItemPreset/ItemPresetService.php @@ -24,6 +24,8 @@ namespace SP\Services\ItemPreset; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemPresetData; use SP\DataModel\ItemSearchData; use SP\Repositories\ItemPreset\ItemPresetRepository; @@ -48,8 +50,8 @@ final class ItemPresetService extends Service * @param ItemPresetRequest $itemPresetRequest * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(ItemPresetRequest $itemPresetRequest) { @@ -60,8 +62,8 @@ final class ItemPresetService extends Service * @param ItemPresetRequest $itemPresetRequest * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update(ItemPresetRequest $itemPresetRequest) { @@ -75,8 +77,8 @@ final class ItemPresetService extends Service * * @return ItemPresetService * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -94,8 +96,8 @@ final class ItemPresetService extends Service * * @return ItemPresetData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -112,8 +114,8 @@ final class ItemPresetService extends Service * Returns all the items * * @return ItemPresetData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -126,8 +128,8 @@ final class ItemPresetService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -138,8 +140,8 @@ final class ItemPresetService extends Service * @param string $type * * @return ItemPresetData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getForCurrentUser(string $type) { @@ -155,8 +157,8 @@ final class ItemPresetService extends Service * @param int $userProfileId * * @return ItemPresetData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getForUser(string $type, int $userId, int $userGroupId, int $userProfileId) { @@ -179,8 +181,8 @@ final class ItemPresetService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { diff --git a/lib/SP/Services/Ldap/LdapImportService.php b/lib/SP/Services/Ldap/LdapImportService.php index 39b8405c..9124db1d 100644 --- a/lib/SP/Services/Ldap/LdapImportService.php +++ b/lib/SP/Services/Ldap/LdapImportService.php @@ -24,6 +24,7 @@ namespace SP\Services\Ldap; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\DataModel\UserData; @@ -139,7 +140,7 @@ final class LdapImportService extends Service ); $this->syncedObjects++; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -231,7 +232,7 @@ final class LdapImportService extends Service ); $this->syncedObjects++; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Mail/MailService.php b/lib/SP/Services/Mail/MailService.php index 0de0b1c5..8970e67a 100644 --- a/lib/SP/Services/Mail/MailService.php +++ b/lib/SP/Services/Mail/MailService.php @@ -24,6 +24,7 @@ namespace SP\Services\Mail; +use Exception; use PHPMailer\PHPMailer\PHPMailer; use SP\Bootstrap; use SP\Core\AppInfoInterface; @@ -72,7 +73,7 @@ final class MailService extends Service $mailer->Subject = $this->getSubjectForAction($mailMessage->getTitle()); $mailer->Body = $mailMessage->composeHtml(); $mailer->send(); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -151,7 +152,7 @@ final class MailService extends Service return $value[0]; }, $this->mailer->getToAddresses())))) ); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Notification/NotificationService.php b/lib/SP/Services/Notification/NotificationService.php index b5df10bc..c74c3877 100644 --- a/lib/SP/Services/Notification/NotificationService.php +++ b/lib/SP/Services/Notification/NotificationService.php @@ -24,6 +24,10 @@ namespace SP\Services\Notification; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; use SP\DataModel\NotificationData; use SP\Repositories\NoSuchItemException; @@ -50,8 +54,8 @@ final class NotificationService extends Service * @param NotificationData $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(NotificationData $itemData) { @@ -64,8 +68,8 @@ final class NotificationService extends Service * @param NotificationData $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update(NotificationData $itemData) { @@ -78,8 +82,8 @@ final class NotificationService extends Service * @param array $ids * * @return NotificationData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -93,8 +97,8 @@ final class NotificationService extends Service * * @return NotificationService * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -111,8 +115,8 @@ final class NotificationService extends Service * @param $id * * @return NotificationService - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function deleteAdmin($id) @@ -130,8 +134,8 @@ final class NotificationService extends Service * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws ServiceException */ public function deleteAdminBatch(array $ids) @@ -149,8 +153,8 @@ final class NotificationService extends Service * @param array $ids * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws ServiceException */ public function deleteByIdBatch(array $ids) @@ -168,8 +172,8 @@ final class NotificationService extends Service * @param int $id * * @return NotificationData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -187,8 +191,8 @@ final class NotificationService extends Service * Returns all the items * * @return NotificationData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -200,8 +204,8 @@ final class NotificationService extends Service * * @param $id * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function setCheckedById($id) @@ -218,8 +222,8 @@ final class NotificationService extends Service * @param $id * * @return NotificationData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getForUserIdByDate($component, $id) { @@ -230,8 +234,8 @@ final class NotificationService extends Service * @param $id * * @return NotificationData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllForUserId($id) { @@ -242,8 +246,8 @@ final class NotificationService extends Service * @param $id * * @return NotificationData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllActiveForUserId($id) { @@ -260,8 +264,8 @@ final class NotificationService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -281,8 +285,8 @@ final class NotificationService extends Service * @param int $userId * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function searchForUserId(ItemSearchData $itemSearchData, $userId) { @@ -290,8 +294,8 @@ final class NotificationService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Plugin/PluginDataService.php b/lib/SP/Services/Plugin/PluginDataService.php index 0f2ba77b..690ed300 100644 --- a/lib/SP/Services/Plugin/PluginDataService.php +++ b/lib/SP/Services/Plugin/PluginDataService.php @@ -24,10 +24,16 @@ namespace SP\Services\Plugin; +use Defuse\Crypto\Exception\CryptoException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Repositories\NoSuchItemException; use SP\Repositories\Plugin\PluginDataModel; use SP\Repositories\Plugin\PluginDataRepository; use SP\Services\Service; +use SP\Services\ServiceException; +use SP\Storage\Database\QueryResult; /** * Class PluginDataService @@ -46,12 +52,12 @@ final class PluginDataService extends Service * * @param PluginDataModel $itemData * - * @return \SP\Storage\Database\QueryResult - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @return QueryResult + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function create(PluginDataModel $itemData) { @@ -64,11 +70,11 @@ final class PluginDataService extends Service * @param PluginDataModel $itemData * * @return int - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function update(PluginDataModel $itemData) { @@ -83,11 +89,11 @@ final class PluginDataService extends Service * * @return PluginDataModel * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function getByItemId(string $name, int $id) { @@ -109,8 +115,8 @@ final class PluginDataService extends Service * @param int $id * * @return PluginDataModel[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -135,8 +141,8 @@ final class PluginDataService extends Service * Returns all the items * * @return PluginDataModel[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -156,8 +162,8 @@ final class PluginDataService extends Service * @param $id * * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -174,8 +180,8 @@ final class PluginDataService extends Service * * @return void * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByItemId(string $name, int $itemId) { diff --git a/lib/SP/Services/Plugin/PluginService.php b/lib/SP/Services/Plugin/PluginService.php index c08e4af5..30cf82ee 100644 --- a/lib/SP/Services/Plugin/PluginService.php +++ b/lib/SP/Services/Plugin/PluginService.php @@ -24,6 +24,8 @@ namespace SP\Services\Plugin; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; @@ -49,11 +51,11 @@ final class PluginService extends Service /** * Creates an item * - * @param \SP\Repositories\Plugin\PluginModel $itemData + * @param PluginModel $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function create(PluginModel $itemData) { @@ -63,11 +65,11 @@ final class PluginService extends Service /** * Updates an item * - * @param \SP\Repositories\Plugin\PluginModel $itemData + * @param PluginModel $itemData * * @return mixed - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update(PluginModel $itemData) { @@ -79,9 +81,9 @@ final class PluginService extends Service * * @param int $id * - * @return \SP\Repositories\Plugin\PluginModel - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return PluginModel + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -99,8 +101,8 @@ final class PluginService extends Service * Returns all the items * * @return PluginModel[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -112,9 +114,9 @@ final class PluginService extends Service * * @param array $ids * - * @return \SP\Repositories\Plugin\PluginModel[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return PluginModel[] + * @throws ConstraintException + * @throws QueryException */ public function getByIdBatch(array $ids) { @@ -127,9 +129,9 @@ final class PluginService extends Service * @param array $ids * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function deleteByIdBatch(array $ids) { @@ -144,8 +146,8 @@ final class PluginService extends Service * @param $id * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -160,8 +162,8 @@ final class PluginService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -173,10 +175,10 @@ final class PluginService extends Service * * @param string $name * - * @return \SP\Repositories\Plugin\PluginModel + * @return PluginModel * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByName($name) { @@ -197,8 +199,8 @@ final class PluginService extends Service * * @return void * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function toggleEnabled($id, $enabled) { @@ -215,8 +217,8 @@ final class PluginService extends Service * * @return void * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function toggleEnabledByName($name, $enabled) { @@ -232,8 +234,8 @@ final class PluginService extends Service * @param $available * * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function toggleAvailable($id, $available) { @@ -249,8 +251,8 @@ final class PluginService extends Service * @param int $available * * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function toggleAvailableByName($name, $available) { @@ -266,8 +268,8 @@ final class PluginService extends Service * * @return bool * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function resetById($id) { @@ -282,8 +284,8 @@ final class PluginService extends Service * Devolver los plugins activados * * @return ItemData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getEnabled() { diff --git a/lib/SP/Services/PublicLink/PublicLinkKey.php b/lib/SP/Services/PublicLink/PublicLinkKey.php index b974ba2f..a5f49322 100644 --- a/lib/SP/Services/PublicLink/PublicLinkKey.php +++ b/lib/SP/Services/PublicLink/PublicLinkKey.php @@ -24,6 +24,7 @@ namespace SP\Services\PublicLink; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use SP\Util\PasswordUtil; /** @@ -48,7 +49,7 @@ final class PublicLinkKey * @param string $salt * @param string $hash * - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function __construct(string $salt, string $hash = null) { diff --git a/lib/SP/Services/PublicLink/PublicLinkService.php b/lib/SP/Services/PublicLink/PublicLinkService.php index 7321d176..510863fe 100644 --- a/lib/SP/Services/PublicLink/PublicLinkService.php +++ b/lib/SP/Services/PublicLink/PublicLinkService.php @@ -24,9 +24,15 @@ namespace SP\Services\PublicLink; +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\Config; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Vault; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\PublicLinkData; @@ -101,8 +107,8 @@ final class PublicLinkService extends Service * @param ItemSearchData $itemSearchData * * @return QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -112,8 +118,8 @@ final class PublicLinkService extends Service /** * @param $id * - * @return \SP\DataModel\PublicLinkListData - * @throws \SP\Core\Exceptions\SPException + * @return PublicLinkListData + * @throws SPException */ public function getById($id) { @@ -131,12 +137,12 @@ final class PublicLinkService extends Service * * @return bool * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws EnvironmentIsBrokenException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException */ public function refresh($id) { @@ -162,7 +168,7 @@ final class PublicLinkService extends Service * @param string|null $hash * * @return PublicLinkKey - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function getPublicLinkKey(string $hash = null) { @@ -178,9 +184,9 @@ final class PublicLinkService extends Service * @return Vault * @throws NoSuchItemException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException */ private function getSecuredLinkData($itemId, PublicLinkKey $key) { @@ -211,8 +217,8 @@ final class PublicLinkService extends Service * * @return $this * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -229,8 +235,8 @@ final class PublicLinkService extends Service * @param array $ids * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws ServiceException */ public function deleteByIdBatch(array $ids) @@ -247,11 +253,11 @@ final class PublicLinkService extends Service * * @return int * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws ConstraintException + * @throws QueryException */ public function create(PublicLinkData $itemData) { @@ -270,8 +276,8 @@ final class PublicLinkService extends Service * Get all items from the service's repository * * @return PublicLinkListData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -284,8 +290,8 @@ final class PublicLinkService extends Service * @param PublicLinkData $publicLinkData * * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function addLinkView(PublicLinkData $publicLinkData) { @@ -323,7 +329,7 @@ final class PublicLinkService extends Service * @param $hash string * * @return bool|PublicLinkData - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getByHash($hash) { @@ -342,9 +348,9 @@ final class PublicLinkService extends Service * @param int $itemId * * @return PublicLinkData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function getHashForItem($itemId) { @@ -364,8 +370,8 @@ final class PublicLinkService extends Service * * @return mixed * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update(PublicLinkData $itemData) { @@ -373,8 +379,8 @@ final class PublicLinkService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Service.php b/lib/SP/Services/Service.php index 2acfa6e9..d623b855 100644 --- a/lib/SP/Services/Service.php +++ b/lib/SP/Services/Service.php @@ -24,7 +24,9 @@ namespace SP\Services; +use Closure; use Defuse\Crypto\Exception\CryptoException; +use Exception; use Psr\Container\ContainerInterface; use SP\Config\Config; use SP\Core\Context\ContextException; @@ -82,13 +84,13 @@ abstract class Service /** * Bubbles a Closure in a database transaction * - * @param \Closure $closure + * @param Closure $closure * * @return mixed * @throws ServiceException - * @throws \Exception + * @throws Exception */ - protected function transactionAware(\Closure $closure) + protected function transactionAware(Closure $closure) { $database = $this->dic->get(Database::class); @@ -99,7 +101,7 @@ abstract class Service $database->endTransaction(); return $result; - } catch (\Exception $e) { + } catch (Exception $e) { $database->rollbackTransaction(); logger('Transaction:Rollback'); diff --git a/lib/SP/Services/ServiceItemTrait.php b/lib/SP/Services/ServiceItemTrait.php index e72bcde8..4771089b 100644 --- a/lib/SP/Services/ServiceItemTrait.php +++ b/lib/SP/Services/ServiceItemTrait.php @@ -24,6 +24,8 @@ namespace SP\Services; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; use SP\DataModel\DataModelInterface; @@ -38,8 +40,8 @@ trait ServiceItemTrait * Returns service items for a select * * @return DataModelInterface[] - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public static function getItemsBasic() { diff --git a/lib/SP/Services/Tag/TagService.php b/lib/SP/Services/Tag/TagService.php index 2b185e5f..67d66959 100644 --- a/lib/SP/Services/Tag/TagService.php +++ b/lib/SP/Services/Tag/TagService.php @@ -24,14 +24,20 @@ namespace SP\Services\Tag; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\TagData; +use SP\Repositories\DuplicatedItemException; use SP\Repositories\NoSuchItemException; use SP\Repositories\Tag\TagRepository; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; +use SP\Storage\Database\QueryResult; /** * Class TagService @@ -50,9 +56,9 @@ final class TagService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -64,8 +70,8 @@ final class TagService extends Service * * @return TagData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -83,8 +89,8 @@ final class TagService extends Service * * @return TagData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByName($name) { @@ -101,8 +107,8 @@ final class TagService extends Service * @param $id * * @return $this - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function delete($id) @@ -133,9 +139,9 @@ final class TagService extends Service * @param $itemData * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\DuplicatedItemException + * @throws ConstraintException + * @throws QueryException + * @throws DuplicatedItemException */ public function create($itemData) { @@ -147,8 +153,8 @@ final class TagService extends Service * * @return int * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -159,8 +165,8 @@ final class TagService extends Service * Get all items from the service's repository * * @return TagData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -168,8 +174,8 @@ final class TagService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Task/Task.php b/lib/SP/Services/Task/Task.php index 39802b4e..3c507979 100644 --- a/lib/SP/Services/Task/Task.php +++ b/lib/SP/Services/Task/Task.php @@ -237,7 +237,7 @@ final class Task * Register a task * * @return Task - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function register() { @@ -254,7 +254,7 @@ final class Task * Session is locked in order to allow other scripts execution * * @return Task - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function registerSession() { diff --git a/lib/SP/Services/Task/TaskFactory.php b/lib/SP/Services/Task/TaskFactory.php index fe3cdfa8..0f9bcb86 100644 --- a/lib/SP/Services/Task/TaskFactory.php +++ b/lib/SP/Services/Task/TaskFactory.php @@ -24,6 +24,7 @@ namespace SP\Services\Task; +use RuntimeException; use SP\Core\Messages\TaskMessage; use SP\Storage\File\FileException; @@ -74,7 +75,7 @@ final class TaskFactory return $task; } - throw new \RuntimeException('Task already registered'); + throw new RuntimeException('Task already registered'); } /** @@ -101,7 +102,7 @@ final class TaskFactory return self::$tasks[$id]; } - throw new \RuntimeException('Task not registered'); + throw new RuntimeException('Task not registered'); } /** diff --git a/lib/SP/Services/Task/TaskService.php b/lib/SP/Services/Task/TaskService.php index fb3a0bb3..b769f033 100644 --- a/lib/SP/Services/Task/TaskService.php +++ b/lib/SP/Services/Task/TaskService.php @@ -24,6 +24,7 @@ namespace SP\Services\Task; +use Closure; use SP\Services\Service; use SP\Services\ServiceException; use SP\Storage\File\FileException; @@ -46,7 +47,7 @@ final class TaskService extends Service */ const STARTUP_WAIT_COUNT = 30; /** - * @var \Closure + * @var Closure */ private $messagePusher; /** @@ -70,11 +71,11 @@ final class TaskService extends Service * Track task status * * @param string $taskId - * @param \Closure $messagePusher + * @param Closure $messagePusher * * @throws ServiceException */ - public function trackStatus($taskId, \Closure $messagePusher) + public function trackStatus($taskId, Closure $messagePusher) { $this->taskId = $taskId; $this->taskDirectory = Util::getTempDir(); diff --git a/lib/SP/Services/Track/TrackService.php b/lib/SP/Services/Track/TrackService.php index 35180983..102a2267 100644 --- a/lib/SP/Services/Track/TrackService.php +++ b/lib/SP/Services/Track/TrackService.php @@ -24,8 +24,14 @@ namespace SP\Services\Track; +use Exception; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemSearchData; use SP\DataModel\TrackData; use SP\Http\Request; @@ -34,6 +40,7 @@ use SP\Repositories\Track\TrackRepository; use SP\Repositories\Track\TrackRequest; use SP\Services\Service; use SP\Services\ServiceException; +use SP\Storage\Database\QueryResult; /** * Class TrackService @@ -62,7 +69,7 @@ final class TrackService extends Service * @param string $source * * @return TrackRequest - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function getTrackRequest($source) { @@ -77,8 +84,8 @@ final class TrackService extends Service /** * @param $id int * - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException * @throws NoSuchItemException */ public function delete($id) @@ -91,8 +98,8 @@ final class TrackService extends Service /** * @param $id int * - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException * @throws NoSuchItemException */ public function unlock($id) @@ -104,8 +111,8 @@ final class TrackService extends Service /** * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function clear() { @@ -116,8 +123,8 @@ final class TrackService extends Service * @param $id int * * @return TrackData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -133,8 +140,8 @@ final class TrackService extends Service /** * @return TrackData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAll() { @@ -147,7 +154,7 @@ final class TrackService extends Service * @param TrackRequest $trackRequest * * @return bool True if delay is performed, false otherwise - * @throws \Exception + * @throws Exception */ public function checkTracking(TrackRequest $trackRequest) { @@ -169,7 +176,7 @@ final class TrackService extends Service return true; } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw $e; @@ -184,8 +191,8 @@ final class TrackService extends Service * @param TrackRequest $trackRequest * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getTracksForClientFromTime(TrackRequest $trackRequest) { @@ -197,8 +204,8 @@ final class TrackService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add(TrackRequest $trackRequest) { @@ -221,9 +228,9 @@ final class TrackService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -231,8 +238,8 @@ final class TrackService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Upgrade/UpgradeAppService.php b/lib/SP/Services/Upgrade/UpgradeAppService.php index 646f37ae..dc2e28c3 100644 --- a/lib/SP/Services/Upgrade/UpgradeAppService.php +++ b/lib/SP/Services/Upgrade/UpgradeAppService.php @@ -24,11 +24,13 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Config\ConfigData; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Providers\Log\FileLogHandler; use SP\Services\Service; +use SP\Storage\File\FileException; use SP\Util\VersionUtil; /** @@ -60,7 +62,7 @@ final class UpgradeAppService extends Service implements UpgradeInterface * @param ConfigData $configData * * @throws UpgradeException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function upgrade($version, ConfigData $configData) { @@ -125,7 +127,7 @@ final class UpgradeAppService extends Service implements UpgradeInterface ->upgrade_310_19012201(); return true; } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } diff --git a/lib/SP/Services/Upgrade/UpgradeAuthToken.php b/lib/SP/Services/Upgrade/UpgradeAuthToken.php index 14dffb11..6f324f51 100644 --- a/lib/SP/Services/Upgrade/UpgradeAuthToken.php +++ b/lib/SP/Services/Upgrade/UpgradeAuthToken.php @@ -24,6 +24,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -46,7 +47,7 @@ final class UpgradeAuthToken extends Service /** * upgrade_300_18072901 * - * @throws \Exception + * @throws Exception */ public function upgrade_300_18072901() { @@ -72,7 +73,7 @@ final class UpgradeAuthToken extends Service ); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Upgrade/UpgradeConfigService.php b/lib/SP/Services/Upgrade/UpgradeConfigService.php index 039a8b80..221b58fc 100644 --- a/lib/SP/Services/Upgrade/UpgradeConfigService.php +++ b/lib/SP/Services/Upgrade/UpgradeConfigService.php @@ -24,6 +24,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Config\ConfigData; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -31,6 +32,7 @@ use SP\Core\MimeTypes; use SP\Providers\Auth\Ldap\LdapTypeInterface; use SP\Providers\Log\FileLogHandler; use SP\Services\Service; +use SP\Storage\File\FileException; use SP\Util\VersionUtil; /** @@ -122,7 +124,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface $message->addDetail(__u('Version'), $version); $this->eventDispatcher->notifyEvent('upgrade.config.old.end', new Event($this, $message)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', @@ -204,7 +206,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface * @param $version * @param ConfigData $configData * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function upgrade($version, ConfigData $configData) { @@ -225,7 +227,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface /** * @param $version * - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function applyUpgrade($version) { @@ -245,7 +247,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface /** * @param $version * - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function upgrade_200_17011202($version) { @@ -264,7 +266,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface /** * @param $version * - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function upgrade_300_18111001($version) { @@ -313,7 +315,7 @@ final class UpgradeConfigService extends Service implements UpgradeInterface /** * @param $version * - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function upgrade_300_18112501($version) { diff --git a/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php b/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php index a829a1f2..0b66a31a 100644 --- a/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php +++ b/lib/SP/Services/Upgrade/UpgradeCustomFieldData.php @@ -25,6 +25,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -48,7 +49,7 @@ final class UpgradeCustomFieldData extends Service /** * upgrade_300_18072902 * - * @throws \Exception + * @throws Exception */ public function upgrade_300_18072902() { @@ -75,7 +76,7 @@ final class UpgradeCustomFieldData extends Service ); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Upgrade/UpgradeCustomFieldDefinition.php b/lib/SP/Services/Upgrade/UpgradeCustomFieldDefinition.php index 3730e0f0..fad92475 100644 --- a/lib/SP/Services/Upgrade/UpgradeCustomFieldDefinition.php +++ b/lib/SP/Services/Upgrade/UpgradeCustomFieldDefinition.php @@ -24,6 +24,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -44,14 +45,14 @@ use SP\Util\Util; final class UpgradeCustomFieldDefinition extends Service { /** - * @var \SP\Storage\Database\Database + * @var Database */ private $db; /** * upgrade_300_18010101 * - * @throws \Exception + * @throws Exception */ public function upgrade_300_18010101() { @@ -98,7 +99,7 @@ final class UpgradeCustomFieldDefinition extends Service ); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); @@ -138,6 +139,7 @@ final class UpgradeCustomFieldDefinition extends Service /** * @param int $typeId + * * @return string */ private function typeMapper(int $typeId) @@ -161,7 +163,7 @@ final class UpgradeCustomFieldDefinition extends Service /** * upgrade_300_18072901 * - * @throws \Exception + * @throws Exception */ public function upgrade_300_18072901() { @@ -189,7 +191,7 @@ final class UpgradeCustomFieldDefinition extends Service ); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Upgrade/UpgradeDatabaseService.php b/lib/SP/Services/Upgrade/UpgradeDatabaseService.php index edff0af2..ee469c0f 100644 --- a/lib/SP/Services/Upgrade/UpgradeDatabaseService.php +++ b/lib/SP/Services/Upgrade/UpgradeDatabaseService.php @@ -24,6 +24,9 @@ namespace SP\Services\Upgrade; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Config\ConfigData; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; @@ -84,8 +87,8 @@ final class UpgradeDatabaseService extends Service implements UpgradeInterface * @return bool * @throws FileException * @throws UpgradeException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException + * @throws DependencyException + * @throws NotFoundException */ public function upgrade($version, ConfigData $configData) { @@ -170,7 +173,7 @@ final class UpgradeDatabaseService extends Service implements UpgradeInterface $this->db->getDbHandler() ->getConnection() ->exec($query); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); logger('SQL: ' . $query); diff --git a/lib/SP/Services/Upgrade/UpgradePlugin.php b/lib/SP/Services/Upgrade/UpgradePlugin.php index 67f94f32..00123015 100644 --- a/lib/SP/Services/Upgrade/UpgradePlugin.php +++ b/lib/SP/Services/Upgrade/UpgradePlugin.php @@ -24,6 +24,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\Plugin\PluginManager; @@ -39,7 +40,7 @@ final class UpgradePlugin extends Service /** * upgrade_300_18010101 * - * @throws \Exception + * @throws Exception */ public function upgrade_310_19012201() { diff --git a/lib/SP/Services/Upgrade/UpgradePublicLink.php b/lib/SP/Services/Upgrade/UpgradePublicLink.php index 93ddaa3a..b4d91320 100644 --- a/lib/SP/Services/Upgrade/UpgradePublicLink.php +++ b/lib/SP/Services/Upgrade/UpgradePublicLink.php @@ -24,6 +24,7 @@ namespace SP\Services\Upgrade; +use Exception; use SP\Core\Events\Event; use SP\Core\Events\EventMessage; use SP\DataModel\PublickLinkOldData; @@ -91,7 +92,7 @@ final class UpgradePublicLink extends Service ); } }); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); diff --git a/lib/SP/Services/Upgrade/UpgradeUtil.php b/lib/SP/Services/Upgrade/UpgradeUtil.php index 3470814a..4e26c43c 100644 --- a/lib/SP/Services/Upgrade/UpgradeUtil.php +++ b/lib/SP/Services/Upgrade/UpgradeUtil.php @@ -24,8 +24,12 @@ namespace SP\Services\Upgrade; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; use SP\Config\Config; use SP\Config\ConfigData; +use SP\Storage\File\FileException; use SP\Util\PasswordUtil; use SP\Util\VersionUtil; @@ -61,10 +65,10 @@ final class UpgradeUtil * * @param Config $config * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public static function setUpgradeKey(Config $config) { @@ -81,8 +85,9 @@ final class UpgradeUtil /** * @param ConfigData $configData - * @param Config $config - * @throws \SP\Storage\File\FileException + * @param Config $config + * + * @throws FileException */ public static function fixAppUpgrade(ConfigData $configData, Config $config) { diff --git a/lib/SP/Services/User/UpdatedMasterPassException.php b/lib/SP/Services/User/UpdatedMasterPassException.php index a625d189..3eda34a6 100644 --- a/lib/SP/Services/User/UpdatedMasterPassException.php +++ b/lib/SP/Services/User/UpdatedMasterPassException.php @@ -24,6 +24,7 @@ namespace SP\Services\User; +use Exception; use SP\Core\Exceptions\SPException; /** @@ -38,9 +39,9 @@ final class UpdatedMasterPassException extends SPException * * @param string $type * @param int $code - * @param \Exception $previous + * @param Exception $previous */ - public function __construct($type, $code = 0, \Exception $previous = null) + public function __construct($type, $code = 0, Exception $previous = null) { parent::__construct(__u('Master password updated'), $type, __u('Please, restart the session for update it'), $code, $previous); } diff --git a/lib/SP/Services/User/UserPassService.php b/lib/SP/Services/User/UserPassService.php index d84e5a3e..fdec3287 100644 --- a/lib/SP/Services/User/UserPassService.php +++ b/lib/SP/Services/User/UserPassService.php @@ -25,10 +25,14 @@ namespace SP\Services\User; use Defuse\Crypto\Exception\CryptoException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Config\Config; use SP\Config\ConfigData; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\UserLoginData; use SP\Repositories\NoSuchItemException; @@ -75,9 +79,9 @@ final class UserPassService extends Service * * @return UserPassResponse * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws CryptoException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ public function updateMasterPassFromOldPass($oldUserPass, UserLoginData $userLoginData) { @@ -98,7 +102,7 @@ final class UserPassService extends Service * * @return UserPassResponse * @throws SPException - * @throws \Psr\Container\ContainerExceptionInterface + * @throws ContainerExceptionInterface */ public function loadUserMPass(UserLoginData $userLoginData, $userPass = null) { @@ -174,10 +178,10 @@ final class UserPassService extends Service * * @return UserPassResponse * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws SPException */ public function updateMasterPassOnLogin($userMPass, UserLoginData $userLoginData) { @@ -247,8 +251,8 @@ final class UserPassService extends Service * @param int $id * @param string $userPass * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function migrateUserPassById($id, $userPass) @@ -259,8 +263,8 @@ final class UserPassService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/User/UserService.php b/lib/SP/Services/User/UserService.php index d95a7cfc..21ce8923 100644 --- a/lib/SP/Services/User/UserService.php +++ b/lib/SP/Services/User/UserService.php @@ -24,6 +24,9 @@ namespace SP\Services\User; +use Defuse\Crypto\Exception\CryptoException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Core\Crypt\Hash; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; @@ -266,7 +269,7 @@ final class UserService extends Service * * @return int * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function createWithMasterPass(UserData $itemData, $userPass, $masterPass) { @@ -435,8 +438,8 @@ final class UserService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/UserGroup/UserGroupService.php b/lib/SP/Services/UserGroup/UserGroupService.php index 1b9db381..decfbbc9 100644 --- a/lib/SP/Services/UserGroup/UserGroupService.php +++ b/lib/SP/Services/UserGroup/UserGroupService.php @@ -25,6 +25,10 @@ namespace SP\Services\UserGroup; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserGroupData; @@ -33,6 +37,7 @@ use SP\Repositories\UserGroup\UserGroupRepository; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; +use SP\Storage\Database\QueryResult; /** * Class UserGroupService @@ -55,9 +60,9 @@ final class UserGroupService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -68,8 +73,8 @@ final class UserGroupService extends Service * @param $id * * @return UserGroupData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -106,8 +111,8 @@ final class UserGroupService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -161,8 +166,8 @@ final class UserGroupService extends Service * Get all items from the service's repository * * @return UserGroupData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -176,8 +181,8 @@ final class UserGroupService extends Service * * @return UserGroupData * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getByName($name) { @@ -196,8 +201,8 @@ final class UserGroupService extends Service * @param $id int * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUsage($id) { @@ -210,8 +215,8 @@ final class UserGroupService extends Service * @param $id int * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUsageByUsers($id) { @@ -219,8 +224,8 @@ final class UserGroupService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/UserGroup/UserToUserGroupService.php b/lib/SP/Services/UserGroup/UserToUserGroupService.php index ceeb2b89..c2664e9d 100644 --- a/lib/SP/Services/UserGroup/UserToUserGroupService.php +++ b/lib/SP/Services/UserGroup/UserToUserGroupService.php @@ -24,6 +24,10 @@ namespace SP\Services\UserGroup; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\UserToUserGroupData; use SP\Repositories\NoSuchItemException; use SP\Repositories\UserGroup\UserToUserGroupRepository; @@ -44,10 +48,10 @@ final class UserToUserGroupService extends Service /** * @param $id * - * @return \SP\DataModel\UserToUserGroupData[] + * @return UserToUserGroupData[] * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getById($id) { @@ -65,8 +69,8 @@ final class UserToUserGroupService extends Service * @param array $users * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($id, array $users) { @@ -78,8 +82,8 @@ final class UserToUserGroupService extends Service * @param array $users * * @return int - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($id, array $users) { @@ -94,8 +98,8 @@ final class UserToUserGroupService extends Service * @param $id * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUsersByGroupId($id) { @@ -116,8 +120,8 @@ final class UserToUserGroupService extends Service * @param $userId * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkUserInGroup($groupId, $userId) { @@ -130,8 +134,8 @@ final class UserToUserGroupService extends Service * @param $userId * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getGroupsForUser($userId) { @@ -139,8 +143,8 @@ final class UserToUserGroupService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/UserPassRecover/UserPassRecoverService.php b/lib/SP/Services/UserPassRecover/UserPassRecoverService.php index ddb63021..234910dc 100644 --- a/lib/SP/Services/UserPassRecover/UserPassRecoverService.php +++ b/lib/SP/Services/UserPassRecover/UserPassRecoverService.php @@ -24,9 +24,16 @@ namespace SP\Services\UserPassRecover; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use SP\Bootstrap; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Core\Messages\MailMessage; use SP\Html\Html; +use SP\Repositories\User\UserPassRecoverRepository; use SP\Services\Service; use SP\Services\ServiceException; use SP\Util\PasswordUtil; @@ -50,7 +57,7 @@ final class UserPassRecoverService extends Service const USER_MAIL_EXIST = 2; /** - * @var \SP\Repositories\User\UserPassRecoverRepository + * @var UserPassRecoverRepository */ protected $userPassRecoverRepository; @@ -79,7 +86,7 @@ final class UserPassRecoverService extends Service * * @return void * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function toggleUsedByHash($hash) { @@ -92,10 +99,10 @@ final class UserPassRecoverService extends Service * @param int $id * * @return string - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function requestForUserId($id) { @@ -116,8 +123,8 @@ final class UserPassRecoverService extends Service * @param int $userId * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function checkAttemptsByUserId($userId) { @@ -129,8 +136,8 @@ final class UserPassRecoverService extends Service * @param $hash * * @return bool - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function add($userId, $hash) { @@ -144,8 +151,8 @@ final class UserPassRecoverService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUserIdForHash($hash) { @@ -159,11 +166,11 @@ final class UserPassRecoverService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { - $this->userPassRecoverRepository = $this->dic->get(\SP\Repositories\User\UserPassRecoverRepository::class); + $this->userPassRecoverRepository = $this->dic->get(UserPassRecoverRepository::class); } } \ No newline at end of file diff --git a/lib/SP/Services/UserProfile/UserProfileService.php b/lib/SP/Services/UserProfile/UserProfileService.php index c5bee52d..a18f9cd0 100644 --- a/lib/SP/Services/UserProfile/UserProfileService.php +++ b/lib/SP/Services/UserProfile/UserProfileService.php @@ -24,6 +24,10 @@ namespace SP\Services\UserProfile; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\ProfileData; @@ -33,6 +37,7 @@ use SP\Repositories\UserProfile\UserProfileRepository; use SP\Services\Service; use SP\Services\ServiceException; use SP\Services\ServiceItemTrait; +use SP\Storage\Database\QueryResult; use SP\Util\Util; /** @@ -53,8 +58,8 @@ final class UserProfileService extends Service * @param $id * * @return UserProfileData - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function getById($id) @@ -74,9 +79,9 @@ final class UserProfileService extends Service /** * @param ItemSearchData $itemSearchData * - * @return \SP\Storage\Database\QueryResult - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @return QueryResult + * @throws ConstraintException + * @throws QueryException */ public function search(ItemSearchData $itemSearchData) { @@ -88,8 +93,8 @@ final class UserProfileService extends Service * * @return $this * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function delete($id) { @@ -105,8 +110,8 @@ final class UserProfileService extends Service * * @return int * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function deleteByIdBatch(array $ids) { @@ -132,8 +137,8 @@ final class UserProfileService extends Service * @param $itemData * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function update($itemData) { @@ -146,8 +151,8 @@ final class UserProfileService extends Service * @param $id * * @return array - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getUsersForProfile($id) { @@ -158,8 +163,8 @@ final class UserProfileService extends Service * Get all items from the service's repository * * @return UserProfileData[] - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function getAllBasic() { @@ -167,8 +172,8 @@ final class UserProfileService extends Service } /** - * @throws \Psr\Container\ContainerExceptionInterface - * @throws \Psr\Container\NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface */ protected function initialize() { diff --git a/lib/SP/Services/Wiki/DokuWikiApi.php b/lib/SP/Services/Wiki/DokuWikiApi.php index 843cea23..14485763 100644 --- a/lib/SP/Services/Wiki/DokuWikiApi.php +++ b/lib/SP/Services/Wiki/DokuWikiApi.php @@ -24,6 +24,7 @@ namespace SP\Services\Wiki; +use InvalidArgumentException; use SP\Core\Exceptions\SPException; defined('APP_ROOT') || die(); @@ -48,7 +49,7 @@ class DokuWikiApi extends DokuWikiApiBase * @param string $user El usuario de conexión * @param string $pass La clave de conexión * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function __construct($url = null, $user = null, $pass = null) { @@ -73,7 +74,7 @@ class DokuWikiApi extends DokuWikiApiBase } catch (SPException $e) { $this->logException($e); throw $e; - } catch (\InvalidArgumentException $e) { + } catch (InvalidArgumentException $e) { throw new SPException($e->getMessage(), SPException::WARNING); } } @@ -86,7 +87,7 @@ class DokuWikiApi extends DokuWikiApiBase * @param string $pass La clave de conexión * * @return DokuWikiApi - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public static function checkConnection($url = null, $user = null, $pass = null) { diff --git a/lib/SP/Services/Wiki/DokuWikiApiBase.php b/lib/SP/Services/Wiki/DokuWikiApiBase.php index a0fa70d7..beb5d048 100644 --- a/lib/SP/Services/Wiki/DokuWikiApiBase.php +++ b/lib/SP/Services/Wiki/DokuWikiApiBase.php @@ -25,6 +25,8 @@ namespace SP\Services\Wiki; use DOMDocument; +use DOMElement; +use Exception; use SP\Config\Config; use SP\Config\ConfigData; use SP\Core\Exceptions\SPException; @@ -60,11 +62,11 @@ abstract class DokuWikiApiBase */ private $xml; /** - * @var \DOMElement + * @var DOMElement */ private $root; /** - * @var \DOMElement + * @var DOMElement */ private $params; @@ -130,7 +132,7 @@ abstract class DokuWikiApiBase $this->params = $this->xml->createElement('params'); $this->root->appendChild($this->params); - } catch (\Exception $e) { + } catch (Exception $e) { throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__); } } @@ -140,7 +142,7 @@ abstract class DokuWikiApiBase * * @param $value * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ protected function addParam($value) { @@ -158,7 +160,7 @@ abstract class DokuWikiApiBase $xmlParam->appendChild($xmlValue); $this->params->appendChild($xmlParam); - } catch (\Exception $e) { + } catch (Exception $e) { throw new SPException($e->getMessage(), SPException::WARNING, __FUNCTION__); } } @@ -201,8 +203,8 @@ abstract class DokuWikiApiBase /** * Escribir el error en el registro de eventos * - * @param \SP\Core\Exceptions\SPException $e - * @param string $source Origen del error + * @param SPException $e + * @param string $source Origen del error */ protected function logException(SPException $e, $source = null) { diff --git a/lib/SP/Storage/Database/DBStorageInterface.php b/lib/SP/Storage/Database/DBStorageInterface.php index 54bb0786..4f16819e 100644 --- a/lib/SP/Storage/Database/DBStorageInterface.php +++ b/lib/SP/Storage/Database/DBStorageInterface.php @@ -24,6 +24,8 @@ namespace SP\Storage\Database; +use PDO; + /** * Interface DBStorageInterface * @@ -34,14 +36,14 @@ interface DBStorageInterface /** * Obtener una conexión PDO * - * @return \PDO + * @return PDO */ public function getConnection(); /** * Obtener una conexión PDO sin seleccionar la BD * - * @return \PDO + * @return PDO */ public function getConnectionSimple(); diff --git a/lib/SP/Storage/Database/Database.php b/lib/SP/Storage/Database/Database.php index cac3c7b5..568b879d 100644 --- a/lib/SP/Storage/Database/Database.php +++ b/lib/SP/Storage/Database/Database.php @@ -24,6 +24,7 @@ namespace SP\Storage\Database; +use Exception; use PDO; use PDOStatement; use SP\Core\Events\Event; @@ -147,7 +148,7 @@ final class Database implements DatabaseInterface processException($e); throw $e; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); throw new QueryException( @@ -197,7 +198,7 @@ final class Database implements DatabaseInterface * @param bool $isCount Indica si es una consulta de contador de registros * @param array $options * - * @return \PDOStatement + * @return PDOStatement * @throws ConstraintException * @throws QueryException */ @@ -239,7 +240,7 @@ final class Database implements DatabaseInterface $this->lastId = $connection->lastInsertId(); return $stmt; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); switch ((int)$e->getCode()) { @@ -318,7 +319,7 @@ final class Database implements DatabaseInterface * @param array $options * @param bool $buffered Set buffered behavior (useful for big datasets) * - * @return \PDOStatement + * @return PDOStatement * @throws ConstraintException * @throws QueryException */ @@ -329,7 +330,7 @@ final class Database implements DatabaseInterface ) { $this->dbHandler ->getConnection() - ->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); + ->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); } return $this->prepareQueryData($queryData, $options); diff --git a/lib/SP/Storage/Database/DatabaseInterface.php b/lib/SP/Storage/Database/DatabaseInterface.php index 687a84c5..29d38801 100644 --- a/lib/SP/Storage/Database/DatabaseInterface.php +++ b/lib/SP/Storage/Database/DatabaseInterface.php @@ -24,6 +24,7 @@ namespace SP\Storage\Database; +use PDOStatement; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; @@ -50,7 +51,7 @@ interface DatabaseInterface * * @param QueryData $queryData * - * @return \PDOStatement + * @return PDOStatement */ public function doQueryRaw(QueryData $queryData); diff --git a/lib/SP/Storage/Database/DatabaseUtil.php b/lib/SP/Storage/Database/DatabaseUtil.php index bf6cbb1e..2a070a83 100644 --- a/lib/SP/Storage/Database/DatabaseUtil.php +++ b/lib/SP/Storage/Database/DatabaseUtil.php @@ -24,6 +24,8 @@ namespace SP\Storage\Database; +use Exception; + /** * Class DBUtil con utilidades de la BD * @@ -101,7 +103,7 @@ final class DatabaseUtil $numTables = (int)$this->DBStorage->getConnection()->query($query)->fetchColumn(); return $numTables === count(self::$tables); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } @@ -117,7 +119,7 @@ final class DatabaseUtil $this->DBStorage->getConnection(); return true; - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); return false; @@ -146,7 +148,7 @@ final class DatabaseUtil foreach ($attributes as $val) { $dbinfo[$val] = $db->getAttribute(constant('PDO::ATTR_' . $val)); } - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); logger($e->getMessage()); @@ -166,7 +168,7 @@ final class DatabaseUtil { try { return $this->DBStorage->getConnection()->quote(trim($str)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } diff --git a/lib/SP/Storage/Database/MySQLHandler.php b/lib/SP/Storage/Database/MySQLHandler.php index b6e68ef7..1ca30a7e 100644 --- a/lib/SP/Storage/Database/MySQLHandler.php +++ b/lib/SP/Storage/Database/MySQLHandler.php @@ -24,6 +24,7 @@ namespace SP\Storage\Database; +use Exception; use PDO; defined('APP_ROOT') || die(); @@ -113,7 +114,7 @@ final class MySQLHandler implements DBStorageInterface $this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, version_compare($serverVersion, '5.1.17', '<')); $this->dbStatus = self::STATUS_OK; - } catch (\Exception $e) { + } catch (Exception $e) { throw new DatabaseException( __u('Unable to connect to DB'), DatabaseException::CRITICAL, @@ -154,7 +155,7 @@ final class MySQLHandler implements DBStorageInterface /** * Obtener una conexión PDO sin seleccionar la BD * - * @return \PDO + * @return PDO * @throws DatabaseException */ public function getConnectionSimple() @@ -172,7 +173,7 @@ final class MySQLHandler implements DBStorageInterface $this->db = new PDO($this->getConnectionUri(), $this->connectionData->getDbUser(), $this->connectionData->getDbPass(), $opts); $this->dbStatus = self::STATUS_OK; - } catch (\Exception $e) { + } catch (Exception $e) { throw new DatabaseException( __u('Unable to connect to DB'), DatabaseException::CRITICAL, diff --git a/lib/SP/Storage/File/ArchiveHandler.php b/lib/SP/Storage/File/ArchiveHandler.php index 1d02b226..f9de3f80 100644 --- a/lib/SP/Storage/File/ArchiveHandler.php +++ b/lib/SP/Storage/File/ArchiveHandler.php @@ -25,6 +25,8 @@ namespace SP\Storage\File; +use Phar; +use PharData; use SP\Core\Exceptions\CheckException; use SP\Core\PhpExtensionChecker; @@ -87,9 +89,9 @@ final class ArchiveHandler { $this->extensionChecker->checkPharAvailable(true); - $archive = new \PharData($this->archive->getFile()); + $archive = new PharData($this->archive->getFile()); $archive->buildFromDirectory($directory, $regex); - $archive->compress(\Phar::GZ); + $archive->compress(Phar::GZ); // Delete the non-compressed archive $this->archive->delete(); @@ -107,9 +109,9 @@ final class ArchiveHandler { $this->extensionChecker->checkPharAvailable(true); - $archive = new \PharData($this->archive->getFile()); + $archive = new PharData($this->archive->getFile()); $archive->addFile($file, basename($file)); - $archive->compress(\Phar::GZ); + $archive->compress(Phar::GZ); // Delete the non-compressed archive $this->archive->delete(); diff --git a/lib/SP/Storage/File/FileCachePacked.php b/lib/SP/Storage/File/FileCachePacked.php index 7e5d81f3..808bf405 100644 --- a/lib/SP/Storage/File/FileCachePacked.php +++ b/lib/SP/Storage/File/FileCachePacked.php @@ -24,6 +24,8 @@ namespace SP\Storage\File; +use RuntimeException; + /** * Class FileCachePacked * @@ -33,7 +35,7 @@ final class FileCachePacked extends FileCacheBase { /** * @return mixed - * @throws \RuntimeException + * @throws RuntimeException * @throws FileException */ public function load() @@ -55,7 +57,7 @@ final class FileCachePacked extends FileCacheBase } /** - * @param mixed $data + * @param mixed $data * * @return FileCacheInterface * @throws FileException diff --git a/lib/SP/Storage/File/FileHandler.php b/lib/SP/Storage/File/FileHandler.php index f6e27fcb..02fade55 100644 --- a/lib/SP/Storage/File/FileHandler.php +++ b/lib/SP/Storage/File/FileHandler.php @@ -194,8 +194,8 @@ final class FileHandler /** * Closes the file * - * @throws FileException * @return FileHandler + * @throws FileException */ public function close() { @@ -252,8 +252,8 @@ final class FileHandler /** * Checks if the file is writable * - * @throws FileException * @return FileHandler + * @throws FileException */ public function checkIsWritable() { @@ -267,8 +267,8 @@ final class FileHandler /** * Checks if the file exists * - * @throws FileException * @return FileHandler + * @throws FileException */ public function checkFileExists() { @@ -347,8 +347,8 @@ final class FileHandler /** * Checks if the file is readable * - * @throws FileException * @return FileHandler + * @throws FileException */ public function checkIsReadable() { diff --git a/lib/SP/Storage/File/XmlHandler.php b/lib/SP/Storage/File/XmlHandler.php index 6f50043f..e6e70bfe 100644 --- a/lib/SP/Storage/File/XmlHandler.php +++ b/lib/SP/Storage/File/XmlHandler.php @@ -28,6 +28,7 @@ use DOMDocument; use DOMElement; use DOMNode; use DOMNodeList; +use DOMXPath; use ReflectionObject; use RuntimeException; @@ -303,7 +304,7 @@ final class XmlHandler implements XmlFileStorageInterface $dom = new DOMDocument('1.0', 'utf-8'); $dom->load($this->fileHandler->getFile()); - $query = (new \DOMXPath($dom))->query($path); + $query = (new DOMXPath($dom))->query($path); if ($query->length === 0) { throw new RuntimeException(__u('XML node does not exist')); diff --git a/lib/SP/Util/Connection.php b/lib/SP/Util/Connection.php index 278e3339..70efa412 100644 --- a/lib/SP/Util/Connection.php +++ b/lib/SP/Util/Connection.php @@ -76,7 +76,7 @@ final class Connection implements ConnectionInterface * @param $type int EL tipo de socket TCP/UDP * * @return resource - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function getSocket($type) { @@ -149,7 +149,7 @@ final class Connection implements ConnectionInterface * @param $message string El mensaje a enviar * * @return int|bool - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function send($message) { diff --git a/lib/SP/Util/ErrorUtil.php b/lib/SP/Util/ErrorUtil.php index c4ec3548..5e9c44cd 100644 --- a/lib/SP/Util/ErrorUtil.php +++ b/lib/SP/Util/ErrorUtil.php @@ -24,6 +24,7 @@ namespace SP\Util; +use Exception; use SP\Core\Acl\AccountPermissionException; use SP\Core\Acl\UnauthorizedPageException; use SP\Core\Exceptions\FileNotFoundException; @@ -51,13 +52,13 @@ final class ErrorUtil /** * Establecer la plantilla de error con el código indicado. * - * @param \SP\Mvc\View\Template $view - * @param \Exception $e - * @param string $replace Template replacement - * @param bool $render + * @param Template $view + * @param Exception $e + * @param string $replace Template replacement + * @param bool $render */ public static function showExceptionInView(Template $view, - \Exception $e, + Exception $e, $replace = null, $render = true) { @@ -79,10 +80,10 @@ final class ErrorUtil /** * Establecer la plantilla de error con el código indicado. * - * @param \SP\Mvc\View\Template $view - * @param int $type int con el tipo de error - * @param bool $render - * @param null $replace + * @param Template $view + * @param int $type int con el tipo de error + * @param bool $render + * @param null $replace */ public static function showErrorInView(Template $view, $type, $render = true, $replace = null) { diff --git a/lib/SP/Util/FileUtil.php b/lib/SP/Util/FileUtil.php index 70d14c4f..db876ee6 100644 --- a/lib/SP/Util/FileUtil.php +++ b/lib/SP/Util/FileUtil.php @@ -45,8 +45,8 @@ final class FileUtil * @param $dir * * @return bool - * @see https://stackoverflow.com/a/7288067 * @throws FileNotFoundException + * @see https://stackoverflow.com/a/7288067 */ public static function rmdir_recursive($dir) { diff --git a/lib/SP/Util/PasswordUtil.php b/lib/SP/Util/PasswordUtil.php index 2697944b..680e41ee 100644 --- a/lib/SP/Util/PasswordUtil.php +++ b/lib/SP/Util/PasswordUtil.php @@ -27,6 +27,7 @@ namespace SP\Util; use Defuse\Crypto\Core; use Defuse\Crypto\Encoding; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; /** * Class PasswordUtil @@ -132,7 +133,7 @@ final class PasswordUtil * @param int $length opcional, con la longitud de la cadena * * @return string - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public static function generateRandomBytes($length = 30) { diff --git a/lib/SP/Util/Util.php b/lib/SP/Util/Util.php index 21672975..3662aa4f 100644 --- a/lib/SP/Util/Util.php +++ b/lib/SP/Util/Util.php @@ -112,13 +112,13 @@ final class Util * Also takes into account some text-based representations of true of false, * such as 'false','N','yes','on','off', etc. * - * @author Samuel Levy - * * @param mixed $in The variable to check * @param bool $strict If set to false, consider everything that is not false to * be true. * * @return bool The boolean equivalent or null (if strict, and no exact equivalent) + * @author Samuel Levy + * */ public static function boolval($in, $strict = false) { @@ -218,7 +218,7 @@ final class Util * @param int $userId * @param string $subject * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public static function lockApp($userId, $subject) { diff --git a/tests/SP/Config/ConfigTest.php b/tests/SP/Config/ConfigTest.php index 6f132f67..ed7f2f13 100644 --- a/tests/SP/Config/ConfigTest.php +++ b/tests/SP/Config/ConfigTest.php @@ -24,12 +24,15 @@ namespace SP\Tests\Config; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use DI\Container; use DI\DependencyException; use DI\NotFoundException; use PHPUnit\Framework\TestCase; use SP\Config\Config; use SP\Config\ConfigData; +use SP\Core\Context\ContextException; +use SP\Storage\File\FileException; use function SP\Tests\getResource; use function SP\Tests\recreateDir; use function SP\Tests\saveResource; @@ -54,7 +57,7 @@ class ConfigTest extends TestCase protected static $currentConfig; /** - * @throws \SP\Core\Context\ContextException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -97,7 +100,7 @@ class ConfigTest extends TestCase * * @param Config $config * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testSaveConfig($config) { @@ -141,8 +144,8 @@ class ConfigTest extends TestCase * * @param Config $config * - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public function testGenerateUpgradeKey($config) { diff --git a/tests/SP/Core/Acl/AclTest.php b/tests/SP/Core/Acl/AclTest.php index 2616a2c4..ccae5ac8 100644 --- a/tests/SP/Core/Acl/AclTest.php +++ b/tests/SP/Core/Acl/AclTest.php @@ -24,9 +24,12 @@ namespace SP\Tests\SP\Core\Acl; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; use SP\Core\Acl\Acl; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; use SP\DataModel\ProfileData; use SP\Services\User\UserLoginResponse; @@ -874,9 +877,9 @@ class AclTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ protected function setUp() { diff --git a/tests/SP/Core/Crypt/CryptPKITest.php b/tests/SP/Core/Crypt/CryptPKITest.php index 289fdb7b..96fc6cc9 100644 --- a/tests/SP/Core/Crypt/CryptPKITest.php +++ b/tests/SP/Core/Crypt/CryptPKITest.php @@ -24,9 +24,12 @@ namespace SP\Tests\SP\Core\Crypt; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use phpseclib\Crypt\RSA; use PHPUnit\Framework\TestCase; use SP\Core\Crypt\CryptPKI; +use SP\Core\Exceptions\SPException; +use SP\Storage\File\FileException; use SP\Util\PasswordUtil; /** @@ -42,8 +45,8 @@ class CryptPKITest extends TestCase private $cryptPki; /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public function testDecryptRSA() { @@ -61,7 +64,7 @@ class CryptPKITest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDecryptRSAPassword() { @@ -77,8 +80,8 @@ class CryptPKITest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public function testDecryptRSAWrongLength() { @@ -92,7 +95,7 @@ class CryptPKITest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testGetPublicKey() { @@ -104,7 +107,7 @@ class CryptPKITest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testGetPrivateKey() { @@ -116,8 +119,8 @@ class CryptPKITest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Storage\File\FileException + * @throws EnvironmentIsBrokenException + * @throws FileException */ public function testEncryptRSA() { @@ -142,7 +145,7 @@ class CryptPKITest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateKeys() { @@ -153,7 +156,7 @@ class CryptPKITest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testGetKeySize() { @@ -164,7 +167,7 @@ class CryptPKITest extends TestCase * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ protected function setUp() { diff --git a/tests/SP/Core/Crypt/CryptTest.php b/tests/SP/Core/Crypt/CryptTest.php index 467ba538..a34ebbda 100644 --- a/tests/SP/Core/Crypt/CryptTest.php +++ b/tests/SP/Core/Crypt/CryptTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -42,7 +42,7 @@ class CryptTest extends TestCase /** * Comprobar la generación de una llave de cifrado * - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testMakeSecuredKey() { diff --git a/tests/SP/Core/Crypt/HashTest.php b/tests/SP/Core/Crypt/HashTest.php index 3051085d..0acbba97 100644 --- a/tests/SP/Core/Crypt/HashTest.php +++ b/tests/SP/Core/Crypt/HashTest.php @@ -24,6 +24,7 @@ namespace SP\Tests\SP\Core\Crypt; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use Faker\Factory; use PHPUnit\Framework\TestCase; use SP\Core\Crypt\Hash; @@ -37,7 +38,7 @@ use SP\Util\PasswordUtil; class HashTest extends TestCase { /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function testHashKey() { @@ -51,7 +52,7 @@ class HashTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function testSignMessage() { diff --git a/tests/SP/Core/Crypt/SecureKeyCookieTest.php b/tests/SP/Core/Crypt/SecureKeyCookieTest.php index ab512182..fe0b584f 100644 --- a/tests/SP/Core/Crypt/SecureKeyCookieTest.php +++ b/tests/SP/Core/Crypt/SecureKeyCookieTest.php @@ -24,6 +24,8 @@ namespace SP\Tests\SP\Core\Crypt; +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use Defuse\Crypto\Key; use Faker\Factory; use PHPUnit\Framework\TestCase; @@ -68,8 +70,8 @@ class SecureKeyCookieTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws CryptoException + * @throws EnvironmentIsBrokenException */ public function testGetKey() { diff --git a/tests/SP/Core/Crypt/VaultTest.php b/tests/SP/Core/Crypt/VaultTest.php index 9051f2e7..a58c26c4 100644 --- a/tests/SP/Core/Crypt/VaultTest.php +++ b/tests/SP/Core/Crypt/VaultTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,6 +24,8 @@ namespace SP\Tests\Core\Crypt; +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use PHPUnit\Framework\TestCase; use SP\Core\Crypt\Vault; use SP\Util\PasswordUtil; @@ -44,7 +46,7 @@ class VaultTest extends TestCase * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ protected function setUp() { @@ -52,7 +54,7 @@ class VaultTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testGetData() { @@ -69,7 +71,7 @@ class VaultTest extends TestCase /** - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testGetTimeSet() { @@ -79,7 +81,7 @@ class VaultTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testReKey() { @@ -94,7 +96,7 @@ class VaultTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testGetTimeUpdated() { diff --git a/tests/SP/DatabaseTestCase.php b/tests/SP/DatabaseTestCase.php index 04b7ec8e..8e5058f6 100644 --- a/tests/SP/DatabaseTestCase.php +++ b/tests/SP/DatabaseTestCase.php @@ -24,10 +24,12 @@ namespace SP\Tests; +use PDO; use PHPUnit\DbUnit\Database\DefaultConnection; use PHPUnit\DbUnit\DataSet\IDataSet; use PHPUnit\DbUnit\TestCaseTrait; use PHPUnit\Framework\TestCase; +use SP\Core\Exceptions\SPException; use SP\Storage\Database\DatabaseConnectionData; /** @@ -50,7 +52,7 @@ abstract class DatabaseTestCase extends TestCase */ protected static $dataset = 'syspass.xml'; /** - * @var \PDO + * @var PDO */ private static $pdo; /** @@ -62,7 +64,7 @@ abstract class DatabaseTestCase extends TestCase * Returns the test database connection. * * @return DefaultConnection - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ final public function getConnection() { diff --git a/tests/SP/DatabaseUtil.php b/tests/SP/DatabaseUtil.php index db7a82f9..066a1367 100644 --- a/tests/SP/DatabaseUtil.php +++ b/tests/SP/DatabaseUtil.php @@ -24,7 +24,10 @@ namespace SP\Tests; +use Exception; +use PDO; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\Database\DatabaseException; /** * Trait DatabaseUtil @@ -39,7 +42,7 @@ class DatabaseUtil * @param string $database * @param string $host * - * @throws \SP\Storage\Database\DatabaseException + * @throws DatabaseException */ public static function createUser($user, $pass, $database, $host) { @@ -57,8 +60,8 @@ class DatabaseUtil } /** - * @return \PDO - * @throws \SP\Storage\Database\DatabaseException + * @return PDO + * @throws DatabaseException */ public static function getConnection() { @@ -79,7 +82,7 @@ class DatabaseUtil try { self::getConnection() ->query(sprintf('DROP USER \'%s\'@\'%s\'', $user, $host)); - } catch (\Exception $e) { + } catch (Exception $e) { processException($e); } } @@ -87,7 +90,7 @@ class DatabaseUtil /** * @param string $database * - * @throws \SP\Storage\Database\DatabaseException + * @throws DatabaseException */ public static function dropDatabase($database) { @@ -98,7 +101,7 @@ class DatabaseUtil /** * @param string $database * - * @throws \SP\Storage\Database\DatabaseException + * @throws DatabaseException */ public static function createDatabase($database) { diff --git a/tests/SP/Http/AddressTest.php b/tests/SP/Http/AddressTest.php index 3b37eb6a..568975fb 100644 --- a/tests/SP/Http/AddressTest.php +++ b/tests/SP/Http/AddressTest.php @@ -42,7 +42,7 @@ class AddressTest extends TestCase * * @param string $address * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function testBinary($address) { @@ -70,7 +70,7 @@ class AddressTest extends TestCase } /** - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function testBinaryInvalidIpv4() { @@ -80,7 +80,7 @@ class AddressTest extends TestCase } /** - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function testBinaryInvalidIpv6() { @@ -97,7 +97,7 @@ class AddressTest extends TestCase * @param string $inMask * @param bool $expected * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function testCheck($address, $inAddress, $inMask, $expected) { @@ -112,7 +112,7 @@ class AddressTest extends TestCase * @param string $inMask * @param bool $expected * - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ public function testCheckWithCidr($address, $inAddress, $inMask, $expected) { diff --git a/tests/SP/Modules/Api/ApiTest.php b/tests/SP/Modules/Api/ApiTest.php index 961a1ddb..dc841a08 100644 --- a/tests/SP/Modules/Api/ApiTest.php +++ b/tests/SP/Modules/Api/ApiTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api; use SP\Services\Api\JsonRpcResponse; use SP\Tests\WebTestCase; +use stdClass; /** * Class ApiTest @@ -43,7 +44,7 @@ class ApiTest extends WebTestCase { $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL), 404); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals('2.0', $result->jsonrpc); $this->assertEquals(JsonRpcResponse::INVALID_REQUEST, $result->error->code); $this->assertNull($result->error->data); @@ -63,7 +64,7 @@ class ApiTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals('2.0', $result->jsonrpc); $this->assertEquals('Internal error', $result->error->message); $this->assertEquals(0, $result->error->code); @@ -84,7 +85,7 @@ class ApiTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data), 404); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals('2.0', $result->jsonrpc); $this->assertEquals(JsonRpcResponse::METHOD_NOT_FOUND, $result->error->code); $this->assertNull($result->error->data); diff --git a/tests/SP/Modules/Api/Controllers/AccountControllerTest.php b/tests/SP/Modules/Api/Controllers/AccountControllerTest.php index 741f366b..cbf228e6 100644 --- a/tests/SP/Modules/Api/Controllers/AccountControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/AccountControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class AccountControllerTest @@ -63,10 +64,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result); + $this->assertInstanceOf(stdClass::class, $result->result); $this->assertEquals(3, $result->result->itemId); $this->assertEquals('Account created', $result->result->resultMessage); @@ -97,10 +98,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result); + $this->assertInstanceOf(stdClass::class, $result->result); $this->assertEquals(4, $result->result->itemId); $this->assertEquals('Account created', $result->result->resultMessage); @@ -137,10 +138,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('password_test', $result->result->result->password); } @@ -167,10 +168,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); $this->assertEquals('Password updated', $result->result->resultMessage); $this->assertEquals($id, $result->result->itemId); @@ -187,10 +188,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('test_123', $result->result->result->password); } @@ -214,12 +215,12 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals($id, $result->result->itemId); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); $this->assertEquals($id, $result->result->result->id); $this->assertEquals(1, $result->result->result->userId); $this->assertEquals(1, $result->result->result->userGroupId); @@ -255,7 +256,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(3, $result->result->count); $this->assertCount(3, $result->result->result); @@ -272,7 +273,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -292,7 +293,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -309,7 +310,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(2, $result->result->count); $this->assertCount(2, $result->result->result); @@ -326,7 +327,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -346,7 +347,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -363,7 +364,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -380,7 +381,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -400,7 +401,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -417,7 +418,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -434,7 +435,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -454,7 +455,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -471,7 +472,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -489,7 +490,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(2, $result->result->count); $this->assertCount(2, $result->result->result); @@ -506,7 +507,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -527,7 +528,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -545,7 +546,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -563,7 +564,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(0, $result->result->count); $this->assertCount(0, $result->result->result); @@ -582,7 +583,7 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(2, $result->result->count); $this->assertCount(2, $result->result->result); @@ -612,16 +613,16 @@ class AccountControllerTest extends WebTestCase 'isPrivateGroup' => 0, 'userId' => 1, 'userGroupId' => 1 - ], + ], 'id' => 1 ]; $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result); + $this->assertInstanceOf(stdClass::class, $result->result); $this->assertEquals(3, $result->result->itemId); $this->assertEquals('Account updated', $result->result->resultMessage); @@ -637,12 +638,12 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals($id, $result->result->itemId); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); $this->assertEquals($id, $result->result->result->id); $this->assertEquals(1, $result->result->result->userId); $this->assertEquals(1, $result->result->result->userGroupId); @@ -691,10 +692,10 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); - $this->assertInstanceOf(\stdClass::class, $result->result); + $this->assertInstanceOf(stdClass::class, $result->result); $this->assertEquals(3, $result->result->itemId); $this->assertEquals('Account updated', $result->result->resultMessage); } @@ -718,9 +719,9 @@ class AccountControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); - $this->assertInstanceOf(\stdClass::class, $result->result); + $this->assertInstanceOf(stdClass::class, $result->result); $this->assertEquals('Account removed', $result->result->resultMessage); $this->assertEquals($id, $result->result->itemId); $this->assertNull($result->result->count); diff --git a/tests/SP/Modules/Api/Controllers/CategoryControllerTest.php b/tests/SP/Modules/Api/Controllers/CategoryControllerTest.php index 99106dcb..2bd9c32d 100644 --- a/tests/SP/Modules/Api/Controllers/CategoryControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/CategoryControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class CategoryControllerTest @@ -52,12 +53,12 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals(5, $result->result->itemId); $this->assertEquals('Category added', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); return $result->result->itemId; } @@ -81,7 +82,7 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->result->id); @@ -110,12 +111,12 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Category updated', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } public function testSearchAction() @@ -131,7 +132,7 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(5, $result->result->count); $this->assertCount(5, $result->result->result); @@ -148,7 +149,7 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -168,7 +169,7 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -195,11 +196,11 @@ class CategoryControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Category deleted', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } } diff --git a/tests/SP/Modules/Api/Controllers/ClientControllerTest.php b/tests/SP/Modules/Api/Controllers/ClientControllerTest.php index 235763c8..f2c4e763 100644 --- a/tests/SP/Modules/Api/Controllers/ClientControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/ClientControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class ClientControllerTest @@ -53,12 +54,12 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals(4, $result->result->itemId); $this->assertEquals('Client added', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); return $result->result->itemId; } @@ -82,7 +83,7 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->result->id); @@ -113,12 +114,12 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Client updated', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } public function testSearchAction() @@ -134,7 +135,7 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(4, $result->result->count); $this->assertCount(4, $result->result->result); @@ -151,7 +152,7 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -171,7 +172,7 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -199,11 +200,11 @@ class ClientControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Client deleted', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } } diff --git a/tests/SP/Modules/Api/Controllers/ConfigControllerTest.php b/tests/SP/Modules/Api/Controllers/ConfigControllerTest.php index 5ec44941..769824a5 100644 --- a/tests/SP/Modules/Api/Controllers/ConfigControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/ConfigControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class ConfigControllerTest @@ -47,7 +48,7 @@ class ConfigControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals('/var/www/html/sysPass/app/backup', $result->result->result); @@ -68,7 +69,7 @@ class ConfigControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals(0, $result->result->itemId); diff --git a/tests/SP/Modules/Api/Controllers/TagControllerTest.php b/tests/SP/Modules/Api/Controllers/TagControllerTest.php index dc079c9d..8b8ef2f9 100644 --- a/tests/SP/Modules/Api/Controllers/TagControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/TagControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class TagControllerTest @@ -52,12 +53,12 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals(7, $result->result->itemId); $this->assertEquals('Tag added', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); return $result->result->itemId; } @@ -81,7 +82,7 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->result->id); @@ -108,12 +109,12 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Tag updated', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } public function testSearchAction() @@ -129,7 +130,7 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(7, $result->result->count); $this->assertCount(7, $result->result->result); @@ -146,7 +147,7 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -166,7 +167,7 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -192,11 +193,11 @@ class TagControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Tag removed', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } } diff --git a/tests/SP/Modules/Api/Controllers/UserGroupControllerTest.php b/tests/SP/Modules/Api/Controllers/UserGroupControllerTest.php index 45678cd4..bf52ad2d 100644 --- a/tests/SP/Modules/Api/Controllers/UserGroupControllerTest.php +++ b/tests/SP/Modules/Api/Controllers/UserGroupControllerTest.php @@ -26,6 +26,7 @@ namespace SP\Tests\Modules\Api\Controllers; use SP\Tests\Modules\Api\ApiTest; use SP\Tests\WebTestCase; +use stdClass; /** * Class UserGroupControllerTest @@ -53,12 +54,12 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals(2, $result->result->itemId); $this->assertEquals('Group added', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); return $result->result->itemId; } @@ -82,7 +83,7 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->result->id); @@ -112,12 +113,12 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Group updated', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } /** @@ -143,12 +144,12 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Group updated', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); return $id; } @@ -172,7 +173,7 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->result->id); @@ -194,7 +195,7 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(2, $result->result->count); $this->assertCount(2, $result->result->result); @@ -211,7 +212,7 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -231,7 +232,7 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertEquals(1, $result->result->count); $this->assertCount(1, $result->result->result); @@ -257,11 +258,11 @@ class UserGroupControllerTest extends WebTestCase $result = self::checkAndProcessJsonResponse(self::postJson(ApiTest::API_URL, $data)); - $this->assertInstanceOf(\stdClass::class, $result); + $this->assertInstanceOf(stdClass::class, $result); $this->assertEquals(0, $result->result->resultCode); $this->assertNull($result->result->count); $this->assertEquals($id, $result->result->itemId); $this->assertEquals('Group deleted', $result->result->resultMessage); - $this->assertInstanceOf(\stdClass::class, $result->result->result); + $this->assertInstanceOf(stdClass::class, $result->result->result); } } diff --git a/tests/SP/Mvc/Controller/Validators/PasswordValidatorTest.php b/tests/SP/Mvc/Controller/Validators/PasswordValidatorTest.php index 7008a351..906b7677 100644 --- a/tests/SP/Mvc/Controller/Validators/PasswordValidatorTest.php +++ b/tests/SP/Mvc/Controller/Validators/PasswordValidatorTest.php @@ -42,7 +42,7 @@ class PasswordValidatorTest extends TestCase private $password; /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidate() { @@ -53,7 +53,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoLength() { @@ -65,7 +65,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoLetters() { @@ -77,7 +77,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoUpper() { @@ -89,7 +89,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoLower() { @@ -101,7 +101,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoNumbers() { @@ -113,7 +113,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoSymbols() { @@ -125,7 +125,7 @@ class PasswordValidatorTest extends TestCase } /** - * @throws \SP\Core\Exceptions\ValidationException + * @throws ValidationException */ public function testValidateNoRegex() { diff --git a/tests/SP/Repositories/AccountFileRepositoryTest.php b/tests/SP/Repositories/AccountFileRepositoryTest.php index cb3c0075..79e88a22 100644 --- a/tests/SP/Repositories/AccountFileRepositoryTest.php +++ b/tests/SP/Repositories/AccountFileRepositoryTest.php @@ -24,6 +24,11 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\FileData; use SP\DataModel\FileExtData; use SP\DataModel\ItemSearchData; @@ -45,9 +50,9 @@ class AccountFileRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -63,8 +68,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDelete() { @@ -76,8 +81,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -88,8 +93,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetInfoById() { @@ -115,8 +120,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetById() { @@ -158,8 +163,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -192,8 +197,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -217,8 +222,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -250,8 +255,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByAccountId() { @@ -284,8 +289,8 @@ class AccountFileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByIdBatch() { diff --git a/tests/SP/Repositories/AccountHistoryRepositoryTest.php b/tests/SP/Repositories/AccountHistoryRepositoryTest.php index 48980adc..e4ba914b 100644 --- a/tests/SP/Repositories/AccountHistoryRepositoryTest.php +++ b/tests/SP/Repositories/AccountHistoryRepositoryTest.php @@ -24,6 +24,13 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountHistoryData; use SP\DataModel\Dto\AccountHistoryCreateDto; use SP\DataModel\ItemSearchData; @@ -47,9 +54,9 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -65,8 +72,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDelete() { @@ -78,8 +85,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -96,8 +103,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAccountsPassData() { @@ -114,8 +121,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetHistoryForAccount() { @@ -138,9 +145,9 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -157,8 +164,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -180,8 +187,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -192,7 +199,7 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetById() { @@ -213,10 +220,10 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws EnvironmentIsBrokenException + * @throws SPException */ public function testUpdatePassword() { @@ -240,8 +247,8 @@ class AccountHistoryRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByAccountIdBatch() { diff --git a/tests/SP/Repositories/AccountRepositoryTest.php b/tests/SP/Repositories/AccountRepositoryTest.php index 5ab85561..5d3d9b3f 100644 --- a/tests/SP/Repositories/AccountRepositoryTest.php +++ b/tests/SP/Repositories/AccountRepositoryTest.php @@ -24,9 +24,13 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\CryptoException; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Exceptions\SPException; use SP\DataModel\AccountData; use SP\DataModel\AccountSearchVData; @@ -39,6 +43,7 @@ use SP\Services\Account\AccountRequest; use SP\Services\Account\AccountSearchFilter; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -58,8 +63,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -98,7 +103,7 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testEditRestore() { @@ -111,7 +116,7 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testEditRestoreUnknownUser() { @@ -124,8 +129,8 @@ class AccountRepositoryTest extends DatabaseTestCase * Comprobar la modificación de una clave de cuenta * * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws CryptoException + * @throws ConstraintException */ public function testEditPassword() { @@ -227,8 +232,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación en lotes * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -244,8 +249,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar la búsqueda de cuentas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -259,7 +264,7 @@ class AccountRepositoryTest extends DatabaseTestCase $this->assertCount(1, $data); $this->assertEquals(1, $result->getNumRows()); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(1, $data[0]->id); $this->assertEquals('Google', $data[0]->name); @@ -273,7 +278,7 @@ class AccountRepositoryTest extends DatabaseTestCase $this->assertCount(1, $data); $this->assertEquals(1, $result->getNumRows()); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Apple', $data[0]->name); } @@ -281,8 +286,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar las cuentas enlazadas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetLinked() { @@ -295,8 +300,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar en incremento del contador de vistas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws SPException */ public function testIncrementViewCounter() @@ -315,8 +320,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Obtener todas las cuentas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -336,8 +341,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws CryptoException + * @throws ConstraintException */ public function testUpdatePassword() { @@ -360,8 +365,8 @@ class AccountRepositoryTest extends DatabaseTestCase * Comprobar en incremento del contador de desencriptado * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testIncrementDecryptCounter() { @@ -379,8 +384,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar el número total de cuentas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetTotalNumAccounts() { @@ -388,8 +393,8 @@ class AccountRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetDataForLink() { @@ -416,8 +421,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar las cuentas devueltas para un filtro de usuario * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetForUser() { @@ -430,8 +435,8 @@ class AccountRepositoryTest extends DatabaseTestCase /** * Comprobar las cuentas devueltas para obtener los datos de las claves * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAccountsPassData() { @@ -442,9 +447,9 @@ class AccountRepositoryTest extends DatabaseTestCase * Comprobar la creación de una cuenta * * @throws SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -492,7 +497,7 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetPasswordHistoryForId() { @@ -524,8 +529,8 @@ class AccountRepositoryTest extends DatabaseTestCase * Comprobar la búsqueda de cuentas mediante filtros * * @throws SPException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByFilter() { @@ -606,7 +611,7 @@ class AccountRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException * @throws SPException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateBulk() { diff --git a/tests/SP/Repositories/AccountToFavoriteRepositoryTest.php b/tests/SP/Repositories/AccountToFavoriteRepositoryTest.php index 0653bf1b..fb33ee34 100644 --- a/tests/SP/Repositories/AccountToFavoriteRepositoryTest.php +++ b/tests/SP/Repositories/AccountToFavoriteRepositoryTest.php @@ -25,7 +25,10 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Repositories\Account\AccountToFavoriteRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; @@ -45,8 +48,8 @@ class AccountToFavoriteRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -62,8 +65,8 @@ class AccountToFavoriteRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -78,7 +81,7 @@ class AccountToFavoriteRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetForUserId() { @@ -99,7 +102,7 @@ class AccountToFavoriteRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { diff --git a/tests/SP/Repositories/AccountToTagRepositoryTest.php b/tests/SP/Repositories/AccountToTagRepositoryTest.php index 465a2f6c..03849128 100644 --- a/tests/SP/Repositories/AccountToTagRepositoryTest.php +++ b/tests/SP/Repositories/AccountToTagRepositoryTest.php @@ -25,7 +25,10 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Account\AccountToTagRepository; use SP\Services\Account\AccountRequest; @@ -49,8 +52,8 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -69,7 +72,7 @@ class AccountToTagRepositoryTest extends DatabaseTestCase * Comprobar la obtención de etiquetas por Id de cuenta * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetTagsByAccountId() { @@ -80,8 +83,8 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de etiquetas asociadas a las cuentas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -114,8 +117,8 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de etiquetas por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByAccountId() { @@ -129,8 +132,8 @@ class AccountToTagRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de etiquetas por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { diff --git a/tests/SP/Repositories/AccountToUserGroupRepositoryTest.php b/tests/SP/Repositories/AccountToUserGroupRepositoryTest.php index 569cd3c5..ef831ec7 100644 --- a/tests/SP/Repositories/AccountToUserGroupRepositoryTest.php +++ b/tests/SP/Repositories/AccountToUserGroupRepositoryTest.php @@ -25,7 +25,10 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Account\AccountToUserGroupRepository; use SP\Services\Account\AccountRequest; @@ -49,8 +52,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -69,7 +72,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase * Comprobar la obtención de grupos de usuarios por Id de cuenta * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUserGroupsByAccountId() { @@ -115,8 +118,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de grupos de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { @@ -152,8 +155,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de grupos de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdateEdit() { @@ -189,8 +192,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de grupos de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testViewDeleteByAccountId() { @@ -206,8 +209,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de grupos de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByAccountId() { @@ -223,8 +226,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de grupos de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAddEdit() { @@ -259,8 +262,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de grupos de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -298,8 +301,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de grupos de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteEditByAccountId() { @@ -315,7 +318,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase * Comprobar la obtención de grupos de usuarios por Id de grupo * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUserGroupsByUserGroupId() { @@ -330,7 +333,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase * Comprobar la eliminación de grupos de usuarios por Id de grupo * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByUserGroupId() { diff --git a/tests/SP/Repositories/AccountToUserRepositoryTest.php b/tests/SP/Repositories/AccountToUserRepositoryTest.php index 95253017..6c6d38ff 100644 --- a/tests/SP/Repositories/AccountToUserRepositoryTest.php +++ b/tests/SP/Repositories/AccountToUserRepositoryTest.php @@ -25,7 +25,10 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemData; use SP\Repositories\Account\AccountToUserRepository; use SP\Services\Account\AccountRequest; @@ -49,8 +52,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -69,7 +72,7 @@ class AccountToUserRepositoryTest extends DatabaseTestCase * Comprobar la obtención de usuarios por Id de cuenta * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUsersByAccountId() { @@ -119,8 +122,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { @@ -158,8 +161,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdateEdit() { @@ -197,8 +200,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteViewByAccountId() { @@ -213,8 +216,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByAccountId() { @@ -229,8 +232,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAddEdit() { @@ -267,8 +270,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la insercción de usuarios por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -305,8 +308,8 @@ class AccountToUserRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de usuarios con permisos de modificación por Id de cuenta * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteEditByAccountId() { diff --git a/tests/SP/Repositories/AuthTokenRepositoryTest.php b/tests/SP/Repositories/AuthTokenRepositoryTest.php index 18e3664e..f93563a5 100644 --- a/tests/SP/Repositories/AuthTokenRepositoryTest.php +++ b/tests/SP/Repositories/AuthTokenRepositoryTest.php @@ -25,10 +25,16 @@ namespace SP\Tests\Repositories; use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Hash; use SP\Core\Crypt\Vault; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AuthTokenData; use SP\DataModel\ItemSearchData; use SP\Repositories\AuthToken\AuthTokenRepository; @@ -37,6 +43,7 @@ use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Util\PasswordUtil; use SP\Util\Util; +use stdClass; use function SP\Tests\setupContext; /** @@ -56,8 +63,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -73,8 +80,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetById() { @@ -91,7 +98,7 @@ class AuthTokenRepositoryTest extends DatabaseTestCase $result = self::$repository->getById(2); $this->assertEquals(1, $result->getNumRows()); - + $data = $result->getData(); $this->assertInstanceOf(AuthTokenData::class, $data); @@ -102,8 +109,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetTokenByUserId() { @@ -114,8 +121,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase /** * @throws CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetTokenByToken() { @@ -140,8 +147,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase /** * @throws CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testRefreshVaultByUserId() { @@ -168,9 +175,9 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ public function testRefreshTokenByUserId() { @@ -186,10 +193,10 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\DuplicatedItemException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException + * @throws DuplicatedItemException * @throws CryptoException */ public function testUpdate() @@ -229,8 +236,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -244,11 +251,11 @@ class AuthTokenRepositoryTest extends DatabaseTestCase $this->assertEquals(2, $result->getNumRows()); $this->assertCount(2, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(ActionsInterface::ACCOUNT_SEARCH, $data[0]->actionId); $this->assertEquals(self::AUTH_TOKEN, $data[0]->token); - $this->assertInstanceOf(\stdClass::class, $data[1]); + $this->assertInstanceOf(stdClass::class, $data[1]); $this->assertEquals(ActionsInterface::ACCOUNT_VIEW_PASS, $data[1]->actionId); $this->assertEquals(self::AUTH_TOKEN, $data[1]->token); @@ -262,8 +269,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -276,8 +283,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetUserIdForToken() { @@ -287,8 +294,8 @@ class AuthTokenRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDelete() { @@ -299,10 +306,10 @@ class AuthTokenRepositoryTest extends DatabaseTestCase /** * @throws CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreate() { diff --git a/tests/SP/Repositories/CategoryRepositoryTest.php b/tests/SP/Repositories/CategoryRepositoryTest.php index d3d7c40c..6f3f66e4 100644 --- a/tests/SP/Repositories/CategoryRepositoryTest.php +++ b/tests/SP/Repositories/CategoryRepositoryTest.php @@ -24,14 +24,19 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; use SP\Repositories\Category\CategoryRepository; use SP\Repositories\DuplicatedItemException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -49,9 +54,9 @@ class CategoryRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -113,7 +118,7 @@ class CategoryRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Linux server', $data[0]->description); @@ -181,10 +186,10 @@ class CategoryRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de categorías * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException */ public function testUpdate() { @@ -214,8 +219,8 @@ class CategoryRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de categorías * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -237,7 +242,7 @@ class CategoryRepositoryTest extends DatabaseTestCase * Comprobar la creación de categorías * * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -264,7 +269,7 @@ class CategoryRepositoryTest extends DatabaseTestCase * Comprobar la eliminación de categorías por Id * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testDelete() { diff --git a/tests/SP/Repositories/ClientRepositoryTest.php b/tests/SP/Repositories/ClientRepositoryTest.php index 338787d9..83f4ef7d 100644 --- a/tests/SP/Repositories/ClientRepositoryTest.php +++ b/tests/SP/Repositories/ClientRepositoryTest.php @@ -24,8 +24,12 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ClientData; use SP\DataModel\ItemSearchData; use SP\Mvc\Model\QueryCondition; @@ -50,9 +54,9 @@ class ClientRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -175,10 +179,10 @@ class ClientRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de clientes * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException */ public function testUpdate() { @@ -207,8 +211,8 @@ class ClientRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de clientes * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -230,7 +234,7 @@ class ClientRepositoryTest extends DatabaseTestCase * Comprobar la creación de clientes * * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -262,8 +266,8 @@ class ClientRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de clientes por Id * - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws QueryException + * @throws ConstraintException */ public function testDelete() { diff --git a/tests/SP/Repositories/ConfigRepositoryTest.php b/tests/SP/Repositories/ConfigRepositoryTest.php index a09cfe2b..f34fc58e 100644 --- a/tests/SP/Repositories/ConfigRepositoryTest.php +++ b/tests/SP/Repositories/ConfigRepositoryTest.php @@ -24,6 +24,11 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ConfigData; use SP\Repositories\Config\ConfigRepository; use SP\Storage\Database\DatabaseConnectionData; @@ -43,9 +48,9 @@ class ConfigRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -61,8 +66,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -81,8 +86,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testHas() { @@ -91,8 +96,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { @@ -114,8 +119,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -130,8 +135,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByParam() { @@ -148,8 +153,8 @@ class ConfigRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByParam() { diff --git a/tests/SP/Repositories/CustomFieldDefRepositoryTest.php b/tests/SP/Repositories/CustomFieldDefRepositoryTest.php index 5023def9..1d2e152a 100644 --- a/tests/SP/Repositories/CustomFieldDefRepositoryTest.php +++ b/tests/SP/Repositories/CustomFieldDefRepositoryTest.php @@ -24,8 +24,13 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldDefinitionData; use SP\DataModel\ItemSearchData; use SP\Repositories\CustomField\CustomFieldDefRepository; @@ -47,9 +52,9 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -67,7 +72,7 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -89,8 +94,8 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testUpdate() @@ -120,8 +125,8 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -136,7 +141,7 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { @@ -181,7 +186,7 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -202,7 +207,7 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -241,7 +246,7 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -268,8 +273,8 @@ class CustomFieldDefRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { diff --git a/tests/SP/Repositories/CustomFieldRepositoryTest.php b/tests/SP/Repositories/CustomFieldRepositoryTest.php index f86155cf..dc2c2099 100644 --- a/tests/SP/Repositories/CustomFieldRepositoryTest.php +++ b/tests/SP/Repositories/CustomFieldRepositoryTest.php @@ -24,8 +24,12 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldData; use SP\Repositories\CustomField\CustomFieldRepository; use SP\Storage\Database\DatabaseConnectionData; @@ -45,9 +49,9 @@ class CustomFieldRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -63,8 +67,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDataBatch() { @@ -81,8 +85,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDataForDefinition() { @@ -99,8 +103,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCheckExists() { @@ -125,8 +129,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllEncrypted() { @@ -144,8 +148,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDefinitionDataBatch() { @@ -157,8 +161,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -173,8 +177,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldData() { @@ -191,8 +195,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetForModuleById() { @@ -283,8 +287,8 @@ class CustomFieldRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -339,7 +343,7 @@ class CustomFieldRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteCustomFieldDefinitionData() { @@ -351,7 +355,7 @@ class CustomFieldRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdate() { diff --git a/tests/SP/Repositories/CustomFieldTypeRepositoryTest.php b/tests/SP/Repositories/CustomFieldTypeRepositoryTest.php index f93fb2a4..15fce72a 100644 --- a/tests/SP/Repositories/CustomFieldTypeRepositoryTest.php +++ b/tests/SP/Repositories/CustomFieldTypeRepositoryTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldTypeData; use SP\Repositories\CustomField\CustomFieldTypeRepository; use SP\Storage\Database\DatabaseConnectionData; @@ -44,9 +49,9 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -62,8 +67,8 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -79,8 +84,8 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDelete() { @@ -98,7 +103,7 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -118,7 +123,7 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -138,8 +143,8 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testCreate() { @@ -155,8 +160,8 @@ class CustomFieldTypeRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdate() { diff --git a/tests/SP/Repositories/EventlogRepositoryTest.php b/tests/SP/Repositories/EventlogRepositoryTest.php index eb2207d1..6d1eb1c5 100644 --- a/tests/SP/Repositories/EventlogRepositoryTest.php +++ b/tests/SP/Repositories/EventlogRepositoryTest.php @@ -24,12 +24,17 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\EventlogData; use SP\DataModel\ItemSearchData; use SP\Repositories\EventLog\EventlogRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -47,9 +52,9 @@ class EventlogRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -68,7 +73,7 @@ class EventlogRepositoryTest extends DatabaseTestCase * Comprobar la búsqueda de eventos por texto * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -81,7 +86,7 @@ class EventlogRepositoryTest extends DatabaseTestCase $this->assertEquals(4, $result->getNumRows()); $this->assertCount(4, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals('login.auth.database', $data[0]->action); $itemSearchData->setSeachString('login.auth.'); @@ -91,7 +96,7 @@ class EventlogRepositoryTest extends DatabaseTestCase $this->assertEquals(4, $result->getNumRows()); $this->assertCount(4, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $itemSearchData->setSeachString('Tiempo inactivo : 0 min.'); @@ -100,7 +105,7 @@ class EventlogRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $itemSearchData->setSeachString('prueba'); @@ -113,8 +118,8 @@ class EventlogRepositoryTest extends DatabaseTestCase /** * Comprobar la limpieza el registro de eventos * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testClear() { @@ -126,8 +131,8 @@ class EventlogRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de eventos * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { diff --git a/tests/SP/Repositories/ItemPresetRepositoryTest.php b/tests/SP/Repositories/ItemPresetRepositoryTest.php index d7385ae8..1e44ffb6 100644 --- a/tests/SP/Repositories/ItemPresetRepositoryTest.php +++ b/tests/SP/Repositories/ItemPresetRepositoryTest.php @@ -24,12 +24,17 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemPresetData; use SP\DataModel\ItemSearchData; use SP\Repositories\ItemPreset\ItemPresetRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -45,9 +50,9 @@ class ItemPresetRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -64,7 +69,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -77,7 +82,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -92,7 +97,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { @@ -103,7 +108,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdate() { @@ -122,7 +127,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateDuplicatedHash() { @@ -141,7 +146,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateUnknownUserId() { @@ -160,7 +165,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateUnknownUserGroupId() { @@ -179,7 +184,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateUnknownUserProfileId() { @@ -198,7 +203,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateUnknownId() { @@ -217,7 +222,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -236,7 +241,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -270,7 +275,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -284,7 +289,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(4, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertEquals(2, $data[0]->userId); @@ -305,7 +310,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertNull($data[0]->userId); @@ -326,7 +331,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(5, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertNull($data[0]->userId); @@ -351,7 +356,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -371,7 +376,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreateDuplicatedHash() { @@ -396,7 +401,7 @@ class ItemPresetRepositoryTest extends DatabaseTestCase * @param int $expected * * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByFilter($userId, $userGroupId, $userProfileId, $expected) { diff --git a/tests/SP/Repositories/NotificationRepositoryTest.php b/tests/SP/Repositories/NotificationRepositoryTest.php index 95ab29bf..94aa0b6e 100644 --- a/tests/SP/Repositories/NotificationRepositoryTest.php +++ b/tests/SP/Repositories/NotificationRepositoryTest.php @@ -25,6 +25,8 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; use SP\Core\Messages\NotificationMessage; @@ -49,8 +51,8 @@ class NotificationRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -66,8 +68,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteAdmin() { @@ -78,8 +80,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteAdminBatch() { @@ -88,8 +90,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByIdBatch() { @@ -134,8 +136,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -165,8 +167,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -214,8 +216,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSetCheckedById() { @@ -224,8 +226,8 @@ class NotificationRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { diff --git a/tests/SP/Repositories/PluginDataRepositoryTest.php b/tests/SP/Repositories/PluginDataRepositoryTest.php index bd17a8d7..1384af77 100644 --- a/tests/SP/Repositories/PluginDataRepositoryTest.php +++ b/tests/SP/Repositories/PluginDataRepositoryTest.php @@ -24,8 +24,14 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\CryptoException; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Repositories\Plugin\PluginDataModel; use SP\Repositories\Plugin\PluginDataRepository; use SP\Storage\Database\DatabaseConnectionData; @@ -46,8 +52,8 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -64,9 +70,9 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException */ public function testUpdate() { @@ -100,9 +106,9 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException */ public function testUpdateUnkown() { @@ -118,7 +124,7 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -141,8 +147,8 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @requires testGetById * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -157,7 +163,7 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByItemId() { @@ -169,7 +175,7 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -197,7 +203,7 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByItemId() { @@ -217,8 +223,8 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -228,9 +234,9 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException */ public function testCreate() { @@ -260,9 +266,9 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException */ public function testCreateUnknown() { @@ -280,12 +286,12 @@ class PluginDataRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { $result = self::$repository->getByIdBatch(['Authenticator', 'XML Exporter', 'Test']); - /** @var \SP\Repositories\Plugin\PluginDataModel[] $data */ + /** @var PluginDataModel[] $data */ $data = $result->getDataAsArray(); $this->assertEquals(3, $result->getNumRows()); diff --git a/tests/SP/Repositories/PluginRepositoryTest.php b/tests/SP/Repositories/PluginRepositoryTest.php index c8376405..387d68ef 100644 --- a/tests/SP/Repositories/PluginRepositoryTest.php +++ b/tests/SP/Repositories/PluginRepositoryTest.php @@ -25,7 +25,11 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; use SP\Repositories\Plugin\PluginModel; @@ -48,8 +52,8 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -65,8 +69,8 @@ class PluginRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { @@ -99,12 +103,12 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { $result = self::$repository->getAll(); - /** @var \SP\Repositories\Plugin\PluginModel[] $data */ + /** @var PluginModel[] $data */ $data = $result->getDataAsArray(); $this->assertEquals(3, $result->getNumRows()); @@ -121,12 +125,12 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByName() { $result = self::$repository->getByName('Authenticator'); - /** @var \SP\Repositories\Plugin\PluginModel $data */ + /** @var PluginModel $data */ $data = $result->getData(); $this->assertEquals(1, $result->getNumRows()); @@ -142,7 +146,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleAvailableByName() { @@ -159,8 +163,8 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @requires testGetById * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -172,7 +176,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleEnabled() { @@ -182,12 +186,12 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { $result = self::$repository->getById(1); - /** @var \SP\Repositories\Plugin\PluginModel $data */ + /** @var PluginModel $data */ $data = $result->getData(); $this->assertEquals(1, $result->getNumRows()); @@ -203,8 +207,8 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -214,7 +218,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetEnabled() { @@ -234,7 +238,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -260,7 +264,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreateBlank() { @@ -271,13 +275,13 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testResetById() { $this->assertEquals(1, self::$repository->resetById(2)); - /** @var \SP\Repositories\Plugin\PluginModel $data */ + /** @var PluginModel $data */ $data = self::$repository->getById(2)->getData(); $this->assertNull($data->getData()); @@ -287,7 +291,7 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -319,13 +323,13 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleEnabledByName() { $this->assertEquals(1, self::$repository->toggleEnabledByName('Authenticator', 1)); - /** @var \SP\Repositories\Plugin\PluginModel $data */ + /** @var PluginModel $data */ $data = self::$repository->getByName('Authenticator')->getData(); $this->assertEquals(1, $data->getEnabled()); @@ -335,13 +339,13 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleAvailable() { $this->assertEquals(1, self::$repository->toggleAvailable(1, 0)); - /** @var \SP\Repositories\Plugin\PluginModel $data */ + /** @var PluginModel $data */ $data = self::$repository->getByName('Authenticator')->getData(); $this->assertEquals(0, $data->getAvailable()); @@ -351,12 +355,12 @@ class PluginRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { $result = self::$repository->getByIdBatch([1, 2, 4]); - /** @var \SP\Repositories\Plugin\PluginModel[] $data */ + /** @var PluginModel[] $data */ $data = $result->getDataAsArray(); $this->assertEquals(2, $result->getNumRows()); diff --git a/tests/SP/Repositories/PublicLinkRepositoryTest.php b/tests/SP/Repositories/PublicLinkRepositoryTest.php index 52ceef63..a76ace38 100644 --- a/tests/SP/Repositories/PublicLinkRepositoryTest.php +++ b/tests/SP/Repositories/PublicLinkRepositoryTest.php @@ -24,8 +24,13 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\PublicLinkData; use SP\DataModel\PublicLinkListData; @@ -50,8 +55,8 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -67,8 +72,8 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetHashForItem() { @@ -85,8 +90,8 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -138,8 +143,8 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -150,11 +155,11 @@ class PublicLinkRepositoryTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException + * @throws DuplicatedItemException + * @throws SPException */ public function testCreate() { @@ -200,7 +205,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -232,7 +237,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -245,7 +250,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testAddLinkView() { @@ -275,7 +280,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByHash() { @@ -307,9 +312,9 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws QueryException + * @throws SPException + * @throws EnvironmentIsBrokenException */ public function testRefresh() { @@ -339,8 +344,8 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testRefreshNullHash() { @@ -360,7 +365,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { @@ -396,7 +401,7 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -430,9 +435,9 @@ class PublicLinkRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws QueryException + * @throws SPException */ public function testUpdate() { diff --git a/tests/SP/Repositories/TagRepositoryTest.php b/tests/SP/Repositories/TagRepositoryTest.php index 9e7150a6..3dfb4643 100644 --- a/tests/SP/Repositories/TagRepositoryTest.php +++ b/tests/SP/Repositories/TagRepositoryTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; use SP\DataModel\TagData; @@ -32,6 +37,7 @@ use SP\Repositories\DuplicatedItemException; use SP\Repositories\Tag\TagRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -49,9 +55,9 @@ class TagRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -70,7 +76,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar la búsqueda mediante texto * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testSearch() { @@ -83,7 +89,7 @@ class TagRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(1, $data[0]->id); $itemSearchData = new ItemSearchData(); @@ -100,7 +106,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar los resultados de obtener las etiquetas por Id * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testGetById() { @@ -121,7 +127,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar la obtención de todas las etiquetas * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testGetAll() { @@ -144,9 +150,9 @@ class TagRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de etiquetas * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -174,7 +180,7 @@ class TagRepositoryTest extends DatabaseTestCase /** * Comprobar la eliminación de etiquetas * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -188,7 +194,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar la creación de etiquetas * * @throws DuplicatedItemException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -213,7 +219,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar la eliminación de etiquetas por Id * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testDelete() { @@ -233,7 +239,7 @@ class TagRepositoryTest extends DatabaseTestCase * Comprobar la obtención de etiquetas por Id en lote * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testGetByIdBatch() { @@ -244,7 +250,7 @@ class TagRepositoryTest extends DatabaseTestCase /** * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testCheckInUse() { diff --git a/tests/SP/Repositories/TrackRepositoryTest.php b/tests/SP/Repositories/TrackRepositoryTest.php index 9af75787..9df753e2 100644 --- a/tests/SP/Repositories/TrackRepositoryTest.php +++ b/tests/SP/Repositories/TrackRepositoryTest.php @@ -25,6 +25,11 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\TrackData; use SP\Repositories\Track\TrackRepository; use SP\Repositories\Track\TrackRequest; @@ -46,15 +51,15 @@ class TrackRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { $dic = setupContext(); self::$dataset = 'syspass_track.xml'; - + // Datos de conexión a la BBDD self::$databaseConnectionData = $dic->get(DatabaseConnectionData::class); @@ -63,8 +68,8 @@ class TrackRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDelete() { @@ -76,9 +81,9 @@ class TrackRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws ConstraintException + * @throws QueryException + * @throws InvalidArgumentException */ public function testGetById() { @@ -98,9 +103,9 @@ class TrackRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws ConstraintException + * @throws QueryException + * @throws InvalidArgumentException */ public function testAdd() { @@ -124,9 +129,9 @@ class TrackRepositoryTest extends DatabaseTestCase /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\InvalidArgumentException + * @throws ConstraintException + * @throws QueryException + * @throws InvalidArgumentException */ public function testGetAll() { @@ -146,9 +151,9 @@ class TrackRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws QueryException */ public function testGetTracksForClientFromTime() { diff --git a/tests/SP/Repositories/UserGroupRepositoryTest.php b/tests/SP/Repositories/UserGroupRepositoryTest.php index bcd8e701..5252e4a3 100644 --- a/tests/SP/Repositories/UserGroupRepositoryTest.php +++ b/tests/SP/Repositories/UserGroupRepositoryTest.php @@ -25,8 +25,11 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserGroupData; use SP\Repositories\DuplicatedItemException; @@ -51,8 +54,8 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -85,7 +88,7 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * Comprobar si el grupo está en uso * - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException * @throws QueryException */ public function testCheckInUse() @@ -204,7 +207,7 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase * * @throws ConstraintException * @throws QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -221,7 +224,7 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * @throws ConstraintException * @throws QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDuplicated() { @@ -263,7 +266,7 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * Comprobar la eliminación de grupos * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDelete() { @@ -277,7 +280,7 @@ class UserGroupRepositoryTestCase extends DatabaseTestCase /** * Comprobar la eliminación de grupos * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteUsed() { diff --git a/tests/SP/Repositories/UserPassRecoverRepositoryTest.php b/tests/SP/Repositories/UserPassRecoverRepositoryTest.php index 8ee49761..7d99d269 100644 --- a/tests/SP/Repositories/UserPassRecoverRepositoryTest.php +++ b/tests/SP/Repositories/UserPassRecoverRepositoryTest.php @@ -24,8 +24,13 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Repositories\User\UserPassRecoverRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; @@ -46,8 +51,8 @@ class UserPassRecoverRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -63,9 +68,9 @@ class UserPassRecoverRepositoryTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -78,7 +83,7 @@ class UserPassRecoverRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAttemptsByUserId() { @@ -91,8 +96,8 @@ class UserPassRecoverRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws QueryException + * @throws EnvironmentIsBrokenException */ public function testGetUserIdForHash() { @@ -107,7 +112,7 @@ class UserPassRecoverRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testToggleUsedByHash() { diff --git a/tests/SP/Repositories/UserProfileRepositoryTest.php b/tests/SP/Repositories/UserProfileRepositoryTest.php index df590bff..4d78e380 100644 --- a/tests/SP/Repositories/UserProfileRepositoryTest.php +++ b/tests/SP/Repositories/UserProfileRepositoryTest.php @@ -25,8 +25,11 @@ namespace SP\Tests\Repositories; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\ProfileData; use SP\DataModel\UserProfileData; @@ -34,6 +37,7 @@ use SP\Repositories\DuplicatedItemException; use SP\Repositories\UserProfile\UserProfileRepository; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -52,8 +56,8 @@ class UserProfileRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -109,7 +113,7 @@ class UserProfileRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Demo', $data[0]->name); @@ -208,7 +212,7 @@ class UserProfileRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDuplicated() { diff --git a/tests/SP/Repositories/UserRepositoryTest.php b/tests/SP/Repositories/UserRepositoryTest.php index db4e2a81..921e9a6d 100644 --- a/tests/SP/Repositories/UserRepositoryTest.php +++ b/tests/SP/Repositories/UserRepositoryTest.php @@ -24,11 +24,15 @@ namespace SP\Tests\Repositories; +use Defuse\Crypto\Exception\CryptoException; use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; use SP\Core\Crypt\Hash; use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserData; use SP\DataModel\UserPreferencesData; @@ -37,6 +41,7 @@ use SP\Repositories\User\UserRepository; use SP\Services\User\UpdatePassRequest; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -56,8 +61,8 @@ class UserRepositoryTest extends DatabaseTestCase /** * @throws DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -75,9 +80,9 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la actualización de usuarios * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -112,7 +117,7 @@ class UserRepositoryTest extends DatabaseTestCase * Comprobar la modificación de las preferencias de usuario * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testUpdatePreferencesById() { @@ -129,7 +134,7 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la obtención de los datos de un usuario * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetById() { @@ -153,7 +158,7 @@ class UserRepositoryTest extends DatabaseTestCase * Comprobar si existe un usuario * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testCheckExistsByLogin() { @@ -180,8 +185,8 @@ class UserRepositoryTest extends DatabaseTestCase * Comprobar la actualización de la clave de un usuario por Id * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws SPException */ public function testUpdatePassById() { @@ -234,7 +239,7 @@ class UserRepositoryTest extends DatabaseTestCase * Actualizar un usuario desde el proceso de login * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testUpdateOnLogin() { @@ -256,7 +261,7 @@ class UserRepositoryTest extends DatabaseTestCase * Eliminar usuarios en lote * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testDeleteByIdBatch() { @@ -270,7 +275,7 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la obtención de los datos de un usuario * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetByLogin() { @@ -292,7 +297,7 @@ class UserRepositoryTest extends DatabaseTestCase * Comprobar la eliminación de usuarios * * @throws QueryException - * @throws \SP\Core\Exceptions\ConstraintException + * @throws ConstraintException */ public function testDelete() { @@ -354,7 +359,7 @@ class UserRepositoryTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(3, $data[0]->id); $this->assertEquals('User A', $data[0]->name); @@ -371,8 +376,8 @@ class UserRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException * @throws QueryException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws SPException */ public function testUpdateMasterPassById() { @@ -395,7 +400,7 @@ class UserRepositoryTest extends DatabaseTestCase /** * Comprobar la creación de usuarios * - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { diff --git a/tests/SP/Repositories/UserToUserGroupRepositoryTest.php b/tests/SP/Repositories/UserToUserGroupRepositoryTest.php index 2a63ce90..876015dc 100644 --- a/tests/SP/Repositories/UserToUserGroupRepositoryTest.php +++ b/tests/SP/Repositories/UserToUserGroupRepositoryTest.php @@ -24,7 +24,11 @@ namespace SP\Tests\SP\Repositories; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\UserToUserGroupData; use SP\Repositories\UserGroup\UserToUserGroupRepository; use SP\Storage\Database\DatabaseConnectionData; @@ -44,9 +48,9 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase private static $repository; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -62,8 +66,8 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetGroupsForUser() { @@ -90,8 +94,8 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdate() { @@ -121,7 +125,7 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -155,7 +159,7 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -168,7 +172,7 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testAdd() { @@ -204,8 +208,8 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAddDuplicated() { @@ -218,7 +222,7 @@ class UserToUserGroupRepositoryTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCheckUserInGroup() { diff --git a/tests/SP/Services/Account/AccountAclServiceTest.php b/tests/SP/Services/Account/AccountAclServiceTest.php index 6495f370..a67c2660 100644 --- a/tests/SP/Services/Account/AccountAclServiceTest.php +++ b/tests/SP/Services/Account/AccountAclServiceTest.php @@ -24,11 +24,18 @@ namespace SP\Tests\Services\Account; +use Closure; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\Acl; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; use SP\Core\Context\StatelessContext; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\Dto\AccountAclDto; use SP\DataModel\Dto\AccountDetailsResponse; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountAcl; use SP\Services\Account\AccountAclService; use SP\Services\Account\AccountService; @@ -45,7 +52,7 @@ use function SP\Tests\setupContext; class AccountAclServiceTest extends DatabaseTestCase { /** - * @var \Closure + * @var Closure */ private static $service; /** @@ -78,9 +85,9 @@ class AccountAclServiceTest extends DatabaseTestCase protected $account; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -161,9 +168,9 @@ class AccountAclServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testGetAclAdmin() { @@ -198,8 +205,8 @@ class AccountAclServiceTest extends DatabaseTestCase * * @param bool $should * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkAllowAll(AccountAclDto $accountAclDto, $should = true) { @@ -245,8 +252,8 @@ class AccountAclServiceTest extends DatabaseTestCase * * @param AccountAcl $accountAclExample * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkForUserByExample(AccountAclDto $accountAclDto, AccountAcl $accountAclExample) { @@ -356,9 +363,9 @@ class AccountAclServiceTest extends DatabaseTestCase * @param int $isAdminAcc * * @return AccountAclDto - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function setUpAccountEnvironment($accountId, $userId, $groupId, $isAdminApp = 0, $isAdminAcc = 0) { @@ -382,9 +389,9 @@ class AccountAclServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testGetAclUser() { @@ -491,8 +498,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile Sets profile action status * @param bool $acl Sets ACL expected result * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkView(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -532,8 +539,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkViewPass(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -573,8 +580,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkDelete(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -614,8 +621,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkEditPass(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -655,8 +662,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkEditAndRestore(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -699,8 +706,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkPermissions(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { @@ -740,8 +747,8 @@ class AccountAclServiceTest extends DatabaseTestCase * @param bool $profile * @param bool $acl * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ private function checkViewFiles(AccountAclDto $accountAclDto, $should = ['view' => true, 'edit' => true], $profile = true, $acl = true) { diff --git a/tests/SP/Services/Account/AccountCryptServiceTest.php b/tests/SP/Services/Account/AccountCryptServiceTest.php index ff505c9a..cd158772 100644 --- a/tests/SP/Services/Account/AccountCryptServiceTest.php +++ b/tests/SP/Services/Account/AccountCryptServiceTest.php @@ -25,7 +25,13 @@ namespace SP\Tests\Services\Account; use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountCryptService; use SP\Services\Account\AccountService; use SP\Services\Crypt\UpdateMasterPassRequest; @@ -54,9 +60,9 @@ class AccountCryptServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -73,11 +79,11 @@ class AccountCryptServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException + * @throws CryptoException + * @throws NoSuchItemException */ public function testUpdateMasterPassword() { @@ -108,9 +114,9 @@ class AccountCryptServiceTest extends DatabaseTestCase /** * @throws CryptoException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testUpdateHistoryMasterPassword() { diff --git a/tests/SP/Services/Account/AccountFileServiceTest.php b/tests/SP/Services/Account/AccountFileServiceTest.php index c486c363..dc6d25a6 100644 --- a/tests/SP/Services/Account/AccountFileServiceTest.php +++ b/tests/SP/Services/Account/AccountFileServiceTest.php @@ -24,7 +24,13 @@ namespace SP\Tests\Services\Account; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; use SP\Core\Exceptions\InvalidImageException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\FileData; use SP\DataModel\FileExtData; use SP\DataModel\ItemSearchData; @@ -48,9 +54,9 @@ class AccountFileServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -66,9 +72,9 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreate() { @@ -121,9 +127,9 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreateInvalid() { @@ -141,8 +147,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -173,8 +179,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetById() { @@ -208,8 +214,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByIdBatch() { @@ -224,8 +230,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetInfoById() { @@ -246,8 +252,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -268,8 +274,8 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByAccountId() { @@ -298,9 +304,9 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testDelete() { @@ -316,9 +322,9 @@ class AccountFileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { diff --git a/tests/SP/Services/Account/AccountHistoryServiceTest.php b/tests/SP/Services/Account/AccountHistoryServiceTest.php index b84c81fa..9bb9cc92 100644 --- a/tests/SP/Services/Account/AccountHistoryServiceTest.php +++ b/tests/SP/Services/Account/AccountHistoryServiceTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,6 +24,13 @@ namespace SP\Tests\Services\Account; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountHistoryData; use SP\DataModel\Dto\AccountHistoryCreateDto; use SP\DataModel\ItemSearchData; @@ -49,9 +56,9 @@ class AccountHistoryServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -67,8 +74,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -83,9 +90,9 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException */ public function testCreate() { @@ -102,8 +109,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -125,8 +132,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetHistoryForAccount() { @@ -149,7 +156,7 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetById() { @@ -169,9 +176,9 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testDelete() { @@ -186,8 +193,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -198,8 +205,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws SPException */ public function testUpdatePasswordMasterPass() { @@ -224,8 +231,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAccountsPassData() { @@ -240,8 +247,8 @@ class AccountHistoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByAccountIdBatch() { diff --git a/tests/SP/Services/Account/AccountSearchServiceTest.php b/tests/SP/Services/Account/AccountSearchServiceTest.php index ab7edc70..4ac98055 100644 --- a/tests/SP/Services/Account/AccountSearchServiceTest.php +++ b/tests/SP/Services/Account/AccountSearchServiceTest.php @@ -24,10 +24,18 @@ namespace SP\Tests\Services\Account; +use Closure; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\UserPreferencesData; use SP\Mvc\Model\QueryCondition; use SP\Services\Account\AccountSearchFilter; +use SP\Services\Account\AccountSearchItem; use SP\Services\Account\AccountSearchService; use SP\Services\User\UserLoginResponse; use SP\Storage\Database\DatabaseConnectionData; @@ -47,14 +55,14 @@ class AccountSearchServiceTest extends DatabaseTestCase */ private static $service; /** - * @var \Closure + * @var Closure */ private static $setupUser; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -78,9 +86,9 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testProcessSearchResultsForUserAdmin() { @@ -128,15 +136,15 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param int $id Category Id * @param array $accountsId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkCategoryById($id, array $accountsId = []) { $rows = count($accountsId); - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setCategoryId($id); @@ -145,7 +153,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $this->assertInstanceOf(QueryResult::class, $result); if ($rows > 0) { - /** @var \SP\Services\Account\AccountSearchItem[] $data */ + /** @var AccountSearchItem[] $data */ $data = $result->getDataAsArray(); $i = 0; @@ -158,9 +166,9 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkNonExistantCategory() { @@ -178,15 +186,15 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param int $id Client Id * @param array $accountsId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkClientById($id, array $accountsId = []) { $rows = count($accountsId); - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setClientId($id); @@ -195,7 +203,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $this->assertEquals($rows, $result->getNumRows()); if ($rows > 0) { - /** @var \SP\Services\Account\AccountSearchItem[] $data */ + /** @var AccountSearchItem[] $data */ $data = $result->getDataAsArray(); $i = 0; @@ -213,15 +221,15 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param array $accountsId * @param string $operator * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkClientAndCategory($clientId, $categoryId, array $accountsId = [], $operator = null) { $rows = count($accountsId); - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setFilterOperator($operator); $searchFilter->setClientId($clientId); @@ -233,7 +241,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $i = 0; - /** @var \SP\Services\Account\AccountSearchItem $item */ + /** @var AccountSearchItem $item */ foreach ($result->getDataAsArray() as $item) { $this->assertEquals($accountsId[$i], $item->getAccountSearchVData()->getId()); $i++; @@ -241,13 +249,13 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkNonExistantClient() { - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setClientId(10); @@ -261,15 +269,15 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param string $string * @param array $accountsId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkString($string, array $accountsId = []) { $rows = count($accountsId); - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setTxtSearch($string); @@ -280,7 +288,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $i = 0; - /** @var \SP\Services\Account\AccountSearchItem $item */ + /** @var AccountSearchItem $item */ foreach ($result->getDataAsArray() as $item) { $this->assertEquals($accountsId[$i], $item->getAccountSearchVData()->getId()); @@ -292,13 +300,13 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param int $rows Expected rows * @param array $accountsId * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkFavorites($rows, array $accountsId = []) { - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setSearchFavorites(true); @@ -309,7 +317,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $i = 0; - /** @var \SP\Services\Account\AccountSearchItem $item */ + /** @var AccountSearchItem $item */ foreach ($result->getDataAsArray() as $item) { $this->assertEquals($accountsId[$i], $item->getAccountSearchVData()->getId()); $i++; @@ -321,15 +329,15 @@ class AccountSearchServiceTest extends DatabaseTestCase * @param array $accountsId * @param string $operator * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ private function checkTags(array $tagsId, array $accountsId = [], $operator = null) { $rows = count($accountsId); - $searchFilter = new \SP\Services\Account\AccountSearchFilter(); + $searchFilter = new AccountSearchFilter(); $searchFilter->setLimitCount(10); $searchFilter->setFilterOperator($operator); $searchFilter->setTagsId($tagsId); @@ -337,7 +345,7 @@ class AccountSearchServiceTest extends DatabaseTestCase $result = self::$service->processSearchResults($searchFilter); $this->assertInstanceOf(QueryResult::class, $result); - /** @var \SP\Services\Account\AccountSearchItem[] $data */ + /** @var AccountSearchItem[] $data */ $data = $result->getDataAsArray(); $this->assertEquals($rows, $result->getNumRows()); @@ -352,13 +360,13 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testProcessSearchResultsForUserDemo() { - \SP\Services\Account\AccountSearchItem::$publicLinkEnabled = false; + AccountSearchItem::$publicLinkEnabled = false; $userData = new UserLoginResponse(); $userData->setId(2); @@ -399,13 +407,13 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testProcessSearchResultsForUserA() { - \SP\Services\Account\AccountSearchItem::$publicLinkEnabled = false; + AccountSearchItem::$publicLinkEnabled = false; $userData = new UserLoginResponse(); $userData->setId(3); @@ -445,13 +453,13 @@ class AccountSearchServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testProcessSearchResultsForUserB() { - \SP\Services\Account\AccountSearchItem::$publicLinkEnabled = false; + AccountSearchItem::$publicLinkEnabled = false; $userData = new UserLoginResponse(); $userData->setId(4); diff --git a/tests/SP/Services/Account/AccountServiceTest.php b/tests/SP/Services/Account/AccountServiceTest.php index 145c0bfd..1e7d2e18 100644 --- a/tests/SP/Services/Account/AccountServiceTest.php +++ b/tests/SP/Services/Account/AccountServiceTest.php @@ -24,12 +24,22 @@ namespace SP\Tests\Services\Account; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use SP\Core\Context\ContextException; +use SP\Core\Context\ContextInterface; use SP\Core\Crypt\Crypt; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountData; use SP\DataModel\AccountSearchVData; use SP\DataModel\AccountVData; use SP\DataModel\ItemSearchData; +use SP\DataModel\ProfileData; use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountBulkRequest; use SP\Services\Account\AccountHistoryService; @@ -38,9 +48,11 @@ use SP\Services\Account\AccountRequest; use SP\Services\Account\AccountSearchFilter; use SP\Services\Account\AccountService; use SP\Services\ServiceException; +use SP\Services\User\UserLoginResponse; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Util\PasswordUtil; +use stdClass; use function SP\Tests\setupContext; /** @@ -55,15 +67,19 @@ class AccountServiceTest extends DatabaseTestCase * @var AccountHistoryService */ protected static $accountHistoryService; + /** + * @var ContextInterface + */ + private static $context; /** * @var AccountService */ private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -71,6 +87,8 @@ class AccountServiceTest extends DatabaseTestCase self::$dataset = 'syspass_account.xml'; + self::$context = $dic->get(ContextInterface::class); + // Datos de conexión a la BBDD self::$databaseConnectionData = $dic->get(DatabaseConnectionData::class); @@ -80,11 +98,11 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws CryptoException + * @throws NoSuchPropertyException */ public function testCreate() { @@ -181,9 +199,9 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testUpdatePasswordMasterPass() @@ -204,8 +222,8 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetTotalNumAccounts() { @@ -214,8 +232,8 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetDataForLink() { @@ -237,8 +255,8 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAccountsPassData() { @@ -246,7 +264,7 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \Exception + * @throws Exception */ public function testEditRestore() { @@ -261,8 +279,8 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetLinked() { @@ -277,7 +295,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ public function testGetPasswordEncrypted() { @@ -294,10 +312,10 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \Exception + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws Exception */ public function testEditPassword() { @@ -325,10 +343,10 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \Exception + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws Exception */ public function testUpdate() { @@ -352,8 +370,6 @@ class AccountServiceTest extends DatabaseTestCase $accountRequest->userGroupsView = [2, 3]; $accountRequest->userGroupsEdit = [2]; $accountRequest->updateTags = true; - $accountRequest->updateUserPermissions = true; - $accountRequest->updateUserGroupPermissions = true; self::$service->update($accountRequest); @@ -400,16 +416,218 @@ class AccountServiceTest extends DatabaseTestCase $this->assertEquals(1, (int)$groups[0]->isEdit); $this->assertEquals(3, $groups[1]->getId()); $this->assertEquals(0, (int)$groups[1]->isEdit); + } + + /** + * @throws NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws Exception + */ + public function testUpdateOwnerByAdmin() + { + $accountRequest = new AccountRequest(); + $accountRequest->id = 1; + $accountRequest->name = 'Prueba 1'; + $accountRequest->login = 'admin'; + $accountRequest->url = 'http://syspass.org'; + $accountRequest->notes = 'notas'; + $accountRequest->userEditId = 1; + $accountRequest->passDateChange = time() + 3600; + $accountRequest->clientId = 1; + $accountRequest->categoryId = 1; + $accountRequest->isPrivate = 0; + $accountRequest->isPrivateGroup = 0; + $accountRequest->parentId = 0; + $accountRequest->userId = 2; + $accountRequest->userGroupId = 2; + + self::$service->update($accountRequest); + + $result = self::$service->getById(1); + + $data = $result->getAccountVData(); + + $this->assertEquals(1, $result->getId()); + $this->assertEquals($accountRequest->userId, $data->getUserId()); + } + + /** + * @throws ConstraintException + * @throws NoSuchItemException + * @throws QueryException + * @throws Exception + */ + public function testUpdateOwnerByOwner() + { + $lastUserData = self::$context->getUserData(); + + $userData = new UserLoginResponse(); + $userData->setId(1); + $userData->setUserGroupId(1); + $userData->setIsAdminApp(false); + $userData->setIsAdminAcc(false); + + $userProfile = new ProfileData(); + $userProfile->setAccEdit(true); + $userProfile->setAccPermission(true); + + self::$context->setUserData($userData); + self::$context->setUserProfile($userProfile); + $accountRequest = new AccountRequest(); + $accountRequest->id = 1; + $accountRequest->name = 'Prueba 1'; + $accountRequest->login = 'admin'; + $accountRequest->url = 'http://syspass.org'; + $accountRequest->notes = 'notas'; + $accountRequest->userEditId = 1; + $accountRequest->passDateChange = time() + 3600; + $accountRequest->clientId = 1; + $accountRequest->categoryId = 1; + $accountRequest->isPrivate = 0; + $accountRequest->isPrivateGroup = 0; + $accountRequest->parentId = 0; + $accountRequest->userId = 2; + $accountRequest->userGroupId = 2; + + self::$service->update($accountRequest); + + $result = self::$service->getById(1); + + $data = $result->getAccountVData(); + + $this->assertEquals(1, $result->getId()); + $this->assertEquals($accountRequest->userId, $data->getUserId()); + $this->assertEquals($accountRequest->userGroupId, $data->getUserGroupId()); + + self::$context->setUserData($lastUserData); + self::$context->setUserProfile(new ProfileData()); + } + + /** + * @throws ConstraintException + * @throws NoSuchItemException + * @throws QueryException + * @throws Exception + */ + public function testUpdateOwnerByForeign() + { + $lastUserData = self::$context->getUserData(); + + $userData = new UserLoginResponse(); + $userData->setId(2); + $userData->setUserGroupId(2); + $userData->setIsAdminApp(false); + $userData->setIsAdminAcc(false); + + $userProfile = new ProfileData(); + $userProfile->setAccEdit(true); + $userProfile->setAccPermission(true); + + self::$context->setUserData($userData); + self::$context->setUserProfile($userProfile); + + $accountRequest = new AccountRequest(); + $accountRequest->id = 1; + $accountRequest->name = 'Prueba 1'; + $accountRequest->login = 'admin'; + $accountRequest->url = 'http://syspass.org'; + $accountRequest->notes = 'notas'; + $accountRequest->userEditId = 1; + $accountRequest->passDateChange = time() + 3600; + $accountRequest->clientId = 1; + $accountRequest->categoryId = 1; + $accountRequest->isPrivate = 0; + $accountRequest->isPrivateGroup = 0; + $accountRequest->parentId = 0; + $accountRequest->userId = 2; + $accountRequest->userGroupId = 2; + + self::$service->update($accountRequest); + + $result = self::$service->getById(1); + + $data = $result->getAccountVData(); + + $this->assertEquals(1, $result->getId()); + $this->assertEquals(1, $data->getUserId()); + $this->assertEquals(1, $data->getUserGroupId()); + + self::$context->setUserData($lastUserData); + self::$context->setUserProfile(new ProfileData()); + } + + /** + * @throws ConstraintException + * @throws NoSuchItemException + * @throws QueryException + * @throws Exception + */ + public function testUpdateGroupByGroup() + { + $lastUserData = self::$context->getUserData(); + + $userData = new UserLoginResponse(); + $userData->setId(2); + $userData->setUserGroupId(1); + $userData->setIsAdminApp(false); + $userData->setIsAdminAcc(false); + + $userProfile = new ProfileData(); + $userProfile->setAccEdit(true); + $userProfile->setAccPermission(true); + + self::$context->setUserData($userData); + self::$context->setUserProfile($userProfile); + + $accountRequest = new AccountRequest(); + $accountRequest->id = 1; + $accountRequest->name = 'Prueba 1'; + $accountRequest->login = 'admin'; + $accountRequest->url = 'http://syspass.org'; + $accountRequest->notes = 'notas'; + $accountRequest->userEditId = 1; + $accountRequest->passDateChange = time() + 3600; + $accountRequest->clientId = 1; + $accountRequest->categoryId = 1; + $accountRequest->isPrivate = 0; + $accountRequest->isPrivateGroup = 0; + $accountRequest->parentId = 0; + $accountRequest->userId = 2; + $accountRequest->userGroupId = 2; + + self::$service->update($accountRequest); + + $result = self::$service->getById(1); + + $data = $result->getAccountVData(); + + $this->assertEquals(1, $result->getId()); + $this->assertEquals(1, $data->getUserId()); + $this->assertEquals($accountRequest->userGroupId, $data->getUserGroupId()); + + self::$context->setUserData($lastUserData); + self::$context->setUserProfile(new ProfileData()); + } + + /** + * @throws Exception + */ + public function testUpdateNotFound() + { $accountRequest = new AccountRequest(); $accountRequest->id = 3; + $this->expectException(NoSuchItemException::class); + self::$service->update($accountRequest); } /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetForUser() { @@ -420,7 +638,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -431,7 +649,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -450,8 +668,8 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testGetByFilter() { @@ -530,7 +748,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -544,7 +762,7 @@ class AccountServiceTest extends DatabaseTestCase $this->assertCount(1, $data); $this->assertEquals(1, $result->getNumRows()); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(1, $data[0]->id); $this->assertEquals('Google', $data[0]->name); @@ -558,7 +776,7 @@ class AccountServiceTest extends DatabaseTestCase $this->assertCount(1, $data); $this->assertEquals(1, $result->getNumRows()); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Apple', $data[0]->name); } @@ -566,7 +784,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testIncrementDecryptCounter() { @@ -584,7 +802,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testIncrementViewCounter() { @@ -602,7 +820,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetPasswordHistoryForId() { @@ -623,7 +841,7 @@ class AccountServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAllBasic() { @@ -637,7 +855,7 @@ class AccountServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateFromHistory() { @@ -671,7 +889,7 @@ class AccountServiceTest extends DatabaseTestCase * @throws ConstraintException * @throws NoSuchItemException * @throws ServiceException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateBulk() { @@ -702,7 +920,7 @@ class AccountServiceTest extends DatabaseTestCase * * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ private function checkBulkData(AccountRequest $accountRequest, $accountId) { diff --git a/tests/SP/Services/Account/AccountToFavoriteServiceTest.php b/tests/SP/Services/Account/AccountToFavoriteServiceTest.php index 8a385d28..c12b1e39 100644 --- a/tests/SP/Services/Account/AccountToFavoriteServiceTest.php +++ b/tests/SP/Services/Account/AccountToFavoriteServiceTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,7 +24,11 @@ namespace SP\Tests\Services\Account; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Services\Account\AccountToFavoriteService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; @@ -43,9 +47,9 @@ class AccountToFavoriteServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -62,7 +66,7 @@ class AccountToFavoriteServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -72,7 +76,7 @@ class AccountToFavoriteServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetForUserId() { @@ -89,7 +93,7 @@ class AccountToFavoriteServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testAdd() { diff --git a/tests/SP/Services/Account/AccountToTagServiceTest.php b/tests/SP/Services/Account/AccountToTagServiceTest.php index 07967604..8b36501f 100644 --- a/tests/SP/Services/Account/AccountToTagServiceTest.php +++ b/tests/SP/Services/Account/AccountToTagServiceTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -24,6 +24,11 @@ namespace SP\Tests\Services\Account; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Services\Account\AccountToTagService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; @@ -42,9 +47,9 @@ class AccountToTagServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -60,8 +65,8 @@ class AccountToTagServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetTagsByAccountId() { diff --git a/tests/SP/Services/Api/ApiRequestTest.php b/tests/SP/Services/Api/ApiRequestTest.php index 1ba726ee..b1c758fd 100644 --- a/tests/SP/Services/Api/ApiRequestTest.php +++ b/tests/SP/Services/Api/ApiRequestTest.php @@ -37,7 +37,7 @@ use function SP\Tests\getResource; class ApiRequestTest extends TestCase { /** - * @throws \SP\Services\Api\ApiRequestException + * @throws ApiRequestException */ public function testGetRequestJsonData() { diff --git a/tests/SP/Services/Api/ApiServiceTest.php b/tests/SP/Services/Api/ApiServiceTest.php index 6f8a5d42..3e44b572 100644 --- a/tests/SP/Services/Api/ApiServiceTest.php +++ b/tests/SP/Services/Api/ApiServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Services\Api; +use Closure; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\SPException; use SP\Services\Api\ApiRequest; use SP\Services\Api\ApiService; use SP\Services\ServiceException; @@ -49,14 +54,14 @@ class ApiServiceTest extends DatabaseTestCase */ private static $service; /** - * @var \Closure + * @var Closure */ private static $changeRequest; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -76,8 +81,8 @@ class ApiServiceTest extends DatabaseTestCase } /** - * @throws \SP\Services\ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws ServiceException + * @throws SPException */ public function testSetup() { @@ -108,7 +113,7 @@ class ApiServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetParam() { @@ -132,7 +137,7 @@ class ApiServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetParamInt() { @@ -153,7 +158,7 @@ class ApiServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetParamString() { @@ -168,7 +173,7 @@ class ApiServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetParamRaw() { @@ -181,7 +186,7 @@ class ApiServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetRequestId() { diff --git a/tests/SP/Services/AuthToken/AuthTokenServiceTest.php b/tests/SP/Services/AuthToken/AuthTokenServiceTest.php index cb6f330a..f4047beb 100644 --- a/tests/SP/Services/AuthToken/AuthTokenServiceTest.php +++ b/tests/SP/Services/AuthToken/AuthTokenServiceTest.php @@ -25,9 +25,17 @@ namespace SP\Tests\Services\AuthToken; use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Hash; use SP\Core\Crypt\Vault; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AuthTokenData; use SP\DataModel\ItemSearchData; use SP\Repositories\DuplicatedItemException; @@ -37,6 +45,7 @@ use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Util\Util; +use stdClass; use function SP\Tests\setupContext; /** @@ -55,9 +64,9 @@ class AuthTokenServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -73,9 +82,9 @@ class AuthTokenServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -90,8 +99,8 @@ class AuthTokenServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -108,7 +117,7 @@ class AuthTokenServiceTest extends DatabaseTestCase } /** - * @throws \Exception + * @throws Exception */ public function testRefreshAndUpdate() { @@ -137,9 +146,9 @@ class AuthTokenServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException */ public function testGetTokenByToken() { @@ -163,9 +172,9 @@ class AuthTokenServiceTest extends DatabaseTestCase /** * @throws CryptoException * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -199,8 +208,8 @@ class AuthTokenServiceTest extends DatabaseTestCase /** * @throws CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetById() { @@ -226,8 +235,8 @@ class AuthTokenServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -241,11 +250,11 @@ class AuthTokenServiceTest extends DatabaseTestCase $this->assertEquals(4, $result->getNumRows()); $this->assertCount(4, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(ActionsInterface::ACCOUNT_SEARCH, $data[0]->actionId); $this->assertEquals(self::AUTH_TOKEN, $data[0]->token); - $this->assertInstanceOf(\stdClass::class, $data[1]); + $this->assertInstanceOf(stdClass::class, $data[1]); $this->assertEquals(ActionsInterface::ACCOUNT_VIEW, $data[1]->actionId); $this->assertEquals(self::AUTH_TOKEN, $data[1]->token); @@ -261,10 +270,10 @@ class AuthTokenServiceTest extends DatabaseTestCase /** * @throws CryptoException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreate() { diff --git a/tests/SP/Services/Backup/FileBackupServiceTest.php b/tests/SP/Services/Backup/FileBackupServiceTest.php index 7d58f8df..b9548d21 100644 --- a/tests/SP/Services/Backup/FileBackupServiceTest.php +++ b/tests/SP/Services/Backup/FileBackupServiceTest.php @@ -24,8 +24,12 @@ namespace SP\Tests\Services\Backup; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; +use SP\Core\Context\ContextException; use SP\Services\Backup\FileBackupService; +use SP\Services\ServiceException; use function SP\Tests\setupContext; /** @@ -36,10 +40,10 @@ use function SP\Tests\setupContext; class FileBackupServiceTest extends TestCase { /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \SP\Services\ServiceException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws ServiceException */ public function testDoBackup() { diff --git a/tests/SP/Services/Category/CategoryServiceTest.php b/tests/SP/Services/Category/CategoryServiceTest.php index d25d2517..93d46646 100644 --- a/tests/SP/Services/Category/CategoryServiceTest.php +++ b/tests/SP/Services/Category/CategoryServiceTest.php @@ -24,14 +24,21 @@ namespace SP\Tests\Services\Category; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CategoryData; use SP\DataModel\ItemSearchData; use SP\Repositories\DuplicatedItemException; use SP\Repositories\NoSuchItemException; use SP\Services\Category\CategoryService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -47,9 +54,9 @@ class CategoryServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -65,8 +72,8 @@ class CategoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -79,7 +86,7 @@ class CategoryServiceTest extends DatabaseTestCase $data = $result->getDataAsArray(); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Linux server', $data[0]->description); @@ -92,8 +99,8 @@ class CategoryServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByName() { @@ -119,8 +126,8 @@ class CategoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -141,9 +148,9 @@ class CategoryServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { @@ -165,8 +172,8 @@ class CategoryServiceTest extends DatabaseTestCase * @throws ConstraintException * @throws DuplicatedItemException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testCreate() { @@ -196,8 +203,8 @@ class CategoryServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -226,7 +233,7 @@ class CategoryServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -248,7 +255,7 @@ class CategoryServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { diff --git a/tests/SP/Services/Client/ClientServiceTest.php b/tests/SP/Services/Client/ClientServiceTest.php index f6003920..1ca5a715 100644 --- a/tests/SP/Services/Client/ClientServiceTest.php +++ b/tests/SP/Services/Client/ClientServiceTest.php @@ -24,8 +24,14 @@ namespace SP\Tests\Services\Client; +use Closure; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ClientData; use SP\DataModel\ItemSearchData; use SP\Repositories\DuplicatedItemException; @@ -45,7 +51,7 @@ use function SP\Tests\setupContext; class ClientServiceTest extends DatabaseTestCase { /** - * @var \Closure + * @var Closure */ private static $setupUser; /** @@ -54,9 +60,9 @@ class ClientServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -78,8 +84,8 @@ class ClientServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -107,8 +113,8 @@ class ClientServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -131,7 +137,7 @@ class ClientServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -152,7 +158,7 @@ class ClientServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAllForUserAdmin() { @@ -161,7 +167,7 @@ class ClientServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAllForUser() { @@ -174,10 +180,10 @@ class ClientServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException */ public function testCreate() { @@ -204,9 +210,9 @@ class ClientServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { @@ -231,7 +237,7 @@ class ClientServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByName() { @@ -257,7 +263,7 @@ class ClientServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDelete() { @@ -281,8 +287,8 @@ class ClientServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdate() { diff --git a/tests/SP/Services/Config/ConfigBackupServiceTest.php b/tests/SP/Services/Config/ConfigBackupServiceTest.php index d260d3ce..68d6603f 100644 --- a/tests/SP/Services/Config/ConfigBackupServiceTest.php +++ b/tests/SP/Services/Config/ConfigBackupServiceTest.php @@ -24,10 +24,15 @@ namespace SP\Tests\Services\Config; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; use SP\Config\Config; use SP\Config\ConfigData; +use SP\Core\Context\ContextException; use SP\Services\Config\ConfigBackupService; +use SP\Services\ServiceException; +use SP\Storage\File\FileException; use function SP\Tests\getResource; use function SP\Tests\recreateDir; use function SP\Tests\saveResource; @@ -57,9 +62,9 @@ class ConfigBackupServiceTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public function testBackup() { @@ -81,11 +86,11 @@ class ConfigBackupServiceTest extends TestCase * * @param ConfigData $configData * - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \SP\Services\ServiceException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws ServiceException + * @throws FileException */ public function testRestore(ConfigData $configData) { diff --git a/tests/SP/Services/Config/ConfigServiceTest.php b/tests/SP/Services/Config/ConfigServiceTest.php index 8c9bb779..559a9c18 100644 --- a/tests/SP/Services/Config/ConfigServiceTest.php +++ b/tests/SP/Services/Config/ConfigServiceTest.php @@ -24,10 +24,16 @@ namespace SP\Tests\Services\Config; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ConfigData; use SP\DataModel\Dto\ConfigRequest; use SP\Repositories\NoSuchItemException; use SP\Services\Config\ConfigService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -45,9 +51,9 @@ class ConfigServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -64,8 +70,8 @@ class ConfigServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -79,8 +85,8 @@ class ConfigServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteByParam() { @@ -92,7 +98,7 @@ class ConfigServiceTest extends DatabaseTestCase } /** - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testSaveBatch() { @@ -109,9 +115,9 @@ class ConfigServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testSave() { @@ -123,9 +129,9 @@ class ConfigServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testCreate() { @@ -138,7 +144,7 @@ class ConfigServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testGetByParam() { diff --git a/tests/SP/Services/Crypt/MasterPassServiceTest.php b/tests/SP/Services/Crypt/MasterPassServiceTest.php index 579aa9e4..e4d93afd 100644 --- a/tests/SP/Services/Crypt/MasterPassServiceTest.php +++ b/tests/SP/Services/Crypt/MasterPassServiceTest.php @@ -24,11 +24,20 @@ namespace SP\Tests\Services\Crypt; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountService; use SP\Services\Crypt\MasterPassService; use SP\Services\Crypt\UpdateMasterPassRequest; use SP\Services\CustomField\CustomFieldService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Tests\Services\Account\AccountCryptServiceTest; @@ -55,9 +64,9 @@ class MasterPassServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -75,8 +84,8 @@ class MasterPassServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Exception + * @throws CryptoException + * @throws Exception */ public function testChangeMasterPassword() { @@ -97,10 +106,10 @@ class MasterPassServiceTest extends DatabaseTestCase /** * @param UpdateMasterPassRequest $request * - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function checckAccounts(UpdateMasterPassRequest $request) { @@ -118,10 +127,10 @@ class MasterPassServiceTest extends DatabaseTestCase /** * @param UpdateMasterPassRequest $request * - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function checkAccountsHistory(UpdateMasterPassRequest $request) { @@ -158,9 +167,9 @@ class MasterPassServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException */ private function checkCustomFields() { @@ -172,8 +181,8 @@ class MasterPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws NoSuchItemException + * @throws ServiceException */ public function testCheckUserUpdateMPass() { @@ -182,8 +191,8 @@ class MasterPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws NoSuchItemException + * @throws ServiceException */ public function testCheckMasterPassword() { diff --git a/tests/SP/Services/Crypt/SecureSessionServiceTest.php b/tests/SP/Services/Crypt/SecureSessionServiceTest.php index 7644cbbb..e0017ce8 100644 --- a/tests/SP/Services/Crypt/SecureSessionServiceTest.php +++ b/tests/SP/Services/Crypt/SecureSessionServiceTest.php @@ -2,8 +2,8 @@ /** * sysPass * - * @author nuxsmin - * @link https://syspass.org + * @author nuxsmin + * @link https://syspass.org * @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org * * This file is part of sysPass. @@ -25,7 +25,10 @@ namespace SP\Tests\Services\Crypt; use Defuse\Crypto\Key; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; +use SP\Core\Context\ContextException; use SP\Core\Crypt\UUIDCookie; use SP\Services\Crypt\SecureSessionService; use function SP\Tests\setupContext; @@ -38,9 +41,9 @@ use function SP\Tests\setupContext; class SecureSessionServiceTest extends TestCase { /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public function testGetKey() { diff --git a/tests/SP/Services/Crypt/TemporaryMasterPassServiceTest.php b/tests/SP/Services/Crypt/TemporaryMasterPassServiceTest.php index 19a06446..c4458dd8 100644 --- a/tests/SP/Services/Crypt/TemporaryMasterPassServiceTest.php +++ b/tests/SP/Services/Crypt/TemporaryMasterPassServiceTest.php @@ -25,9 +25,14 @@ namespace SP\Tests\Services\Crypt; use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; +use SP\Repositories\NoSuchItemException; use SP\Services\Crypt\TemporaryMasterPassService; +use SP\Services\ServiceException; use function SP\Tests\setupContext; /** @@ -47,9 +52,9 @@ class TemporaryMasterPassServiceTest extends TestCase private $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public function setUp() { @@ -62,7 +67,7 @@ class TemporaryMasterPassServiceTest extends TestCase } /** - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testCreate() { @@ -79,9 +84,9 @@ class TemporaryMasterPassServiceTest extends TestCase * * @param $key * - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchItemException + * @throws ServiceException */ public function testGetUsingKey($key) { @@ -97,7 +102,7 @@ class TemporaryMasterPassServiceTest extends TestCase * * @param $key * - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testCheckTempMasterPass($key) { @@ -112,7 +117,7 @@ class TemporaryMasterPassServiceTest extends TestCase } /** - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testExpiredKey() { diff --git a/tests/SP/Services/CustomField/CustomFieldCryptServiceTest.php b/tests/SP/Services/CustomField/CustomFieldCryptServiceTest.php index ef37cfbb..108426e3 100644 --- a/tests/SP/Services/CustomField/CustomFieldCryptServiceTest.php +++ b/tests/SP/Services/CustomField/CustomFieldCryptServiceTest.php @@ -24,10 +24,17 @@ namespace SP\Tests\Services\CustomField; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Services\Crypt\UpdateMasterPassRequest; use SP\Services\CustomField\CustomFieldCryptService; use SP\Services\CustomField\CustomFieldService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Tests\Services\Account\AccountCryptServiceTest; @@ -50,9 +57,9 @@ class CustomFieldCryptServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -69,10 +76,10 @@ class CustomFieldCryptServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException + * @throws CryptoException */ public function testUpdateMasterPassword() { diff --git a/tests/SP/Services/CustomField/CustomFieldDefServiceTest.php b/tests/SP/Services/CustomField/CustomFieldDefServiceTest.php index 0a34cd27..567fefe5 100644 --- a/tests/SP/Services/CustomField/CustomFieldDefServiceTest.php +++ b/tests/SP/Services/CustomField/CustomFieldDefServiceTest.php @@ -24,8 +24,12 @@ namespace SP\Tests\Services\CustomField; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\CustomFieldDefinitionData; use SP\DataModel\ItemSearchData; use SP\Repositories\NoSuchItemException; @@ -48,9 +52,9 @@ class CustomFieldDefServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -66,7 +70,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase } /** - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testDelete() { @@ -86,7 +90,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAllBasic() { @@ -119,7 +123,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase } /** - * @throws \SP\Services\ServiceException + * @throws ServiceException */ public function testDeleteByIdBatch() { @@ -142,7 +146,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -167,7 +171,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -191,8 +195,8 @@ class CustomFieldDefServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testUpdate() { @@ -223,7 +227,7 @@ class CustomFieldDefServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { diff --git a/tests/SP/Services/CustomField/CustomFieldServiceTest.php b/tests/SP/Services/CustomField/CustomFieldServiceTest.php index a8ce9faa..be514862 100644 --- a/tests/SP/Services/CustomField/CustomFieldServiceTest.php +++ b/tests/SP/Services/CustomField/CustomFieldServiceTest.php @@ -24,12 +24,19 @@ namespace SP\Tests\Services\CustomField; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; use SP\Core\Acl\ActionsInterface; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\CustomFieldData; use SP\Repositories\NoSuchItemException; use SP\Services\CustomField\CustomFieldService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use SP\Tests\Services\Account\AccountCryptServiceTest; @@ -48,9 +55,9 @@ class CustomFieldServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -66,8 +73,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDefinitionDataBatch() { @@ -79,10 +86,10 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testUpdateMasterPass() { @@ -101,8 +108,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllEncrypted() { @@ -116,8 +123,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDataBatch() { @@ -133,10 +140,10 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdateOrCreateData() { @@ -186,8 +193,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetForModuleAndItemId() { @@ -295,7 +302,7 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteCustomFieldData() { @@ -313,8 +320,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteCustomFieldDefinitionData() { @@ -326,8 +333,8 @@ class CustomFieldServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -340,10 +347,10 @@ class CustomFieldServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws QueryException + * @throws NoSuchItemException + * @throws ServiceException */ public function testCreate() { diff --git a/tests/SP/Services/Eventlog/EventlogServiceTest.php b/tests/SP/Services/Eventlog/EventlogServiceTest.php index 9fa07494..96131d15 100644 --- a/tests/SP/Services/Eventlog/EventlogServiceTest.php +++ b/tests/SP/Services/Eventlog/EventlogServiceTest.php @@ -24,12 +24,18 @@ namespace SP\Tests\Services\Eventlog; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\EventlogData; use SP\DataModel\ItemSearchData; use SP\Services\EventLog\EventlogService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -45,9 +51,9 @@ class EventlogServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -63,9 +69,9 @@ class EventlogServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testClear() { @@ -75,8 +81,8 @@ class EventlogServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -89,7 +95,7 @@ class EventlogServiceTest extends DatabaseTestCase $this->assertEquals(4, $result->getNumRows()); $this->assertCount(4, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals('login.auth.database', $data[0]->action); $itemSearchData->setSeachString('login.auth.'); @@ -99,7 +105,7 @@ class EventlogServiceTest extends DatabaseTestCase $this->assertEquals(4, $result->getNumRows()); $this->assertCount(4, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $itemSearchData->setSeachString('Tiempo inactivo : 0 min.'); @@ -108,7 +114,7 @@ class EventlogServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $itemSearchData->setSeachString('prueba'); @@ -120,7 +126,7 @@ class EventlogServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { diff --git a/tests/SP/Services/Export/XmlExportServiceTest.php b/tests/SP/Services/Export/XmlExportServiceTest.php index 5e06ce1d..13fefeb4 100644 --- a/tests/SP/Services/Export/XmlExportServiceTest.php +++ b/tests/SP/Services/Export/XmlExportServiceTest.php @@ -25,11 +25,15 @@ namespace SP\Tests\Services\Export; use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Services\Export\VerifyResult; use SP\Services\Export\XmlExportService; use SP\Services\Export\XmlVerifyService; use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\File\FileException; use SP\Tests\DatabaseTestCase; use SP\Util\PasswordUtil; use function SP\Tests\setupContext; @@ -51,9 +55,9 @@ class XmlExportServiceTest extends DatabaseTestCase private static $xmlVerifyService; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -71,7 +75,7 @@ class XmlExportServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDoExportWithoutPassword() { @@ -87,8 +91,8 @@ class XmlExportServiceTest extends DatabaseTestCase * * @param $file * - * @throws \SP\Services\ServiceException - * @throws \SP\Storage\File\FileException + * @throws ServiceException + * @throws FileException */ private function verifyExportWithoutPassword($file) { @@ -120,7 +124,7 @@ class XmlExportServiceTest extends DatabaseTestCase /** * @throws CryptoException * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDoExportWithPassword() { @@ -139,7 +143,7 @@ class XmlExportServiceTest extends DatabaseTestCase * * @throws CryptoException * @throws ServiceException - * @throws \SP\Storage\File\FileException + * @throws FileException */ private function verifyExportWithPassword($file, $password) { diff --git a/tests/SP/Services/Export/XmlVerifyServiceTest.php b/tests/SP/Services/Export/XmlVerifyServiceTest.php index 0030244d..74d7328f 100644 --- a/tests/SP/Services/Export/XmlVerifyServiceTest.php +++ b/tests/SP/Services/Export/XmlVerifyServiceTest.php @@ -24,9 +24,16 @@ namespace SP\Tests\Services\Export; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use DOMDocument; use PHPUnit\Framework\TestCase; +use SP\Core\Context\ContextException; use SP\Services\Export\VerifyResult; use SP\Services\Export\XmlVerifyService; +use SP\Services\ServiceException; +use SP\Storage\File\FileException; use function SP\Tests\setupContext; /** @@ -42,9 +49,9 @@ class XmlVerifyServiceTest extends TestCase private static $xmlVerifyService; /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException + * @throws DependencyException + * @throws NotFoundException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -54,9 +61,9 @@ class XmlVerifyServiceTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Services\ServiceException - * @throws \SP\Storage\File\FileException + * @throws CryptoException + * @throws ServiceException + * @throws FileException */ public function testVerifyEncrypted() { @@ -77,8 +84,8 @@ class XmlVerifyServiceTest extends TestCase } /** - * @throws \SP\Services\ServiceException - * @throws \SP\Storage\File\FileException + * @throws ServiceException + * @throws FileException */ public function testVerify() { @@ -100,7 +107,7 @@ class XmlVerifyServiceTest extends TestCase public function testCheckXmlHash() { - $dom = new \DOMDocument(); + $dom = new DOMDocument(); $dom->load(RESOURCE_DIR . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'data_syspass_encrypted.xml'); $this->assertTrue(XmlVerifyService::checkXmlHash($dom, 'test_encrypt')); diff --git a/tests/SP/Services/Import/CsvImportTest.php b/tests/SP/Services/Import/CsvImportTest.php index 7d02d150..d693feea 100644 --- a/tests/SP/Services/Import/CsvImportTest.php +++ b/tests/SP/Services/Import/CsvImportTest.php @@ -24,8 +24,15 @@ namespace SP\Tests\Services\Import; +use Defuse\Crypto\Exception\CryptoException; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountService; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; @@ -34,6 +41,7 @@ use SP\Services\Import\FileImport; use SP\Services\Import\ImportException; use SP\Services\Import\ImportParams; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\File\FileException; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -50,9 +58,9 @@ class CsvImportTest extends DatabaseTestCase protected static $dic; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -65,14 +73,14 @@ class CsvImportTest extends DatabaseTestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ImportException + * @throws FileException */ public function testDoImport() { @@ -91,12 +99,12 @@ class CsvImportTest extends DatabaseTestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function checkImportedData() { @@ -162,7 +170,7 @@ class CsvImportTest extends DatabaseTestCase /** * @throws ImportException - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDoImportInvalidData() { diff --git a/tests/SP/Services/Import/KeepassImportTest.php b/tests/SP/Services/Import/KeepassImportTest.php index 48180307..1488e7c4 100644 --- a/tests/SP/Services/Import/KeepassImportTest.php +++ b/tests/SP/Services/Import/KeepassImportTest.php @@ -24,9 +24,17 @@ namespace SP\Tests\Services\Import; +use Defuse\Crypto\Exception\CryptoException; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountSearchVData; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountSearchFilter; use SP\Services\Account\AccountService; use SP\Services\Category\CategoryService; @@ -37,6 +45,7 @@ use SP\Services\Import\ImportParams; use SP\Services\Import\KeepassImport; use SP\Services\Import\XmlFileImport; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\File\FileException; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -53,9 +62,9 @@ class KeepassImportTest extends DatabaseTestCase protected static $dic; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -69,14 +78,14 @@ class KeepassImportTest extends DatabaseTestCase /** * @throws ImportException - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws NoSuchItemException + * @throws FileException */ public function testDoImport() { @@ -93,13 +102,13 @@ class KeepassImportTest extends DatabaseTestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws SPException */ private function checkImportedData() { diff --git a/tests/SP/Services/Import/SyspassImportTest.php b/tests/SP/Services/Import/SyspassImportTest.php index ee85dead..1d192ed5 100644 --- a/tests/SP/Services/Import/SyspassImportTest.php +++ b/tests/SP/Services/Import/SyspassImportTest.php @@ -24,16 +24,25 @@ namespace SP\Tests\Services\Import; +use Defuse\Crypto\Exception\CryptoException; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Repositories\NoSuchItemException; use SP\Services\Account\AccountService; use SP\Services\Category\CategoryService; use SP\Services\Client\ClientService; use SP\Services\Import\FileImport; +use SP\Services\Import\ImportException; use SP\Services\Import\ImportParams; use SP\Services\Import\SyspassImport; use SP\Services\Import\XmlFileImport; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\File\FileException; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -50,9 +59,9 @@ class SyspassImportTest extends DatabaseTestCase protected static $dic; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -65,14 +74,14 @@ class SyspassImportTest extends DatabaseTestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws ImportException + * @throws FileException */ public function testDoImport() { @@ -89,12 +98,12 @@ class SyspassImportTest extends DatabaseTestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws DependencyException + * @throws NotFoundException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ private function checkImportedData() { diff --git a/tests/SP/Services/Import/XmlFileImportTest.php b/tests/SP/Services/Import/XmlFileImportTest.php index 6a2277dc..da9ad9b4 100644 --- a/tests/SP/Services/Import/XmlFileImportTest.php +++ b/tests/SP/Services/Import/XmlFileImportTest.php @@ -28,6 +28,7 @@ use PHPUnit\Framework\TestCase; use SP\Services\Import\FileImport; use SP\Services\Import\ImportException; use SP\Services\Import\XmlFileImport; +use SP\Storage\File\FileException; /** * Class XmlFileImportTest @@ -38,8 +39,8 @@ class XmlFileImportTest extends TestCase { /** - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws ImportException + * @throws FileException */ public function testDetectXMLFormat() { @@ -57,8 +58,8 @@ class XmlFileImportTest extends TestCase } /** - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws ImportException + * @throws FileException */ public function testInvalidFile() { @@ -70,8 +71,8 @@ class XmlFileImportTest extends TestCase } /** - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws ImportException + * @throws FileException */ public function testEmptyFile() { diff --git a/tests/SP/Services/Import/XmlImportTest.php b/tests/SP/Services/Import/XmlImportTest.php index 4c3bf5fe..130b9ee2 100644 --- a/tests/SP/Services/Import/XmlImportTest.php +++ b/tests/SP/Services/Import/XmlImportTest.php @@ -25,11 +25,16 @@ namespace SP\Tests\Services\Import; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Services\Import\FileImport; +use SP\Services\Import\ImportException; use SP\Services\Import\ImportParams; use SP\Services\Import\XmlFileImport; use SP\Services\Import\XmlImport; use SP\Storage\Database\DatabaseConnectionData; +use SP\Storage\File\FileException; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -46,9 +51,9 @@ class XmlImportTest extends DatabaseTestCase protected static $dic; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -61,8 +66,8 @@ class XmlImportTest extends DatabaseTestCase } /** - * @throws \SP\Services\Import\ImportException - * @throws \SP\Storage\File\FileException + * @throws ImportException + * @throws FileException */ public function testDoImport() { diff --git a/tests/SP/Services/Install/InstallerTest.php b/tests/SP/Services/Install/InstallerTest.php index 4e783b7e..6c82be26 100644 --- a/tests/SP/Services/Install/InstallerTest.php +++ b/tests/SP/Services/Install/InstallerTest.php @@ -24,9 +24,14 @@ namespace SP\Tests\Services\Install; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use DI\Container; +use DI\DependencyException; +use DI\NotFoundException; use PHPUnit\Framework\TestCase; use SP\Config\Config; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\InvalidArgumentException; use SP\Core\Exceptions\SPException; use SP\Services\Crypt\MasterPassService; use SP\Services\Install\InstallData; @@ -56,7 +61,7 @@ class InstallerTest extends TestCase private static $dic; /** - * @throws \SP\Core\Context\ContextException + * @throws ContextException */ public static function setUpBeforeClass() { @@ -75,11 +80,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testRun() { @@ -117,11 +122,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testFailDbHostName() { @@ -144,11 +149,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testFailDbHostIp() { @@ -171,11 +176,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testFailDbHostPort() { @@ -198,11 +203,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testFailDbUser() { @@ -225,11 +230,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testFailDbPass() { @@ -252,11 +257,11 @@ class InstallerTest extends TestCase } /** - * @throws \DI\DependencyException - * @throws \DI\NotFoundException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\SPException + * @throws DependencyException + * @throws NotFoundException + * @throws EnvironmentIsBrokenException + * @throws InvalidArgumentException + * @throws SPException */ public function testHostingMode() { diff --git a/tests/SP/Services/Install/MySQLTest.php b/tests/SP/Services/Install/MySQLTest.php index 39e8c6c1..dd2ea857 100644 --- a/tests/SP/Services/Install/MySQLTest.php +++ b/tests/SP/Services/Install/MySQLTest.php @@ -26,8 +26,10 @@ namespace SP\Tests\Services\Install; use PHPUnit\Framework\TestCase; use SP\Config\ConfigData; +use SP\Core\Exceptions\SPException; use SP\Services\Install\InstallData; use SP\Services\Install\MySQL; +use SP\Storage\Database\DatabaseException; use SP\Storage\Database\MySQLHandler; use SP\Tests\DatabaseUtil; use SP\Util\PasswordUtil; @@ -42,7 +44,7 @@ class MySQLTest extends TestCase const DB_NAME = 'syspass-test-install'; /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCheckDatabaseNotExist() { @@ -81,8 +83,8 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Storage\Database\DatabaseException - * @throws \SP\Core\Exceptions\SPException + * @throws DatabaseException + * @throws SPException */ public function testCheckDatabaseExist() { @@ -96,7 +98,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testSetupDbUser() { @@ -113,7 +115,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDatabase() { @@ -131,7 +133,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCheckConnection() { @@ -152,7 +154,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testConnectDatabase() { @@ -163,7 +165,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDBUser() { @@ -182,7 +184,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testRollback() { @@ -196,7 +198,7 @@ class MySQLTest extends TestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDBStructure() { diff --git a/tests/SP/Services/ItemPreset/ItemPresetServiceTest.php b/tests/SP/Services/ItemPreset/ItemPresetServiceTest.php index b4b493e2..aeea8a89 100644 --- a/tests/SP/Services/ItemPreset/ItemPresetServiceTest.php +++ b/tests/SP/Services/ItemPreset/ItemPresetServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Services\ItemPreset; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\ItemPreset\AccountPermission; use SP\DataModel\ItemPresetData; use SP\DataModel\ItemSearchData; @@ -33,6 +38,7 @@ use SP\Services\ItemPreset\ItemPresetRequest; use SP\Services\ItemPreset\ItemPresetService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -48,9 +54,9 @@ class ItemPresetServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -73,8 +79,8 @@ class ItemPresetServiceTest extends DatabaseTestCase * @param int $userProfileId * @param int $expected * - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetForUser($userId, $userGroupId, $userProfileId, $expected) { @@ -102,9 +108,9 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testGetById() { @@ -122,8 +128,8 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -150,10 +156,10 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException + * @throws NoSuchPropertyException */ public function testUpdate() { @@ -181,8 +187,8 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testUpdateUnKnown() { @@ -205,9 +211,9 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testDelete() { @@ -220,8 +226,8 @@ class ItemPresetServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testDeleteUnKnown() { @@ -231,8 +237,8 @@ class ItemPresetServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -246,7 +252,7 @@ class ItemPresetServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(4, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertEquals(2, $data[0]->userId); @@ -267,7 +273,7 @@ class ItemPresetServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertNull($data[0]->userId); @@ -288,7 +294,7 @@ class ItemPresetServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(5, $data[0]->id); $this->assertEquals('permission', $data[0]->type); $this->assertNull($data[0]->userId); @@ -313,7 +319,7 @@ class ItemPresetServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetForCurrentUser() { @@ -326,12 +332,12 @@ class ItemPresetServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\NoSuchPropertyException + * @throws QueryException + * @throws NoSuchPropertyException */ public function testCreate() { - $accountPermission = new \SP\DataModel\ItemPreset\AccountPermission(); + $accountPermission = new AccountPermission(); $accountPermission->setUsersEdit([1, 2]); $accountPermission->setUsersView([3]); $accountPermission->setUserGroupsView([2]); @@ -357,7 +363,7 @@ class ItemPresetServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreateDuplicatedHash() { diff --git a/tests/SP/Services/Notification/NotificationServiceTest.php b/tests/SP/Services/Notification/NotificationServiceTest.php index b1b82b01..e6156584 100644 --- a/tests/SP/Services/Notification/NotificationServiceTest.php +++ b/tests/SP/Services/Notification/NotificationServiceTest.php @@ -24,8 +24,12 @@ namespace SP\Tests\Services\Notification; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; use SP\Core\Messages\NotificationMessage; use SP\DataModel\ItemSearchData; use SP\DataModel\NotificationData; @@ -54,9 +58,9 @@ class NotificationServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -74,8 +78,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAll() { @@ -88,8 +92,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearchForUserId() { @@ -145,8 +149,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testGetAllActiveForNonAdmin() @@ -182,8 +186,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testGetAllActiveForAdmin() @@ -221,7 +225,7 @@ class NotificationServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSetCheckedById() { @@ -235,8 +239,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testGetForUserIdByDate() @@ -253,8 +257,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testCreate() @@ -284,8 +288,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetByIdBatch() { @@ -310,8 +314,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearchNonAdmin() { @@ -372,8 +376,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearchAdmin() { @@ -425,8 +429,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testGetById() @@ -442,9 +446,9 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws ServiceException */ public function testDeleteAdminBatch() { @@ -462,7 +466,7 @@ class NotificationServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteAdmin() { @@ -478,8 +482,8 @@ class NotificationServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllForUserId() { @@ -495,7 +499,7 @@ class NotificationServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdate() { @@ -538,7 +542,7 @@ class NotificationServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -553,8 +557,8 @@ class NotificationServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { diff --git a/tests/SP/Services/Plugin/PluginDataServiceTest.php b/tests/SP/Services/Plugin/PluginDataServiceTest.php index f1092f31..989a98b1 100644 --- a/tests/SP/Services/Plugin/PluginDataServiceTest.php +++ b/tests/SP/Services/Plugin/PluginDataServiceTest.php @@ -24,10 +24,18 @@ namespace SP\Tests\Services\Plugin; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Repositories\NoSuchItemException; use SP\Repositories\Plugin\PluginDataModel; use SP\Services\Plugin\PluginDataService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; use function SP\Tests\setupContext; @@ -45,9 +53,9 @@ class PluginDataServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -65,10 +73,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testUpdate() { @@ -93,10 +101,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testUpdateUnkown() { @@ -110,7 +118,7 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -128,8 +136,8 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -144,8 +152,8 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteUnkown() { @@ -157,10 +165,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testCreate() { @@ -183,10 +191,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testCreateUnknown() { @@ -203,10 +211,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testGetByItemId() { @@ -221,10 +229,10 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testGetByItemIdUnkown() { @@ -236,7 +244,7 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -259,7 +267,7 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdUnkown() { @@ -271,7 +279,7 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByItemId() { @@ -283,7 +291,7 @@ class PluginDataServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByItemIdUnkown() { diff --git a/tests/SP/Services/Plugin/PluginOperationTest.php b/tests/SP/Services/Plugin/PluginOperationTest.php index f6e775b0..8e31e635 100644 --- a/tests/SP/Services/Plugin/PluginOperationTest.php +++ b/tests/SP/Services/Plugin/PluginOperationTest.php @@ -24,12 +24,21 @@ namespace SP\Tests\Services\Plugin; +use Closure; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\NoSuchPropertyException; +use SP\Core\Exceptions\QueryException; use SP\Plugin\PluginOperation; use SP\Repositories\NoSuchItemException; use SP\Services\Plugin\PluginDataService; +use SP\Services\ServiceException; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -41,14 +50,14 @@ class PluginOperationTest extends DatabaseTestCase { /** - * @var \Closure + * @var Closure */ private static $pluginOperation; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -66,11 +75,11 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testUpdate() { @@ -82,21 +91,21 @@ class PluginOperationTest extends DatabaseTestCase $this->assertEquals(1, $pluginOperation->update(1, $data)); $this->assertEquals($data, $pluginOperation->get(1)); - $data = new \stdClass(); + $data = new stdClass(); $data->id = 1; $data->name = 'test'; - $data->test = new \stdClass(); + $data->test = new stdClass(); $this->assertEquals(1, $pluginOperation->update(1, $data)); $this->assertEquals($data, $pluginOperation->get(1)); } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testUpdateUnknown() { @@ -111,11 +120,11 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testUpdateWrongPlugin() { @@ -128,9 +137,9 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testDelete() { @@ -144,9 +153,9 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testDeleteUnknown() { @@ -165,11 +174,11 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testGetUnknown() { @@ -180,21 +189,21 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testCreate() { /** @var PluginOperation $pluginOperation */ $pluginOperation = self::$pluginOperation->call($this, 'Authenticator'); - $data = new \stdClass(); + $data = new stdClass(); $data->id = 1; $data->name = 'test'; - $data->test = new \stdClass(); + $data->test = new stdClass(); $pluginOperation->create(4, $data); @@ -202,21 +211,21 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testCreateDuplicated() { /** @var PluginOperation $pluginOperation */ $pluginOperation = self::$pluginOperation->call($this, 'Authenticator'); - $data = new \stdClass(); + $data = new stdClass(); $data->id = 1; $data->name = 'test'; - $data->test = new \stdClass(); + $data->test = new stdClass(); $this->expectException(ConstraintException::class); @@ -224,21 +233,21 @@ class PluginOperationTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\NoSuchPropertyException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws CryptoException + * @throws ConstraintException + * @throws NoSuchPropertyException + * @throws QueryException + * @throws ServiceException */ public function testCreateWrongPlugin() { /** @var PluginOperation $pluginOperation */ $pluginOperation = self::$pluginOperation->call($this, 'Test'); - $data = new \stdClass(); + $data = new stdClass(); $data->id = 1; $data->name = 'test'; - $data->test = new \stdClass(); + $data->test = new stdClass(); $this->expectException(ConstraintException::class); diff --git a/tests/SP/Services/Plugin/PluginServiceTest.php b/tests/SP/Services/Plugin/PluginServiceTest.php index 86da6e75..2bdb6d78 100644 --- a/tests/SP/Services/Plugin/PluginServiceTest.php +++ b/tests/SP/Services/Plugin/PluginServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Services\Plugin; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemData; use SP\DataModel\ItemSearchData; use SP\Repositories\NoSuchItemException; @@ -48,9 +53,9 @@ class PluginServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -68,7 +73,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdate() { @@ -100,8 +105,8 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -116,8 +121,8 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws QueryException + * @throws NoSuchItemException */ public function testToggleAvailable() { @@ -134,7 +139,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException * @throws NoSuchItemException */ public function testResetById() @@ -153,7 +158,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByName() { @@ -173,8 +178,8 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -189,7 +194,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -224,7 +229,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -245,7 +250,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -267,7 +272,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreateBlank() { @@ -278,7 +283,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetEnabled() { @@ -295,7 +300,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAll() { @@ -315,7 +320,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleEnabledByName() { @@ -333,7 +338,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleAvailableByName() { @@ -350,7 +355,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByIdBatch() { @@ -367,7 +372,7 @@ class PluginServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testToggleEnabled() { diff --git a/tests/SP/Services/PublicLink/PublicLinkServiceTest.php b/tests/SP/Services/PublicLink/PublicLinkServiceTest.php index ddb20af5..d66966a0 100644 --- a/tests/SP/Services/PublicLink/PublicLinkServiceTest.php +++ b/tests/SP/Services/PublicLink/PublicLinkServiceTest.php @@ -24,9 +24,16 @@ namespace SP\Tests\Services\PublicLink; +use Defuse\Crypto\Exception\CryptoException; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; use SP\Config\ConfigData; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Vault; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\AccountExtData; use SP\DataModel\ItemSearchData; use SP\DataModel\PublicLinkData; @@ -58,9 +65,9 @@ class PublicLinkServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -78,8 +85,8 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -108,7 +115,7 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetByHash() { @@ -138,8 +145,8 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -192,8 +199,8 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetHashForItem() { @@ -208,10 +215,10 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreate() { @@ -251,7 +258,7 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @param PublicLinkListData $data * - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws CryptoException */ private function checkVaultData(PublicLinkListData $data) { @@ -269,10 +276,10 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testCreateSameItemId() { @@ -294,8 +301,8 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -311,10 +318,10 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws EnvironmentIsBrokenException + * @throws QueryException + * @throws SPException */ public function testRefresh() { @@ -333,7 +340,7 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws ServiceException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -348,8 +355,8 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testAddLinkView() { @@ -385,9 +392,9 @@ class PublicLinkServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -427,8 +434,8 @@ class PublicLinkServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException - * @throws \Defuse\Crypto\Exception\CryptoException + * @throws SPException + * @throws CryptoException */ public function testGetById() { diff --git a/tests/SP/Services/Tag/TagServiceTest.php b/tests/SP/Services/Tag/TagServiceTest.php index 953086ef..91480e2a 100644 --- a/tests/SP/Services/Tag/TagServiceTest.php +++ b/tests/SP/Services/Tag/TagServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\Services\Tag; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\TagData; use SP\Repositories\DuplicatedItemException; @@ -33,6 +38,7 @@ use SP\Services\ServiceException; use SP\Services\Tag\TagService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -48,9 +54,9 @@ class TagServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -66,7 +72,7 @@ class TagServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteByIdBatch() { @@ -80,8 +86,8 @@ class TagServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testDelete() @@ -99,8 +105,8 @@ class TagServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -127,7 +133,7 @@ class TagServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -148,7 +154,7 @@ class TagServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetAllBasic() { @@ -168,7 +174,7 @@ class TagServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -181,7 +187,7 @@ class TagServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(1, $data[0]->id); $itemSearchData = new ItemSearchData(); @@ -198,7 +204,7 @@ class TagServiceTest extends DatabaseTestCase * @throws ConstraintException * @throws DuplicatedItemException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -218,7 +224,7 @@ class TagServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByName() { diff --git a/tests/SP/Services/Task/TaskServiceTest.php b/tests/SP/Services/Task/TaskServiceTest.php index a13961f0..27517a00 100644 --- a/tests/SP/Services/Task/TaskServiceTest.php +++ b/tests/SP/Services/Task/TaskServiceTest.php @@ -25,9 +25,11 @@ namespace SP\Tests\Services\Task; use PHPUnit\Framework\TestCase; +use SP\Core\Context\ContextException; use SP\Services\Task\Task; use SP\Services\Task\TaskFactory; use SP\Services\Task\TaskService; +use SP\Storage\File\FileException; use function SP\Tests\setupContext; /** @@ -40,8 +42,8 @@ class TaskServiceTest extends TestCase private static $pids = []; /** - * @throws \SP\Storage\File\FileException - * @throws \SP\Core\Context\ContextException + * @throws FileException + * @throws ContextException */ public function testTrackStatus() { @@ -82,7 +84,7 @@ class TaskServiceTest extends TestCase TaskFactory::end($task); }); - while(count(self::$pids) > 0) { + while (count(self::$pids) > 0) { foreach (self::$pids as $key => $pid) { $res = pcntl_waitpid($pid, $status); diff --git a/tests/SP/Services/Track/TrackServiceTest.php b/tests/SP/Services/Track/TrackServiceTest.php index 3eddd2f3..334a0e94 100644 --- a/tests/SP/Services/Track/TrackServiceTest.php +++ b/tests/SP/Services/Track/TrackServiceTest.php @@ -24,6 +24,13 @@ namespace SP\Tests\Services\Track; +use DI\DependencyException; +use DI\NotFoundException; +use Exception; +use SP\Core\Context\ContextException; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\InvalidArgumentException; +use SP\Core\Exceptions\QueryException; use SP\DataModel\TrackData; use SP\Repositories\NoSuchItemException; use SP\Repositories\Track\TrackRequest; @@ -46,9 +53,9 @@ class TrackServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException */ public static function setUpBeforeClass() { @@ -64,8 +71,8 @@ class TrackServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException * @throws NoSuchItemException */ public function testDelete() @@ -81,10 +88,10 @@ class TrackServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws QueryException + * @throws ServiceException */ public function testAdd() { @@ -108,8 +115,8 @@ class TrackServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAddNoAddress() { @@ -124,9 +131,9 @@ class TrackServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws QueryException */ public function testGetAll() { @@ -144,9 +151,9 @@ class TrackServiceTest extends DatabaseTestCase /** * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws QueryException */ public function testGetById() { @@ -165,8 +172,8 @@ class TrackServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \Exception + * @throws InvalidArgumentException + * @throws Exception */ public function testCheckTracking() { @@ -180,9 +187,9 @@ class TrackServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\InvalidArgumentException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws InvalidArgumentException + * @throws QueryException */ public function testGetTracksForClientFromTime() { diff --git a/tests/SP/Services/User/UserPassServiceTest.php b/tests/SP/Services/User/UserPassServiceTest.php index fd9deef5..1771e871 100644 --- a/tests/SP/Services/User/UserPassServiceTest.php +++ b/tests/SP/Services/User/UserPassServiceTest.php @@ -24,7 +24,15 @@ namespace SP\Tests\Services\User; +use Closure; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Crypt; +use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\UserLoginData; use SP\Repositories\NoSuchItemException; use SP\Services\User\UserLoginResponse; @@ -45,7 +53,7 @@ class UserPassServiceTest extends DatabaseTestCase const NEW_MASTERPASS = '00123456789'; /** - * @var \Closure + * @var Closure */ private static $getUserLoginResponse; @@ -55,10 +63,10 @@ class UserPassServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -78,8 +86,8 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws SPException */ public function testCreateMasterPass() { @@ -91,9 +99,9 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws ConstraintException + * @throws QueryException + * @throws NoSuchItemException */ public function testMigrateUserPassById() { @@ -105,8 +113,8 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws SPException */ public function testUpdateMasterPassFromOldPass() { @@ -125,7 +133,7 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testLoadUserMPass() { @@ -144,7 +152,7 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testLoadUserMPassOutdated() { @@ -164,7 +172,7 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testLoadUserMPassChangedPass() { @@ -184,7 +192,7 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testLoadUserMPassNotSet() { @@ -199,8 +207,8 @@ class UserPassServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws SPException */ public function testUpdateMasterPassOnLogin() { diff --git a/tests/SP/Services/User/UserServiceTest.php b/tests/SP/Services/User/UserServiceTest.php index 5c44851a..d68e9eed 100644 --- a/tests/SP/Services/User/UserServiceTest.php +++ b/tests/SP/Services/User/UserServiceTest.php @@ -24,9 +24,15 @@ namespace SP\Tests\SP\Services\User; +use Defuse\Crypto\Exception\CryptoException; +use DI\DependencyException; +use DI\NotFoundException; use SP\Config\ConfigData; +use SP\Core\Context\ContextException; use SP\Core\Crypt\Hash; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserData; use SP\DataModel\UserPreferencesData; @@ -37,6 +43,7 @@ use SP\Services\User\UserLoginRequest; use SP\Services\User\UserService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -59,10 +66,10 @@ class UserServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -80,8 +87,8 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -93,8 +100,8 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetUsageForUser() { @@ -102,7 +109,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateOnLogin() { @@ -151,11 +158,11 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException + * @throws ServiceException */ public function testUpdate() { @@ -192,11 +199,11 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException + * @throws ServiceException */ public function testUpdateDuplicatedLogin() { @@ -220,11 +227,11 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException + * @throws ServiceException */ public function testUpdateDuplicatedEmail() { @@ -248,11 +255,11 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException + * @throws ServiceException */ public function testUpdateUnknown() { @@ -276,11 +283,11 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException - * @throws \SP\Repositories\DuplicatedItemException - * @throws \SP\Services\ServiceException + * @throws ConstraintException + * @throws QueryException + * @throws SPException + * @throws DuplicatedItemException + * @throws ServiceException */ public function testUpdateNull() { @@ -294,9 +301,9 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testUpdatePass() { @@ -315,7 +322,7 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -330,7 +337,7 @@ class UserServiceTest extends DatabaseTestCase $data = $result->getDataAsArray(); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(3, $data[0]->id); $this->assertEquals('User A', $data[0]->name); @@ -347,7 +354,7 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws ServiceException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDeleteByIdBatch() { @@ -359,8 +366,8 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \Defuse\Crypto\Exception\CryptoException - * @throws \SP\Core\Exceptions\SPException + * @throws CryptoException + * @throws SPException */ public function testCreateWithMasterPass() { @@ -401,7 +408,7 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUserEmailForGroup() { @@ -411,7 +418,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetByLogin() { @@ -446,7 +453,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -487,7 +494,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDuplicatedLogin() { @@ -511,7 +518,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDuplicatedEmail() { @@ -535,7 +542,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateNull() { @@ -557,7 +564,7 @@ class UserServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testGetById() { @@ -593,8 +600,8 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdatePreferencesById() { @@ -619,7 +626,7 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdateLastLoginById() { @@ -632,7 +639,7 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCheckExistsByLogin() { @@ -643,8 +650,8 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDelete() { @@ -655,8 +662,8 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteUsed() { @@ -667,8 +674,8 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testDeleteUnknown() { @@ -679,8 +686,8 @@ class UserServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdateOnLogin() { diff --git a/tests/SP/Services/UserGroup/UserGroupServiceTest.php b/tests/SP/Services/UserGroup/UserGroupServiceTest.php index 8bc53a50..96b0e549 100644 --- a/tests/SP/Services/UserGroup/UserGroupServiceTest.php +++ b/tests/SP/Services/UserGroup/UserGroupServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\SP\Services\UserGroup; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\UserGroupData; use SP\Repositories\DuplicatedItemException; @@ -49,10 +54,10 @@ class UserGroupServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -68,8 +73,8 @@ class UserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -87,7 +92,7 @@ class UserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDelete() { @@ -97,7 +102,7 @@ class UserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteUsed() { @@ -107,7 +112,7 @@ class UserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testDeleteUnknown() { @@ -118,8 +123,8 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { @@ -130,8 +135,8 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatchUsed() { @@ -143,8 +148,8 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatchUnknown() { @@ -155,8 +160,8 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -187,7 +192,7 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUsage() { @@ -195,14 +200,14 @@ class UserGroupServiceTest extends DatabaseTestCase $this->assertCount(1, self::$service->getUsage(3)); - $this->assertCount(0, self::$service->getUsage(4)); + $this->assertCount(0, self::$service->getUsage(4)); } /** * @throws ConstraintException * @throws NoSuchItemException * @throws ServiceException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testCreate() { @@ -233,7 +238,7 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testSearch() { @@ -271,7 +276,7 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetByName() { @@ -289,7 +294,7 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetById() { @@ -307,7 +312,7 @@ class UserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUsageByUsers() { diff --git a/tests/SP/Services/UserGroup/UserToUserGroupServiceTest.php b/tests/SP/Services/UserGroup/UserToUserGroupServiceTest.php index 0d1df415..f477f1d7 100644 --- a/tests/SP/Services/UserGroup/UserToUserGroupServiceTest.php +++ b/tests/SP/Services/UserGroup/UserToUserGroupServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\SP\Services\UserGroup; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\UserToUserGroupData; use SP\Repositories\NoSuchItemException; use SP\Services\UserGroup\UserToUserGroupService; @@ -46,10 +51,10 @@ class UserToUserGroupServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -65,8 +70,8 @@ class UserToUserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testCheckUserInGroup() { @@ -78,8 +83,8 @@ class UserToUserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetGroupsForUser() { @@ -100,8 +105,8 @@ class UserToUserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAdd() { @@ -117,8 +122,8 @@ class UserToUserGroupServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testAddDuplicated() { @@ -131,7 +136,7 @@ class UserToUserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testUpdate() { @@ -148,8 +153,8 @@ class UserToUserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Repositories\NoSuchItemException + * @throws QueryException + * @throws NoSuchItemException */ public function testGetById() { @@ -179,7 +184,7 @@ class UserToUserGroupServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testGetUsersByGroupId() { diff --git a/tests/SP/Services/UserPassRecover/UserPassRecoverServiceTest.php b/tests/SP/Services/UserPassRecover/UserPassRecoverServiceTest.php index a662183d..e5eaa1bd 100644 --- a/tests/SP/Services/UserPassRecover/UserPassRecoverServiceTest.php +++ b/tests/SP/Services/UserPassRecover/UserPassRecoverServiceTest.php @@ -24,7 +24,13 @@ namespace SP\Tests\SP\Services\UserPassRecover; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\Services\ServiceException; use SP\Services\UserPassRecover\UserPassRecoverService; use SP\Storage\Database\DatabaseConnectionData; @@ -45,10 +51,10 @@ class UserPassRecoverServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -66,9 +72,9 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws EnvironmentIsBrokenException + * @throws QueryException + * @throws SPException */ public function testToggleUsedByHash() { @@ -81,9 +87,9 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ServiceException - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ - public function testToggleUsedByHashExpired () + public function testToggleUsedByHashExpired() { $this->expectException(ServiceException::class); @@ -92,8 +98,8 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws QueryException */ public function testAdd() { @@ -107,8 +113,8 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws QueryException */ public function testRequestForUserId() { @@ -126,8 +132,8 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws ServiceException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException + * @throws EnvironmentIsBrokenException + * @throws QueryException */ public function testCheckAttemptsByUserId() { @@ -144,9 +150,9 @@ class UserPassRecoverServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws EnvironmentIsBrokenException + * @throws QueryException + * @throws ServiceException */ public function testGetUserIdForHash() { diff --git a/tests/SP/Services/UserProfile/UserProfileServiceTest.php b/tests/SP/Services/UserProfile/UserProfileServiceTest.php index 624e308b..14604ed7 100644 --- a/tests/SP/Services/UserProfile/UserProfileServiceTest.php +++ b/tests/SP/Services/UserProfile/UserProfileServiceTest.php @@ -24,7 +24,12 @@ namespace SP\Tests\SP\Services\UserProfile; +use DI\DependencyException; +use DI\NotFoundException; +use SP\Core\Context\ContextException; use SP\Core\Exceptions\ConstraintException; +use SP\Core\Exceptions\QueryException; +use SP\Core\Exceptions\SPException; use SP\DataModel\ItemSearchData; use SP\DataModel\ProfileData; use SP\DataModel\UserProfileData; @@ -34,6 +39,7 @@ use SP\Services\ServiceException; use SP\Services\UserProfile\UserProfileService; use SP\Storage\Database\DatabaseConnectionData; use SP\Tests\DatabaseTestCase; +use stdClass; use function SP\Tests\setupContext; /** @@ -49,10 +55,10 @@ class UserProfileServiceTest extends DatabaseTestCase private static $service; /** - * @throws \DI\NotFoundException - * @throws \SP\Core\Context\ContextException - * @throws \DI\DependencyException - * @throws \SP\Core\Exceptions\SPException + * @throws NotFoundException + * @throws ContextException + * @throws DependencyException + * @throws SPException */ public static function setUpBeforeClass() { @@ -68,8 +74,8 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testSearch() { @@ -82,7 +88,7 @@ class UserProfileServiceTest extends DatabaseTestCase $this->assertEquals(1, $result->getNumRows()); $this->assertCount(1, $data); - $this->assertInstanceOf(\stdClass::class, $data[0]); + $this->assertInstanceOf(stdClass::class, $data[0]); $this->assertEquals(2, $data[0]->id); $this->assertEquals('Demo', $data[0]->name); @@ -96,8 +102,8 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetAllBasic() { @@ -113,8 +119,8 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws ConstraintException + * @throws QueryException */ public function testGetUsersForProfile() { @@ -126,9 +132,9 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdate() { @@ -142,9 +148,9 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdateUnknown() { @@ -158,9 +164,9 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Core\Exceptions\SPException + * @throws ConstraintException + * @throws QueryException + * @throws SPException */ public function testUpdateDuplicated() { @@ -175,8 +181,8 @@ class UserProfileServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatch() { @@ -187,8 +193,8 @@ class UserProfileServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatchUsed() { @@ -201,8 +207,8 @@ class UserProfileServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException - * @throws \SP\Services\ServiceException + * @throws QueryException + * @throws ServiceException */ public function testDeleteByIdBatchUnknown() { @@ -215,7 +221,7 @@ class UserProfileServiceTest extends DatabaseTestCase /** * @throws ConstraintException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException * @throws NoSuchItemException */ public function testGetById() @@ -233,7 +239,7 @@ class UserProfileServiceTest extends DatabaseTestCase /** * @throws ConstraintException * @throws NoSuchItemException - * @throws \SP\Core\Exceptions\QueryException + * @throws QueryException */ public function testDelete() { @@ -247,7 +253,7 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreate() { @@ -271,7 +277,7 @@ class UserProfileServiceTest extends DatabaseTestCase } /** - * @throws \SP\Core\Exceptions\SPException + * @throws SPException */ public function testCreateDuplicated() { diff --git a/tests/SP/Storage/ArchiveHandlerTest.php b/tests/SP/Storage/ArchiveHandlerTest.php index 8597b1c1..1c5ab437 100644 --- a/tests/SP/Storage/ArchiveHandlerTest.php +++ b/tests/SP/Storage/ArchiveHandlerTest.php @@ -25,8 +25,12 @@ namespace SP\Tests\Storage; use PHPUnit\Framework\TestCase; +use RuntimeException; +use SP\Core\Exceptions\CheckException; use SP\Core\PhpExtensionChecker; use SP\Storage\File\ArchiveHandler; +use SP\Storage\File\FileException; +use UnexpectedValueException; /** * Class ArchiveHandlerTest @@ -38,8 +42,8 @@ class ArchiveHandlerTest extends TestCase const ARCHIVE = TMP_PATH . DIRECTORY_SEPARATOR . 'test_archive'; /** - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ public function testCompressFile() { @@ -52,12 +56,12 @@ class ArchiveHandlerTest extends TestCase } /** - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ public function testCompressInvalidFile() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $archive = TMP_PATH . DIRECTORY_SEPARATOR . 'test_archive_file'; @@ -66,8 +70,8 @@ class ArchiveHandlerTest extends TestCase } /** - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ public function testCompressDirectory() { @@ -80,12 +84,12 @@ class ArchiveHandlerTest extends TestCase } /** - * @throws \SP\Core\Exceptions\CheckException - * @throws \SP\Storage\File\FileException + * @throws CheckException + * @throws FileException */ public function testCompressInvalidDirectory() { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); $archive = TMP_PATH . DIRECTORY_SEPARATOR . 'test_archive_dir'; diff --git a/tests/SP/Storage/FileCachePackedTest.php b/tests/SP/Storage/FileCachePackedTest.php index 154fd83d..97a4a6ca 100644 --- a/tests/SP/Storage/FileCachePackedTest.php +++ b/tests/SP/Storage/FileCachePackedTest.php @@ -28,6 +28,7 @@ use Faker\Factory; use PHPUnit\Framework\TestCase; use SP\Storage\File\FileCachePacked; use SP\Storage\File\FileException; +use stdClass; /** * Class FileCachePackedTest @@ -51,11 +52,11 @@ class FileCachePackedTest extends TestCase $faker = Factory::create(); do { - $data = new \stdClass(); + $data = new stdClass(); $data->id = uniqid(); $data->name = $faker->name; $data->values = [1, 2, 3]; - $data->object = new \stdClass(); + $data->object = new stdClass(); $data->object->uid = uniqid(); $data->object->type = $faker->address; $data->object->notes = $faker->text; @@ -67,7 +68,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDeleteInvalid() { @@ -77,7 +78,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testSave() { @@ -88,7 +89,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testLoad() { @@ -99,7 +100,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testIsExpired() { @@ -111,7 +112,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testIsExpiredDate() { @@ -123,7 +124,7 @@ class FileCachePackedTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDelete() { diff --git a/tests/SP/Storage/FileCacheTest.php b/tests/SP/Storage/FileCacheTest.php index 1ca3a940..2c493c82 100644 --- a/tests/SP/Storage/FileCacheTest.php +++ b/tests/SP/Storage/FileCacheTest.php @@ -28,6 +28,7 @@ use Faker\Factory; use PHPUnit\Framework\TestCase; use SP\Storage\File\FileCache; use SP\Storage\File\FileException; +use stdClass; /** * Class FileCacheTest @@ -51,11 +52,11 @@ class FileCacheTest extends TestCase $faker = Factory::create(); do { - $data = new \stdClass(); + $data = new stdClass(); $data->id = uniqid(); $data->name = $faker->name; $data->values = [1, 2, 3]; - $data->object = new \stdClass(); + $data->object = new stdClass(); $data->object->uid = uniqid(); $data->object->type = $faker->address; $data->object->notes = $faker->text; @@ -67,7 +68,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDeleteInvalid() { @@ -77,7 +78,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testSave() { @@ -88,7 +89,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testLoad() { @@ -99,7 +100,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testIsExpired() { @@ -111,7 +112,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testIsExpiredDate() { @@ -123,7 +124,7 @@ class FileCacheTest extends TestCase } /** - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDelete() { diff --git a/tests/SP/Storage/FileHandlerTest.php b/tests/SP/Storage/FileHandlerTest.php index 1e25b899..9eb14219 100644 --- a/tests/SP/Storage/FileHandlerTest.php +++ b/tests/SP/Storage/FileHandlerTest.php @@ -53,7 +53,7 @@ class FileHandlerTest extends TestCase /** * Comprobar la escritura de texto en un archivo * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testWrite() { @@ -74,7 +74,7 @@ class FileHandlerTest extends TestCase */ public function testCheckIsWritable() { - (new \SP\Storage\File\FileHandler(self::$validFile)) + (new FileHandler(self::$validFile)) ->clearCache() ->checkIsWritable(); @@ -84,11 +84,11 @@ class FileHandlerTest extends TestCase /** * Comprobar el tamaño del archivo * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testGetFileSize() { - $size = (new \SP\Storage\File\FileHandler(self::$validFile))->getFileSize(); + $size = (new FileHandler(self::$validFile))->getFileSize(); $this->assertEquals(10, $size); } @@ -101,13 +101,13 @@ class FileHandlerTest extends TestCase */ public function testCheckFileExists() { - (new \SP\Storage\File\FileHandler(self::$validFile)) + (new FileHandler(self::$validFile)) ->clearCache() ->checkFileExists(); - $this->expectException(\SP\Storage\File\FileException::class); + $this->expectException(FileException::class); - (new \SP\Storage\File\FileHandler(self::$missingFile)) + (new FileHandler(self::$missingFile)) ->clearCache() ->checkFileExists(); } @@ -115,11 +115,11 @@ class FileHandlerTest extends TestCase /** * Abrir un archivo * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testOpenAndRead() { - $handler = new \SP\Storage\File\FileHandler(self::$validFile); + $handler = new FileHandler(self::$validFile); $handler->open('rb'); $this->assertEquals('valid_file', $handler->read()); $this->assertEquals('valid_file', $handler->readToString()); @@ -128,7 +128,7 @@ class FileHandlerTest extends TestCase /** * Comprobar a cerrar un archivo * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testClose() { @@ -136,7 +136,7 @@ class FileHandlerTest extends TestCase $handler->open('rb'); $handler->close(); - $this->expectException(\SP\Storage\File\FileException::class); + $this->expectException(FileException::class); $handler->close(); } @@ -144,7 +144,7 @@ class FileHandlerTest extends TestCase * Comprobar si es posible leer el archivo * * @doesNotPerformAssertions - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testCheckIsReadable() { @@ -156,11 +156,11 @@ class FileHandlerTest extends TestCase /** * Comprobar la eliminación de un archivo * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testDelete() { - (new \SP\Storage\File\FileHandler(self::$validFile))->delete(); + (new FileHandler(self::$validFile))->delete(); $this->assertFileNotExists(self::$validFile); } diff --git a/tests/SP/Storage/XmlHandlerTest.php b/tests/SP/Storage/XmlHandlerTest.php index 6d52a041..12737e84 100644 --- a/tests/SP/Storage/XmlHandlerTest.php +++ b/tests/SP/Storage/XmlHandlerTest.php @@ -25,8 +25,11 @@ namespace SP\Tests\Storage; use PHPUnit\Framework\TestCase; +use RuntimeException; use SP\Storage\File\FileException; use SP\Storage\File\FileHandler; +use SP\Storage\File\XmlHandler; +use stdClass; /** * Class XmlHandlerTest @@ -38,7 +41,7 @@ use SP\Storage\File\FileHandler; class XmlHandlerTest extends TestCase { /** - * @var \SP\Storage\File\XmlHandler + * @var XmlHandler */ protected static $xmlHandler; /** @@ -53,9 +56,9 @@ class XmlHandlerTest extends TestCase public static function setUpBeforeClass() { $file = RESOURCE_DIR . DIRECTORY_SEPARATOR . 'config.xml'; - self::$xmlHandler = new \SP\Storage\File\XmlHandler(new FileHandler($file)); + self::$xmlHandler = new XmlHandler(new FileHandler($file)); - self::$itemsData = new \stdClass(); + self::$itemsData = new stdClass(); self::$itemsData->configString = 'Hello world.'; self::$itemsData->configNumber = 1; self::$itemsData->configArray = [1, 2, 3, 4]; @@ -75,11 +78,11 @@ class XmlHandlerTest extends TestCase /** * Test para comprobar la carga de un archivo XML * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testLoadMissingNode() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); self::$xmlHandler->load('root')->getItems(); } @@ -87,7 +90,7 @@ class XmlHandlerTest extends TestCase /** * Test para comprobar la carga de un archivo XML * - * @throws \SP\Storage\File\FileException + * @throws FileException */ public function testLoad() { @@ -110,7 +113,7 @@ class XmlHandlerTest extends TestCase */ public function testSaveNoItems() { - $this->expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); self::$xmlHandler->save(null, 'config'); } diff --git a/tests/SP/Util/PasswordUtilTest.php b/tests/SP/Util/PasswordUtilTest.php index 5a483263..184318f8 100644 --- a/tests/SP/Util/PasswordUtilTest.php +++ b/tests/SP/Util/PasswordUtilTest.php @@ -24,6 +24,7 @@ namespace SP\Tests\Util; +use Defuse\Crypto\Exception\EnvironmentIsBrokenException; use PHPUnit\Framework\TestCase; use SP\Util\PasswordUtil; @@ -118,7 +119,7 @@ class PasswordUtilTest extends TestCase } /** - * @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException + * @throws EnvironmentIsBrokenException */ public function testGenerateRandomBytes() { diff --git a/tests/SP/WebTestCase.php b/tests/SP/WebTestCase.php index 7ecc7394..7ab7adb8 100644 --- a/tests/SP/WebTestCase.php +++ b/tests/SP/WebTestCase.php @@ -26,6 +26,7 @@ namespace SP\Tests; use Goutte\Client; use PHPUnit\Framework\TestCase; +use stdClass; use Symfony\Component\BrowserKit\Response; /** @@ -64,7 +65,7 @@ abstract class WebTestCase extends TestCase * * @param int $httpCode * - * @return \stdClass + * @return stdClass */ protected static function checkAndProcessJsonResponse(Client $client, $httpCode = 200) { diff --git a/tests/SP/bootstrap.php b/tests/SP/bootstrap.php index 512165bc..d6a8e0c7 100644 --- a/tests/SP/bootstrap.php +++ b/tests/SP/bootstrap.php @@ -24,7 +24,10 @@ namespace SP\Tests; +use DI\Container; use DI\ContainerBuilder; +use Exception; +use SP\Core\Context\ContextException; use SP\Core\Context\ContextInterface; use SP\DataModel\ProfileData; use SP\Services\User\UserLoginResponse; @@ -97,9 +100,9 @@ function getRealIpAddress() /** * Configura el contexto de la aplicación para los tests * - * @throws \SP\Core\Context\ContextException - * @return \DI\Container - * @throws \Exception + * @return Container + * @throws ContextException + * @throws Exception */ function setupContext() { diff --git a/tests/res/config/config.xml b/tests/res/config/config.xml index f947cbd8..c55f112f 100644 --- a/tests/res/config/config.xml +++ b/tests/res/config/config.xml @@ -7,14 +7,15 @@ 1 0 + 1 1 - 6e25e727e111c62fb67f71e79416188468cf6e42 + eb725bdc8626e1870679fd4bb25aaf912ee538f5 0 0 - 1548757579 - 56f7423606d1826a78ed319dd580f58e2cd9ca89 + 1555874716 + ed4374e29e7b32af62420fd471c817c0bbc5a395 sysPass @@ -33,7 +34,7 @@ 0 - 555f5a697f06b6760e3e71f409418743c8546781 + f1aece78ba8d79cee3440a216f86cfa838b7770f PDF JPG