diff --git a/rector.php b/rector.php index 95e660b1c..73ca57400 100644 --- a/rector.php +++ b/rector.php @@ -2,14 +2,21 @@ declare(strict_types=1); -use Rector\Config\RectorConfig; +use Rector\TypeDeclaration\Rector\ClassMethod\StrictStringParamConcatRector; use Rector\Set\ValueObject\LevelSetList; +use Rector\Set\ValueObject\SetList; +use Rector\Config\RectorConfig; return RectorConfig::configure() ->withPaths([ __DIR__ . '/src', - __DIR__ . '/tests', ]) ->withSets([ LevelSetList::UP_TO_PHP_80, + SetList::TYPE_DECLARATION, + ]) + ->withSkip([ + StrictStringParamConcatRector::class => [ + __DIR__ . '/src/Database/Adapters/Idiorm/Statements/Criteria.php', + ], ]); diff --git a/src/App/Adapters/AppAdapter.php b/src/App/Adapters/AppAdapter.php index eff84e1ac..ebf5a41de 100644 --- a/src/App/Adapters/AppAdapter.php +++ b/src/App/Adapters/AppAdapter.php @@ -28,9 +28,6 @@ abstract class AppAdapter implements AppInterface { use AppTrait; - /** - * @var string - */ private static string $baseDir; /** diff --git a/src/App/Adapters/ConsoleAppAdapter.php b/src/App/Adapters/ConsoleAppAdapter.php index 1cf0cefd4..a6887d547 100644 --- a/src/App/Adapters/ConsoleAppAdapter.php +++ b/src/App/Adapters/ConsoleAppAdapter.php @@ -38,19 +38,10 @@ class ConsoleAppAdapter extends AppAdapter { use ConsoleAppTrait; - /** - * @var ArgvInput - */ protected ArgvInput $input; - /** - * @var ConsoleOutput - */ protected ConsoleOutput $output; - /** - * @var Application|null - */ protected ?Application $application = null; public function __construct() @@ -69,7 +60,6 @@ public function __construct() } /** - * @return int|null * @throws DiException * @throws EnvException * @throws BaseException diff --git a/src/App/Adapters/WebAppAdapter.php b/src/App/Adapters/WebAppAdapter.php index 8a8555b4d..7959b1ccc 100644 --- a/src/App/Adapters/WebAppAdapter.php +++ b/src/App/Adapters/WebAppAdapter.php @@ -80,7 +80,6 @@ public function __construct() /** * Starts the web app - * @return int|null * @throws BaseException * @throws ConfigException * @throws CsrfException @@ -147,7 +146,7 @@ public function start(): ?int } $dispatcher = new RouteDispatcher(); - $dispatcher->dispatch($matchedRoute, $this->request, $this->response); + $dispatcher->dispatch($matchedRoute, $this->request); stop(); } catch (StopExecutionException $exception) { $this->handleCors($this->response); diff --git a/src/App/App.php b/src/App/App.php index ab1f8f101..16a2f4561 100644 --- a/src/App/App.php +++ b/src/App/App.php @@ -34,51 +34,31 @@ class App */ public const CONSOLE = 'console'; - /** - * @var string - */ - private static $baseDir; + private static ?string $baseDir = null; - /** - * @var AppInterface - */ - private $adapter; + private AppInterface $adapter; - /** - * @param AppInterface $adapter - */ public function __construct(AppInterface $adapter) { $this->adapter = $adapter; } - /** - * @param string $baseDir - */ - public static function setBaseDir(string $baseDir) + public static function setBaseDir(string $baseDir): void { self::$baseDir = $baseDir; } - /** - * @return string - */ public static function getBaseDir(): string { return self::$baseDir; } - /** - * @return AppInterface - */ public function getAdapter(): AppInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/App/Contracts/AppInterface.php b/src/App/Contracts/AppInterface.php index b6bbc82d8..1ae2040e4 100644 --- a/src/App/Contracts/AppInterface.php +++ b/src/App/Contracts/AppInterface.php @@ -22,7 +22,6 @@ interface AppInterface { /** * Starts the app - * @return int|null */ public function start(): ?int; } diff --git a/src/App/Exceptions/AppException.php b/src/App/Exceptions/AppException.php index cae9064f1..edc4a164e 100644 --- a/src/App/Exceptions/AppException.php +++ b/src/App/Exceptions/AppException.php @@ -24,9 +24,6 @@ */ class AppException extends BaseException { - /** - * @return AppException - */ public static function missingAppKey(): self { return new self( diff --git a/src/App/Exceptions/BaseException.php b/src/App/Exceptions/BaseException.php index 03fcab03b..ff55e5ea5 100644 --- a/src/App/Exceptions/BaseException.php +++ b/src/App/Exceptions/BaseException.php @@ -25,18 +25,12 @@ */ abstract class BaseException extends Exception { - /** - * @param string $message - * @param int $code - */ final public function __construct(string $message = '', int $code = 0) { parent::__construct($message, $code); } /** - * @param string $methodName - * @param string $className * @return static */ public static function methodNotSupported(string $methodName, string $className) @@ -48,7 +42,6 @@ public static function methodNotSupported(string $methodName, string $className) } /** - * @param string $name * @return static */ public static function adapterNotSupported(string $name) @@ -60,7 +53,6 @@ public static function adapterNotSupported(string $name) } /** - * @param string $name * @return static */ public static function driverNotSupported(string $name) @@ -72,7 +64,6 @@ public static function driverNotSupported(string $name) } /** - * @param string $name * @return static */ public static function fileNotFound(string $name) @@ -84,8 +75,6 @@ public static function fileNotFound(string $name) } /** - * @param string $subject - * @param string $name * @return static */ public static function notFound(string $subject, string $name) @@ -97,8 +86,6 @@ public static function notFound(string $subject, string $name) } /** - * @param string $instance - * @param string $name * @return static */ public static function notInstanceOf(string $instance, string $name) @@ -110,7 +97,6 @@ public static function notInstanceOf(string $instance, string $name) } /** - * @param string $name * @return static */ public static function cantConnect(string $name) @@ -122,10 +108,8 @@ public static function cantConnect(string $name) } /** - * @param string $name * @return static */ - public static function missingConfig(string $name) { return new static( @@ -135,7 +119,6 @@ public static function missingConfig(string $name) } /** - * @param string $name * @return static */ public static function requestMethodNotAvailable(string $name) diff --git a/src/App/Exceptions/StopExecutionException.php b/src/App/Exceptions/StopExecutionException.php index d50cbe1ba..8512dcc5e 100644 --- a/src/App/Exceptions/StopExecutionException.php +++ b/src/App/Exceptions/StopExecutionException.php @@ -24,10 +24,6 @@ */ class StopExecutionException extends BaseException { - /** - * @param int|null $code - * @return StopExecutionException - */ public static function executionTerminated(?int $code): self { return new self( diff --git a/src/App/Factories/AppFactory.php b/src/App/Factories/AppFactory.php index 4e258d41d..fe030f56b 100644 --- a/src/App/Factories/AppFactory.php +++ b/src/App/Factories/AppFactory.php @@ -34,15 +34,9 @@ class AppFactory App::CONSOLE => ConsoleAppAdapter::class, ]; - /** - * @var array - */ - private static $instances = []; + private static array $instances = []; /** - * @param string $type - * @param string $baseDir - * @return App * @throws BaseException */ public static function create(string $type, string $baseDir): App @@ -55,19 +49,12 @@ public static function create(string $type, string $baseDir): App return self::$instances[$type]; } - /** - * @param string $type - * @return void - */ - public static function destroy(string $type) + public static function destroy(string $type): void { unset(self::$instances[$type]); } /** - * @param string $type - * @param string $baseDir - * @return App * @throws BaseException */ private static function createInstance(string $type, string $baseDir): App diff --git a/src/App/Helpers/app.php b/src/App/Helpers/app.php index 8ec9e2e0d..e140c56d4 100644 --- a/src/App/Helpers/app.php +++ b/src/App/Helpers/app.php @@ -16,14 +16,12 @@ /** * Stops the app execution - * @param Closure|null $closure - * @param int|null $code * @return never * @throws StopExecutionException */ -function stop(?Closure $closure = null, ?int $code = 0) +function stop(?Closure $closure = null, ?int $code = 0): void { - if ($closure instanceof \Closure) { + if ($closure instanceof Closure) { $closure(); } diff --git a/src/App/Helpers/dir.php b/src/App/Helpers/dir.php index 47ff42250..7051ab379 100644 --- a/src/App/Helpers/dir.php +++ b/src/App/Helpers/dir.php @@ -16,7 +16,6 @@ /** * Gets base directory - * @return string */ function base_dir(): string { @@ -25,7 +24,6 @@ function base_dir(): string /** * Gets the log directory - * @return string */ function logs_dir(): string { @@ -34,7 +32,6 @@ function logs_dir(): string /** * Gets the framework directory - * @return string */ function framework_dir(): string { @@ -43,8 +40,6 @@ function framework_dir(): string /** * Gets modules directory - * @param string|null $moduleDir - * @return string */ function modules_dir(?string $moduleDir = null): string { @@ -53,7 +48,6 @@ function modules_dir(?string $moduleDir = null): string /** * Gets public directory - * @return string */ function public_dir(): string { @@ -62,7 +56,6 @@ function public_dir(): string /** * Gets uploads directory - * @return string */ function uploads_dir(): string { @@ -71,7 +64,6 @@ function uploads_dir(): string /** * Gets assets directory - * @return string */ function assets_dir(): string { @@ -80,7 +72,6 @@ function assets_dir(): string /** * Gets hooks directory - * @return string */ function hooks_dir(): string { @@ -89,8 +80,6 @@ function hooks_dir(): string /** * Recursively deletes folder - * @param string $dir - * @return bool */ function deleteDirectoryWithFiles(string $dir): bool { @@ -110,8 +99,6 @@ function deleteDirectoryWithFiles(string $dir): bool /** * Gets directory classes - * @param string $path - * @return array */ function get_directory_classes(string $path): array { diff --git a/src/App/Helpers/misc.php b/src/App/Helpers/misc.php index a008e3b3e..7e59f9e42 100644 --- a/src/App/Helpers/misc.php +++ b/src/App/Helpers/misc.php @@ -17,9 +17,7 @@ /** * Compose a message - * @param string $subject * @param string|array $params - * @return string */ function _message(string $subject, $params): string { @@ -34,8 +32,6 @@ function _message(string $subject, $params): string /** * Validates base64 string - * @param string $string - * @return boolean */ function valid_base64(string $string): bool { @@ -50,8 +46,6 @@ function valid_base64(string $string): bool /** * Generates random number sequence - * @param int $length - * @return int */ function random_number(int $length = 10): int { @@ -64,8 +58,6 @@ function random_number(int $length = 10): int /** * Slugify the string - * @param string $text - * @return string */ function slugify(string $text): string { @@ -84,7 +76,6 @@ function slugify(string $text): string /** * Checks the app debug mode - * @return bool */ function is_debug_mode(): bool { @@ -93,8 +84,6 @@ function is_debug_mode(): bool /** * Gets the caller class - * @param integer $index - * @return string|null */ function get_caller_class(int $index = 2): ?string { @@ -106,8 +95,6 @@ function get_caller_class(int $index = 2): ?string /** * Gets the caller function - * @param integer $index - * @return string|null */ function get_caller_function(int $index = 2): ?string { @@ -123,7 +110,6 @@ function get_caller_function(int $index = 2): ?string /** * Exports the variable * @param $var - * @return string * @throws ExceptionInterface */ function export($var): string diff --git a/src/App/Helpers/uuid.php b/src/App/Helpers/uuid.php index d12b509b3..05b9ca049 100644 --- a/src/App/Helpers/uuid.php +++ b/src/App/Helpers/uuid.php @@ -16,7 +16,6 @@ /** * Generate a standard v4 UUID (random) - * @return string */ function uuid_random(): string { @@ -25,7 +24,6 @@ function uuid_random(): string /** * Generate an ordered UUID (time-based) - * @return string */ function uuid_ordered(): string { diff --git a/src/App/Traits/AppTrait.php b/src/App/Traits/AppTrait.php index 8642ddf33..6ff9dedd0 100644 --- a/src/App/Traits/AppTrait.php +++ b/src/App/Traits/AppTrait.php @@ -36,16 +36,14 @@ trait AppTrait { /** * Sets the app base directory - * @param string $baseDir */ - public static function setBaseDir(string $baseDir) + public static function setBaseDir(string $baseDir): void { self::$baseDir = $baseDir; } /** * Gets the app base directory - * @return string */ public static function getBaseDir(): string { diff --git a/src/App/Traits/ConsoleAppTrait.php b/src/App/Traits/ConsoleAppTrait.php index 7c4c7b496..733906004 100644 --- a/src/App/Traits/ConsoleAppTrait.php +++ b/src/App/Traits/ConsoleAppTrait.php @@ -43,21 +43,15 @@ protected function loadEnvironment() ->load(new Setup('config', 'env')); } - /** - * @param string $name - * @param string $version - * @return Application - */ public function createApplication(string $name, string $version): Application { return new Application($name, $version); } /** - * @return void * @throws ReflectionException */ - private function registerCoreCommands() + private function registerCoreCommands(): void { $directory = framework_dir() . DS . 'Console' . DS . 'Commands'; $namespace = '\\Quantum\\Console\\Commands\\'; @@ -66,10 +60,9 @@ private function registerCoreCommands() } /** - * @return void * @throws ReflectionException */ - private function registerAppCommands() + private function registerAppCommands(): void { $directory = base_dir() . DS . 'shared' . DS . 'Commands'; $namespace = '\\Shared\\Commands\\'; @@ -78,11 +71,9 @@ private function registerAppCommands() } /** - * @param string $directory - * @param string $namespace * @throws ReflectionException */ - private function registerCommands(string $directory, string $namespace) + private function registerCommands(string $directory, string $namespace): void { $commands = CommandDiscovery::discover($directory, $namespace); diff --git a/src/App/Traits/WebAppTrait.php b/src/App/Traits/WebAppTrait.php index 7362527ce..8173c0307 100644 --- a/src/App/Traits/WebAppTrait.php +++ b/src/App/Traits/WebAppTrait.php @@ -16,6 +16,7 @@ use Quantum\Environment\Exceptions\EnvException; use Quantum\Config\Exceptions\ConfigException; +use Quantum\Loader\Exceptions\LoaderException; use Quantum\Http\Exceptions\HttpException; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; @@ -47,14 +48,12 @@ protected function loadEnvironment() } /** - * @param Request $request - * @param Response $response * @throws BaseException * @throws DiException * @throws ReflectionException * @throws HttpException */ - private function initializeRequestResponse(Request $request, Response $response) + private function initializeRequestResponse(Request $request, Response $response): void { $request->init(Server::getInstance()); $response->init(); @@ -63,17 +62,16 @@ private function initializeRequestResponse(Request $request, Response $response) /** * @throws DebugBarException */ - private function initializeDebugger() + private function initializeDebugger(): void { $debugger = Debugger::getInstance(); $debugger->initStore(); } /** - * @return ViewCache * @throws ConfigException * @throws DiException - * @throws ReflectionException + * @throws ReflectionException|LoaderException */ private function setupViewCache(): ViewCache { @@ -87,12 +85,11 @@ private function setupViewCache(): ViewCache } /** - * @param Response $response * @throws ConfigException * @throws DiException * @throws ReflectionException */ - private function handleCors(Response $response) + private function handleCors(Response $response): void { if (!config()->has('cors')) { config()->import(new Setup('config', 'cors')); diff --git a/src/Archive/Adapters/PharAdapter.php b/src/Archive/Adapters/PharAdapter.php index 7f14f7388..81bf5a722 100644 --- a/src/Archive/Adapters/PharAdapter.php +++ b/src/Archive/Adapters/PharAdapter.php @@ -19,6 +19,7 @@ use Quantum\Archive\Contracts\ArchiveInterface; use Quantum\App\Exceptions\BaseException; use Quantum\Storage\FileSystem; +use ReflectionException; use Exception; use Phar; @@ -28,28 +29,16 @@ */ class PharAdapter implements ArchiveInterface { - /** - * @var FileSystem - */ - private $fs; + private FileSystem $fs; - /** - * @var string - */ - private $archiveName; + private ?string $archiveName = null; - /** - * @var Phar|null - */ - private $archive = null; + private ?\Phar $archive = null; - /** - * @var bool - */ - private $requiresReopen = true; + private bool $requiresReopen = true; /** - * @throws BaseException + * @throws BaseException|ReflectionException */ public function __construct() { @@ -62,7 +51,6 @@ public function setName(string $archiveName): void } /** - * @return bool * @throws ArchiveException */ public function removeArchive(): bool diff --git a/src/Archive/Adapters/ZipAdapter.php b/src/Archive/Adapters/ZipAdapter.php index 5cad5a6e1..ba5379496 100644 --- a/src/Archive/Adapters/ZipAdapter.php +++ b/src/Archive/Adapters/ZipAdapter.php @@ -17,8 +17,9 @@ use Quantum\Archive\Exceptions\ArchiveException; use Quantum\Storage\Factories\FileSystemFactory; use Quantum\Archive\Contracts\ArchiveInterface; -use Quantum\Storage\FileSystem; use Quantum\App\Exceptions\BaseException; +use Quantum\Storage\FileSystem; +use ReflectionException; use ZipArchive; use Exception; @@ -28,38 +29,23 @@ */ class ZipAdapter implements ArchiveInterface { - /** - * @var FileSystem - */ - private $fs; + private FileSystem $fs; - /** - * @var string - */ - private $archiveName; + private ?string $archiveName = null; - /** - * @var ZipArchive - */ - private $archive = null; + private ?ZipArchive $archive = null; - /** - * @var bool - */ - private $requiresReopen = true; + private bool $requiresReopen = true; /** - * @throws BaseException + * @throws BaseException|ReflectionException */ public function __construct() { $this->fs = FileSystemFactory::get(); } - /** - * @param string $archiveName - */ - public function setName(string $archiveName) + public function setName(string $archiveName): void { $this->archiveName = $archiveName; } @@ -215,7 +201,7 @@ private function ensureArchiveOpen(): void /** * @throws ArchiveException */ - private function openArchive() + private function openArchive(): void { if (empty($this->archiveName)) { throw ArchiveException::missingArchiveName(); diff --git a/src/Archive/Archive.php b/src/Archive/Archive.php index 5a461db90..0e6b0ff1b 100644 --- a/src/Archive/Archive.php +++ b/src/Archive/Archive.php @@ -44,30 +44,19 @@ class Archive */ public const ZIP = 'zip'; - /** - * @var ArchiveInterface - */ - private $adapter; + private ArchiveInterface $adapter; - /** - * @param ArchiveInterface $adapter - */ public function __construct(ArchiveInterface $adapter) { $this->adapter = $adapter; } - /** - * @return ArchiveInterface - */ public function getAdapter(): ArchiveInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Archive/Contracts/ArchiveInterface.php b/src/Archive/Contracts/ArchiveInterface.php index 874129b08..c9bbec28f 100644 --- a/src/Archive/Contracts/ArchiveInterface.php +++ b/src/Archive/Contracts/ArchiveInterface.php @@ -22,66 +22,47 @@ interface ArchiveInterface { /** * Checks for the existence of a file - * @param string $filename - * @return bool */ public function offsetExists(string $filename): bool; /** * Makes a new empty directory - * @param string $directory - * @return bool */ public function addEmptyDir(string $directory): bool; /** * Adds new file to the archive - * @param string $filePath - * @param string $entryName - * @return bool */ public function addFile(string $filePath, string $entryName): bool; /** * Adds new file to the archive from string - * @param string $entryName - * @param string $content - * @return bool */ public function addFromString(string $entryName, string $content): bool; /** * Adds multiple files to the archive - * @param array $fileNames - * @return bool */ public function addMultipleFiles(array $fileNames): bool; /** * Files count in the archive - * @return int */ public function count(): int; /** * Extracts the archive - * @param string $pathToExtract * @param string|array $files - * @return bool */ public function extractTo(string $pathToExtract, $files = null): bool; /** * Delete the file from the archive - * @param string $filename - * @return bool */ public function deleteFile(string $filename): bool; /** * Delete a multiple files - * @param array $fileNames - * @return bool */ public function deleteMultipleFiles(array $fileNames): bool; } diff --git a/src/Archive/Exceptions/ArchiveException.php b/src/Archive/Exceptions/ArchiveException.php index 5d40aaa2b..8fed68430 100644 --- a/src/Archive/Exceptions/ArchiveException.php +++ b/src/Archive/Exceptions/ArchiveException.php @@ -25,10 +25,6 @@ */ class ArchiveException extends BaseException { - /** - * @param string $name - * @return ArchiveException - */ public static function cantOpen(string $name): self { return new self( @@ -37,9 +33,6 @@ public static function cantOpen(string $name): self ); } - /** - * @return ArchiveException - */ public static function missingArchiveName(): self { return new self( diff --git a/src/Archive/Factories/ArchiveFactory.php b/src/Archive/Factories/ArchiveFactory.php index 73668eb5f..629734ee3 100644 --- a/src/Archive/Factories/ArchiveFactory.php +++ b/src/Archive/Factories/ArchiveFactory.php @@ -16,8 +16,8 @@ use Quantum\Archive\Exceptions\ArchiveException; use Quantum\Archive\Adapters\PharAdapter; -use Quantum\Archive\Adapters\ZipAdapter; use Quantum\App\Exceptions\BaseException; +use Quantum\Archive\Adapters\ZipAdapter; use Quantum\Archive\Archive; /** @@ -34,14 +34,9 @@ class ArchiveFactory Archive::ZIP => ZipAdapter::class, ]; - /** - * @var array - */ - private static $instances = []; + private static array $instances = []; /** - * @param string $type - * @return Archive * @throws BaseException */ public static function get(string $type = Archive::PHAR): Archive @@ -54,8 +49,6 @@ public static function get(string $type = Archive::PHAR): Archive } /** - * @param string $type - * @return Archive * @throws BaseException */ private static function createInstance(string $type): Archive diff --git a/src/Asset/Asset.php b/src/Asset/Asset.php index 6e8bfe85f..ec227cd5b 100644 --- a/src/Asset/Asset.php +++ b/src/Asset/Asset.php @@ -10,7 +10,6 @@ * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ * @since 3.0.0 - * */ namespace Quantum\Asset; @@ -31,47 +30,27 @@ class Asset */ public const JS = 2; - /** - * @var int - */ - private $type; + private int $type; - /** - * @var string - */ - private $path; + private string $path; - /** - * @var string|null - */ - private $name; + private ?string $name; - /** - * @var array|null - */ - private $attributes = []; + private ?array $attributes; - /** - * @var int - */ - private $position; + private ?int $position; /** * Asset templates * @var string[] */ - private $templates = [ + private array $templates = [ self::CSS => '', self::JS => '', ]; /** * Asset constructor - * @param int $type - * @param string $path - * @param string|null $name - * @param int|null $position - * @param array|null $attributes */ public function __construct(int $type, string $path, ?string $name = null, ?int $position = -1, ?array $attributes = []) { @@ -84,7 +63,6 @@ public function __construct(int $type, string $path, ?string $name = null, ?int /** * Gets asset type - * @return int */ public function getType(): int { @@ -93,7 +71,6 @@ public function getType(): int /** * Gets asset path - * @return string */ public function getPath(): string { @@ -102,7 +79,6 @@ public function getPath(): string /** * Gets asset name - * @return string|null */ public function getName(): ?string { @@ -111,7 +87,6 @@ public function getName(): ?string /** * Gets asset position - * @return int|null */ public function getPosition(): ?int { @@ -120,7 +95,6 @@ public function getPosition(): ?int /** * Gets asset attributes - * @return array */ public function getAttributes(): array { @@ -129,7 +103,6 @@ public function getAttributes(): array /** * Gets asset url - * @return string */ public function url(): string { @@ -142,7 +115,6 @@ public function url(): string /** * Renders asset tag - * @return string */ public function tag(): string { diff --git a/src/Asset/AssetManager.php b/src/Asset/AssetManager.php index 7ccb79fa2..da4149655 100644 --- a/src/Asset/AssetManager.php +++ b/src/Asset/AssetManager.php @@ -32,22 +32,21 @@ class AssetManager ]; /** - * Asset store + * Asset store * @var Asset[] */ - private $store = []; + private array $store = []; /** * Published assets * @var array[] */ - private $published = []; + private array $published = []; /** * Asset instance - * @var AssetManager|null */ - private static $instance = null; + private static ?AssetManager $instance = null; private function __construct() { @@ -58,7 +57,6 @@ private function __construct() /** * AssetManager instance - * @return AssetManager */ public static function getInstance(): AssetManager { @@ -71,8 +69,6 @@ public static function getInstance(): AssetManager /** * Gets the asset by name - * @param string $name - * @return Asset|null */ public function get(string $name): ?Asset { @@ -87,8 +83,6 @@ public function get(string $name): ?Asset /** * Asset url - * @param string $path - * @return string */ public function url(string $path): string { @@ -104,7 +98,7 @@ public function url(string $path): string * @param Asset[] $assets * @throws AssetException */ - public function register(array $assets) + public function register(array $assets): void { foreach ($assets as $asset) { $this->registerAsset($asset); @@ -113,10 +107,9 @@ public function register(array $assets) /** * Register single asset - * @param Asset $asset * @throws AssetException */ - public function registerAsset(Asset $asset) + public function registerAsset(Asset $asset): void { if ($asset->getName() && $this->get($asset->getName())) { throw AssetException::nameInUse($asset->getName()); @@ -125,10 +118,7 @@ public function registerAsset(Asset $asset) $this->store[] = $asset; } - /** - * @return void - */ - public function flush() + public function flush(): void { $this->store = []; $this->published = []; @@ -136,7 +126,6 @@ public function flush() /** * Dumps the assets - * @param int $type * @throws AssetException * @throws LangException */ @@ -157,7 +146,7 @@ public function dump(int $type): void * Publishes assets * @throws AssetException */ - private function publish() + private function publish(): void { if ($this->store !== []) { $this->setPriorityAssets(); @@ -172,7 +161,7 @@ private function publish() * Sets assets with ordered position * @throws AssetException */ - private function setPriorityAssets() + private function setPriorityAssets(): void { foreach ($this->store as $asset) { $position = $asset->getPosition(); @@ -191,7 +180,7 @@ private function setPriorityAssets() /** * Sets assets without ordered position */ - private function setRegularAssets() + private function setRegularAssets(): void { foreach ($this->store as $asset) { if ($asset->getPosition() == -1) { @@ -202,10 +191,8 @@ private function setRegularAssets() /** * Sets the Position - * @param Asset $asset - * @param int $index */ - private function setPosition(Asset $asset, int $index) + private function setPosition(Asset $asset, int $index): void { $type = $asset->getType(); diff --git a/src/Asset/Exceptions/AssetException.php b/src/Asset/Exceptions/AssetException.php index 394216080..6321078b0 100644 --- a/src/Asset/Exceptions/AssetException.php +++ b/src/Asset/Exceptions/AssetException.php @@ -24,11 +24,6 @@ */ class AssetException extends \Exception { - /** - * @param int $position - * @param string $name - * @return AssetException - */ public static function positionInUse(int $position, string $name): AssetException { return new self( @@ -37,10 +32,6 @@ public static function positionInUse(int $position, string $name): AssetExceptio ); } - /** - * @param string|null $name - * @return AssetException - */ public static function nameInUse(?string $name): AssetException { return new self( diff --git a/src/Asset/Helpers/asset.php b/src/Asset/Helpers/asset.php index 6c5429930..659d02732 100644 --- a/src/Asset/Helpers/asset.php +++ b/src/Asset/Helpers/asset.php @@ -18,7 +18,6 @@ /** * Gets the AssetFactory instance - * @return AssetManager */ function asset(): AssetManager { @@ -27,8 +26,6 @@ function asset(): AssetManager /** * Dumps the assets - * @param string $type - * @return void * @throws AssetException * @throws LangException */ diff --git a/src/Auth/Adapters/JwtAuthAdapter.php b/src/Auth/Adapters/JwtAuthAdapter.php index 44e3bd68d..d13433edb 100644 --- a/src/Auth/Adapters/JwtAuthAdapter.php +++ b/src/Auth/Adapters/JwtAuthAdapter.php @@ -37,10 +37,6 @@ class JwtAuthAdapter implements AuthenticatableInterface use AuthTrait; /** - * @param AuthServiceInterface $authService - * @param Mailer $mailer - * @param Hasher $hasher - * @param JwtToken|null $jwt * @throws AuthException */ public function __construct(AuthServiceInterface $authService, Mailer $mailer, Hasher $hasher, ?JwtToken $jwt = null) @@ -111,8 +107,6 @@ public function user(): ?User /** * Refresh user data - * @param string $uuid - * @return bool * @throws JwtException */ public function refreshUser(string $uuid): bool @@ -130,9 +124,6 @@ public function refreshUser(string $uuid): bool /** * Verify OTP - * @param int $otp - * @param string $otpToken - * @return array * @throws AuthException * @throws JwtException */ @@ -144,8 +135,6 @@ public function verifyOtp(int $otp, string $otpToken): array /** * Get Updated Tokens - * @param User $user - * @return array * @throws JwtException */ protected function getUpdatedTokens(User $user): array @@ -158,8 +147,6 @@ protected function getUpdatedTokens(User $user): array /** * Set Updated Tokens - * @param User $user - * @return array * @throws JwtException */ protected function setUpdatedTokens(User $user): array @@ -181,7 +168,6 @@ protected function setUpdatedTokens(User $user): array /** * Check Refresh Token - * @return User|null */ protected function checkRefreshToken(): ?User { @@ -191,9 +177,6 @@ protected function checkRefreshToken(): ?User ); } - /** - * @return User|null - */ private function getUserFromAccessToken(): ?User { $authorizationBearer = Request::getAuthorizationBearer(); @@ -210,7 +193,6 @@ private function getUserFromAccessToken(): ?User } /** - * @return User|null * @throws JwtException */ private function getUserFromRefreshToken(): ?User diff --git a/src/Auth/Adapters/SessionAuthAdapter.php b/src/Auth/Adapters/SessionAuthAdapter.php index 49ea54953..0a06b9568 100644 --- a/src/Auth/Adapters/SessionAuthAdapter.php +++ b/src/Auth/Adapters/SessionAuthAdapter.php @@ -39,9 +39,6 @@ class SessionAuthAdapter implements AuthenticatableInterface use AuthTrait; /** - * @param AuthServiceInterface $authService - * @param Mailer $mailer - * @param Hasher $hasher * @throws AuthException */ public function __construct(AuthServiceInterface $authService, Mailer $mailer, Hasher $hasher) @@ -128,8 +125,6 @@ public function user(): ?User /** * Refresh user data - * @param string $uuid - * @return bool * @throws BaseException * @throws ConfigException * @throws DiException @@ -153,9 +148,6 @@ public function refreshUser(string $uuid): bool /** * Verify OTP - * @param int $otp - * @param string $otpToken - * @return bool * @throws AuthException * @throws BaseException * @throws ConfigException @@ -195,9 +187,9 @@ private function checkRememberToken() /** * Set Remember Token - * @param User $user + * @throws BaseException */ - private function setRememberToken(User $user) + private function setRememberToken(User $user): void { $rememberToken = $this->generateToken(); @@ -213,7 +205,7 @@ private function setRememberToken(User $user) /** * Remove Remember token */ - private function removeRememberToken() + private function removeRememberToken(): void { if (cookie()->has($this->keyFields[AuthKeys::REMEMBER_TOKEN])) { $user = $this->authService->get( diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php index a481c4c88..fc70fa710 100644 --- a/src/Auth/Auth.php +++ b/src/Auth/Auth.php @@ -38,30 +38,19 @@ class Auth */ public const JWT = 'jwt'; - /** - * @var AuthenticatableInterface - */ - private $adapter; + private AuthenticatableInterface $adapter; - /** - * @param AuthenticatableInterface $adapter - */ public function __construct(AuthenticatableInterface $adapter) { $this->adapter = $adapter; } - /** - * @return AuthenticatableInterface - */ public function getAdapter(): AuthenticatableInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Auth/Contracts/AuthServiceInterface.php b/src/Auth/Contracts/AuthServiceInterface.php index 09c45f45d..a25f0c256 100644 --- a/src/Auth/Contracts/AuthServiceInterface.php +++ b/src/Auth/Contracts/AuthServiceInterface.php @@ -24,31 +24,21 @@ interface AuthServiceInterface { /** * Get - * @param string $field - * @param string|null $value - * @return User|null */ public function get(string $field, ?string $value): ?User; /** - * Add - * @param array $data - * @return User - */ + * Add + */ public function add(array $data): User; /** * Update - * @param string $field - * @param string|null $value - * @param array $data - * @return User|null */ public function update(string $field, ?string $value, array $data): ?User; /** * User Schema - * @return array */ public function userSchema(): array; } diff --git a/src/Auth/Contracts/AuthenticatableInterface.php b/src/Auth/Contracts/AuthenticatableInterface.php index faf37aba8..f54a62326 100644 --- a/src/Auth/Contracts/AuthenticatableInterface.php +++ b/src/Auth/Contracts/AuthenticatableInterface.php @@ -29,27 +29,22 @@ interface AuthenticatableInterface /** * Sign In - * @param string $username - * @param string $password * @return mixed */ public function signin(string $username, string $password); /** * Sign Out - * @return bool */ public function signout(): bool; /** * Check - * @return bool */ public function check(): bool; /** * User - * @return User|null */ public function user(): ?User; } diff --git a/src/Auth/Exceptions/AuthException.php b/src/Auth/Exceptions/AuthException.php index d668dd90b..f47d451d5 100644 --- a/src/Auth/Exceptions/AuthException.php +++ b/src/Auth/Exceptions/AuthException.php @@ -25,9 +25,6 @@ */ class AuthException extends BaseException { - /** - * @return AuthException - */ public static function incorrectCredentials(): self { return new self( @@ -36,9 +33,6 @@ public static function incorrectCredentials(): self ); } - /** - * @return AuthException - */ public static function inactiveAccount(): self { return new self( @@ -47,9 +41,6 @@ public static function inactiveAccount(): self ); } - /** - * @return AuthException - */ public static function incorrectVerificationCode(): self { return new self( @@ -58,9 +49,6 @@ public static function incorrectVerificationCode(): self ); } - /** - * @return AuthException - */ public static function verificationCodeExpired(): self { return new self( @@ -69,9 +57,6 @@ public static function verificationCodeExpired(): self ); } - /** - * @return AuthException - */ public static function incorrectUserSchema(): self { return new self( diff --git a/src/Auth/Factories/AuthFactory.php b/src/Auth/Factories/AuthFactory.php index d34582704..8408553fb 100644 --- a/src/Auth/Factories/AuthFactory.php +++ b/src/Auth/Factories/AuthFactory.php @@ -46,11 +46,9 @@ class AuthFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Auth * @throws AuthException * @throws BaseException * @throws ConfigException @@ -76,9 +74,6 @@ public static function get(?string $adapter = null): Auth } /** - * @param string $adapterClass - * @param string $adapter - * @return Auth * @throws AuthException * @throws BaseException * @throws ConfigException @@ -97,8 +92,6 @@ private static function createInstance(string $adapterClass, string $adapter): A } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string @@ -111,8 +104,6 @@ private static function getAdapterClass(string $adapter): string } /** - * @param string $adapter - * @return AuthServiceInterface * @throws BaseException * @throws DiException * @throws ReflectionException @@ -131,10 +122,6 @@ private static function createAuthService(string $adapter): AuthServiceInterface return $authService; } - /** - * @param string $adapter - * @return JwtToken|null - */ private static function createJwtInstance(string $adapter): ?JwtToken { return $adapter === Auth::JWT ? (new JwtToken())->setLeeway(1)->setClaims((array) config()->get('auth.claims')) : null; diff --git a/src/Auth/Helpers/auth.php b/src/Auth/Helpers/auth.php index 1f869fe4c..e4f1e7bd5 100644 --- a/src/Auth/Helpers/auth.php +++ b/src/Auth/Helpers/auth.php @@ -22,8 +22,6 @@ /** * Gets the Auth handler - * @param string|null $adapter - * @return Auth * @throws AuthException * @throws BaseException * @throws ConfigException diff --git a/src/Auth/Traits/AuthTrait.php b/src/Auth/Traits/AuthTrait.php index 94be7a394..97ba89564 100644 --- a/src/Auth/Traits/AuthTrait.php +++ b/src/Auth/Traits/AuthTrait.php @@ -87,9 +87,6 @@ public function check(): bool /** * Sign Up - * @param array $userData - * @param array|null $customData - * @return User */ public function signup(array $userData, ?array $customData = null): User { @@ -119,9 +116,8 @@ public function signup(array $userData, ?array $customData = null): User /** * Activate - * @param string $token */ - public function activate(string $token) + public function activate(string $token): void { $this->authService->update( $this->keyFields[AuthKeys::ACTIVATION_TOKEN], @@ -132,8 +128,6 @@ public function activate(string $token) /** * Forget - * @param string $username - * @return string|null */ public function forget(string $username): ?string { @@ -166,10 +160,8 @@ public function forget(string $username): ?string /** * Reset - * @param string $token - * @param string $password */ - public function reset(string $token, string $password) + public function reset(string $token, string $password): void { $user = $this->authService->get($this->keyFields[AuthKeys::RESET_TOKEN], $token); @@ -191,8 +183,6 @@ public function reset(string $token, string $password) /** * Resend OTP - * @param string $otpToken - * @return string * @throws AuthException * @throws Exception */ @@ -210,9 +200,6 @@ public function resendOtp(string $otpToken): string /** * Gets the user by username and password - * @param string $username - * @param string $password - * @return User * @throws AuthException */ protected function getUser(string $username, string $password): User @@ -236,8 +223,6 @@ protected function getUser(string $username, string $password): User /** * Two-Step Verification - * @param User $user - * @return string * @throws Exception */ protected function twoStepVerification(User $user): string @@ -275,9 +260,6 @@ protected function twoStepVerification(User $user): string /** * Verify and update OTP - * @param int $otp - * @param string $otpToken - * @return User * @throws AuthException * @throws Exception */ @@ -308,8 +290,6 @@ protected function verifyAndUpdateOtp(int $otp, string $otpToken): User /** * Filters and gets the visible fields - * @param User $user - * @return array */ protected function getVisibleFields(User $user): array { @@ -328,8 +308,6 @@ protected function getVisibleFields(User $user): array /** * Is user account activated - * @param User $user - * @return bool */ protected function isActivated(User $user): bool { @@ -338,8 +316,6 @@ protected function isActivated(User $user): bool /** * Generate Token - * @param string|null $val - * @return string */ protected function generateToken(?string $val = null): string { @@ -348,8 +324,6 @@ protected function generateToken(?string $val = null): string /** * Send email - * @param User $user - * @param array $body */ protected function sendMail(User $user, array $body) { @@ -366,7 +340,6 @@ protected function sendMail(User $user, array $body) /** * Verify user schema - * @param array $schema * @throws AuthException */ protected function verifySchema(array $schema) @@ -388,9 +361,6 @@ protected function verifySchema(array $schema) } } - /** - * @return bool - */ protected function isTwoFactorEnabled(): bool { return filter_var(config()->get('auth.two_fa'), FILTER_VALIDATE_BOOLEAN); diff --git a/src/Auth/User.php b/src/Auth/User.php index cc7d38397..fad45a7c4 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -20,14 +20,10 @@ */ class User { - /** - * @var array - */ - private $data = []; + private array $data = []; /** * Set Data - * @param array $data * @return $this */ public function setData(array $data): self @@ -38,7 +34,6 @@ public function setData(array $data): self /** * Get Data - * @return array */ public function getData(): array { @@ -47,7 +42,6 @@ public function getData(): array /** * Get Fields - * @return array */ public function getFields(): array { @@ -56,7 +50,6 @@ public function getFields(): array /** * Set Fields - * @param array $schema * @return $this */ public function setFields(array $schema): self @@ -72,8 +65,6 @@ public function setFields(array $schema): self /** * Get Field Value - * @param string $field - * @return string|null */ public function getFieldValue(string $field): ?string { @@ -82,8 +73,6 @@ public function getFieldValue(string $field): ?string /** * Set Fields Value - * @param string $field - * @param string|null $value * @return $this */ public function setFieldValue(string $field, ?string $value): self @@ -94,8 +83,6 @@ public function setFieldValue(string $field, ?string $value): self /** * Has Field - * @param string $field - * @return bool */ public function hasField(string $field): bool { @@ -104,7 +91,6 @@ public function hasField(string $field): bool /** * Gets the user property - * @param string $property * @return string|null */ public function __get(string $property) diff --git a/src/Cache/Adapters/DatabaseAdapter.php b/src/Cache/Adapters/DatabaseAdapter.php index ea5997934..62d45d4b8 100644 --- a/src/Cache/Adapters/DatabaseAdapter.php +++ b/src/Cache/Adapters/DatabaseAdapter.php @@ -37,14 +37,8 @@ class DatabaseAdapter implements CacheInterface */ private $prefix; - /** - * @var DbModel - */ private DbModel $cacheModel; - /** - * @param array $params - */ public function __construct(array $params) { $this->ttl = $params['ttl']; @@ -189,8 +183,6 @@ public function clear(): bool /** * Gets the hashed key - * @param string $key - * @return string */ private function keyHash(string $key): string { diff --git a/src/Cache/Adapters/FileAdapter.php b/src/Cache/Adapters/FileAdapter.php index 614c1ca7d..d874162e3 100644 --- a/src/Cache/Adapters/FileAdapter.php +++ b/src/Cache/Adapters/FileAdapter.php @@ -30,10 +30,7 @@ */ class FileAdapter implements CacheInterface { - /** - * @var FileSystem - */ - private $fs; + private FileSystem $fs; /** * @var int @@ -51,7 +48,6 @@ class FileAdapter implements CacheInterface private $cacheDir; /** - * @param array $params * @throws BaseException * @throws ConfigException * @throws DiException @@ -210,8 +206,6 @@ public function clear(): bool /** * Gets the path for given cache key - * @param string $key - * @return string */ private function getPath(string $key): string { diff --git a/src/Cache/Adapters/MemcachedAdapter.php b/src/Cache/Adapters/MemcachedAdapter.php index fd4f2dcc9..96f2603aa 100644 --- a/src/Cache/Adapters/MemcachedAdapter.php +++ b/src/Cache/Adapters/MemcachedAdapter.php @@ -38,13 +38,9 @@ class MemcachedAdapter implements CacheInterface */ private $prefix; - /** - * @var Memcached - */ - private $memcached; + private Memcached $memcached; /** - * @param array $params * @throws BaseException */ public function __construct(array $params) @@ -171,8 +167,6 @@ public function clear(): bool /** * Gets the hashed key - * @param string $key - * @return string */ private function keyHash(string $key): string { diff --git a/src/Cache/Adapters/RedisAdapter.php b/src/Cache/Adapters/RedisAdapter.php index d77c329ea..dea031a04 100644 --- a/src/Cache/Adapters/RedisAdapter.php +++ b/src/Cache/Adapters/RedisAdapter.php @@ -37,13 +37,9 @@ class RedisAdapter implements CacheInterface */ private $prefix; - /** - * @var Redis - */ - private $redis; + private Redis $redis; /** - * @param array $params * @throws RedisException */ public function __construct(array $params) @@ -169,8 +165,6 @@ public function clear() /** * Gets the hashed key - * @param string $key - * @return string */ private function keyHash(string $key): string { diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index dc0d18789..4c4df2049 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -52,14 +52,10 @@ class Cache */ public const REDIS = 'redis'; - /** - * @var CacheInterface - */ - private $adapter; + private CacheInterface $adapter; /** * Cache constructor - * @param CacheInterface $cacheAdapter */ public function __construct(CacheInterface $cacheAdapter) { @@ -68,7 +64,6 @@ public function __construct(CacheInterface $cacheAdapter) /** * Gets the current adapter - * @return CacheInterface */ public function getAdapter(): CacheInterface { @@ -76,8 +71,6 @@ public function getAdapter(): CacheInterface } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Cache/Factories/CacheFactory.php b/src/Cache/Factories/CacheFactory.php index d7407b834..1bebf336a 100644 --- a/src/Cache/Factories/CacheFactory.php +++ b/src/Cache/Factories/CacheFactory.php @@ -45,11 +45,9 @@ class CacheFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Cache * @throws BaseException * @throws ConfigException * @throws DiException @@ -72,19 +70,12 @@ public static function get(?string $adapter = null): Cache return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Cache - */ private static function createInstance(string $adapterClass, string $adapter): Cache { return new Cache(new $adapterClass(config()->get('cache.' . $adapter))); } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Cache/Helpers/cache.php b/src/Cache/Helpers/cache.php index cde21b342..82f44b162 100644 --- a/src/Cache/Helpers/cache.php +++ b/src/Cache/Helpers/cache.php @@ -19,8 +19,6 @@ use Quantum\Cache\Cache; /** - * @param string|null $adapter - * @return Cache * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Captcha/Adapters/HcaptchaAdapter.php b/src/Captcha/Adapters/HcaptchaAdapter.php index 5e652b147..55851c8f6 100644 --- a/src/Captcha/Adapters/HcaptchaAdapter.php +++ b/src/Captcha/Adapters/HcaptchaAdapter.php @@ -42,8 +42,6 @@ class HcaptchaAdapter implements CaptchaInterface /** * Hcaptcha constructor - * @param array $params - * @param HttpClient $httpClient */ public function __construct(array $params, HttpClient $httpClient) { diff --git a/src/Captcha/Adapters/RecaptchaAdapter.php b/src/Captcha/Adapters/RecaptchaAdapter.php index 7078e4c09..7378e8749 100644 --- a/src/Captcha/Adapters/RecaptchaAdapter.php +++ b/src/Captcha/Adapters/RecaptchaAdapter.php @@ -42,8 +42,6 @@ class RecaptchaAdapter implements CaptchaInterface /** * RecaptchaAdapter constructor - * @param array $params - * @param HttpClient $httpClient */ public function __construct(array $params, HttpClient $httpClient) { diff --git a/src/Captcha/Captcha.php b/src/Captcha/Captcha.php index 531f4cef7..94a18bfda 100644 --- a/src/Captcha/Captcha.php +++ b/src/Captcha/Captcha.php @@ -40,30 +40,19 @@ class Captcha */ public const RECAPTCHA = 'recaptcha'; - /** - * @var CaptchaInterface - */ - private $adapter; + private CaptchaInterface $adapter; - /** - * @param CaptchaInterface $adapter - */ public function __construct(CaptchaInterface $adapter) { $this->adapter = $adapter; } - /** - * @return CaptchaInterface - */ public function getAdapter(): CaptchaInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Captcha/Contracts/CaptchaInterface.php b/src/Captcha/Contracts/CaptchaInterface.php index 7a5971b6a..551010581 100644 --- a/src/Captcha/Contracts/CaptchaInterface.php +++ b/src/Captcha/Contracts/CaptchaInterface.php @@ -35,36 +35,21 @@ interface CaptchaInterface */ public const CAPTCHA_INVISIBLE = 'invisible'; - /** - * @return string - */ public function getName(): string; - /** - * @return string|null - */ public function getType(): ?string; - /** - * @param string $type - * @return self - */ public function setType(string $type): self; /** - * @param string $formIdentifier * @return mixed */ public function addToForm(string $formIdentifier); /** - * @param string $response * @return mixed */ public function verify(string $response); - /** - * @return string|null - */ public function getErrorMessage(): ?string; } diff --git a/src/Captcha/Factories/CaptchaFactory.php b/src/Captcha/Factories/CaptchaFactory.php index efad95056..2ca22c771 100644 --- a/src/Captcha/Factories/CaptchaFactory.php +++ b/src/Captcha/Factories/CaptchaFactory.php @@ -18,9 +18,9 @@ use Quantum\Captcha\Adapters\RecaptchaAdapter; use Quantum\Captcha\Adapters\HcaptchaAdapter; use Quantum\Config\Exceptions\ConfigException; -use Quantum\HttpClient\HttpClient; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\HttpClient\HttpClient; use Quantum\Captcha\Captcha; use Quantum\Loader\Setup; use ReflectionException; @@ -42,11 +42,9 @@ class CaptchaFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Captcha * @throws BaseException * @throws ConfigException * @throws DiException @@ -69,19 +67,12 @@ public static function get(?string $adapter = null): Captcha return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Captcha - */ private static function createInstance(string $adapterClass, string $adapter): Captcha { return new Captcha(new $adapterClass(config()->get('captcha.' . $adapter), new HttpClient())); } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Captcha/Helpers/captcha.php b/src/Captcha/Helpers/captcha.php index def4c3f95..8fe75d26d 100644 --- a/src/Captcha/Helpers/captcha.php +++ b/src/Captcha/Helpers/captcha.php @@ -19,8 +19,6 @@ use Quantum\Captcha\Captcha; /** - * @param string|null $adapter - * @return Captcha * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Captcha/Traits/CaptchaTrait.php b/src/Captcha/Traits/CaptchaTrait.php index 10357f3f8..7157fc0df 100644 --- a/src/Captcha/Traits/CaptchaTrait.php +++ b/src/Captcha/Traits/CaptchaTrait.php @@ -31,47 +31,27 @@ */ trait CaptchaTrait { - /** - * @var string|null - */ protected ?string $siteKey; - /** - * @var string|null - */ protected ?string $secretKey; - /** - * @var HttpClient - */ protected HttpClient $http; /** * @var mixed|null */ - protected $type = null; + protected $type; - /** - * @var array - */ protected array $errorCodes = []; - /** - * @var array - */ protected array $elementAttributes = []; - /** - * @return string|null - */ public function getType(): ?string { return $this->type; } /** - * @param string $type - * @return CaptchaInterface * @throws Exception */ public function setType(string $type): CaptchaInterface @@ -84,9 +64,6 @@ public function setType(string $type): CaptchaInterface return $this; } - /** - * @return string - */ public function getName(): string { return $this->name; @@ -94,9 +71,6 @@ public function getName(): string /** * Generates an HTML code block for the captcha - * @param string $formIdentifier - * @param array $attributes - * @return string * @throws AssetException * @throws Exception */ @@ -117,8 +91,6 @@ public function addToForm(string $formIdentifier = '', array $attributes = []): /** * Checks the code given by the captcha - * @param string $code - * @return bool * @throws LangException * @throws ErrorException * @throws BaseException @@ -170,9 +142,6 @@ public function verify(string $code): bool return isset($response->success) && $response->success; } - /** - * @return string|null - */ public function getErrorMessage(): ?string { if (!empty($this->errorCodes)) { @@ -182,10 +151,6 @@ public function getErrorMessage(): ?string return null; } - /** - * @param array $attributes - * @return string - */ protected function getVisibleElement(array $attributes = []): string { $this->extractAttributes($attributes); @@ -194,8 +159,6 @@ protected function getVisibleElement(array $attributes = []): string } /** - * @param string $formIdentifier - * @return string * @throws Exception */ protected function getInvisibleElement(string $formIdentifier): string @@ -220,7 +183,6 @@ function onSubmit (){ /** * @param $type - * @return bool */ protected function isValidCaptchaType($type): bool { @@ -233,7 +195,6 @@ protected function isValidCaptchaType($type): bool } /** - * @param array $attributes * @return void */ protected function extractAttributes(array $attributes) @@ -247,10 +208,6 @@ protected function extractAttributes(array $attributes) } } - /** - * @param string $challengeTs - * @return bool - */ protected function detectReplayAttack(string $challengeTs): bool { return time() - strtotime($challengeTs) > self::MAX_TIME_DIFF; diff --git a/src/Config/Config.php b/src/Config/Config.php index 469598549..655b8a960 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -15,6 +15,7 @@ namespace Quantum\Config; use Quantum\Config\Exceptions\ConfigException; +use Quantum\Loader\Exceptions\LoaderException; use Quantum\Contracts\StorageInterface; use Quantum\Di\Exceptions\DiException; use Dflydev\DotAccessData\Data; @@ -29,21 +30,12 @@ */ class Config implements StorageInterface { - /** - * Configs - * @var Data|null - */ - private static $configs = null; + private static ?Data $configs = null; - /** - * Instance of Config - * @var Config - */ - private static $instance = null; + private static ?Config $instance = null; /** * GetInstance - * @return Config */ public static function getInstance(): Config { @@ -56,12 +48,11 @@ public static function getInstance(): Config /** * Loads configuration - * @param Setup $setup * @throws ConfigException * @throws DiException * @throws ReflectionException */ - public function load(Setup $setup) + public function load(Setup $setup): void { if (self::$configs !== null) { return; @@ -72,12 +63,11 @@ public function load(Setup $setup) /** * Imports new config file - * @param Setup $setup * @throws ConfigException * @throws DiException - * @throws ReflectionException + * @throws ReflectionException|LoaderException */ - public function import(Setup $setup) + public function import(Setup $setup): void { $fileName = $setup->getFilename(); @@ -94,7 +84,6 @@ public function import(Setup $setup) /** * Gets the config item by given key - * @param string $key * @param mixed $default * @return mixed|null */ @@ -109,7 +98,6 @@ public function get(string $key, $default = null) /** * Get all configs - * @return Data|null */ public function all(): ?Data { @@ -118,8 +106,6 @@ public function all(): ?Data /** * Checks config data - * @param string $key - * @return bool */ public function has(string $key): bool { @@ -128,11 +114,9 @@ public function has(string $key): bool /** * Sets new value - * @param string $key * @param mixed $value - * @return void */ - public function set(string $key, $value) + public function set(string $key, $value): void { if (!self::$configs) { self::$configs = new Data([$key => $value]); @@ -143,9 +127,8 @@ public function set(string $key, $value) /** * Removes the data from config - * @param string $key */ - public function delete(string $key) + public function delete(string $key): void { self::$configs && self::$configs->remove($key); } @@ -153,7 +136,7 @@ public function delete(string $key) /** * Deletes whole config data */ - public function flush() + public function flush(): void { self::$configs = null; } diff --git a/src/Config/Exceptions/ConfigException.php b/src/Config/Exceptions/ConfigException.php index bd2e0929a..b40910df7 100644 --- a/src/Config/Exceptions/ConfigException.php +++ b/src/Config/Exceptions/ConfigException.php @@ -25,10 +25,6 @@ */ class ConfigException extends BaseException { - /** - * @param string $name - * @return ConfigException - */ public static function configCollision(string $name): self { return new self( diff --git a/src/Config/Helpers/config.php b/src/Config/Helpers/config.php index 0b9aebaf0..877f549c9 100644 --- a/src/Config/Helpers/config.php +++ b/src/Config/Helpers/config.php @@ -16,7 +16,6 @@ /** * Config facade - * @return Config */ function config(): Config { diff --git a/src/Console/CommandDiscovery.php b/src/Console/CommandDiscovery.php index 6cc1018c9..3b0ffe381 100644 --- a/src/Console/CommandDiscovery.php +++ b/src/Console/CommandDiscovery.php @@ -24,9 +24,6 @@ class CommandDiscovery { /** - * @param string $directory - * @param string $namespace - * @return array * @throws ReflectionException */ public static function discover(string $directory, string $namespace): array diff --git a/src/Console/Commands/CronRunCommand.php b/src/Console/Commands/CronRunCommand.php index eceb55a24..6c2d6c3f3 100644 --- a/src/Console/Commands/CronRunCommand.php +++ b/src/Console/Commands/CronRunCommand.php @@ -26,27 +26,24 @@ class CronRunCommand extends QtCommand { /** * The console command name. - * @var string */ - protected $name = 'cron:run'; + protected ?string $name = 'cron:run'; /** * The console command description. - * @var string */ - protected $description = 'Run scheduled cron tasks'; + protected ?string $description = 'Run scheduled cron tasks'; /** * Command help text. - * @var string */ - protected $help = 'Executes scheduled tasks defined in the cron directory. Use --task to run a single task or --force to bypass locks.'; + protected ?string $help = 'Executes scheduled tasks defined in the cron directory. Use --task to run a single task or --force to bypass locks.'; /** * Command options * @var array> */ - protected $options = [ + protected array $options = [ ['force', 'f', 'none', 'Force run tasks ignoring locks'], ['task', 't', 'optional', 'Run a specific task by name'], ['path', 'p', 'optional', 'Custom cron directory path'], @@ -55,7 +52,7 @@ class CronRunCommand extends QtCommand /** * Executes the command */ - public function exec() + public function exec(): void { $force = (bool) $this->getOption('force'); $taskName = $this->getOption('task'); @@ -78,9 +75,6 @@ public function exec() /** * Run all due tasks - * @param CronManager $manager - * @param bool $force - * @return void */ private function runAllDueTasks(CronManager $manager, bool $force): void { @@ -115,10 +109,6 @@ private function runAllDueTasks(CronManager $manager, bool $force): void /** * Run a specific task - * @param CronManager $manager - * @param string $taskName - * @param bool $force - * @return void * @throws CronException */ private function runSpecificTask(CronManager $manager, string $taskName, bool $force): void diff --git a/src/Console/Commands/DebugBarCommand.php b/src/Console/Commands/DebugBarCommand.php index 423087086..899a75295 100644 --- a/src/Console/Commands/DebugBarCommand.php +++ b/src/Console/Commands/DebugBarCommand.php @@ -31,37 +31,31 @@ class DebugBarCommand extends QtCommand { /** * File System - * @var FileSystem|null */ protected ?FileSystem $fs = null; /** * Command name - * @var string */ - protected $name = 'install:debugbar'; + protected ?string $name = 'install:debugbar'; /** * Command description - * @var string */ - protected $description = 'Publishes debugbar assets'; + protected ?string $description = 'Publishes debugbar assets'; /** * Command help text - * @var string */ - protected $help = 'The command will publish debugbar assets'; + protected ?string $help = 'The command will publish debugbar assets'; /** * Path to public debug bar resources - * @var string */ private string $publicDebugBarFolderPath = 'public/assets/DebugBar/Resources'; /** * Path to vendor debug bar resources - * @var string */ private string $vendorDebugBarFolderPath = 'vendor/php-debugbar/php-debugbar/src/DebugBar/Resources'; @@ -73,7 +67,7 @@ class DebugBarCommand extends QtCommand * @throws DiException * @throws ReflectionException */ - public function exec() + public function exec(): void { $this->fs = FileSystemFactory::get(); @@ -89,12 +83,9 @@ public function exec() /** * Recursively copies the debug bar assets - * @param string $src - * @param string $dst - * @return void * @throws FileSystemException */ - private function copyResources(string $src, string $dst) + private function copyResources(string $src, string $dst): void { $dir = opendir($src); diff --git a/src/Console/Commands/EnvCommand.php b/src/Console/Commands/EnvCommand.php index 5d8a48267..7836a6014 100644 --- a/src/Console/Commands/EnvCommand.php +++ b/src/Console/Commands/EnvCommand.php @@ -30,27 +30,23 @@ class EnvCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'core:env'; + protected ?string $name = 'core:env'; /** * Command description - * @var string */ - protected $description = 'Generates new .env file'; + protected ?string $description = 'Generates new .env file'; /** * Command help text - * @var string */ - protected $help = 'The command will generate new .env file from .env.example'; + protected ?string $help = 'The command will generate new .env file from .env.example'; /** * Command options - * @var array */ - protected $options = [ + protected array $options = [ ['yes', 'y', 'none', 'Acceptance of the confirmation'], ]; @@ -61,7 +57,7 @@ class EnvCommand extends QtCommand * @throws DiException * @throws ReflectionException */ - public function exec() + public function exec(): void { $fs = FileSystemFactory::get(); diff --git a/src/Console/Commands/InstallToolkitCommand.php b/src/Console/Commands/InstallToolkitCommand.php index e91f7f751..a9ba2a6f4 100644 --- a/src/Console/Commands/InstallToolkitCommand.php +++ b/src/Console/Commands/InstallToolkitCommand.php @@ -29,30 +29,26 @@ class InstallToolkitCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'install:toolkit'; + protected ?string $name = 'install:toolkit'; /** * Command description - * @var string */ - protected $description = 'Installs toolkit'; + protected ?string $description = 'Installs toolkit'; /** * Command arguments - * @var array */ - protected $args = [ + protected array $args = [ ['username', 'required', 'The username for basic auth'], ['password', 'required', 'The password for basic auth'], ]; /** * Command help text - * @var string */ - protected $help = 'The command will install Toolkit and its assets into your project'; + protected ?string $help = 'The command will install Toolkit and its assets into your project'; /** * Command name to generate modules @@ -64,7 +60,7 @@ class InstallToolkitCommand extends QtCommand * @throws ExceptionInterface * @throws EnvException */ - public function exec() + public function exec(): void { $name = $this->getArgument('username'); @@ -90,8 +86,6 @@ public function exec() /** * Runs an external command - * @param string $commandName - * @param array $arguments * @throws ExceptionInterface */ protected function runExternalCommand(string $commandName, array $arguments) diff --git a/src/Console/Commands/KeyGenerateCommand.php b/src/Console/Commands/KeyGenerateCommand.php index b8d3ddb5d..4bbb02643 100644 --- a/src/Console/Commands/KeyGenerateCommand.php +++ b/src/Console/Commands/KeyGenerateCommand.php @@ -27,27 +27,23 @@ class KeyGenerateCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'core:key'; + protected ?string $name = 'core:key'; /** * Command description - * @var string */ - protected $description = 'Generates and stores the application key'; + protected ?string $description = 'Generates and stores the application key'; /** * Command help text - * @var string */ - protected $help = 'The command will generate APP_KEY and store in .env file'; + protected ?string $help = 'The command will generate APP_KEY and store in .env file'; /** * Command options - * @var array */ - protected $options = [ + protected array $options = [ ['length', 'l', 'required', 'Length of the key', 32], ['yes', 'y', 'none', 'Acceptance of the confirmation'], ]; @@ -57,7 +53,7 @@ class KeyGenerateCommand extends QtCommand * @throws EnvException * @throws Exception */ - public function exec() + public function exec(): void { if (Environment::getInstance()->hasKey('APP_KEY') && env('APP_KEY') !== '' && !$this->getOption('yes')) { if (!$this->confirm('The operation will remove the existing key and will create new one. Continue?')) { @@ -75,7 +71,6 @@ public function exec() /** * Generates random string - * @return string * @throws Exception */ private function generateRandomKey(): string diff --git a/src/Console/Commands/MigrationGenerateCommand.php b/src/Console/Commands/MigrationGenerateCommand.php index edb6da4e9..9c071b7af 100644 --- a/src/Console/Commands/MigrationGenerateCommand.php +++ b/src/Console/Commands/MigrationGenerateCommand.php @@ -27,21 +27,19 @@ class MigrationGenerateCommand extends QtCommand { /** * The console command name. - * @var string */ - protected $name = 'migration:generate'; + protected ?string $name = 'migration:generate'; /** * The console command description. - * @var string */ - protected $description = 'Generates new migration file'; + protected ?string $description = 'Generates new migration file'; /** * Command arguments * @var string[][] */ - protected $args = [ + protected array $args = [ ['action', 'required', 'The action to perform. [create] for creating table, [alter] for altering table, [rename] for renaming table, [drop] for dropping table'], ['table', 'required', 'The table name'], ]; @@ -51,7 +49,7 @@ class MigrationGenerateCommand extends QtCommand * @throws LangException * @throws MigrationException */ - public function exec() + public function exec(): void { $migrationManager = new MigrationManager(); diff --git a/src/Console/Commands/MigrationMigrateCommand.php b/src/Console/Commands/MigrationMigrateCommand.php index f9c870d94..5b90d1c1c 100644 --- a/src/Console/Commands/MigrationMigrateCommand.php +++ b/src/Console/Commands/MigrationMigrateCommand.php @@ -31,21 +31,19 @@ class MigrationMigrateCommand extends QtCommand { /** * The console command name. - * @var string */ - protected $name = 'migration:migrate'; + protected ?string $name = 'migration:migrate'; /** * The console command description. - * @var string */ - protected $description = 'Migrates the migrations'; + protected ?string $description = 'Migrates the migrations'; /** * Command arguments * @var string[][] */ - protected $args = [ + protected array $args = [ ['direction', 'optional', '[up] for upgrade, [down] for downgrade'], ]; @@ -53,7 +51,7 @@ class MigrationMigrateCommand extends QtCommand * Command options * @var string[][] */ - protected $options = [ + protected array $options = [ ['step', 's', 'optional', 'Number of migrations to apply'], ]; @@ -65,7 +63,7 @@ class MigrationMigrateCommand extends QtCommand * @throws DiException * @throws LangException */ - public function exec() + public function exec(): void { $direction = $this->getArgument('direction') ?: MigrationManager::UPGRADE; diff --git a/src/Console/Commands/ModuleGenerateCommand.php b/src/Console/Commands/ModuleGenerateCommand.php index 713405c3b..f2bd84d8e 100644 --- a/src/Console/Commands/ModuleGenerateCommand.php +++ b/src/Console/Commands/ModuleGenerateCommand.php @@ -27,35 +27,31 @@ class ModuleGenerateCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'module:generate'; + protected ?string $name = 'module:generate'; /** * Command description - * @var string */ - protected $description = 'Generate new module'; + protected ?string $description = 'Generate new module'; /** * Command arguments * @var string[][] */ - protected $args = [ + protected array $args = [ ['module', 'required', 'The module name'], ]; /** * Command help text - * @var string */ - protected $help = 'The command will create files for new module'; + protected ?string $help = 'The command will create files for new module'; /** * Command options - * @var array */ - protected $options = [ + protected array $options = [ ['yes', 'y', 'none', 'Module enabled status'], ['template', 't', 'optional', 'The module template', 'DefaultWeb'], ['with-assets', 'a', 'none', 'Install module will assets'], @@ -65,7 +61,7 @@ class ModuleGenerateCommand extends QtCommand * Executes the command * @throws ExceptionInterface */ - public function exec() + public function exec(): void { try { $moduleName = $this->getArgument('module'); diff --git a/src/Console/Commands/OpenApiCommand.php b/src/Console/Commands/OpenApiCommand.php index c63f4bded..1656a0db7 100644 --- a/src/Console/Commands/OpenApiCommand.php +++ b/src/Console/Commands/OpenApiCommand.php @@ -24,6 +24,7 @@ use Quantum\Router\RouteBuilder; use Quantum\Storage\FileSystem; use Quantum\Console\QtCommand; +use ReflectionException; use OpenApi\Generator; use Quantum\Di\Di; @@ -35,7 +36,6 @@ class OpenApiCommand extends QtCommand { /** * File System - * @var FileSystem */ protected FileSystem $fs; @@ -48,45 +48,39 @@ public function __construct() /** * Command name - * @var string */ - protected $name = 'install:openapi'; + protected ?string $name = 'install:openapi'; /** * Command description - * @var string */ - protected $description = 'Generates files for OpenApi UI'; + protected ?string $description = 'Generates files for OpenApi UI'; /** * Command arguments * @var string[][] */ - protected $args = [ + protected array $args = [ ['module', 'required', 'The module name'], ]; /** * Command help text - * @var string */ - protected $help = 'The command will publish OpenApi UI resources'; + protected ?string $help = 'The command will publish OpenApi UI resources'; /** * Path to public debug bar resources - * @var string */ private string $publicOpenApiFolderPath = 'public/assets/OpenApiUi'; /** * Path to vendor debug bar resources - * @var string */ private string $vendorOpenApiFolderPath = 'vendor/swagger-api/swagger-ui/dist'; /** * Exclude File Names - * @var array */ private array $excludeFileNames = ['index.html', 'swagger-initializer.js', 'favicon-16x16.png', 'favicon-32x32.png']; @@ -96,8 +90,9 @@ public function __construct() * @throws ModuleException * @throws RouteException * @throws DiException + * @throws ReflectionException */ - public function exec() + public function exec(): void { $moduleLoader = ModuleLoader::getInstance(); @@ -145,7 +140,7 @@ public function exec() /** * Copies OpenApi resources */ - private function copyResources() + private function copyResources(): void { $dir = opendir($this->vendorOpenApiFolderPath); @@ -162,9 +157,8 @@ private function copyResources() /** * Generates file with OpenApi specifications - * @param string $module */ - private function generateOpenapiSpecification(string $module) + private function generateOpenapiSpecification(string $module): void { $annotationPath = modules_dir() . DS . $module . DS . 'Controllers' . DS . 'OpenApi' . DS; @@ -179,8 +173,6 @@ private function generateOpenapiSpecification(string $module) /** * Gets the OpenApi routes - * @param string $module - * @return string */ private function openapiRoutes(string $module): string { diff --git a/src/Console/Commands/ResourceCacheClearCommand.php b/src/Console/Commands/ResourceCacheClearCommand.php index 6cdaa32f4..d9b217589 100644 --- a/src/Console/Commands/ResourceCacheClearCommand.php +++ b/src/Console/Commands/ResourceCacheClearCommand.php @@ -32,66 +32,44 @@ class ResourceCacheClearCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'cache:clear'; + protected ?string $name = 'cache:clear'; /** * Command description - * @var string */ - protected $description = 'Clears resource cache'; + protected ?string $description = 'Clears resource cache'; /** * Command help text - * @var string */ - protected $help = 'The command will clear the resource cache'; + protected ?string $help = 'The command will clear the resource cache'; /** * Command options - * @var array */ - protected $options = [ + protected array $options = [ ['all', 'all', 'none', ''], ['type', 't', 'required', ''], ['module', 'm', 'required', ''], ]; - /** - * @var array - */ protected array $types = ['views', 'asserts']; - /** - * @var array - */ protected array $modules = []; - /** - * @var string|null - */ protected ?string $type = null; - /** - * @var string|null - */ protected ?string $module = null; - /** - * @var string - */ protected string $cacheDir = ''; - /** - * @var FileSystem|null - */ protected ?FileSystem $fs = null; /** * @throws BaseException|ReflectionException */ - public function exec() + public function exec(): void { try { $this->importConfig(); @@ -121,10 +99,7 @@ public function exec() $this->info('Resource cache cleared successfully.'); } - /** - * @return void - */ - private function importModules() + private function importModules(): void { try { if (!config()->has('modules')) { @@ -141,7 +116,6 @@ private function importModules() } /** - * @return void * @throws ConfigException * @throws DiException * @throws ReflectionException @@ -156,8 +130,6 @@ private function importConfig(): void } /** - * @param string|null $moduleOption - * @return void * @throws Exception */ private function initModule(?string $moduleOption): void @@ -175,8 +147,6 @@ private function initModule(?string $moduleOption): void } /** - * @param string|null $typeOption - * @return void * @throws Exception */ private function initType(?string $typeOption): void @@ -192,11 +162,6 @@ private function initType(?string $typeOption): void } } - /** - * @param string|null $moduleName - * @param string|null $type - * @return void - */ private function clearResourceModuleAndType(?string $moduleName = null, ?string $type = null): void { $dir = $this->cacheDir; @@ -216,10 +181,6 @@ private function clearResourceModuleAndType(?string $moduleName = null, ?string $this->removeFilesFromDirectory($dir); } - /** - * @param string $dir - * @return void - */ private function removeFilesFromDirectory(string $dir): void { $entries = $this->fs->glob($dir . DS . '*'); diff --git a/src/Console/Commands/RouteListCommand.php b/src/Console/Commands/RouteListCommand.php index fa057e29f..d9f46bc49 100644 --- a/src/Console/Commands/RouteListCommand.php +++ b/src/Console/Commands/RouteListCommand.php @@ -33,21 +33,19 @@ class RouteListCommand extends QtCommand { /** * The console command name. - * @var string */ - protected $name = 'route:list'; + protected ?string $name = 'route:list'; /** * The console command description. - * @var string */ - protected $description = 'Display all registered routes'; + protected ?string $description = 'Display all registered routes'; /** * Command options * @var array> */ - protected $options = [ + protected array $options = [ ['module', 'm', 'optional', 'Filter by module name'], ]; @@ -55,7 +53,7 @@ class RouteListCommand extends QtCommand * Executes the command * @throws DiException */ - public function exec() + public function exec(): void { try { $moduleLoader = ModuleLoader::getInstance(); @@ -106,9 +104,6 @@ static function (Route $route) use ($module): bool { /** * Composes a table row - * @param Route $route - * @param int $maxContentLength - * @return array */ private function composeTableRow(Route $route, int $maxContentLength = 25): array { diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index b6679d777..a4904de64 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -41,39 +41,34 @@ class ServeCommand extends QtCommand /** * The console command name. - * @var string */ - protected $name = 'serve'; + protected ?string $name = 'serve'; /** * The console command description. - * @var string */ - protected $description = 'Serves the application on the PHP development server'; + protected ?string $description = 'Serves the application on the PHP development server'; /** * Default host - * @var string */ - protected $defaultHost = '127.0.0.1'; + protected string $defaultHost = '127.0.0.1'; /** * Default port - * @var int */ - protected $defaultPort = 8000; + protected int $defaultPort = 8000; /** * Max ports to scan - * @var int */ - protected $maxPortScan = 50; + protected int $maxPortScan = 50; /** * Command arguments * @var array> */ - protected $options = [ + protected array $options = [ ['host', null, 'optional', 'Host', '127.0.0.1'], ['port', null, 'optional', 'Port', '8000'], ['open', 'o', 'none', 'Open browser'], @@ -82,7 +77,7 @@ class ServeCommand extends QtCommand /** * Execute the command. */ - public function exec() + public function exec(): void { $host = $this->host(); $startPort = $this->port(); @@ -93,10 +88,7 @@ public function exec() } /** - * Start server on first available port. - * @param string $host - * @param int $startPort - * @return array + * Start the server on the first available port. * @throws RuntimeException */ protected function startServerOnAvailablePort(string $host, int $startPort): array @@ -131,7 +123,6 @@ protected function startServerOnAvailablePort(string $host, int $startPort): arr /** * Handle server execution (browser opening and process monitoring). - * @param array $serverData */ protected function handleServerExecution(array $serverData): void { @@ -155,9 +146,6 @@ protected function cleanupProcess($process): void /** * Check if port is already in use by another process. - * @param string $host - * @param int $port - * @return bool */ protected function isPortInUse(string $host, int $port): bool { @@ -171,8 +159,6 @@ protected function isPortInUse(string $host, int $port): bool /** * Start PHP built-in server. - * @param string $host - * @param int $port * @return resource */ protected function startPhpServer(string $host, int $port) @@ -202,8 +188,6 @@ protected function startPhpServer(string $host, int $port) /** * Wait until the PHP server is ready to accept connections. - * @param string $host - * @param int $port * @param resource $process */ protected function waitUntilServerIsReady(string $host, int $port, $process): void @@ -245,7 +229,6 @@ protected function waitForProcess($process): void /** * Determine whether the browser should be opened. - * @return bool */ protected function shouldOpenBrowser(): bool { @@ -254,7 +237,6 @@ protected function shouldOpenBrowser(): bool /** * Open the default browser. - * @param string $url */ protected function openBrowser(string $url): void { @@ -277,8 +259,6 @@ protected function openBrowser(string $url): void /** * Resolve platform-specific browser command. - * @param string $url - * @return array|null */ protected function browserCommand(string $url): ?array { @@ -296,7 +276,6 @@ protected function browserCommand(string $url): ?array /** * Get host option. - * @return string */ protected function host(): string { @@ -305,7 +284,6 @@ protected function host(): string /** * Get and validate port option. - * @return int */ protected function port(): int { diff --git a/src/Console/Commands/VersionCommand.php b/src/Console/Commands/VersionCommand.php index 17d7863f9..0c67514c7 100644 --- a/src/Console/Commands/VersionCommand.php +++ b/src/Console/Commands/VersionCommand.php @@ -31,21 +31,18 @@ class VersionCommand extends QtCommand { /** * Command name - * @var string */ - protected $name = 'core:version'; + protected ?string $name = 'core:version'; /** * Command description - * @var string */ - protected $description = 'Core version'; + protected ?string $description = 'Core version'; /** * Command help text - * @var string */ - protected $help = 'Printing the current version of the framework into the terminal'; + protected ?string $help = 'Printing the current version of the framework into the terminal'; /** * Executes the command and prints greetings into the terminal @@ -54,7 +51,7 @@ class VersionCommand extends QtCommand * @throws BaseException * @throws ReflectionException */ - public function exec() + public function exec(): void { Environment::getInstance()->load(new Setup('config', 'env')); diff --git a/src/Console/QtCommand.php b/src/Console/QtCommand.php index b38ab3cdc..6b1d093b6 100644 --- a/src/Console/QtCommand.php +++ b/src/Console/QtCommand.php @@ -30,45 +30,34 @@ abstract class QtCommand extends Command implements CommandInterface { /** * Console command name - * @var string */ - protected $name; + protected ?string $name = null; /** * Console command description. - * @var string */ - protected $description; + protected ?string $description = null; /** * Console command help text - * @var string */ - protected $help; + protected ?string $help = null; /** * Console command input arguments - * @var array * @example ['name', 'type', 'description'] */ - protected $args = []; + protected array $args = []; /** * Console command options - * @var array * @example ['name', 'shortcut', 'type', 'description', 'default'] */ - protected $options = []; + protected array $options = []; - /** - * @var InputInterface - */ - protected $input; + protected ?InputInterface $input = null; - /** - * @var OutputInterface - */ - protected $output; + protected ?OutputInterface $output = null; /** * QtCommand constructor. @@ -88,7 +77,6 @@ public function __construct() /** * Returns the argument value for a given argument name. - * @param string|null $key * @return mixed|string */ public function getArgument(?string $key = null) @@ -98,7 +86,6 @@ public function getArgument(?string $key = null) /** * Returns the option value for a given option name. - * @param string|null $key * @return mixed|string */ public function getOption(?string $key = null) @@ -108,44 +95,38 @@ public function getOption(?string $key = null) /** * Outputs the string to console - * @param string $message */ - public function output(string $message) + public function output(string $message): void { $this->output->writeln($message); } /** - * Outputs the string to console as info - * @param string $message + * Outputs the string to the console as info */ - public function info(string $message) + public function info(string $message): void { $this->output->writeln("$message"); } /** * Outputs the string to console as comment - * @param string $message */ - public function comment(string $message) + public function comment(string $message): void { $this->output->writeln("$message"); } /** * Outputs the string to console as question - * @param string $message */ - public function question(string $message) + public function question(string $message): void { $this->output->writeln("$message"); } /** * Asks confirmation - * @param string $message - * @return bool */ public function confirm(string $message): bool { @@ -157,10 +138,9 @@ public function confirm(string $message): bool } /** - * Outputs the string to console as error - * @param string $message + * Outputs the string to the console as an error */ - public function error(string $message) + public function error(string $message): void { $this->output->writeln("$message"); } @@ -176,11 +156,8 @@ protected function configure() /** * Executes the current command. - * @param InputInterface $input - * @param OutputInterface $output - * @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; $this->output = $output; @@ -192,7 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Sets command arguments */ - private function setArguments() + private function setArguments(): void { foreach ($this->args as $arg) { switch ($arg[1]) { @@ -212,7 +189,7 @@ private function setArguments() /** * Sets command options */ - private function setOptions() + private function setOptions(): void { foreach ($this->options as $option) { switch ($option[2]) { diff --git a/src/Contracts/StorageInterface.php b/src/Contracts/StorageInterface.php index 435827298..eb9d523b1 100644 --- a/src/Contracts/StorageInterface.php +++ b/src/Contracts/StorageInterface.php @@ -27,28 +27,23 @@ public function all(); /** * Checks if the storage contains a key - * @param string $key - * @return bool */ public function has(string $key): bool; /** * Gets the value from the storage by given key - * @param string $key * @return mixed|null */ public function get(string $key); /** * Sets storage value with the given key - * @param string $key * @param mixed $value */ public function set(string $key, $value); /** * Deletes the data from the storage by given key - * @param string $key */ public function delete(string $key); diff --git a/src/Cookie/Contracts/CookieStorageInterface.php b/src/Cookie/Contracts/CookieStorageInterface.php index fa5351dae..33926f379 100644 --- a/src/Cookie/Contracts/CookieStorageInterface.php +++ b/src/Cookie/Contracts/CookieStorageInterface.php @@ -24,20 +24,12 @@ interface CookieStorageInterface extends StorageInterface { /** * Sets data by given key - * @param string $key * @param mixed $value - * @param int $time - * @param string $path - * @param string $domain - * @param bool $secure - * @param bool $httponly */ public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false); /** * Deletes data by given key - * @param string $key - * @param string $path */ public function delete(string $key, string $path = '/'); } diff --git a/src/Cookie/Cookie.php b/src/Cookie/Cookie.php index a52d6d8f4..415295f23 100644 --- a/src/Cookie/Cookie.php +++ b/src/Cookie/Cookie.php @@ -25,28 +25,24 @@ class Cookie implements CookieStorageInterface { /** * Cookie storage - * @var array $storage */ - private static $storage = []; + private static array $storage = []; /** * Cookie instance - * @var Cookie|null */ - private static $instance = null; + private static ?Cookie $instance = null; /** * Cookie constructor. */ private function __construct() { - // Preventing to create new object through constructor + // Preventing to create a new object through constructor } /** * Gets the cookie instance - * @param array $storage - * @return Cookie */ public static function getInstance(array &$storage): Cookie { @@ -95,7 +91,7 @@ public function get(string $key) * @inheritDoc * @throws BaseException */ - public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false) + public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): void { self::$storage[$key] = crypto_encode($value); setcookie($key, crypto_encode($value), ['expires' => $time !== 0 ? time() + $time : $time, 'path' => $path, 'domain' => $domain, 'secure' => $secure, 'httponly' => $httponly]); @@ -104,7 +100,7 @@ public function set(string $key, $value = '', int $time = 0, string $path = '/', /** * @inheritDoc */ - public function delete(string $key, string $path = '/') + public function delete(string $key, string $path = '/'): void { if ($this->has($key)) { unset(self::$storage[$key]); @@ -115,7 +111,7 @@ public function delete(string $key, string $path = '/') /** * @inheritDoc */ - public function flush() + public function flush(): void { if (count(self::$storage)) { foreach (array_keys(self::$storage) as $key) { diff --git a/src/Cookie/Helpers/cookie.php b/src/Cookie/Helpers/cookie.php index 0b70ed964..5ab4748dc 100644 --- a/src/Cookie/Helpers/cookie.php +++ b/src/Cookie/Helpers/cookie.php @@ -16,7 +16,6 @@ /** * Gets cookie handler - * @return Cookie */ function cookie(): Cookie { diff --git a/src/Cron/Contracts/CronTaskInterface.php b/src/Cron/Contracts/CronTaskInterface.php index 49e63a10f..3acaf6b77 100644 --- a/src/Cron/Contracts/CronTaskInterface.php +++ b/src/Cron/Contracts/CronTaskInterface.php @@ -22,25 +22,21 @@ interface CronTaskInterface { /** * Get the cron expression - * @return string */ public function getExpression(): string; /** * Get the task name - * @return string */ public function getName(): string; /** * Check if the task should run at the current time - * @return bool */ public function shouldRun(): bool; /** * Execute the task - * @return void */ public function handle(): void; } diff --git a/src/Cron/CronLock.php b/src/Cron/CronLock.php index 590b8aec6..1e90b10a1 100644 --- a/src/Cron/CronLock.php +++ b/src/Cron/CronLock.php @@ -2,7 +2,11 @@ namespace Quantum\Cron; +use Quantum\Config\Exceptions\ConfigException; use Quantum\Cron\Exceptions\CronException; +use Quantum\App\Exceptions\BaseException; +use Quantum\Di\Exceptions\DiException; +use ReflectionException; /** * CronLock - file based lock with flock() @@ -17,17 +21,23 @@ class CronLock { private string $lockDirectory; + private string $taskName; + private string $lockFile; /** @var resource|null */ - private $lockHandle = null; + private $lockHandle; private bool $ownsLock = false; + private int $maxLockAge; private const DEFAULT_MAX_LOCK_AGE = 86400; + /** + * @throws BaseException|ConfigException|CronException|DiException|ReflectionException + */ public function __construct(string $taskName, ?string $lockDirectory = null, ?int $maxLockAge = null) { $this->taskName = $this->sanitizeTaskName($taskName); @@ -68,7 +78,7 @@ public function acquire(): bool } /** - * Update lock timestamp (useful for long-running jobs) + * Update the lock timestamp (useful for long-running jobs) */ public function refresh(): bool { @@ -89,6 +99,12 @@ public function getTimestamp(): int return $timestamp ?? 0; } + /** + * @throws BaseException + * @throws ConfigException + * @throws DiException + * @throws ReflectionException + */ public function release(): bool { if (!$this->ownsLock || $this->lockHandle === null) { @@ -111,6 +127,10 @@ public function release(): bool /** * Check if another process currently holds the lock. + * @throws BaseException + * @throws ConfigException + * @throws DiException + * @throws ReflectionException */ public function isLocked(): bool { @@ -151,7 +171,7 @@ private function sanitizeTaskName(string $taskName): string private function resolveLockDirectory(?string $lockDirectory): string { $path = $lockDirectory ?? cron_config('lock_path'); - return $path === null ? $this->getDefaultLockDirectory() : $path; + return $path ?? $this->getDefaultLockDirectory(); } private function getDefaultLockDirectory(): string @@ -159,6 +179,13 @@ private function getDefaultLockDirectory(): string return base_dir() . DS . 'runtime' . DS . 'cron' . DS . 'locks'; } + /** + * @throws BaseException + * @throws ConfigException + * @throws CronException + * @throws DiException + * @throws ReflectionException + */ private function ensureLockDirectoryExists(): void { if ($this->lockDirectory === '') { @@ -172,6 +199,13 @@ private function ensureLockDirectoryExists(): void } } + /** + * @throws BaseException + * @throws ConfigException + * @throws CronException + * @throws DiException + * @throws ReflectionException + */ private function createDirectory(string $directory): void { if (fs()->isDirectory($directory)) { @@ -190,8 +224,10 @@ private function createDirectory(string $directory): void } /** - * Removes stale lock files that are NOT currently locked by any process. - * Safe because we take LOCK_EX before removing. + * @throws BaseException + * @throws ConfigException + * @throws DiException + * @throws ReflectionException */ private function cleanupStaleLocks(): void { @@ -228,6 +264,9 @@ private function cleanupStaleLocks(): void } } + /** + * @param $handle + */ private function writeTimestampToHandle($handle): bool { if (ftruncate($handle, 0) === false) { @@ -251,6 +290,9 @@ private function writeTimestampToHandle($handle): bool return true; } + /** + * @param $handle + */ private function readTimestampFromHandle($handle): ?int { if (rewind($handle) === false) { @@ -261,7 +303,7 @@ private function readTimestampFromHandle($handle): ?int return null; } - $timestamp = (int) trim((string) $content); + $timestamp = (int) trim($content); return $timestamp > 0 ? $timestamp : null; } } diff --git a/src/Cron/CronManager.php b/src/Cron/CronManager.php index 8e107bc8b..8f564f504 100644 --- a/src/Cron/CronManager.php +++ b/src/Cron/CronManager.php @@ -14,10 +14,14 @@ namespace Quantum\Cron; +use Quantum\Config\Exceptions\ConfigException; use Quantum\Cron\Contracts\CronTaskInterface; use Quantum\Logger\Factories\LoggerFactory; use Quantum\Cron\Exceptions\CronException; +use Quantum\App\Exceptions\BaseException; +use Quantum\Di\Exceptions\DiException; use Quantum\Logger\Logger; +use ReflectionException; /** * Class CronManager @@ -29,7 +33,7 @@ class CronManager * Loaded tasks * @var array */ - private $tasks = []; + private array $tasks = []; /** * Cron directory path @@ -39,9 +43,8 @@ class CronManager /** * Execution statistics - * @var array */ - private $stats = [ + private array $stats = [ 'total' => 0, 'executed' => 0, 'skipped' => 0, @@ -51,7 +54,6 @@ class CronManager /** * CronManager constructor - * @param string|null $cronDirectory */ public function __construct(?string $cronDirectory = null) { @@ -60,10 +62,13 @@ public function __construct(?string $cronDirectory = null) } /** - * Load tasks from cron directory + * Load tasks from the cron directory * @return void * @throws CronException */ + /** + * @throws CronException|BaseException|ConfigException|DiException|ReflectionException + */ public function loadTasks(): void { if (!fs()->isDirectory($this->cronDirectory)) { @@ -83,10 +88,7 @@ public function loadTasks(): void } /** - * Load a single task from file - * @param string $file - * @return void - * @throws CronException + * @throws BaseException|ConfigException|CronException|DiException|ReflectionException */ private function loadTaskFromFile(string $file): void { @@ -104,9 +106,7 @@ private function loadTaskFromFile(string $file): void } /** - * Create task from array definition - * @param array $definition - * @return CronTask + * Create a task from array definition * @throws CronException */ private function createTaskFromArray(array $definition): CronTask @@ -127,6 +127,10 @@ private function createTaskFromArray(array $definition): CronTask * @param bool $force Ignore locks * @return array Statistics */ + /** + * @return array|int[] + * @throws BaseException|ConfigException|CronException|DiException|ReflectionException + */ public function runDueTasks(bool $force = false): array { $this->loadTasks(); @@ -144,10 +148,7 @@ public function runDueTasks(bool $force = false): array /** * Run a specific task by name - * @param string $taskName - * @param bool $force Ignore locks - * @return void - * @throws CronException + * @throws BaseException|ConfigException|CronException|DiException|ReflectionException */ public function runTaskByName(string $taskName, bool $force = false): void { @@ -162,9 +163,7 @@ public function runTaskByName(string $taskName, bool $force = false): void /** * Run a single task - * @param CronTaskInterface $task - * @param bool $force Ignore locks - * @return void + * @throws BaseException|ConfigException|CronException|DiException|ReflectionException */ private function runTask(CronTaskInterface $task, bool $force = false): void { @@ -209,7 +208,6 @@ public function getTasks(): array /** * Get execution statistics - * @return array */ public function getStats(): array { @@ -218,7 +216,6 @@ public function getStats(): array /** * Get default cron directory - * @return string */ private function getDefaultCronDirectory(): string { @@ -227,10 +224,6 @@ private function getDefaultCronDirectory(): string /** * Log a message - * @param string $level - * @param string $message - * @param array $context - * @return void */ private function log(string $level, string $message, array $context = []): void { diff --git a/src/Cron/CronTask.php b/src/Cron/CronTask.php index f48bdfd7c..7ac24f12e 100644 --- a/src/Cron/CronTask.php +++ b/src/Cron/CronTask.php @@ -26,15 +26,13 @@ class CronTask implements CronTaskInterface { /** * Cron expression instance - * @var CronExpression */ - private $cronExpression; + private ?CronExpression $cronExpression = null; /** * Task name - * @var string */ - private $name; + private string $name; /** * Task callback @@ -44,9 +42,6 @@ class CronTask implements CronTaskInterface /** * CronTask constructor - * @param string $name - * @param string $expression - * @param callable $callback * @throws CronException */ public function __construct(string $name, string $expression, callable $callback) @@ -95,7 +90,6 @@ public function handle(): void /** * Get the next run date - * @return \DateTime */ public function getNextRunDate(): \DateTime { @@ -104,7 +98,6 @@ public function getNextRunDate(): \DateTime /** * Get the previous run date - * @return \DateTime */ public function getPreviousRunDate(): \DateTime { diff --git a/src/Cron/Exceptions/CronException.php b/src/Cron/Exceptions/CronException.php index db278a6a9..9a94dbad6 100644 --- a/src/Cron/Exceptions/CronException.php +++ b/src/Cron/Exceptions/CronException.php @@ -24,8 +24,6 @@ class CronException extends \Exception { /** * Task not found exception - * @param string $taskName - * @return CronException */ public static function taskNotFound(string $taskName): CronException { @@ -34,8 +32,6 @@ public static function taskNotFound(string $taskName): CronException /** * Invalid cron expression exception - * @param string $expression - * @return CronException */ public static function invalidExpression(string $expression): CronException { @@ -44,8 +40,6 @@ public static function invalidExpression(string $expression): CronException /** * Lock acquire failed exception - * @param string $taskName - * @return CronException */ public static function lockAcquireFailed(string $taskName): CronException { @@ -54,9 +48,6 @@ public static function lockAcquireFailed(string $taskName): CronException /** * Task execution failed exception - * @param string $taskName - * @param string $error - * @return CronException */ public static function taskExecutionFailed(string $taskName, string $error): CronException { @@ -65,8 +56,6 @@ public static function taskExecutionFailed(string $taskName, string $error): Cro /** * Invalid task file exception - * @param string $file - * @return CronException */ public static function invalidTaskFile(string $file): CronException { @@ -75,8 +64,6 @@ public static function invalidTaskFile(string $file): CronException /** * Cron directory not found exception - * @param string $directory - * @return CronException */ public static function cronDirectoryNotFound(string $directory): CronException { @@ -85,8 +72,6 @@ public static function cronDirectoryNotFound(string $directory): CronException /** * Lock directory not writable exception - * @param string $directory - * @return CronException */ public static function lockDirectoryNotWritable(string $directory): CronException { diff --git a/src/Cron/Helpers/cron.php b/src/Cron/Helpers/cron.php index 844c0b40e..feb3c925f 100644 --- a/src/Cron/Helpers/cron.php +++ b/src/Cron/Helpers/cron.php @@ -20,7 +20,6 @@ if (!function_exists('cron_config')) { /** * Resolve cron configuration value - * @param string $key * @param mixed $default * @return mixed|null */ @@ -47,8 +46,6 @@ function cron_config(string $key, $default = null) if (!function_exists('cron_manager')) { /** * Get CronManager instance - * @param string|null $cronDirectory - * @return CronManager */ function cron_manager(?string $cronDirectory = null): CronManager { @@ -59,10 +56,6 @@ function cron_manager(?string $cronDirectory = null): CronManager if (!function_exists('cron_task')) { /** * Create a new cron task - * @param string $name - * @param string $expression - * @param callable $callback - * @return CronTask * @throws \Quantum\Cron\Exceptions\CronException */ function cron_task(string $name, string $expression, callable $callback): CronTask @@ -74,8 +67,6 @@ function cron_task(string $name, string $expression, callable $callback): CronTa if (!function_exists('schedule')) { /** * Create a new schedule with fluent API - * @param string $name - * @return Schedule */ function schedule(string $name): Schedule { diff --git a/src/Cron/Schedule.php b/src/Cron/Schedule.php index 154cee05c..35e12c9d8 100644 --- a/src/Cron/Schedule.php +++ b/src/Cron/Schedule.php @@ -25,25 +25,22 @@ class Schedule { /** * Task name - * @var string */ - private $name; + private string $name; /** * Cron expression - * @var string */ - private $expression; + private ?string $expression = null; /** * Task callback * @var callable|null */ - private $callback = null; + private $callback; /** * Schedule constructor - * @param string $name */ public function __construct(string $name) { @@ -52,7 +49,6 @@ public function __construct(string $name) /** * Run the task every minute - * @return self */ public function everyMinute(): self { @@ -62,7 +58,6 @@ public function everyMinute(): self /** * Run the task every five minutes - * @return self */ public function everyFiveMinutes(): self { @@ -72,7 +67,6 @@ public function everyFiveMinutes(): self /** * Run the task every ten minutes - * @return self */ public function everyTenMinutes(): self { @@ -82,7 +76,6 @@ public function everyTenMinutes(): self /** * Run the task every fifteen minutes - * @return self */ public function everyFifteenMinutes(): self { @@ -92,7 +85,6 @@ public function everyFifteenMinutes(): self /** * Run the task every thirty minutes - * @return self */ public function everyThirtyMinutes(): self { @@ -102,7 +94,6 @@ public function everyThirtyMinutes(): self /** * Run the task hourly - * @return self */ public function hourly(): self { @@ -112,8 +103,6 @@ public function hourly(): self /** * Run the task hourly at a specific minute - * @param int $minute - * @return self */ public function hourlyAt(int $minute): self { @@ -123,7 +112,6 @@ public function hourlyAt(int $minute): self /** * Run the task every two hours - * @return self */ public function everyTwoHours(): self { @@ -133,7 +121,6 @@ public function everyTwoHours(): self /** * Run the task every three hours - * @return self */ public function everyThreeHours(): self { @@ -143,7 +130,6 @@ public function everyThreeHours(): self /** * Run the task every four hours - * @return self */ public function everyFourHours(): self { @@ -153,7 +139,6 @@ public function everyFourHours(): self /** * Run the task every six hours - * @return self */ public function everySixHours(): self { @@ -163,7 +148,6 @@ public function everySixHours(): self /** * Run the task daily - * @return self */ public function daily(): self { @@ -174,7 +158,6 @@ public function daily(): self /** * Run the task daily at a specific time * @param string $time Format: "HH:MM" - * @return self */ public function dailyAt(string $time): self { @@ -187,9 +170,6 @@ public function dailyAt(string $time): self /** * Run the task twice daily - * @param int $firstHour - * @param int $secondHour - * @return self */ public function twiceDaily(int $firstHour = 1, int $secondHour = 13): self { @@ -199,7 +179,6 @@ public function twiceDaily(int $firstHour = 1, int $secondHour = 13): self /** * Run the task weekly - * @return self */ public function weekly(): self { @@ -211,7 +190,6 @@ public function weekly(): self * Run the task weekly on a specific day and time * @param int $dayOfWeek 0-6 (Sunday = 0) * @param string $time Format: "HH:MM" - * @return self */ public function weeklyOn(int $dayOfWeek, string $time = '0:00'): self { @@ -224,7 +202,6 @@ public function weeklyOn(int $dayOfWeek, string $time = '0:00'): self /** * Run the task monthly - * @return self */ public function monthly(): self { @@ -234,9 +211,7 @@ public function monthly(): self /** * Run the task monthly on a specific day and time - * @param int $dayOfMonth * @param string $time Format: "HH:MM" - * @return self */ public function monthlyOn(int $dayOfMonth = 1, string $time = '0:00'): self { @@ -249,10 +224,6 @@ public function monthlyOn(int $dayOfMonth = 1, string $time = '0:00'): self /** * Run the task twice monthly - * @param int $firstDay - * @param int $secondDay - * @param string $time - * @return self */ public function twiceMonthly(int $firstDay = 1, int $secondDay = 16, string $time = '0:00'): self { @@ -265,7 +236,6 @@ public function twiceMonthly(int $firstDay = 1, int $secondDay = 16, string $tim /** * Run the task quarterly - * @return self */ public function quarterly(): self { @@ -275,7 +245,6 @@ public function quarterly(): self /** * Run the task yearly - * @return self */ public function yearly(): self { @@ -285,7 +254,6 @@ public function yearly(): self /** * Run the task on weekdays - * @return self */ public function weekdays(): self { @@ -295,7 +263,6 @@ public function weekdays(): self /** * Run the task on weekends - * @return self */ public function weekends(): self { @@ -305,7 +272,6 @@ public function weekends(): self /** * Run the task on Mondays - * @return self */ public function mondays(): self { @@ -314,7 +280,6 @@ public function mondays(): self /** * Run the task on Tuesdays - * @return self */ public function tuesdays(): self { @@ -323,7 +288,6 @@ public function tuesdays(): self /** * Run the task on Wednesdays - * @return self */ public function wednesdays(): self { @@ -332,7 +296,6 @@ public function wednesdays(): self /** * Run the task on Thursdays - * @return self */ public function thursdays(): self { @@ -341,7 +304,6 @@ public function thursdays(): self /** * Run the task on Fridays - * @return self */ public function fridays(): self { @@ -350,7 +312,6 @@ public function fridays(): self /** * Run the task on Saturdays - * @return self */ public function saturdays(): self { @@ -359,7 +320,6 @@ public function saturdays(): self /** * Run the task on Sundays - * @return self */ public function sundays(): self { @@ -369,7 +329,6 @@ public function sundays(): self /** * Run the task on specific days * @param int|array $days - * @return self */ public function days($days): self { @@ -381,7 +340,6 @@ public function days($days): self /** * Set the time for the task * @param string $time Format: "HH:MM" - * @return self */ public function at(string $time): self { @@ -400,8 +358,6 @@ public function at(string $time): self /** * Set custom cron expression - * @param string $expression - * @return self */ public function cron(string $expression): self { @@ -411,8 +367,6 @@ public function cron(string $expression): self /** * Set the callback for the task - * @param callable $callback - * @return self */ public function call(callable $callback): self { @@ -422,7 +376,6 @@ public function call(callable $callback): self /** * Build and return the CronTask - * @return CronTask * @throws CronException */ public function build(): CronTask @@ -440,7 +393,6 @@ public function build(): CronTask /** * Get the cron expression - * @return string|null */ public function getExpression(): ?string { diff --git a/src/Csrf/Csrf.php b/src/Csrf/Csrf.php index 053a9f64a..069217953 100644 --- a/src/Csrf/Csrf.php +++ b/src/Csrf/Csrf.php @@ -39,19 +39,10 @@ class Csrf */ public const TOKEN_KEY = 'csrf-token'; - /** - * @var Csrf|null - */ private static ?Csrf $instance = null; - /** - * @var Session - */ private Session $storage; - /** - * @var Hasher - */ private Hasher $hasher; /** @@ -68,7 +59,6 @@ private function __construct() /** * Csrf instance - * @return Csrf */ public static function getInstance(): Csrf { @@ -81,8 +71,6 @@ public static function getInstance(): Csrf /** * Generates the CSRF token or returns the previously generated one - * @param string $key - * @return string|null */ public function generateToken(string $key): ?string { @@ -95,8 +83,6 @@ public function generateToken(string $key): ?string /** * Checks the token - * @param Request|null $request - * @return bool * @throws CsrfException */ public function checkToken(?Request $request): bool diff --git a/src/Csrf/Exceptions/CsrfException.php b/src/Csrf/Exceptions/CsrfException.php index 38b4e61e0..189f0309d 100644 --- a/src/Csrf/Exceptions/CsrfException.php +++ b/src/Csrf/Exceptions/CsrfException.php @@ -25,9 +25,6 @@ */ class CsrfException extends BaseException { - /** - * @return CsrfException - */ public static function tokenNotFound(): self { return new self( @@ -36,9 +33,6 @@ public static function tokenNotFound(): self ); } - /** - * @return CsrfException - */ public static function tokenNotMatched(): self { return new self( diff --git a/src/Csrf/Helpers/csrf.php b/src/Csrf/Helpers/csrf.php index 7aa60deaf..ccce8dba6 100644 --- a/src/Csrf/Helpers/csrf.php +++ b/src/Csrf/Helpers/csrf.php @@ -18,7 +18,6 @@ /** * Gets the Csrf instance - * @return Csrf */ function csrf(): Csrf { @@ -27,7 +26,6 @@ function csrf(): Csrf /** * Generates the CSRF token - * @return string|null * @throws BaseException */ function csrf_token(): ?string diff --git a/src/Database/Adapters/Idiorm/IdiormDbal.php b/src/Database/Adapters/Idiorm/IdiormDbal.php index 6027a4bef..ffd294001 100644 --- a/src/Database/Adapters/Idiorm/IdiormDbal.php +++ b/src/Database/Adapters/Idiorm/IdiormDbal.php @@ -89,33 +89,29 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * Hidden fields - * @var array */ - private $hidden; + private array $hidden; /** * Idiorm Patch object - * @var IdiormPatch */ - private $ormPatch = null; + private ?IdiormPatch $ormPatch = null; /** * ORM Model - * @var ORM|null */ - private $ormModel; + private ?ORM $ormModel = null; /** * Active connection - * @var array|null */ - private static $connection = null; + private static ?array $connection = null; /** * Operators map * @var array */ - private $operators = [ + private array $operators = [ '=' => 'where_equal', '!=' => 'where_not_equal', '>' => 'where_gt', @@ -133,17 +129,9 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * ORM Class - * @var string */ - private static $ormClass = ORM::class; + private static string $ormClass = ORM::class; - /** - * @param string $table - * @param string|null $modelName - * @param string $idColumn - * @param array $foreignKeys - * @param array $hidden - */ public function __construct( string $table, ?string $modelName = null, @@ -161,7 +149,7 @@ public function __construct( /** * @inheritDoc */ - public static function connect(array $config) + public static function connect(array $config): void { $driver = $config['driver'] ?? ''; $charset = $config['charset'] ?? self::DEFAULT_CHARSET; @@ -184,7 +172,7 @@ public static function getConnection(): ?array /** * @inheritDoc */ - public static function disconnect() + public static function disconnect(): void { self::$connection = null; (self::$ormClass)::reset_db(); @@ -200,7 +188,6 @@ public function getTable(): string /** * Gets the ORM model - * @return ORM * @throws BaseException */ public function getOrmModel(): ORM @@ -218,7 +205,6 @@ public function getOrmModel(): ORM /** * Gets foreign keys - * @return array */ public function getForeignKeys(): array { @@ -227,7 +213,6 @@ public function getForeignKeys(): array /** * Gets the associated model name - * @return string */ public function getModelName(): string { @@ -247,19 +232,11 @@ public function truncate(): bool } } - /** - * @param ORM $ormModel - */ protected function updateOrmModel(ORM $ormModel) { $this->ormModel = $ormModel; } - /** - * @param string $driver - * @param array $config - * @return array - */ protected static function getBaseConfig(string $driver, array $config): array { return [ @@ -269,12 +246,6 @@ protected static function getBaseConfig(string $driver, array $config): array ]; } - /** - * @param string $driver - * @param array $config - * @param string $charset - * @return array - */ protected static function getDriverConfig(string $driver, array $config, string $charset): array { if ($driver === self::DRIVER_MYSQL || $driver === self::DRIVER_PGSQL) { @@ -294,9 +265,6 @@ protected static function getDriverConfig(string $driver, array $config, string /** * Builds connection string - * @param string $driver - * @param array $config - * @return string */ protected static function buildConnectionString(string $driver, array $config): string { diff --git a/src/Database/Adapters/Idiorm/IdiormPatch.php b/src/Database/Adapters/Idiorm/IdiormPatch.php index cec72f7a3..c75b686a1 100644 --- a/src/Database/Adapters/Idiorm/IdiormPatch.php +++ b/src/Database/Adapters/Idiorm/IdiormPatch.php @@ -15,6 +15,7 @@ namespace Quantum\Database\Adapters\Idiorm; use ORM; +use RuntimeException; /** * Class IdiormPatch @@ -22,21 +23,14 @@ */ class IdiormPatch extends ORM { - /** - * @var object - */ - private $ormModel; + private ?object $ormModel = null; - /** - * @var object - */ - private static $instance = null; + private static ?IdiormPatch $instance = null; /** * Get Instance - * @return IdiormPatch|object */ - public static function getInstance() + public static function getInstance(): IdiormPatch { if (self::$instance == null) { self::$instance = new self('dummy'); @@ -47,8 +41,6 @@ public static function getInstance() /** * Set ORM Object - * @param object $ormModel - * @return $this */ public function use(object $ormModel): IdiormPatch { @@ -58,10 +50,6 @@ public function use(object $ormModel): IdiormPatch /** * Add an LEFT JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $table_alias - * @return object */ public function leftJoin(string $table, array $constraint, ?string $table_alias = null): object { @@ -70,10 +58,6 @@ public function leftJoin(string $table, array $constraint, ?string $table_alias /** * Add an RIGHT JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $table_alias - * @return object */ public function rightJoin(string $table, array $constraint, ?string $table_alias = null): object { @@ -82,14 +66,12 @@ public function rightJoin(string $table, array $constraint, ?string $table_alias /** * Add Join - * @param string $operator - * @param string $table - * @param array $constraint - * @param string|null $table_alias - * @return object */ public function addJoin(string $operator, string $table, array $constraint, ?string $table_alias = null): object { + if ($this->ormModel === null) { + throw new RuntimeException('ORM model is not set. Call use() method first.'); + } return $this->ormModel->_add_join_source($operator, $table, $constraint, $table_alias); } } diff --git a/src/Database/Adapters/Idiorm/Statements/Criteria.php b/src/Database/Adapters/Idiorm/Statements/Criteria.php index cc17973a7..6df57a07d 100644 --- a/src/Database/Adapters/Idiorm/Statements/Criteria.php +++ b/src/Database/Adapters/Idiorm/Statements/Criteria.php @@ -91,10 +91,7 @@ public function isNotNull(string $column): DbalInterface /** * Adds Criteria - * @param string $column - * @param string $operator * @param mixed $value - * @param string|null $func * @throws DatabaseException */ protected function addCriteria(string $column, string $operator, $value, ?string $func = null) @@ -110,7 +107,6 @@ protected function addCriteria(string $column, string $operator, $value, ?string /** * Adds one or more OR criteria in brackets - * @param array $orCriterias * @throws DatabaseException */ protected function orCriteria(array $orCriterias) diff --git a/src/Database/Adapters/Idiorm/Statements/Join.php b/src/Database/Adapters/Idiorm/Statements/Join.php index 0beecf7bc..27ba0c4b8 100644 --- a/src/Database/Adapters/Idiorm/Statements/Join.php +++ b/src/Database/Adapters/Idiorm/Statements/Join.php @@ -107,9 +107,6 @@ public function joinTo(DbModel $relatedModel, bool $switch = true): DbalInterfac } /** - * @param DbModel $relatedModel - * @param array $relation - * @return void * @throws BaseException */ protected function applyHasRelation(DbModel $relatedModel, array $relation): void @@ -125,9 +122,6 @@ protected function applyHasRelation(DbModel $relatedModel, array $relation): voi } /** - * @param DbModel $relatedModel - * @param array $relation - * @return void * @throws BaseException */ protected function applyBelongsTo(DbModel $relatedModel, array $relation): void @@ -143,8 +137,6 @@ protected function applyBelongsTo(DbModel $relatedModel, array $relation): void } /** - * @param DbModel $modelToJoin - * @return array * @throws ModelException */ private function getValidatedRelation(DbModel $modelToJoin): array diff --git a/src/Database/Adapters/Idiorm/Statements/Query.php b/src/Database/Adapters/Idiorm/Statements/Query.php index b82621823..4a408059b 100644 --- a/src/Database/Adapters/Idiorm/Statements/Query.php +++ b/src/Database/Adapters/Idiorm/Statements/Query.php @@ -106,8 +106,6 @@ public static function queryLog(): array /** * Fetches columns of the table - * @param string $table - * @return array * @throws DatabaseException */ public static function fetchColumns(string $table): array diff --git a/src/Database/Adapters/Idiorm/Statements/Reducer.php b/src/Database/Adapters/Idiorm/Statements/Reducer.php index 1da757fc3..03df1588e 100644 --- a/src/Database/Adapters/Idiorm/Statements/Reducer.php +++ b/src/Database/Adapters/Idiorm/Statements/Reducer.php @@ -16,6 +16,7 @@ use Quantum\Database\Exceptions\DatabaseException; use Quantum\Database\Contracts\DbalInterface; +use Quantum\App\Exceptions\BaseException; use RecursiveIteratorIterator; use RecursiveArrayIterator; @@ -27,11 +28,11 @@ trait Reducer { /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function select(...$columns): DbalInterface { - array_walk($columns, function (&$column) { + array_walk($columns, function (&$column): void { if (is_array($column)) { $column = array_flip($column); } @@ -46,7 +47,7 @@ public function select(...$columns): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function groupBy(string $column): DbalInterface { @@ -56,7 +57,7 @@ public function groupBy(string $column): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function orderBy(string $column, string $direction): DbalInterface { @@ -74,7 +75,7 @@ public function orderBy(string $column, string $direction): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function offset(int $offset): DbalInterface { @@ -84,7 +85,7 @@ public function offset(int $offset): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function limit(int $limit): DbalInterface { diff --git a/src/Database/Adapters/Idiorm/Statements/Result.php b/src/Database/Adapters/Idiorm/Statements/Result.php index f95b6409d..b33437632 100644 --- a/src/Database/Adapters/Idiorm/Statements/Result.php +++ b/src/Database/Adapters/Idiorm/Statements/Result.php @@ -16,6 +16,7 @@ use Quantum\Database\Exceptions\DatabaseException; use Quantum\Database\Contracts\DbalInterface; +use Quantum\App\Exceptions\BaseException; /** * Trait Result @@ -25,11 +26,11 @@ trait Result { /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function get(): array { - return array_map(function ($element) { + return array_map(function ($element): object { $item = clone $this; $item->updateOrmModel($element); return $item; @@ -38,7 +39,7 @@ public function get(): array /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function findOne(int $id): DbalInterface { @@ -53,7 +54,7 @@ public function findOne(int $id): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function findOneBy(string $column, $value): DbalInterface { @@ -67,7 +68,7 @@ public function findOneBy(string $column, $value): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function first(): DbalInterface { @@ -81,7 +82,7 @@ public function first(): DbalInterface /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function count(): int { @@ -90,7 +91,7 @@ public function count(): int /** * @inheritDoc - * @throws DatabaseException + * @throws DatabaseException|BaseException */ public function asArray(): array { @@ -105,7 +106,6 @@ public function asArray(): array /** * @param $result - * @return array */ public function setHidden($result): array { diff --git a/src/Database/Adapters/Idiorm/Statements/Transaction.php b/src/Database/Adapters/Idiorm/Statements/Transaction.php index fe2fa3cd0..4c8629fc4 100644 --- a/src/Database/Adapters/Idiorm/Statements/Transaction.php +++ b/src/Database/Adapters/Idiorm/Statements/Transaction.php @@ -27,7 +27,7 @@ trait Transaction * Begins a transaction * @throws BaseException */ - public static function beginTransaction() + public static function beginTransaction(): void { if (!self::getConnection()) { throw DatabaseException::missingConfig('database'); diff --git a/src/Database/Adapters/Sleekdb/SleekDbal.php b/src/Database/Adapters/Sleekdb/SleekDbal.php index b0e317295..5ec34e205 100644 --- a/src/Database/Adapters/Sleekdb/SleekDbal.php +++ b/src/Database/Adapters/Sleekdb/SleekDbal.php @@ -41,30 +41,18 @@ class SleekDbal implements DbalInterface use Reducer; use Join; - /** - * @var bool - */ - protected $isNew = false; + protected bool $isNew = false; - /** - * @var array - */ - protected $data = []; + protected array $data = []; /** * @var array */ protected $modifiedFields = []; - /** - * @var array - */ - protected $criterias = []; + protected array $criterias = []; - /** - * @var array - */ - protected $havings = []; + protected array $havings = []; /** * @var array @@ -98,27 +86,23 @@ class SleekDbal implements DbalInterface /** * Associated model name - * @var string */ - private $modelName; + private ?string $modelName; /** * The database table associated with model - * @var string */ - private $table; + private string $table; /** * ID column of table - * @var string */ - private $idColumn; + private string $idColumn; /** * Foreign keys - * @var array */ - private $foreignKeys; + private array $foreignKeys; /** * Hidden fields @@ -128,26 +112,21 @@ class SleekDbal implements DbalInterface /** * ORM Model - * @var object|null */ - private $ormModel = null; + private ?Store $ormModel = null; - /** - * @var QueryBuilder|null - */ - private $queryBuilder; + private ?QueryBuilder $queryBuilder = null; /** * Active connection - * @var array|null */ - private static $connection = null; + private static ?array $connection = null; /** * Operators map * @var string[] */ - private $operators = [ + private array $operators = [ '=', '!=', '>', '>=', '<', '<=', @@ -156,13 +135,6 @@ class SleekDbal implements DbalInterface 'BETWEEN', 'NOT BETWEEN', ]; - /** - * @param string $table - * @param string|null $modelName - * @param string $idColumn - * @param array $foreignKeys - * @param array $hidden - */ public function __construct( string $table, ?string $modelName = null, @@ -185,30 +157,25 @@ public function __get(string $key) /** * @inheritDoc */ - public static function connect(array $config) + public static function connect(array $config): void { self::$connection = $config; } - public function setData(array $data) + public function setData(array $data): void { $this->data = $data; } /** * @param $modifiedFields - * @return void */ - public function setModifiedFields($modifiedFields) + public function setModifiedFields($modifiedFields): void { $this->modifiedFields = $modifiedFields; } - /** - * @param bool $isNew - * @return void - */ - public function setIsNew(bool $isNew) + public function setIsNew(bool $isNew): void { $this->isNew = $isNew; } @@ -224,7 +191,7 @@ public static function getConnection(): ?array /** * @inheritDoc */ - public static function disconnect() + public static function disconnect(): void { self::$connection = null; } @@ -239,7 +206,6 @@ public function getTable(): string /** * Gets the ORM model - * @return Store * @throws DatabaseException * @throws IOException * @throws InvalidArgumentException @@ -267,10 +233,7 @@ public function getOrmModel(): Store return $this->ormModel; } - /** - * @param array|null $modelData - */ - public function updateOrmModel(?array $modelData) + public function updateOrmModel(?array $modelData): void { $this->data = $modelData; $this->modifiedFields = $modelData; @@ -292,7 +255,6 @@ public function truncate(): bool /** * Gets the query builder object - * @return QueryBuilder * @throws BaseException * @throws DatabaseException * @throws IOException @@ -343,7 +305,6 @@ public function getBuilder(): QueryBuilder /** * Gets foreign keys - * @return array */ public function getForeignKeys(): array { @@ -352,7 +313,6 @@ public function getForeignKeys(): array /** * Gets the associated model name - * @return string */ public function getModelName(): string { diff --git a/src/Database/Adapters/Sleekdb/Statements/Criteria.php b/src/Database/Adapters/Sleekdb/Statements/Criteria.php index ba790b5bf..66ef06128 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Criteria.php +++ b/src/Database/Adapters/Sleekdb/Statements/Criteria.php @@ -90,7 +90,6 @@ public function isNotNull(string $column): DbalInterface /** * Adds one or more OR criteria in brackets - * @param array $orCriterias * @throws DatabaseException */ protected function orCriteria(array $orCriterias) diff --git a/src/Database/Adapters/Sleekdb/Statements/Join.php b/src/Database/Adapters/Sleekdb/Statements/Join.php index 96201e07e..36966d058 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Join.php +++ b/src/Database/Adapters/Sleekdb/Statements/Join.php @@ -45,7 +45,7 @@ public function joinTo(DbModel $model, bool $switch = true): DbalInterface * Starts to apply joins * @throws ModelException */ - private function applyJoins() + private function applyJoins(): void { if (!empty($this->joins)) { $this->applyJoin($this->queryBuilder, $this, $this->joins[0]); @@ -54,11 +54,6 @@ private function applyJoins() /** * Apply the join to query builder - * @param QueryBuilder $queryBuilder - * @param SleekDbal $currentItem - * @param array $nextItem - * @param int $level - * @return QueryBuilder * @throws ModelException */ private function applyJoin(QueryBuilder $queryBuilder, SleekDbal $currentItem, array $nextItem, int $level = 1): QueryBuilder @@ -96,11 +91,6 @@ private function applyJoin(QueryBuilder $queryBuilder, SleekDbal $currentItem, a /** * Apply join condition for JOINTO type - * @param QueryBuilder $queryBuilder - * @param DbModel $relatedModel - * @param SleekDbal $currentModel - * @param array $currentItem - * @return void * @throws InvalidArgumentException * @throws ModelException */ @@ -124,10 +114,6 @@ private function applyJoinTo(QueryBuilder $queryBuilder, DbModel $relatedModel, } /** - * @param QueryBuilder $queryBuilder - * @param array $currentItem - * @param array $relation - * @return void * @throws InvalidArgumentException */ private function applyHasRelation(QueryBuilder $queryBuilder, array $currentItem, array $relation): void @@ -140,11 +126,6 @@ private function applyHasRelation(QueryBuilder $queryBuilder, array $currentItem } /** - * @param QueryBuilder $queryBuilder - * @param array $currentItem - * @param array $relation - * @param SleekDbal $currentModel - * @return void * @throws InvalidArgumentException * @throws ModelException */ @@ -162,9 +143,6 @@ private function applyBelongsTo(QueryBuilder $queryBuilder, array $currentItem, } /** - * @param SleekDbal $currentModel - * @param DbModel $relatedModel - * @return array * @throws ModelException */ private function getValidatedRelation(SleekDbal $currentModel, DbModel $relatedModel): array diff --git a/src/Database/Adapters/Sleekdb/Statements/Model.php b/src/Database/Adapters/Sleekdb/Statements/Model.php index fb0047c80..94158673a 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Model.php +++ b/src/Database/Adapters/Sleekdb/Statements/Model.php @@ -14,12 +14,13 @@ namespace Quantum\Database\Adapters\Sleekdb\Statements; -use Quantum\Database\Exceptions\DatabaseException; -use Quantum\Database\Contracts\DbalInterface; use SleekDB\Exceptions\InvalidConfigurationException; +use Quantum\Database\Exceptions\DatabaseException; use SleekDB\Exceptions\InvalidArgumentException; +use Quantum\Database\Contracts\DbalInterface; use SleekDB\Exceptions\IdNotAllowedException; use Quantum\Model\Exceptions\ModelException; +use Quantum\App\Exceptions\BaseException; use SleekDB\Exceptions\JsonException; use SleekDB\Exceptions\IOException; @@ -35,6 +36,7 @@ trait Model public function create(): DbalInterface { $this->isNew = true; + $this->modifiedFields = []; return $this; } @@ -58,7 +60,7 @@ public function prop(string $key, $value = null) * @throws IdNotAllowedException * @throws InvalidArgumentException * @throws InvalidConfigurationException - * @throws JsonException + * @throws JsonException|BaseException */ public function save(): bool { diff --git a/src/Database/Adapters/Sleekdb/Statements/Reducer.php b/src/Database/Adapters/Sleekdb/Statements/Reducer.php index 80d538b22..5b3a68e3f 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Reducer.php +++ b/src/Database/Adapters/Sleekdb/Statements/Reducer.php @@ -29,7 +29,7 @@ trait Reducer */ public function select(...$columns): DbalInterface { - array_walk($columns, function (&$column) { + array_walk($columns, function (&$column): void { if (is_array($column)) { $column = array_flip($column); } @@ -79,10 +79,6 @@ public function limit(int $limit): DbalInterface return $this; } - /** - * @param array $columns - * @return array - */ private function selectPatch(array $columns): array { foreach ($columns as &$column) { diff --git a/src/Database/Adapters/Sleekdb/Statements/Result.php b/src/Database/Adapters/Sleekdb/Statements/Result.php index 47cb69604..19f97946e 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Result.php +++ b/src/Database/Adapters/Sleekdb/Statements/Result.php @@ -36,7 +36,7 @@ abstract protected function resetBuilderState(): void; public function get(): array { try { - return array_map(function ($element) { + return array_map(function ($element): object { $item = clone $this; $item->updateOrmModel($element); return $item; @@ -139,7 +139,6 @@ public function asArray(): array /** * @param $result - * @return array */ public function setHidden($result): array { diff --git a/src/Database/Contracts/DbalInterface.php b/src/Database/Contracts/DbalInterface.php index 6348a7605..684b1b390 100644 --- a/src/Database/Contracts/DbalInterface.php +++ b/src/Database/Contracts/DbalInterface.php @@ -24,13 +24,11 @@ interface DbalInterface { /** * Connects to database - * @param array $config */ public static function connect(array $config); /** * Gets the active connection - * @return array|null */ public static function getConnection(): ?array; @@ -41,113 +39,85 @@ public static function disconnect(); /** * Gets the table - * @return string */ public function getTable(): string; /** * Selects the values from provided table columns * @param mixed $columns - * @return DbalInterface */ public function select(...$columns): DbalInterface; /** * Finds the record by primary key - * @param int $id - * @return DbalInterface */ public function findOne(int $id): DbalInterface; /** * Finds the record by given column and value - * @param string $column * @param mixed $value - * @return DbalInterface */ public function findOneBy(string $column, $value): DbalInterface; /** * Gets the first item - * @return DbalInterface */ public function first(): DbalInterface; /** * Adds a criteria to query - * @param string $column - * @param string $operator * @param mixed|null $value - * @return DbalInterface */ public function criteria(string $column, string $operator, $value = null): DbalInterface; /** * Adds criteria to query * @param array ...$criterias - * @return DbalInterface */ public function criterias(...$criterias): DbalInterface; /** * Adds having criteria to query - * @param string $column - * @param string $operator - * @param string|null $value - * @return DbalInterface */ public function having(string $column, string $operator, ?string $value = null): DbalInterface; /** * Groups the result by given column - * @param string $column - * @return DbalInterface */ public function groupBy(string $column): DbalInterface; /** * Orders the result by ascending or descending - * @param string $column - * @param string $direction - * @return DbalInterface */ public function orderBy(string $column, string $direction): DbalInterface; /** * Returns the result by given offset (works when limit also applied) - * @param integer $offset - * @return DbalInterface */ public function offset(int $offset): DbalInterface; /** * Returns the limited result set - * @param int $limit - * @return DbalInterface */ public function limit(int $limit): DbalInterface; /** * Gets the result set - * @return array */ public function get(): array; /** * Returns the count - * @return int */ public function count(): int; /** * Returns the data as array - * @return array */ public function asArray(): array; /** * Sets or gets the model property - * @param string $key * @param mixed|null $value * @return void|mixed|null */ @@ -155,53 +125,41 @@ public function prop(string $key, $value = null); /** * Creates new db record - * @return DbalInterface */ public function create(): DbalInterface; /** * Saves the data into the database - * @return bool */ public function save(): bool; /** * Deletes the record from the database - * @return bool */ public function delete(): bool; /** * Deletes all records from the table - * @return bool */ public function truncate(): bool; /** * Deletes many records by previously applied criteria - * @return bool */ public function deleteMany(): bool; /** * Joins two models - * @param DbModel $model - * @param bool $switch - * @return DbalInterface */ public function joinTo(DbModel $model, bool $switch = true): DbalInterface; /** * Checks if the given column is NULL - * @param string $column - * @return DbalInterface */ public function isNull(string $column): DbalInterface; /** * Checks if the given column is NOT NULL - * @param string $column - * @return DbalInterface */ public function isNotNull(string $column): DbalInterface; } diff --git a/src/Database/Contracts/RelationalInterface.php b/src/Database/Contracts/RelationalInterface.php index b08d01eaf..56f8e34fd 100644 --- a/src/Database/Contracts/RelationalInterface.php +++ b/src/Database/Contracts/RelationalInterface.php @@ -22,72 +22,47 @@ interface RelationalInterface { /** * Raw execute - * @param string $query - * @param array $parameters - * @return bool */ public static function execute(string $query, array $parameters = []): bool; /** * Raw query - * @param string $query - * @param array $parameters - * @return array */ public static function query(string $query, array $parameters = []): array; /** * Gets the last query executed - * @return string|null */ public static function lastQuery(): ?string; /** * Returns the PDOStatement instance last used - * @return object */ public static function lastStatement(): object; /** * Get an array containing all the queries * run on a specified connection up to now. - * @return array */ public static function queryLog(): array; /** * Adds a simple JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $tableAlias - * @return DbalInterface */ public function join(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an INNER JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $tableAlias - * @return DbalInterface */ public function innerJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an LEFT JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $tableAlias - * @return DbalInterface */ public function leftJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an RIGHT JOIN source to the query - * @param string $table - * @param array $constraint - * @param string|null $tableAlias - * @return DbalInterface */ public function rightJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; diff --git a/src/Database/Database.php b/src/Database/Database.php index 1d775abd6..a9233eac4 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -49,14 +49,10 @@ class Database /** * Database instance - * @var Database|null */ - private static $instance = null; + private static ?Database $instance = null; - /** - * @var string - */ - private $ormClass; + private string $ormClass; /** * @throws BaseException @@ -83,7 +79,6 @@ private function __construct() /** * Get Instance - * @return Database */ public static function getInstance(): Database { @@ -96,7 +91,6 @@ public static function getInstance(): Database /** * Gets the ORM class - * @return string */ public function getOrmClass(): string { @@ -105,7 +99,6 @@ public function getOrmClass(): string /** * Gets the DB configurations - * @return array|null */ public function getConfigs(): ?array { @@ -113,8 +106,6 @@ public function getConfigs(): ?array } /** - * @param string $adapter - * @return string * @throws BaseException */ private function getAdapterClass(string $adapter): string diff --git a/src/Database/Exceptions/DatabaseException.php b/src/Database/Exceptions/DatabaseException.php index f1e69358a..739237071 100644 --- a/src/Database/Exceptions/DatabaseException.php +++ b/src/Database/Exceptions/DatabaseException.php @@ -25,9 +25,6 @@ */ class DatabaseException extends BaseException { - /** - * @return DatabaseException - */ public static function incorrectConfig(): self { return new self( @@ -36,10 +33,6 @@ public static function incorrectConfig(): self ); } - /** - * @param string $operator - * @return DatabaseException - */ public static function operatorNotSupported(string $operator): self { return new self( @@ -48,10 +41,6 @@ public static function operatorNotSupported(string $operator): self ); } - /** - * @param string $name - * @return DatabaseException - */ public static function tableAlreadyExists(string $name): self { return new self( @@ -60,10 +49,6 @@ public static function tableAlreadyExists(string $name): self ); } - /** - * @param string $name - * @return DatabaseException - */ public static function tableDoesNotExists(string $name): self { return new self( diff --git a/src/Database/Factories/TableFactory.php b/src/Database/Factories/TableFactory.php index 41cb00e67..bf4ffc83a 100644 --- a/src/Database/Factories/TableFactory.php +++ b/src/Database/Factories/TableFactory.php @@ -26,8 +26,6 @@ class TableFactory { /** * Creates new table - * @param string $name - * @return Table * @throws DatabaseException */ public function create(string $name): Table @@ -41,8 +39,6 @@ public function create(string $name): Table /** * Get the table - * @param string $name - * @return Table * @throws DatabaseException */ public function get(string $name): Table @@ -56,9 +52,6 @@ public function get(string $name): Table /** * Renames the table - * @param string $oldName - * @param string $newName - * @return bool * @throws DatabaseException */ public function rename(string $oldName, string $newName): bool @@ -73,8 +66,6 @@ public function rename(string $oldName, string $newName): bool /** * Drops the table - * @param string $name - * @return bool * @throws DatabaseException */ public function drop(string $name): bool @@ -89,8 +80,6 @@ public function drop(string $name): bool /** * Checks if the DB table exists - * @param string $name - * @return bool */ public function checkTableExists(string $name): bool { @@ -105,8 +94,6 @@ public function checkTableExists(string $name): bool /** * Creates new Table instance - * @param string $name - * @return Table */ private function createInstance(string $name): Table { diff --git a/src/Database/Schemas/Column.php b/src/Database/Schemas/Column.php index af55a7f4e..b729aac80 100644 --- a/src/Database/Schemas/Column.php +++ b/src/Database/Schemas/Column.php @@ -117,80 +117,42 @@ class Column */ public const ATTR_ZEROFILL = 'UNSIGNED ZEROFILL'; - /** - * @var string - */ - private $name; + private string $name; - /** - * @var string - */ - private $newName; + private ?string $newName = null; - /** - * @var string - */ - private $type; + private ?string $type = null; /** * @var mixed */ private $constraint; - /** - * @var string - */ - private $attribute = null; + private ?string $attribute = null; - /** - * @var string - */ - private $nullable = 'NOT NULL'; + private string $nullable = 'NOT NULL'; /** * @var mixed */ private $default; - /** - * @var bool - */ - private $defaultQuoted = true; + private bool $defaultQuoted = true; - /** - * @var string - */ - private $autoincrement = null; + private ?string $autoincrement = null; - /** - * @var string - */ - private $indexKey = null; + private ?string $indexKey = null; - /** - * @var string - */ - private $indexName = null; + private ?string $indexName = null; - /** - * @var string - */ - private $indexDrop = null; + private ?string $indexDrop = null; - /** - * @var string - */ - private $comment; + private ?string $comment = null; - /** - * @var string - */ - private $afterColumn; + private ?string $afterColumn = null; /** * Column constructor. - * @param string $name - * @param string|null $type * @param mixed $constraint */ public function __construct(string $name, ?string $type = null, $constraint = null) @@ -205,8 +167,6 @@ public function __construct(string $name, ?string $type = null, $constraint = nu /** * Renames the column - * @param string $newName - * @return $this */ public function renameTo(string $newName): Column { @@ -222,8 +182,6 @@ public function indexDrop(string $indexName): Column /** * Gets the column property - * @param string $property - * @param string|null $action * @return mixed */ public function get(string $property, ?string $action = null) @@ -234,7 +192,7 @@ public function get(string $property, ?string $action = null) /** * Makes the column auto incremental */ - public function autoIncrement() + public function autoIncrement(): void { $this->autoincrement = 'AUTO_INCREMENT'; $this->primary(); @@ -243,16 +201,15 @@ public function autoIncrement() /** * Adds a primary key the column */ - public function primary() + public function primary(): void { $this->indexKey = Key::PRIMARY; } /** * Adds an index key to the column - * @param string|null $name */ - public function index(?string $name = null) + public function index(?string $name = null): void { $this->indexKey = Key::INDEX; @@ -263,9 +220,8 @@ public function index(?string $name = null) /** * Adds unique key to the column - * @param string|null $name */ - public function unique(?string $name = null) + public function unique(?string $name = null): void { $this->indexKey = Key::UNIQUE; @@ -276,9 +232,8 @@ public function unique(?string $name = null) /** * Adds a fulltext key the column - * @param string|null $name */ - public function fulltext(?string $name = null) + public function fulltext(?string $name = null): void { $this->indexKey = Key::FULLTEXT; @@ -289,9 +244,8 @@ public function fulltext(?string $name = null) /** * Adds a spatial key the column - * @param string|null $name */ - public function spatial(?string $name = null) + public function spatial(?string $name = null): void { $this->indexKey = Key::SPATIAL; @@ -302,9 +256,8 @@ public function spatial(?string $name = null) /** * Adds or removes nullable property - * @param bool $indeed */ - public function nullable(bool $indeed = true) + public function nullable(bool $indeed = true): void { $this->nullable = ($indeed ? '' : 'NOT ') . 'NULL'; } @@ -312,9 +265,8 @@ public function nullable(bool $indeed = true) /** * Adds default value to the column * @param mixed $value - * @param bool $quoted */ - public function default($value, bool $quoted = true) + public function default($value, bool $quoted = true): void { $this->default = $value; $this->defaultQuoted = $quoted; @@ -322,34 +274,30 @@ public function default($value, bool $quoted = true) /** * Adds or removes attribute to the column - * @param string|null $value */ - public function attribute(?string $value) + public function attribute(?string $value): void { $this->attribute = $value ? strtoupper($value) : null; } /** * Adds or removes comment to the column - * @param string|null $comment */ - public function comment(?string $comment) + public function comment(?string $comment): void { $this->comment = $comment; } /** * Adds column after a given column - * @param string $columnName */ - public function after(string $columnName) + public function after(string $columnName): void { $this->afterColumn = $columnName; } /** * Adds quotes on default value - * @return bool */ public function defaultQuoted(): bool { diff --git a/src/Database/Schemas/Table.php b/src/Database/Schemas/Table.php index 3ed8cafc7..cccf9029f 100644 --- a/src/Database/Schemas/Table.php +++ b/src/Database/Schemas/Table.php @@ -60,24 +60,12 @@ class Table */ public const RENAME = 4; - /** - * @var string - */ private string $name; - /** - * @var string - */ private string $newName = ''; - /** - * @var int|null - */ private ?int $action = null; - /** - * @var array - */ private array $columns = []; /** @@ -92,7 +80,6 @@ class Table /** * Table constructor. - * @param string $name */ public function __construct(string $name) { @@ -111,8 +98,6 @@ public function __destruct() /** * Renames the table - * @param string $newName - * @return Table */ public function renameTo(string $newName): Table { @@ -122,9 +107,6 @@ public function renameTo(string $newName): Table /** * Sets an action on a table to be performed - * @param int $action - * @param array|null $data - * @return Table */ public function setAction(int $action, ?array $data = null): Table { @@ -140,10 +122,7 @@ public function setAction(int $action, ?array $data = null): Table /** * Adds column to the table - * @param string $name - * @param string $type * @param mixed $constraint - * @return Table */ public function addColumn(string $name, string $type, $constraint = null): Table { @@ -157,10 +136,7 @@ public function addColumn(string $name, string $type, $constraint = null): Table /** * Modifies the column - * @param string $name - * @param string $type * @param mixed $constraint - * @return Table */ public function modifyColumn(string $name, string $type, $constraint = null): Table { @@ -176,10 +152,8 @@ public function modifyColumn(string $name, string $type, $constraint = null): Ta /** * Renames the column name - * @param string $oldName - * @param string $newName */ - public function renameColumn(string $oldName, string $newName) + public function renameColumn(string $oldName, string $newName): void { if ($this->action == self::ALTER) { $this->columns[] = [ @@ -191,9 +165,8 @@ public function renameColumn(string $oldName, string $newName) /** * Drops the column - * @param string $name */ - public function dropColumn(string $name) + public function dropColumn(string $name): void { if ($this->action == self::ALTER) { $this->columns[] = [ @@ -205,11 +178,8 @@ public function dropColumn(string $name) /** * Adds new index to column - * @param string $columnName - * @param string $indexType - * @param string|null $indexName */ - public function addIndex(string $columnName, string $indexType, ?string $indexName = null) + public function addIndex(string $columnName, string $indexType, ?string $indexName = null): void { if ($this->action == self::ALTER) { $this->columns[] = [ @@ -223,9 +193,8 @@ public function addIndex(string $columnName, string $indexType, ?string $indexNa /** * Drops the column index - * @param string $indexName */ - public function dropIndex(string $indexName) + public function dropIndex(string $indexName): void { if ($this->action == self::ALTER) { $this->columns[] = [ @@ -237,8 +206,6 @@ public function dropIndex(string $indexName) /** * Adds columns after specified one - * @param string $columnName - * @return $this */ public function after(string $columnName): Table { @@ -248,7 +215,6 @@ public function after(string $columnName): Table /** * Gets the generated query - * @return string */ public function getSql(): string { @@ -274,8 +240,6 @@ public function getSql(): string /** * Allows to call methods of Column class - * @param string $method - * @param array|null $arguments * @return $this * @throws BaseException */ @@ -293,7 +257,7 @@ public function __call(string $method, ?array $arguments) * Saves the query * @throws DatabaseException */ - private function save() + private function save(): void { $sql = $this->getSql(); @@ -304,8 +268,6 @@ private function save() /** * Checks if column exists on a table - * @param string $columnName - * @return bool * @throws DatabaseException */ private function checkColumnExists(string $columnName): bool @@ -326,7 +288,6 @@ private function checkColumnExists(string $columnName): bool /** * Gets the column key - * @return int */ private function columnKey(): int { diff --git a/src/Database/Traits/RelationalTrait.php b/src/Database/Traits/RelationalTrait.php index 0c96d2848..0bb49b8ba 100644 --- a/src/Database/Traits/RelationalTrait.php +++ b/src/Database/Traits/RelationalTrait.php @@ -24,9 +24,6 @@ trait RelationalTrait { /** * Raw execute - * @param string $query - * @param array $parameters - * @return bool * @throws DatabaseException */ public static function execute(string $query, array $parameters = []): bool @@ -36,9 +33,6 @@ public static function execute(string $query, array $parameters = []): bool /** * Raw query - * @param string $query - * @param array $parameters - * @return array * @throws DatabaseException */ public static function query(string $query, array $parameters = []): array @@ -48,9 +42,6 @@ public static function query(string $query, array $parameters = []): array /** * Fetches table columns - * @param string $query - * @param array $parameters - * @return array * @throws DatabaseException */ public static function fetchColumns(string $query, array $parameters = []): array @@ -60,7 +51,6 @@ public static function fetchColumns(string $query, array $parameters = []): arra /** * Gets the last query executed - * @return string|null * @throws DatabaseException */ public static function lastQuery(): ?string @@ -71,7 +61,6 @@ public static function lastQuery(): ?string /** * Get an array containing all the queries * run on a specified connection up to now. - * @return array * @throws DatabaseException */ public static function queryLog(): array @@ -81,9 +70,6 @@ public static function queryLog(): array /** * Resolves the requested query - * @param string $method - * @param string $query - * @param array $parameters * @return mixed * @throws DatabaseException */ diff --git a/src/Database/Traits/TableTrait.php b/src/Database/Traits/TableTrait.php index bd2920182..c5ad9401a 100644 --- a/src/Database/Traits/TableTrait.php +++ b/src/Database/Traits/TableTrait.php @@ -25,7 +25,6 @@ trait TableTrait { /** * Generates create table statement - * @return string */ protected function createTableSql(): string { @@ -43,7 +42,6 @@ protected function createTableSql(): string /** * Generates alter table statement - * @return string */ protected function alterTableSql(): string { @@ -61,7 +59,6 @@ protected function alterTableSql(): string /** * Prepares rename table statement - * @return string */ protected function renameTableSql(): string { @@ -70,7 +67,6 @@ protected function renameTableSql(): string /** * Prepares drop table statement - * @return string */ protected function dropTableSql(): string { @@ -79,7 +75,6 @@ protected function dropTableSql(): string /** * Prepares columns statements for table - * @return string */ protected function columnsSql(): string { @@ -120,9 +115,6 @@ protected function columnsSql(): string /** * Composes the column - * @param Column $column - * @param string|null $action - * @return string */ protected function composeColumn(Column $column, ?string $action = null): string { @@ -142,9 +134,6 @@ protected function composeColumn(Column $column, ?string $action = null): string /** * Prepares column attributes * @param mixed $definition - * @param string $before - * @param string $after - * @return string */ protected function columnAttrSql($definition, string $before = '', string $after = ''): string { @@ -160,7 +149,6 @@ protected function columnAttrSql($definition, string $before = '', string $after /** * Prepares statement for primary key - * @return string */ protected function primaryKeysSql(): string { @@ -184,8 +172,6 @@ protected function primaryKeysSql(): string /** * Prepares statement for index keys - * @param string $type - * @return string */ protected function indexKeysSql(string $type): string { @@ -211,7 +197,6 @@ protected function indexKeysSql(string $type): string /** * Builds a complete statement for index keys - * @return string */ protected function indexesSql(): string { @@ -228,7 +213,6 @@ protected function indexesSql(): string /** * Builds a statement for drop indexes - * @return string */ protected function dropIndexesSql(): string { diff --git a/src/Database/Traits/TransactionTrait.php b/src/Database/Traits/TransactionTrait.php index aebc36c1b..3b5792d90 100644 --- a/src/Database/Traits/TransactionTrait.php +++ b/src/Database/Traits/TransactionTrait.php @@ -54,7 +54,6 @@ public static function rollback(): void /** * Resolves the transaction method call - * @param string $method * @return mixed * @throws BaseException */ @@ -71,7 +70,6 @@ protected static function resolveTransaction(string $method) /** * Transaction wrapper using a closure - * @param callable $callback * @return mixed * @throws BaseException * @throws DatabaseException diff --git a/src/Debugger/Debugger.php b/src/Debugger/Debugger.php index 71a116714..e5af9c187 100644 --- a/src/Debugger/Debugger.php +++ b/src/Debugger/Debugger.php @@ -57,38 +57,28 @@ class Debugger /** * Store - * @var DebuggerStore */ - private $store; + private DebuggerStore $store; - /** - * @var Debugger - */ - private static $instance; + private static ?Debugger $instance = null; /** * DebugBar instance - * @var DebugBar */ - private $debugBar; + private DebugBar $debugBar; /** * Assets url - * @var string */ - private $assetsUrl = '/assets/DebugBar/Resources'; + private string $assetsUrl = '/assets/DebugBar/Resources'; /** * Custom CSS - * @var string */ - private $customCss = 'custom_debugbar.css'; + private string $customCss = 'custom_debugbar.css'; /** * Debugger constructor. - * @param DebuggerStore $store - * @param DebugBar $debugBar - * @param array $collectors * @throws DebugBarException */ public function __construct(DebuggerStore $store, DebugBar $debugBar, array $collectors = []) @@ -102,10 +92,6 @@ public function __construct(DebuggerStore $store, DebugBar $debugBar, array $col } /** - * @param DebuggerStore|null $store - * @param DebugBar|null $debugBar - * @param array|null $collectors - * @return Debugger * @throws DebugBarException */ public static function getInstance(?DebuggerStore $store = null, ?DebugBar $debugBar = null, ?array $collectors = []): Debugger @@ -123,17 +109,13 @@ public static function getInstance(?DebuggerStore $store = null, ?DebugBar $debu /** * Checks if debug bar enabled - * @return bool */ public function isEnabled(): bool { return filter_var(config()->get('app.debug'), FILTER_VALIDATE_BOOLEAN); } - /** - * @return void - */ - public function initStore() + public function initStore(): void { $this->store->init([ Debugger::MESSAGES, @@ -146,21 +128,15 @@ public function initStore() /** * Adds data to the store cell - * @param string $cell - * @param string $level * @param mixed $data */ - public function addToStoreCell(string $cell, string $level, $data) + public function addToStoreCell(string $cell, string $level, $data): void { if (!empty($data)) { $this->store->set($cell, [$level => $data]); } } - /** - * @param string $cell - * @return array - */ public function getStoreCell(string $cell): array { return $this->store->get($cell); @@ -168,24 +144,19 @@ public function getStoreCell(string $cell): array /** * Clears the store cell - * @param string $cell */ - public function clearStoreCell(string $cell) + public function clearStoreCell(string $cell): void { $this->store->delete($cell); } - /** - * @return void - */ - public function resetStore() + public function resetStore(): void { $this->store->flush(); } /** * Renders the debug bar - * @return string * @throws DebugBarException */ public function render(): string @@ -201,7 +172,6 @@ public function render(): string /** * Creates a tab - * @param string $type * @throws DebugBarException */ protected function createTab(string $type) @@ -212,17 +182,14 @@ protected function createTab(string $type) $messages = $this->store->get($type); - if (count($messages) > 0) { - foreach ($messages as $message) { - $fn = key($message); - $this->debugBar[$type]->$fn($message[$fn]); - } + foreach ($messages as $message) { + $fn = key($message); + $this->debugBar[$type]->$fn($message[$fn]); } } /** * Gets the renderer - * @return JavascriptRenderer */ protected function getRenderer(): JavascriptRenderer { @@ -232,9 +199,6 @@ protected function getRenderer(): JavascriptRenderer ->addAssets([$this->customCss], []); } - /** - * @return array - */ protected static function getDefaultCollectors(): array { return [ diff --git a/src/Debugger/DebuggerStore.php b/src/Debugger/DebuggerStore.php index ce8e24656..d5d0a6d21 100644 --- a/src/Debugger/DebuggerStore.php +++ b/src/Debugger/DebuggerStore.php @@ -22,13 +22,9 @@ */ class DebuggerStore implements StorageInterface { - private static $store = []; + private static array $store = []; - /** - * @param array $keys - * @return void - */ - public function init(array $keys) + public function init(array $keys): void { foreach ($keys as $key) { if (!isset(self::$store[$key])) { @@ -45,30 +41,20 @@ public function all(): array return self::$store; } - /** - * @param string $key - * @return bool - */ public function has(string $key): bool { return isset(self::$store[$key]); } - /** - * @param string $key - * @return array - */ public function get(string $key): array { return self::$store[$key] ?? []; } /** - * @param string $key * @param mixed $value - * @return void */ - public function set(string $key, $value) + public function set(string $key, $value): void { if (is_array($value)) { foreach ($value as $level => $data) { @@ -77,21 +63,14 @@ public function set(string $key, $value) } } - /** - * @param string $key - * @return void - */ - public function delete(string $key) + public function delete(string $key): void { if ($this->has($key)) { self::$store[$key] = []; } } - /** - * @return void - */ - public function flush() + public function flush(): void { self::$store = []; } diff --git a/src/Di/Di.php b/src/Di/Di.php index 7d5b632b5..11e72dfed 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -45,8 +45,6 @@ class Di /** * Register dependencies - * @param array $dependencies - * @return void * @throws DiException */ public static function registerDependencies(array $dependencies): void @@ -60,9 +58,6 @@ public static function registerDependencies(array $dependencies): void /** * Registers new dependency - * @param string $concrete - * @param string|null $abstract - * @return void * @throws DiException */ public static function register(string $concrete, ?string $abstract = null): void @@ -86,8 +81,6 @@ public static function register(string $concrete, ?string $abstract = null): voi /** * Checks if a dependency registered - * @param string $abstract - * @return bool */ public static function isRegistered(string $abstract): bool { @@ -99,7 +92,6 @@ public static function isRegistered(string $abstract): bool * @template T of object * @param class-string $abstract * @param T $instance - * @param bool $override * @throws DiException */ public static function set(string $abstract, object $instance, bool $override = true): void @@ -161,8 +153,6 @@ public static function create(string $dependency, array $args = []) /** * Autowire callable parameters - * @param callable $entry - * @param array $args * @return list * @throws DiException * @throws ReflectionException @@ -181,9 +171,6 @@ public static function autowire(callable $entry, array $args = []): array return self::resolveParameters($reflection->getParameters(), $args); } - /** - * @return void - */ public static function reset(): void { self::$dependencies = []; @@ -193,9 +180,6 @@ public static function reset(): void /** * Resolves the dependency - * @param string $abstract - * @param array $args - * @param bool $singleton * @return mixed|object * @throws DiException|ReflectionException */ @@ -223,8 +207,6 @@ private static function resolve(string $abstract, array $args = [], bool $single /** * Instantiates the dependency - * @param string $concrete - * @param array $args * @return mixed * @throws ReflectionException|DiException */ @@ -242,9 +224,6 @@ private static function instantiate(string $concrete, array $args = []) /** * Resolve parameter list - * @param array $parameters - * @param array $args - * @return array * @throws DiException */ private static function resolveParameters(array $parameters, array &$args = []): array @@ -260,8 +239,6 @@ private static function resolveParameters(array $parameters, array &$args = []): /** * Resolve single parameter - * @param ReflectionParameter $param - * @param array $args * @return array|mixed|object|null * @throws DiException|ReflectionException */ @@ -300,8 +277,6 @@ private static function resolveParameter(ReflectionParameter $param, array &$arg /** * Checks if the class is instantiable - * @param string $class - * @return bool */ protected static function instantiable(string $class): bool { @@ -310,8 +285,6 @@ protected static function instantiable(string $class): bool } /** - * @param string $abstract - * @return void * @throws DiException */ private static function checkCircularDependency(string $abstract): void diff --git a/src/Di/Exceptions/DiException.php b/src/Di/Exceptions/DiException.php index 4056e7886..63fe899e6 100644 --- a/src/Di/Exceptions/DiException.php +++ b/src/Di/Exceptions/DiException.php @@ -25,10 +25,6 @@ */ class DiException extends BaseException { - /** - * @param string $name - * @return DiException - */ public static function dependencyNotRegistered(string $name): DiException { return new self( @@ -37,10 +33,6 @@ public static function dependencyNotRegistered(string $name): DiException ); } - /** - * @param string $name - * @return DiException - */ public static function dependencyAlreadyRegistered(string $name): DiException { return new self( @@ -49,10 +41,6 @@ public static function dependencyAlreadyRegistered(string $name): DiException ); } - /** - * @param string $name - * @return DiException - */ public static function dependencyNotInstantiable(string $name): DiException { return new self( @@ -61,10 +49,6 @@ public static function dependencyNotInstantiable(string $name): DiException ); } - /** - * @param string $name - * @return DiException - */ public static function invalidAbstractDependency(string $name): DiException { return new self( @@ -73,10 +57,6 @@ public static function invalidAbstractDependency(string $name): DiException ); } - /** - * @param string $chain - * @return DiException - */ public static function circularDependency(string $chain): DiException { return new self( @@ -85,10 +65,6 @@ public static function circularDependency(string $chain): DiException ); } - /** - * @param string|null $entry - * @return DiException - */ public static function invalidCallable(?string $entry = null): DiException { return new self( diff --git a/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php b/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php index d499707a8..d340db4f3 100644 --- a/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php +++ b/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php @@ -57,8 +57,6 @@ public function __construct() /** * Encrypts the string - * @param string $plain - * @return string * @throws CryptorException */ public function encrypt(string $plain): string @@ -73,8 +71,6 @@ public function encrypt(string $plain): string /** * Decrypts the string - * @param string $encrypted - * @return string * @throws CryptorException */ public function decrypt(string $encrypted): string @@ -89,7 +85,6 @@ public function decrypt(string $encrypted): string /** * Generate key pairs - * @return array * @throws BaseException */ private function generateKeyPair(): array diff --git a/src/Encryption/Adapters/SymmetricEncryptionAdapter.php b/src/Encryption/Adapters/SymmetricEncryptionAdapter.php index 15e0b6fb7..8abc9fabd 100644 --- a/src/Encryption/Adapters/SymmetricEncryptionAdapter.php +++ b/src/Encryption/Adapters/SymmetricEncryptionAdapter.php @@ -51,8 +51,6 @@ public function __construct() /** * Encrypts the string - * @param string $plain - * @return string */ public function encrypt(string $plain): string { @@ -65,8 +63,6 @@ public function encrypt(string $plain): string /** * Decrypts the string - * @param string $encrypted - * @return string * @throws CryptorException */ public function decrypt(string $encrypted): string @@ -89,7 +85,6 @@ public function decrypt(string $encrypted): string /** * Generates initialization vector - * @return string */ private function generateIV(): string { diff --git a/src/Encryption/Contracts/EncryptionInterface.php b/src/Encryption/Contracts/EncryptionInterface.php index 945fea051..d336e113f 100644 --- a/src/Encryption/Contracts/EncryptionInterface.php +++ b/src/Encryption/Contracts/EncryptionInterface.php @@ -20,15 +20,7 @@ */ interface EncryptionInterface { - /** - * @param string $plain - * @return string - */ public function encrypt(string $plain): string; - /** - * @param string $encrypted - * @return string - */ public function decrypt(string $encrypted): string; } diff --git a/src/Encryption/Cryptor.php b/src/Encryption/Cryptor.php index b3692a5db..38ec4a431 100644 --- a/src/Encryption/Cryptor.php +++ b/src/Encryption/Cryptor.php @@ -37,38 +37,24 @@ class Cryptor */ public const ASYMMETRIC = 'asymmetric'; - /** - * @var EncryptionInterface - */ - private $adapter; + private EncryptionInterface $adapter; - /** - * @param EncryptionInterface $adapter - */ public function __construct(EncryptionInterface $adapter) { $this->adapter = $adapter; } - /** - * @return EncryptionInterface - */ public function getAdapter(): EncryptionInterface { return $this->adapter; } - /** - * @return bool - */ public function isAsymmetric(): bool { return $this->adapter instanceof AsymmetricEncryptionAdapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Encryption/Exceptions/CryptorException.php b/src/Encryption/Exceptions/CryptorException.php index ebefb8d99..81008ff2d 100644 --- a/src/Encryption/Exceptions/CryptorException.php +++ b/src/Encryption/Exceptions/CryptorException.php @@ -25,9 +25,6 @@ */ class CryptorException extends BaseException { - /** - * @return CryptorException - */ public static function publicKeyNotProvided(): self { return new self( @@ -36,9 +33,6 @@ public static function publicKeyNotProvided(): self ); } - /** - * @return CryptorException - */ public static function privateKeyNotProvided(): self { return new self( @@ -47,9 +41,6 @@ public static function privateKeyNotProvided(): self ); } - /** - * @return CryptorException - */ public static function invalidCipher(): self { return new self( diff --git a/src/Encryption/Factories/CryptorFactory.php b/src/Encryption/Factories/CryptorFactory.php index b63ea76ae..a3025c1ad 100644 --- a/src/Encryption/Factories/CryptorFactory.php +++ b/src/Encryption/Factories/CryptorFactory.php @@ -34,14 +34,9 @@ class CryptorFactory Cryptor::ASYMMETRIC => AsymmetricEncryptionAdapter::class, ]; - /** - * @var array - */ - private static $instances = []; + private static array $instances = []; /** - * @param string $type - * @return Cryptor * @throws BaseException */ public static function get(string $type = Cryptor::SYMMETRIC): Cryptor @@ -54,8 +49,6 @@ public static function get(string $type = Cryptor::SYMMETRIC): Cryptor } /** - * @param string $type - * @return Cryptor * @throws BaseException */ private static function createInstance(string $type): Cryptor diff --git a/src/Encryption/Helpers/encryption.php b/src/Encryption/Helpers/encryption.php index 111416ed5..b1303372d 100644 --- a/src/Encryption/Helpers/encryption.php +++ b/src/Encryption/Helpers/encryption.php @@ -19,8 +19,6 @@ /** * Encodes the data cryptographically * @param $data - * @param string $type - * @return string * @throws BaseException */ function crypto_encode($data, string $type = Cryptor::SYMMETRIC): string @@ -31,8 +29,6 @@ function crypto_encode($data, string $type = Cryptor::SYMMETRIC): string } /** - * @param string $encryptedData - * @param string $type * @return mixed|string * @throws BaseException */ diff --git a/src/Environment/Environment.php b/src/Environment/Environment.php index b78653625..6e2845cb2 100644 --- a/src/Environment/Environment.php +++ b/src/Environment/Environment.php @@ -35,40 +35,27 @@ class Environment { /** * Environment file - * @var string */ private string $envFile = '.env'; - /** - * @var bool - */ private bool $isMutable = false; /** * Loaded env content - * @var array */ private array $envContent = []; - /** - * @var bool - */ private bool $loaded = false; - /** - * @var string - */ private static string $appEnv = Env::PRODUCTION; /** * Instance of Environment - * @var Environment|null */ private static ?Environment $instance = null; /** * GetInstance - * @return Environment */ public static function getInstance(): Environment { @@ -79,10 +66,6 @@ public static function getInstance(): Environment return self::$instance; } - /** - * @param bool $isMutable - * @return Environment - */ public function setMutable(bool $isMutable): Environment { $this->isMutable = $isMutable; @@ -91,14 +74,12 @@ public function setMutable(bool $isMutable): Environment /** * Loads environment variables from file - * @param Setup $setup - * @return void * @throws BaseException * @throws EnvException * @throws DiException * @throws ReflectionException */ - public function load(Setup $setup) + public function load(Setup $setup): void { if ($this->loaded) { return; @@ -122,7 +103,6 @@ public function load(Setup $setup) /** * Gets the app current environment - * @return string */ public function getAppEnv(): string { @@ -131,7 +111,6 @@ public function getAppEnv(): string /** * Gets the environment variable value - * @param string $key * @param null|mixed $default * @return mixed * @throws EnvException @@ -151,8 +130,6 @@ public function getValue(string $key, $default = null) /** * Checks if there is a such key - * @param string $key - * @return bool */ public function hasKey(string $key): bool { @@ -161,8 +138,6 @@ public function hasKey(string $key): bool /** * Gets the row of .env file by given key - * @param string $key - * @return string|null */ public function getRow(string $key): ?string { @@ -171,16 +146,13 @@ public function getRow(string $key): ?string /** * Creates or updates the row in .env - * @param string $key - * @param string|null $value - * @return void * @throws BaseException * @throws DiException * @throws EnvException * @throws ReflectionException * @throws ConfigException */ - public function updateRow(string $key, ?string $value) + public function updateRow(string $key, ?string $value): void { if (!$this->isMutable) { throw EnvException::environmentImmutable(); @@ -207,8 +179,6 @@ public function updateRow(string $key, ?string $value) /** * Finds the row by provided key - * @param string $key - * @return string|null */ private function findKeyRow(string $key): ?string { @@ -221,10 +191,6 @@ private function findKeyRow(string $key): ?string return null; } - /** - * @param bool $forceMutableReload - * @return array - */ private function loadDotenvFile(bool $forceMutableReload = false): array { $baseDir = App::getBaseDir(); @@ -238,9 +204,6 @@ private function loadDotenvFile(bool $forceMutableReload = false): array return is_array($loadedVars) ? $loadedVars : []; } - /** - * @return string - */ private function getEnvFilePath(): string { return App::getBaseDir() . DS . $this->envFile; diff --git a/src/Environment/Exceptions/EnvException.php b/src/Environment/Exceptions/EnvException.php index f8be14b51..1d98a5a1b 100644 --- a/src/Environment/Exceptions/EnvException.php +++ b/src/Environment/Exceptions/EnvException.php @@ -25,9 +25,6 @@ */ class EnvException extends BaseException { - /** - * @return EnvException - */ public static function environmentImmutable(): self { return new self( @@ -36,9 +33,6 @@ public static function environmentImmutable(): self ); } - /** - * @return EnvException - */ public static function environmentNotLoaded(): self { return new self( diff --git a/src/Environment/Helpers/env.php b/src/Environment/Helpers/env.php index 5be3a12e4..a798720b9 100644 --- a/src/Environment/Helpers/env.php +++ b/src/Environment/Helpers/env.php @@ -17,7 +17,6 @@ /** * Gets environment variable - * @param string $var * @param $default * @return mixed * @throws EnvException diff --git a/src/Environment/Helpers/server.php b/src/Environment/Helpers/server.php index 7750542bd..58e046f49 100644 --- a/src/Environment/Helpers/server.php +++ b/src/Environment/Helpers/server.php @@ -16,7 +16,6 @@ /** * Gets Server instance - * @return Server */ function server(): Server { @@ -25,7 +24,6 @@ function server(): Server /** * Gets user IP - * @return string|null */ function get_user_ip(): ?string { @@ -38,7 +36,6 @@ function get_user_ip(): ?string * Get all headers * Built-in PHP function synonym of apache_request_headers() * Declaring here for Nginx server - * @return array */ function getallheaders(): array { diff --git a/src/Environment/Server.php b/src/Environment/Server.php index d08e9051e..7f183cc1d 100644 --- a/src/Environment/Server.php +++ b/src/Environment/Server.php @@ -20,12 +20,9 @@ */ class Server { - /** - * @var array - */ - private $server; + private array $server; - private static $instance = null; + private static ?Server $instance = null; /** * Server constructor. @@ -37,7 +34,6 @@ private function __construct() /** * Get Instance - * @return Server */ public static function getInstance(): Server { @@ -51,14 +47,11 @@ public static function getInstance(): Server /** * Flushes the server params */ - public function flush() + public function flush(): void { $this->server = []; } - /** - * @return array - */ public function all(): array { return $this->server; @@ -75,7 +68,6 @@ public function get($key) /** * @param $key - * @return bool */ public function has($key): bool { @@ -86,38 +78,26 @@ public function has($key): bool * @param $key * @param $value */ - public function set($key, $value) + public function set($key, $value): void { $this->server[$key] = $value; } - /** - * @return string|null - */ public function uri(): ?string { return $this->get('REQUEST_URI'); } - /** - * @return string|null - */ public function query(): ?string { return $this->get('QUERY_STRING'); } - /** - * @return string|null - */ public function method(): ?string { return $this->get('REQUEST_METHOD'); } - /** - * @return string|null - */ public function protocol(): ?string { $https = $this->get('HTTPS'); @@ -126,26 +106,16 @@ public function protocol(): ?string return (!empty($https) && strtolower($https) !== 'off') || $port == 443 ? 'https' : 'http'; } - /** - * @return string|null - */ public function host(): ?string { return $this->get('SERVER_NAME'); } - /** - * @return string|null - */ public function port(): ?string { return $this->get('SERVER_PORT'); } - /** - * @param bool $exact - * @return string|null - */ public function contentType(bool $exact = false): ?string { $contentType = $this->get('CONTENT_TYPE'); @@ -157,25 +127,16 @@ public function contentType(bool $exact = false): ?string return $contentType; } - /** - * @return string|null - */ public function referrer(): ?string { return $this->get('HTTP_REFERER'); } - /** - * @return bool - */ public function ajax(): bool { return strtolower($this->get('HTTP_X_REQUESTED_WITH') ?? '') === 'xmlhttprequest'; } - /** - * @return string|null - */ public function ip(): ?string { return $this->get('HTTP_CLIENT_IP') @@ -183,9 +144,6 @@ public function ip(): ?string ?? $this->get('REMOTE_ADDR'); } - /** - * @return array - */ public function getAllHeaders(): array { $data = $this->all(); @@ -194,7 +152,7 @@ public function getAllHeaders(): array return []; } - return array_reduce(array_keys($data), function ($headers, $key) use ($data) { + return array_reduce(array_keys($data), function (array $headers, $key) use ($data): array { if (strpos($key, 'HTTP_') === 0) { $formattedKey = strtolower(str_replace('_', '-', substr($key, 5))); $headers[$formattedKey] = $data[$key]; @@ -203,9 +161,6 @@ public function getAllHeaders(): array }, []); } - /** - * @return string|null - */ public function acceptedLang(): ?string { $accept = $this->get('HTTP_ACCEPT_LANGUAGE'); diff --git a/src/Hasher/Exceptions/HasherException.php b/src/Hasher/Exceptions/HasherException.php index 239c5b775..867156761 100644 --- a/src/Hasher/Exceptions/HasherException.php +++ b/src/Hasher/Exceptions/HasherException.php @@ -25,11 +25,6 @@ */ class HasherException extends BaseException { - /** - * - * @param string $algorithm - * @return self - */ public static function algorithmNotSupported(string $algorithm): self { return new self( @@ -38,10 +33,6 @@ public static function algorithmNotSupported(string $algorithm): self ); } - /** - * - * @return self - */ public static function invalidBcryptCost(): self { return new self( diff --git a/src/Hasher/Hasher.php b/src/Hasher/Hasher.php index c1bd05af2..97ca9410a 100644 --- a/src/Hasher/Hasher.php +++ b/src/Hasher/Hasher.php @@ -34,24 +34,16 @@ class Hasher /** * The algorithm - * @var string */ - private $algorithm = self::DEFAULT_ALGORITHM; + private string $algorithm = self::DEFAULT_ALGORITHM; /** * The cost - * @var int */ - private $cost = self::DEFAULT_COST; - - public function __construct() - { - } + private int $cost = self::DEFAULT_COST; /** * Sets the algorithm - * @param string $algorithm - * @return $this */ public function setAlgorithm(string $algorithm): Hasher { @@ -61,7 +53,6 @@ public function setAlgorithm(string $algorithm): Hasher /** * Gets the current algorithm - * @return string */ public function getAlgorithm(): string { @@ -70,8 +61,6 @@ public function getAlgorithm(): string /** * Sets the cost - * @param int $cost - * @return $this * @throws HasherException */ public function setCost(int $cost): Hasher @@ -86,7 +75,6 @@ public function setCost(int $cost): Hasher /** * Gets the current cost - * @return int */ public function getCost(): int { @@ -95,8 +83,6 @@ public function getCost(): int /** * Hashes the given string - * @param string $password - * @return string|null */ public function hash(string $password): ?string { @@ -105,8 +91,6 @@ public function hash(string $password): ?string /** * Checks if re-hash needed - * @param string $hash - * @return bool */ public function needsRehash(string $hash): bool { @@ -115,9 +99,6 @@ public function needsRehash(string $hash): bool /** * Checks the given string against the hash - * @param string $password - * @param string $hash - * @return bool */ public function check(string $password, string $hash): bool { @@ -126,8 +107,6 @@ public function check(string $password, string $hash): bool /** * Gets an info of given hash - * @param string $hash - * @return array|null */ public function info(string $hash): ?array { diff --git a/src/Hook/Exceptions/HookException.php b/src/Hook/Exceptions/HookException.php index a8ab404a2..9014b11cf 100644 --- a/src/Hook/Exceptions/HookException.php +++ b/src/Hook/Exceptions/HookException.php @@ -25,10 +25,6 @@ */ class HookException extends BaseException { - /** - * @param string $name - * @return HookException - */ public static function hookDuplicateName(string $name): self { return new self( @@ -37,10 +33,6 @@ public static function hookDuplicateName(string $name): self ); } - /** - * @param string $name - * @return HookException - */ public static function unregisteredHookName(string $name): self { return new self( diff --git a/src/Hook/Helpers/hook.php b/src/Hook/Helpers/hook.php index 688adfd1c..3a4d1b115 100644 --- a/src/Hook/Helpers/hook.php +++ b/src/Hook/Helpers/hook.php @@ -16,7 +16,6 @@ /** * Gets the HookManager instance - * @return HookManager */ function hook(): HookManager { diff --git a/src/Hook/HookManager.php b/src/Hook/HookManager.php index 470f79b08..a9e6b42bb 100644 --- a/src/Hook/HookManager.php +++ b/src/Hook/HookManager.php @@ -15,6 +15,7 @@ namespace Quantum\Hook; use Quantum\Config\Exceptions\ConfigException; +use Quantum\Loader\Exceptions\LoaderException; use Quantum\Hook\Exceptions\HookException; use Quantum\Di\Exceptions\DiException; use Quantum\Loader\Setup; @@ -33,20 +34,16 @@ class HookManager /** * Registered hooks store - * @var array */ - private static $store = []; + private static array $store = []; - /** - * @var HookManager|null - */ - private static $instance = null; + private static ?HookManager $instance = null; /** * @throws HookException * @throws ConfigException * @throws DiException - * @throws ReflectionException + * @throws ReflectionException|LoaderException */ private function __construct() { @@ -63,7 +60,6 @@ private function __construct() /** * HookManager instance - * @return HookManager */ public static function getInstance(): HookManager { @@ -75,12 +71,10 @@ public static function getInstance(): HookManager } /** - * Adds new listener for given hook - * @param string $name - * @param callable $function + * Adds a new listener for a given hook * @throws HookException */ - public function on(string $name, callable $function) + public function on(string $name, callable $function): void { if (!$this->exists($name)) { throw HookException::unregisteredHookName($name); @@ -91,11 +85,9 @@ public function on(string $name, callable $function) /** * Fires the hook - * @param string $name - * @param array|null $args * @throws HookException */ - public function fire(string $name, ?array $args = null) + public function fire(string $name, ?array $args = null): void { if (!$this->exists($name)) { throw HookException::unregisteredHookName($name); @@ -109,7 +101,6 @@ public function fire(string $name, ?array $args = null) /** * Gets all registered hooks - * @return array */ public static function getRegistered(): array { @@ -118,7 +109,6 @@ public static function getRegistered(): array /** * Registers new hook - * @param string $name * @throws HookException */ protected function register(string $name) @@ -132,8 +122,6 @@ protected function register(string $name) /** * Checks if hooks registered - * @param string $name - * @return bool */ protected function exists(string $name): bool { diff --git a/src/Http/Helpers/http.php b/src/Http/Helpers/http.php index 83d0bcbad..e0a93d4b1 100644 --- a/src/Http/Helpers/http.php +++ b/src/Http/Helpers/http.php @@ -24,8 +24,8 @@ /** * Gets the base url - * @param bool $withModulePrefix - * @return string + * @throws DiException + * @throws ReflectionException */ function base_url(bool $withModulePrefix = false): string { @@ -34,7 +34,6 @@ function base_url(bool $withModulePrefix = false): string /** * Gets the current url - * @return string */ function current_url(): string { @@ -43,26 +42,20 @@ function current_url(): string /** * Redirect - * @param string $url - * @param int $code */ -function redirect(string $url, int $code = StatusCode::FOUND) +function redirect(string $url, int $code = StatusCode::FOUND): void { Response::redirect($url, $code); } /** * Redirect with data - * @param string $url - * @param array $data - * @param int $code - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function redirectWith(string $url, array $data, int $code = StatusCode::FOUND) +function redirectWith(string $url, array $data, int $code = StatusCode::FOUND): void { session()->set(ReservedKeys::PREV_REQUEST, $data); Response::redirect($url, $code); @@ -70,7 +63,6 @@ function redirectWith(string $url, array $data, int $code = StatusCode::FOUND) /** * Gets old input values after redirect - * @param string $key * @return mixed|null * @throws ConfigException * @throws DiException @@ -99,7 +91,6 @@ function old(string $key) /** * Gets the referrer - * @return string|null */ function get_referrer(): ?string { @@ -108,14 +99,13 @@ function get_referrer(): ?string /** * Handles page not found - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException * @throws DebugBarException */ -function page_not_found() +function page_not_found(): void { $acceptHeader = Response::getHeader('Accept'); diff --git a/src/Http/Request.php b/src/Http/Request.php index 0ec72cb30..203287bc9 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -61,7 +61,6 @@ class Request { /** * @param string $function The function name - * @param array $arguments * @return mixed */ public function __call(string $function, array $arguments) @@ -71,7 +70,6 @@ public function __call(string $function, array $arguments) /** * @param string $function The function name - * @param array $arguments * @return mixed */ public static function __callStatic(string $function, array $arguments) diff --git a/src/Http/Request/HttpRequest.php b/src/Http/Request/HttpRequest.php index b72a1c593..246064244 100644 --- a/src/Http/Request/HttpRequest.php +++ b/src/Http/Request/HttpRequest.php @@ -64,29 +64,21 @@ abstract class HttpRequest /** * Request method - * @var string|null */ private static ?string $__method = null; - /** - * @var Server - */ protected static Server $server; - /** - * @var bool - */ private static bool $initialized = false; /** * Initializes the request static properties using the server instance. - * @param Server $server * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ - public static function init(Server $server) + public static function init(Server $server): void { if (self::$initialized) { return; @@ -111,7 +103,7 @@ public static function init(Server $server) /** * Flushes the request header , body and files */ - public static function flush() + public static function flush(): void { self::$__headers = []; self::$__request = []; @@ -127,9 +119,8 @@ public static function flush() /** * Sets the merged request parameters - * @param array $params */ - public static function setRequestParams(array $params) + public static function setRequestParams(array $params): void { self::$__request = array_merge( self::getParams(), @@ -142,11 +133,10 @@ public static function setRequestParams(array $params) /** * Sets the uploaded files array merging handled $_FILES and parsed files - * @param array $files * @throws BaseException * @throws ReflectionException */ - public static function setUploadedFiles(array $files) + public static function setUploadedFiles(array $files): void { self::$__files = array_merge( self::handleFiles($_FILES), @@ -156,7 +146,6 @@ public static function setUploadedFiles(array $files) /** * Gets the request method - * @return string|null */ public static function getMethod(): ?string { @@ -165,11 +154,9 @@ public static function getMethod(): ?string /** * Sets the request method - * @param string $method - * @return void * @throws BaseException */ - public static function setMethod(string $method) + public static function setMethod(string $method): void { if (!in_array(strtoupper($method), self::METHODS)) { throw HttpException::requestMethodNotAvailable($method); @@ -180,8 +167,6 @@ public static function setMethod(string $method) /** * Checks if the current method matches the given method - * @param string $method - * @return bool */ public static function isMethod(string $method): bool { @@ -190,7 +175,6 @@ public static function isMethod(string $method): bool /** * Gets Cross Site Request Forgery Token - * @return string|null */ public static function getCsrfToken(): ?string { @@ -207,8 +191,6 @@ public static function getCsrfToken(): ?string /** * Gets the base url - * @param bool $withModulePrefix - * @return string * @throws DiException|ReflectionException */ public static function getBaseUrl(bool $withModulePrefix = false): string @@ -227,7 +209,6 @@ public static function getBaseUrl(bool $withModulePrefix = false): string /** * Gets the current url - * @return string */ public static function getCurrentUrl(): string { @@ -240,7 +221,6 @@ public static function getCurrentUrl(): string /** * Gets the protocol, host, and optional port part of the URL. - * @return string */ private static function getHostPrefix(): string { @@ -258,7 +238,7 @@ private static function getHostPrefix(): string /** * Sets server data (method, protocol, host, port, uri, query). */ - private static function setServerInfo() + private static function setServerInfo(): void { foreach (['method', 'protocol', 'host', 'port', 'uri', 'query'] as $name) { self::${"__{$name}"} = self::$server->$name(); @@ -268,7 +248,7 @@ private static function setServerInfo() /** * Sets the normalized request content type. */ - private static function setContentType() + private static function setContentType(): void { self::$__contentType = self::$server->contentType(true); } @@ -276,8 +256,8 @@ private static function setContentType() /** * Sets request headers, normalizing keys to lowercase. */ - private static function setRequestHeaders() + private static function setRequestHeaders(): void { - self::$__headers = array_change_key_case((array) getallheaders()); + self::$__headers = array_change_key_case(getallheaders()); } } diff --git a/src/Http/Response.php b/src/Http/Response.php index 45aac302f..173539519 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -48,7 +48,6 @@ class Response { /** * @param string $function The function name - * @param array $arguments * @return mixed */ public function __call(string $function, array $arguments) @@ -58,7 +57,6 @@ public function __call(string $function, array $arguments) /** * @param string $function The function name - * @param array $arguments * @return mixed */ public static function __callStatic(string $function, array $arguments) diff --git a/src/Http/Response/HttpResponse.php b/src/Http/Response/HttpResponse.php index dbdd93eef..6e9b1e1ae 100644 --- a/src/Http/Response/HttpResponse.php +++ b/src/Http/Response/HttpResponse.php @@ -44,15 +44,12 @@ abstract class HttpResponse */ private static $callbackFunction = ''; - /** - * @var bool - */ - private static $initialized = false; + private static bool $initialized = false; /** * Initialize the Response */ - public static function init() + public static function init(): void { if (self::$initialized) { return; @@ -66,7 +63,7 @@ public static function init() /** * Flushes the response header and body */ - public static function flush() + public static function flush(): void { self::$__statusCode = StatusCode::OK; self::$__headers = []; @@ -80,7 +77,7 @@ public static function flush() * Sends all response data to the client and finishes the request. * @throws Exception */ - public static function send() + public static function send(): void { if (Environment::getInstance()->getAppEnv() !== Env::TESTING) { while (ob_get_level() > 0) { diff --git a/src/Http/Traits/Request/Body.php b/src/Http/Traits/Request/Body.php index 527a64290..e40650efc 100644 --- a/src/Http/Traits/Request/Body.php +++ b/src/Http/Traits/Request/Body.php @@ -25,14 +25,11 @@ trait Body { /** * Request body - * @var array */ - private static $__request = []; + private static array $__request = []; /** * Checks if request contains a data by given key - * @param string $key - * @return bool */ public static function has(string $key): bool { @@ -41,9 +38,6 @@ public static function has(string $key): bool /** * Retrieves data from request by given key - * @param string $key - * @param string|null $default - * @param bool $raw * @return mixed */ public static function get(string $key, ?string $default = null, bool $raw = false) @@ -65,10 +59,9 @@ public static function get(string $key, ?string $default = null, bool $raw = fal /** * Sets new key/value pair into request - * @param string $key * @param mixed $value */ - public static function set(string $key, $value) + public static function set(string $key, $value): void { if ($key === ReservedKeys::RENDERED_VIEW) { throw new InvalidArgumentException("Cannot set reserved key: `$key`"); @@ -79,7 +72,6 @@ public static function set(string $key, $value) /** * Gets all request parameters - * @return array */ public static function all(): array { @@ -88,9 +80,8 @@ public static function all(): array /** * Deletes the element from request by given key - * @param string $key */ - public static function delete(string $key) + public static function delete(string $key): void { if (self::has($key)) { unset(self::$__request[$key]); diff --git a/src/Http/Traits/Request/File.php b/src/Http/Traits/Request/File.php index b28f1a4a4..11161526a 100644 --- a/src/Http/Traits/Request/File.php +++ b/src/Http/Traits/Request/File.php @@ -27,14 +27,11 @@ trait File { /** * Files - * @var array */ private static array $__files = []; /** * Checks to see if request contains file - * @param string $key - * @return bool */ public static function hasFile(string $key): bool { @@ -60,7 +57,6 @@ public static function hasFile(string $key): bool /** * Gets the file or array of file objects - * @param string $key * @return mixed * @throws BaseException */ @@ -75,7 +71,6 @@ public static function getFile(string $key) /** * Handle files - * @param array $files * @return array> * @throws BaseException * @throws ReflectionException diff --git a/src/Http/Traits/Request/Header.php b/src/Http/Traits/Request/Header.php index 657991086..85912a3c9 100644 --- a/src/Http/Traits/Request/Header.php +++ b/src/Http/Traits/Request/Header.php @@ -22,14 +22,11 @@ trait Header { /** * Request headers - * @var array */ - private static $__headers = []; + private static array $__headers = []; /** * Checks the request header existence by given key - * @param string $key - * @return bool */ public static function hasHeader(string $key): bool { @@ -40,8 +37,6 @@ public static function hasHeader(string $key): bool /** * Gets the request header by given key - * @param string $key - * @return string|null */ public static function getHeader(string $key): ?string { @@ -55,17 +50,15 @@ public static function getHeader(string $key): ?string /** * Sets the request header - * @param string $key * @param mixed $value */ - public static function setHeader(string $key, $value) + public static function setHeader(string $key, $value): void { self::$__headers[strtolower($key)] = $value; } /** * Gets all request headers - * @return array */ public static function allHeaders(): array { @@ -74,9 +67,8 @@ public static function allHeaders(): array /** * Deletes the header by given key - * @param string $key */ - public static function deleteHeader(string $key) + public static function deleteHeader(string $key): void { if (self::hasHeader($key)) { unset(self::$__headers[strtolower($key)]); @@ -85,7 +77,6 @@ public static function deleteHeader(string $key) /** * Gets Authorization Bearer token - * @return string|null */ public static function getAuthorizationBearer(): ?string { @@ -102,7 +93,6 @@ public static function getAuthorizationBearer(): ?string /** * Gets Basic Auth Credentials - * @return array|null */ public static function getBasicAuthCredentials(): ?array { @@ -133,7 +123,6 @@ public static function getBasicAuthCredentials(): ?array /** * Checks to see if request was AJAX request - * @return bool */ public static function isAjax(): bool { @@ -142,17 +131,12 @@ public static function isAjax(): bool /** * Gets the referrer - * @return string|null */ public static function getReferrer(): ?string { return self::$server->referrer(); } - /** - * @param string $key - * @return array - */ private static function normalizeHeaderKey(string $key): array { $keyWithHyphens = str_replace('_', '-', strtolower($key)); diff --git a/src/Http/Traits/Request/Internal.php b/src/Http/Traits/Request/Internal.php index 83dc2e4ab..0ca0c6d01 100644 --- a/src/Http/Traits/Request/Internal.php +++ b/src/Http/Traits/Request/Internal.php @@ -29,11 +29,6 @@ trait Internal { /** * Creates an internal request for testing purposes - * @param string $method - * @param string $url - * @param array $params - * @param array $headers - * @param array $files * @throws BaseException * @throws ReflectionException * @throws ConfigException @@ -45,7 +40,7 @@ public static function create( array $params = [], array $headers = [], array $files = [] - ) { + ): void { $parsed = parse_url($url); $server = Server::getInstance(); @@ -82,10 +77,8 @@ public static function create( self::detectAndSetContentType($server, $params, $files); - if ($headers !== []) { - foreach ($headers as $name => $value) { - $server->set('HTTP_' . strtoupper(str_replace('-', '_', $name)), $value); - } + foreach ($headers as $name => $value) { + $server->set('HTTP_' . strtoupper(str_replace('-', '_', $name)), $value); } self::flush(); @@ -104,9 +97,6 @@ public static function create( /** * Detects the content type * @param $server - * @param array|null $data - * @param array|null $files - * @return void */ protected static function detectAndSetContentType($server, ?array $data = null, ?array $files = null): void { diff --git a/src/Http/Traits/Request/Params.php b/src/Http/Traits/Request/Params.php index 356c195f0..89bf43e0a 100644 --- a/src/Http/Traits/Request/Params.php +++ b/src/Http/Traits/Request/Params.php @@ -30,11 +30,10 @@ trait Params * Request content type * @var string|null */ - private static $__contentType = null; + private static $__contentType; /** * Gets the GET params. - * @return array */ private static function getParams(): array { @@ -47,7 +46,6 @@ private static function getParams(): array /** * Gets the POST params. - * @return array */ private static function postParams(): array { @@ -60,7 +58,6 @@ private static function postParams(): array /** * Parses and returns JSON payload parameters. - * @return array */ private static function jsonPayloadParams(): array { @@ -76,7 +73,6 @@ private static function jsonPayloadParams(): array /** * Parses and returns URL-encoded parameters. - * @return array */ private static function urlEncodedParams(): array { @@ -114,7 +110,6 @@ private static function getRawInputParams(): array /** * Retrieves the raw HTTP request body as a string. - * @return string */ private static function getRawInput(): string { diff --git a/src/Http/Traits/Request/Query.php b/src/Http/Traits/Request/Query.php index 32627a3dd..c6fef39c9 100644 --- a/src/Http/Traits/Request/Query.php +++ b/src/Http/Traits/Request/Query.php @@ -22,13 +22,11 @@ trait Query { /** * Query string - * @var string|null */ - private static $__query = null; + private static ?string $__query = null; /** * Gets the query string - * @return string|null */ public static function getQuery(): ?string { @@ -37,17 +35,14 @@ public static function getQuery(): ?string /** * Sets the query string - * @param string $query */ - public static function setQuery(string $query) + public static function setQuery(string $query): void { self::$__query = $query; } /** * Gets the query param - * @param string $key - * @return string|null */ public static function getQueryParam(string $key): ?string { @@ -69,10 +64,8 @@ public static function getQueryParam(string $key): ?string /** * Sets the query param - * @param string $key - * @param string $value */ - public static function setQueryParam(string $key, string $value) + public static function setQueryParam(string $key, string $value): void { $queryParams = self::$__query ? explode('&', self::$__query) : []; $queryParams[] = $key . '=' . $value; diff --git a/src/Http/Traits/Request/RawInput.php b/src/Http/Traits/Request/RawInput.php index c135f0899..3ab036ce8 100644 --- a/src/Http/Traits/Request/RawInput.php +++ b/src/Http/Traits/Request/RawInput.php @@ -31,7 +31,6 @@ trait RawInput { /** * Parses raw input data and returns parsed parameters and files - * @param string $rawInput * @return array|array[] * @throws BaseException * @throws ConfigException @@ -53,7 +52,6 @@ public static function parse(string $rawInput): array /** * Extracts boundary string from Content-Type header - * @return string|null */ private static function getBoundary(): ?string { @@ -70,9 +68,6 @@ private static function getBoundary(): ?string /** * Splits raw input into multipart blocks - * @param string $boundary - * @param string $rawInput - * @return array */ private static function getBlocks(string $boundary, string $rawInput): array { @@ -84,8 +79,6 @@ private static function getBlocks(string $boundary, string $rawInput): array /** * Processes multipart blocks and extracts parameters and files - * @param array $blocks - * @return array * @throws BaseException * @throws ConfigException * @throws DiException @@ -132,11 +125,8 @@ private static function processBlocks(array $blocks): array /** * Adds a parsed file to the files collection - * @param array $files - * @param string $nameParam - * @param UploadedFile $file */ - private static function addFileToCollection(array &$files, string $nameParam, UploadedFile $file) + private static function addFileToCollection(array &$files, string $nameParam, UploadedFile $file): void { $arrayParam = self::arrayParam($nameParam); @@ -155,7 +145,6 @@ private static function addFileToCollection(array &$files, string $nameParam, Up /** * Detects the block type as a string identifier. - * @param string $block * @return string One of 'file', 'stream', 'param' */ private static function detectBlockType(string $block): string @@ -173,8 +162,6 @@ private static function detectBlockType(string $block): string /** * Gets the parsed param - * @param string $block - * @return array */ private static function getParsedStream(string $block): array { @@ -185,8 +172,6 @@ private static function getParsedStream(string $block): array /** * Gets the parsed file - * @param string $block - * @return array|null * @throws BaseException * @throws ConfigException * @throws DiException @@ -212,7 +197,7 @@ private static function getParsedFile(string $block): ?array 'size' => $fs->size($tempName), ]); - register_shutdown_function(function () use ($fs, $tempName) { + register_shutdown_function(function () use ($fs, $tempName): void { $fs->remove($tempName); }); @@ -221,7 +206,6 @@ private static function getParsedFile(string $block): ?array /** * Parses a file block into metadata and binary content - * @param string $block * @return array{string, string, string, string} */ private static function parseFileData(string $block): array @@ -250,8 +234,6 @@ private static function parseFileData(string $block): array /** * Parses a block and extracts normal form parameters - * @param string $block - * @return array */ private static function getParsedParameter(string $block): array { @@ -272,7 +254,6 @@ private static function getParsedParameter(string $block): array /** * Extracts name, filename, and content type from header lines - * @param string $rawHeaders * @return array{string, string, string} */ private static function parseHeaders(string $rawHeaders): array @@ -305,7 +286,6 @@ private static function parseHeaders(string $rawHeaders): array /** * Parses array-like parameter names - * @param string $parameter * @return array|string */ private static function arrayParam(string $parameter) diff --git a/src/Http/Traits/Request/Route.php b/src/Http/Traits/Request/Route.php index c1895deb1..f5ec59913 100644 --- a/src/Http/Traits/Request/Route.php +++ b/src/Http/Traits/Request/Route.php @@ -22,23 +22,13 @@ */ trait Route { - /** - * @var MatchedRoute|null - */ private static ?MatchedRoute $route = null; - /** - * @param MatchedRoute|null $route - * @return void - */ public static function setMatchedRoute(?MatchedRoute $route): void { self::$route = $route; } - /** - * @return MatchedRoute|null - */ public static function getMatchedRoute(): ?MatchedRoute { return self::$route; diff --git a/src/Http/Traits/Request/Url.php b/src/Http/Traits/Request/Url.php index b2b9c0317..9fbd424cc 100644 --- a/src/Http/Traits/Request/Url.php +++ b/src/Http/Traits/Request/Url.php @@ -22,27 +22,23 @@ trait Url { /** * Scheme - * @var string|null */ - private static $__protocol = null; + private static ?string $__protocol = null; /** * Host name - * @var string|null */ - private static $__host = null; + private static ?string $__host = null; /** * Server port - * @var string|null */ - private static $__port = null; + private static ?string $__port = null; /** * Request URI - * @var string|null */ - private static $__uri = null; + private static ?string $__uri = null; /** * Gets the protocol @@ -55,9 +51,8 @@ public static function getProtocol(): ?string /** * Sets the protocol - * @param string $protocol */ - public static function setProtocol(string $protocol) + public static function setProtocol(string $protocol): void { self::$__protocol = $protocol; } @@ -73,9 +68,8 @@ public static function getHost(): ?string /** * Sets the host name - * @param string $host */ - public static function setHost(string $host) + public static function setHost(string $host): void { self::$__host = $host; } @@ -91,16 +85,14 @@ public static function getPort(): ?string /** * Sets the port - * @param string $port */ - public static function setPort(string $port) + public static function setPort(string $port): void { self::$__port = $port; } /** * Gets the URI - * @return string|null */ public static function getUri(): ?string { @@ -109,17 +101,14 @@ public static function getUri(): ?string /** * Sets the URI - * @param string $uri */ - public static function setUri(string $uri) + public static function setUri(string $uri): void { self::$__uri = ltrim($uri, '/'); } /** * Returns the URI segment at the specified index. - * @param int $index - * @return string|null */ public static function getSegment(int $index): ?string { @@ -130,7 +119,6 @@ public static function getSegment(int $index): ?string /** * Gets all URI segments as an array. - * @return array */ public static function getAllSegments(): array { diff --git a/src/Http/Traits/Response/Body.php b/src/Http/Traits/Response/Body.php index 3fde453d9..82add5494 100644 --- a/src/Http/Traits/Response/Body.php +++ b/src/Http/Traits/Response/Body.php @@ -29,14 +29,13 @@ trait Body { /** * Response - * @var array */ - private static $__response = []; + private static array $__response = []; /** * @var string[] */ - private static $formatters = [ + private static array $formatters = [ ContentType::HTML => 'formatHtml', ContentType::XML => 'formatXml', ContentType::JSON => 'formatJson', @@ -45,8 +44,6 @@ trait Body /** * Checks if response contains a data by given key - * @param string $key - * @return bool */ public static function has(string $key): bool { @@ -55,8 +52,6 @@ public static function has(string $key): bool /** * Gets the data from response by given key - * @param string $key - * @param string|null $default * @return mixed */ public static function get(string $key, ?string $default = null) @@ -66,17 +61,15 @@ public static function get(string $key, ?string $default = null) /** * Sets new key/value pair into response - * @param string $key * @param mixed $value */ - public static function set(string $key, $value) + public static function set(string $key, $value): void { self::$__response[$key] = $value; } /** * Gets all response parameters - * @return array */ public static function all(): array { @@ -85,9 +78,8 @@ public static function all(): array /** * Deletes the element from response by given key - * @param string $key */ - public static function delete(string $key) + public static function delete(string $key): void { if (self::has($key)) { unset(self::$__response[$key]); @@ -96,10 +88,8 @@ public static function delete(string $key) /** * Prepares the JSON response - * @param array|null $data - * @param int|null $code */ - public static function json(?array $data = null, ?int $code = null) + public static function json(?array $data = null, ?int $code = null): void { self::setContentType(ContentType::JSON); @@ -114,11 +104,8 @@ public static function json(?array $data = null, ?int $code = null) /** * Prepares the JSONP response - * @param string $callback - * @param array|null $data - * @param int|null $code */ - public static function jsonp(string $callback, ?array $data = null, ?int $code = null) + public static function jsonp(string $callback, ?array $data = null, ?int $code = null): void { self::setContentType(ContentType::JSONP); @@ -135,8 +122,6 @@ public static function jsonp(string $callback, ?array $data = null, ?int $code = /** * Returns response with function - * @param array $data - * @return string */ public static function getJsonPData(array $data): string { @@ -145,10 +130,8 @@ public static function getJsonPData(array $data): string /** * Prepares the XML response - * @param array|null $data - * @param int|null $code */ - public static function xml(?array $data = null, $root = '', ?int $code = null) + public static function xml(?array $data = null, $root = '', ?int $code = null): void { self::setContentType(ContentType::XML); @@ -165,10 +148,8 @@ public static function xml(?array $data = null, $root = '', ?int $c /** * Prepares the HTML content - * @param string $html - * @param int|null $code */ - public static function html(string $html, ?int $code = null) + public static function html(string $html, ?int $code = null): void { self::setContentType(ContentType::HTML); @@ -181,7 +162,6 @@ public static function html(string $html, ?int $code = null) /** * Gets the response content - * @return string * @throws HttpException */ public static function getContent(): string @@ -199,8 +179,6 @@ public static function getContent(): string /** * Transforms array to XML - * @param array $arr - * @return string * @throws Exception */ private static function arrayToXML(array $arr): string @@ -216,10 +194,8 @@ private static function arrayToXML(array $arr): string /** * Compose XML - * @param array $arr - * @param SimpleXMLElement $simpleXML */ - private static function composeXML(array $arr, SimpleXMLElement &$simpleXML) + private static function composeXML(array $arr, SimpleXMLElement &$simpleXML): void { foreach ($arr as $key => $value) { if (is_numeric($key)) { @@ -257,7 +233,6 @@ private static function composeXML(array $arr, SimpleXMLElement &$simpleXML) /** * Formats data as JSON - * @return string */ private static function formatJson(): string { @@ -266,7 +241,6 @@ private static function formatJson(): string /** * Formats data as XML - * @return string * @throws Exception */ private static function formatXml(): string @@ -276,7 +250,6 @@ private static function formatXml(): string /** * Formats data as HTML - * @return string */ private static function formatHtml(): string { @@ -285,7 +258,6 @@ private static function formatHtml(): string /** * Formats data as JSONP - * @return string */ private static function formatJsonp(): string { diff --git a/src/Http/Traits/Response/Header.php b/src/Http/Traits/Response/Header.php index 30a70f3a0..05f425453 100644 --- a/src/Http/Traits/Response/Header.php +++ b/src/Http/Traits/Response/Header.php @@ -25,14 +25,11 @@ trait Header { /** * Response headers - * @var array */ - private static $__headers = []; + private static array $__headers = []; /** * Checks the response header existence by given key - * @param string $key - * @return bool */ public static function hasHeader(string $key): bool { @@ -41,8 +38,6 @@ public static function hasHeader(string $key): bool /** * Gets the response header by given key - * @param string $key - * @return string|null */ public static function getHeader(string $key): ?string { @@ -51,17 +46,14 @@ public static function getHeader(string $key): ?string /** * Sets the response header - * @param string $key - * @param string $value */ - public static function setHeader(string $key, string $value) + public static function setHeader(string $key, string $value): void { self::$__headers[$key] = $value; } /** * Get all response headers - * @return array */ public static function allHeaders(): array { @@ -70,9 +62,8 @@ public static function allHeaders(): array /** * Deletes the header by given key - * @param string $key */ - public static function deleteHeader(string $key) + public static function deleteHeader(string $key): void { if (self::hasHeader($key)) { unset(self::$__headers[$key]); @@ -81,16 +72,14 @@ public static function deleteHeader(string $key) /** * Sets the content type - * @param string $contentType */ - public static function setContentType(string $contentType) + public static function setContentType(string $contentType): void { self::setHeader('Content-Type', $contentType); } /** * Gets the content type - * @return string */ public static function getContentType(): string { @@ -99,11 +88,9 @@ public static function getContentType(): string /** * Redirect - * @param string $url - * @param int $code * @throws StopExecutionException */ - public static function redirect(string $url, int $code = 302) + public static function redirect(string $url, int $code = 302): void { self::setStatusCode($code); self::setHeader('Location', $url); diff --git a/src/Http/Traits/Response/Status.php b/src/Http/Traits/Response/Status.php index 81abdf25b..3b9411649 100644 --- a/src/Http/Traits/Response/Status.php +++ b/src/Http/Traits/Response/Status.php @@ -25,15 +25,14 @@ trait Status { /** * Status code - * @var int */ - private static $__statusCode = StatusCode::OK; + private static int $__statusCode = StatusCode::OK; /** * Status texts * @var string[] */ - private static $texts = [ + private static array $texts = [ StatusCode::CONTINUE => 'Continue', StatusCode::SWITCHING_PROTOCOLS => 'Switching Protocols', StatusCode::PROCESSING => 'Processing', @@ -104,8 +103,6 @@ trait Status /** * Gets the reason phrase for a given HTTP status code. - * @param int $code - * @return string */ public static function getText(int $code): string { @@ -118,9 +115,8 @@ public static function getText(int $code): string /** * Sets the status code - * @param int $code */ - public static function setStatusCode(int $code) + public static function setStatusCode(int $code): void { if (!isset(self::$texts[$code])) { throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code)); @@ -131,7 +127,6 @@ public static function setStatusCode(int $code) /** * Gets the status code - * @return int */ public static function getStatusCode(): int { @@ -140,7 +135,6 @@ public static function getStatusCode(): int /** * Gets the status text - * @return string */ public static function getStatusText(): string { diff --git a/src/HttpClient/Exceptions/HttpClientException.php b/src/HttpClient/Exceptions/HttpClientException.php index ccef57249..7dbff486e 100644 --- a/src/HttpClient/Exceptions/HttpClientException.php +++ b/src/HttpClient/Exceptions/HttpClientException.php @@ -25,10 +25,6 @@ */ class HttpClientException extends BaseException { - /** - * @return HttpClientException - */ - public static function requestNotCreated(): self { return new self( diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index 5407eb832..0a1004c8a 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -56,38 +56,23 @@ class HttpClient /** * @var MultiCurl|Curl */ - private $client = null; + private $client; - /** - * @var string - */ - private $method = 'GET'; + private string $method = 'GET'; /** * @var mixed|null */ - private $data = null; + private $data; - /** - * @var array - */ private array $requestHeaders = []; - /** - * @var array - */ - private $response = []; + private array $response = []; - /** - * @var array - */ - private $errors = []; + private array $errors = []; /** * Creates request - * @param string $url - * @param Curl|null $client - * @return HttpClient */ public function createRequest(string $url, ?Curl $client = null): HttpClient { @@ -98,14 +83,12 @@ public function createRequest(string $url, ?Curl $client = null): HttpClient /** * Creates multi request - * @param MultiCurl|null $client - * @return HttpClient */ public function createMultiRequest(?MultiCurl $client = null): HttpClient { $this->client = $client ?: new MultiCurl(); - $this->client->complete(function (Curl $instance) { + $this->client->complete(function (Curl $instance): void { $this->handleResponse($instance); }); @@ -114,10 +97,6 @@ public function createMultiRequest(?MultiCurl $client = null): HttpClient /** * Creates async multi request - * @param callable $success - * @param callable $error - * @param MultiCurl|null $client - * @return HttpClient */ public function createAsyncMultiRequest(callable $success, callable $error, ?MultiCurl $client = null): HttpClient { @@ -131,8 +110,6 @@ public function createAsyncMultiRequest(callable $success, callable $error, ?Mul /** * Sets http method - * @param string $method - * @return $this * @throws BaseException */ public function setMethod(string $method): HttpClient @@ -147,7 +124,6 @@ public function setMethod(string $method): HttpClient /** * Gets the current http method - * @return string */ public function getMethod(): string { @@ -157,7 +133,6 @@ public function getMethod(): string /** * Sets data * @param mixed $data - * @return HttpClient */ public function setData($data): HttpClient { @@ -176,7 +151,6 @@ public function getData() /** * Checks if the request is multi cURL - * @return bool */ public function isMultiRequest(): bool { @@ -205,7 +179,6 @@ public function start(): HttpClient /** * Gets single or all request headers - * @param string|null $header * @return mixed|null * @throws BaseException */ @@ -222,7 +195,6 @@ public function getRequestHeaders(?string $header = null) /** * Gets the response headers - * @param string|null $header * @return mixed|null * @throws BaseException */ @@ -241,7 +213,6 @@ public function getResponseHeaders(?string $header = null) /** * Gets the response cookies - * @param string|null $cookie * @return mixed|null * @throws BaseException */ @@ -272,7 +243,6 @@ public function getResponseBody() /** * Gets the entire response - * @return array */ public function getResponse(): array { @@ -281,7 +251,6 @@ public function getResponse(): array /** * Returns the errors - * @return array */ public function getErrors(): array { @@ -290,7 +259,6 @@ public function getErrors(): array /** * Gets the curl info - * @param int|null $option * @return mixed * @throws BaseException */ @@ -303,7 +271,6 @@ public function info(?int $option = null) /** * Gets the current url being executed - * @return string|null * @throws BaseException */ public function url(): ?string @@ -314,9 +281,6 @@ public function url(): ?string } /** - * @param string $method - * @param array $arguments - * @return $this * @throws BaseException * @throws HttpClientException */ @@ -338,7 +302,6 @@ public function __call(string $method, array $arguments): HttpClient } /** - * @return void * @throws ErrorException */ private function startSingleRequest(): void @@ -355,9 +318,8 @@ private function startSingleRequest(): void /** * Handles the response - * @param Curl $instance */ - private function handleResponse(Curl $instance) + private function handleResponse(Curl $instance): void { if ($instance->isError()) { $this->errors[$instance->getId()] = [ @@ -373,10 +335,6 @@ private function handleResponse(Curl $instance) ]; } - /** - * @param CaseInsensitiveArray $headers - * @return array - */ private function formatHeaders(CaseInsensitiveArray $headers): array { $formatted = []; @@ -389,7 +347,6 @@ private function formatHeaders(CaseInsensitiveArray $headers): array } /** - * @return void * @throws BaseException */ private function ensureSingleRequest(): void @@ -399,11 +356,6 @@ private function ensureSingleRequest(): void } } - /** - * @param string $method - * @param array $arguments - * @return void - */ private function interceptCall(string $method, array $arguments): void { switch ($method) { diff --git a/src/Jwt/Exceptions/JwtException.php b/src/Jwt/Exceptions/JwtException.php index bdb3edf6c..cbbb9e5e6 100644 --- a/src/Jwt/Exceptions/JwtException.php +++ b/src/Jwt/Exceptions/JwtException.php @@ -25,9 +25,6 @@ */ class JwtException extends BaseException { - /** - * @return JwtException - */ public static function payloadNotFound(): self { return new self( diff --git a/src/Jwt/JwtToken.php b/src/Jwt/JwtToken.php index 82393ca80..95a2d926a 100644 --- a/src/Jwt/JwtToken.php +++ b/src/Jwt/JwtToken.php @@ -28,30 +28,23 @@ class JwtToken extends JWT { /** * JWT secret key - * @var string */ private string $key; /** * Encryption algorithm - * @var string */ private string $algorithm = 'HS256'; /** * Payload data - * @var array */ private array $payload = []; - /** - * @var object|null - */ private ?object $fetchedPayload = null; /** * JwtToken constructor. - * @param string|null $key * @throws EnvException */ public function __construct(?string $key = null) @@ -61,7 +54,6 @@ public function __construct(?string $key = null) /** * Sets extra leeway time - * @return $this */ public function setLeeway($leeway): JwtToken { @@ -71,8 +63,6 @@ public function setLeeway($leeway): JwtToken /** * Sets the encryption algorithm - * @param string $algorithm - * @return $this */ public function setAlgorithm(string $algorithm): JwtToken { @@ -82,9 +72,7 @@ public function setAlgorithm(string $algorithm): JwtToken /** * Sets the claim - * @param string $key * @param mixed $value - * @return $this */ public function setClaim(string $key, $value): JwtToken { @@ -94,8 +82,6 @@ public function setClaim(string $key, $value): JwtToken /** * Set claims - * @param array $claims - * @return $this */ public function setClaims(array $claims): JwtToken { @@ -108,8 +94,6 @@ public function setClaims(array $claims): JwtToken /** * Sets user data - * @param array $data - * @return $this */ public function setData(array $data): JwtToken { @@ -119,12 +103,9 @@ public function setData(array $data): JwtToken /** * Composes and signs the JWT - * @param mixed|null $keyId - * @param array|null $head - * @return string * @throws JwtException */ - public function compose($keyId = null, ?array $head = null): string + public function compose(?string $keyId = null, ?array $head = null): string { if (empty($this->payload)) { throw JwtException::payloadNotFound(); @@ -135,8 +116,6 @@ public function compose($keyId = null, ?array $head = null): string /** * Retrieve and verifies the JWT - * @param string $jwt - * @return $this */ public function retrieve(string $jwt): JwtToken { @@ -155,7 +134,6 @@ public function fetchPayload(): ?object /** * Fetches the user data - * @return array|null */ public function fetchData(): ?array { @@ -164,7 +142,6 @@ public function fetchData(): ?array /** * Fetches the claim - * @param string $key * @return mixed|null */ public function fetchClaim(string $key) diff --git a/src/Lang/Exceptions/LangException.php b/src/Lang/Exceptions/LangException.php index 7c5eb097c..9b7b72695 100644 --- a/src/Lang/Exceptions/LangException.php +++ b/src/Lang/Exceptions/LangException.php @@ -25,9 +25,6 @@ */ class LangException extends BaseException { - /** - * @return LangException - */ public static function translationsNotFound(): self { return new self( @@ -36,9 +33,6 @@ public static function translationsNotFound(): self ); } - /** - * @return LangException - */ public static function misconfiguredDefaultConfig(): self { return new self( diff --git a/src/Lang/Factories/LangFactory.php b/src/Lang/Factories/LangFactory.php index 5c2d47186..486e9f2ed 100644 --- a/src/Lang/Factories/LangFactory.php +++ b/src/Lang/Factories/LangFactory.php @@ -35,7 +35,6 @@ class LangFactory private static ?Lang $instance = null; /** - * @return Lang * @throws ConfigException * @throws LangException * @throws DiException @@ -58,7 +57,6 @@ public static function get(): Lang } /** - * @return array * @throws ConfigException * @throws DiException * @throws ReflectionException @@ -77,9 +75,6 @@ private static function loadLangConfig(): array } /** - * @param array $supported - * @param string|null $default - * @return string * @throws LangException */ private static function detectLanguage(array $supported, ?string $default): string @@ -105,10 +100,6 @@ private static function detectLanguage(array $supported, ?string $default): stri return $lang; } - /** - * @param array $supported - * @return string|null - */ private static function getLangFromQuery(array $supported): ?string { $queryLang = Request::getQueryParam('lang'); @@ -116,10 +107,6 @@ private static function getLangFromQuery(array $supported): ?string return $queryLang && in_array($queryLang, $supported) ? $queryLang : null; } - /** - * @param array $supported - * @return string|null - */ private static function getLangFromUrlSegment(array $supported): ?string { $segmentIndex = (int) config()->get('lang.url_segment'); @@ -133,10 +120,6 @@ private static function getLangFromUrlSegment(array $supported): ?string return $segmentLang && in_array($segmentLang, $supported) ? $segmentLang : null; } - /** - * @param array $supported - * @return string|null - */ private static function getLangFromHeader(array $supported): ?string { $acceptedLang = server()->acceptedLang(); diff --git a/src/Lang/Helpers/lang.php b/src/Lang/Helpers/lang.php index 1649d99ba..5c5c4ccb3 100644 --- a/src/Lang/Helpers/lang.php +++ b/src/Lang/Helpers/lang.php @@ -19,7 +19,6 @@ /** * Gets the current lang - * @return string|null * @throws ConfigException * @throws DiException * @throws LangException @@ -32,9 +31,7 @@ function current_lang(): ?string /** * Gets translation - * @param string $key * @param $params - * @return string|null * @throws ConfigException * @throws ReflectionException * @throws DiException @@ -47,15 +44,13 @@ function t(string $key, $params = null): ?string /** * Outputs the translation - * @param string $key * @param $params - * @return void * @throws ConfigException * @throws DiException * @throws LangException * @throws ReflectionException */ -function _t(string $key, $params = null) +function _t(string $key, $params = null): void { echo t($key, $params); } diff --git a/src/Lang/Lang.php b/src/Lang/Lang.php index b4d96eaea..d607c1f92 100644 --- a/src/Lang/Lang.php +++ b/src/Lang/Lang.php @@ -25,26 +25,12 @@ */ class Lang { - /** - * @var string|null - */ - private $currentLang = null; + private ?string $currentLang = null; - /** - * @var Translator - */ - private $translator; + private Translator $translator; - /** - * @var bool - */ - private $isEnabled; + private bool $isEnabled; - /** - * @param string $lang - * @param bool $isEnabled - * @param Translator $translator - */ public function __construct(string $lang, bool $isEnabled, Translator $translator) { $this->isEnabled = $isEnabled; @@ -53,8 +39,7 @@ public function __construct(string $lang, bool $isEnabled, Translator $translato } /** - * Set current language - * @param string $lang + * Set the current language * @return $this */ public function setLang(string $lang): self @@ -65,7 +50,6 @@ public function setLang(string $lang): self /** * Get current language - * @return string|null */ public function getLang(): ?string { @@ -74,7 +58,6 @@ public function getLang(): ?string /** * Is multilang enabled - * @return bool */ public function isEnabled(): bool { @@ -96,9 +79,7 @@ public function load(): void /** * Get translation by key - * @param string $key * @param $params - * @return string|null */ public function getTranslation(string $key, $params = null): ?string { diff --git a/src/Lang/Translator.php b/src/Lang/Translator.php index 66d3e9341..886f5f09c 100644 --- a/src/Lang/Translator.php +++ b/src/Lang/Translator.php @@ -29,14 +29,8 @@ class Translator { protected string $lang; - /** - * @var Data|null - */ private ?Data $translations = null; - /** - * @param string $lang - */ public function __construct(string $lang) { $this->lang = $lang; @@ -82,7 +76,6 @@ public function loadTranslations(): void /** * Load translations - * @param array $files * @throws BaseException * @throws ConfigException * @throws DiException @@ -101,9 +94,7 @@ private function loadFiles(array $files): void /** * Get translation by key - * @param string $key * @param array|string|null $params - * @return string */ public function get(string $key, $params = null): string { diff --git a/src/Loader/Loader.php b/src/Loader/Loader.php index 89b1f827b..d3ded9e1a 100644 --- a/src/Loader/Loader.php +++ b/src/Loader/Loader.php @@ -25,38 +25,31 @@ class Loader { /** * Current module - * @var string */ - private $module; + private ?string $module = null; /** * Environment - * @var string */ - private $pathPrefix; + private ?string $pathPrefix = null; /** * File name - * @var string */ - private $fileName; + private ?string $fileName = null; /** * Hierarchical - * @var bool */ - private $hierarchical; + private bool $hierarchical = false; /** * Exception message - * @var string */ - private $exceptionMessage; + private string $exceptionMessage = ''; /** * Setups the loader - * @param Setup $setup - * @return $this */ public function setup(Setup $setup): Loader { @@ -71,9 +64,7 @@ public function setup(Setup $setup): Loader /** * Sets new value - * @param string $property * @param mixed $value - * @return $this */ public function set(string $property, $value): Loader { @@ -83,9 +74,8 @@ public function set(string $property, $value): Loader /** * Loads .php files from given directory - * @param string $dir */ - public function loadDir(string $dir) + public function loadDir(string $dir): void { foreach (glob($dir . DS . '*.php') as $filename) { require_once $filename; @@ -104,7 +94,6 @@ public function load() /** * Checks if the setup points to valid file - * @return bool */ public function fileExists(): bool { @@ -124,7 +113,6 @@ public function fileExists(): bool /** * Gets the file path - * @return string * @throws LoaderException */ public function getFilePath(): string @@ -146,9 +134,6 @@ public function getFilePath(): string return $filePath; } - /** - * @return string - */ private function resolveFilePath(): string { $filePath = ''; @@ -161,8 +146,6 @@ private function resolveFilePath(): string $filePath .= $this->pathPrefix . DS; } - $filePath .= $this->fileName . '.php'; - - return $filePath; + return $filePath . ($this->fileName . '.php'); } } diff --git a/src/Loader/Setup.php b/src/Loader/Setup.php index c04e8365e..5dee46e68 100644 --- a/src/Loader/Setup.php +++ b/src/Loader/Setup.php @@ -14,44 +14,28 @@ namespace Quantum\Loader; +use Quantum\Di\Exceptions\DiException; +use ReflectionException; + /** * Class Setup * @package Quantum\Loader */ class Setup { - /** - * @var bool - */ - protected $hierarchical = false; + protected bool $hierarchical; - /** - * @var string|null - */ - protected $module; + protected ?string $module; - /** - * @var string|null - */ - protected $pathPrefix; + protected ?string $pathPrefix; - /** - * @var string|null - */ - protected $fileName; + protected ?string $fileName; - /** - * @var string - */ - protected $exceptionMessage; + protected string $exceptionMessage; /** * Setup constructor. - * @param string|null $pathPrefix - * @param string|null $fileName - * @param bool $hierarchical - * @param string|null $module - * @param string|null $exceptionMessage + * @throws DiException|ReflectionException */ public function __construct(?string $pathPrefix = null, ?string $fileName = null, bool $hierarchical = true, ?string $module = null, ?string $exceptionMessage = null) { @@ -64,8 +48,6 @@ public function __construct(?string $pathPrefix = null, ?string $fileName = null /** * Sets the path prefix - * @param string $pathPrefix - * @return $this */ public function setPathPrefix(string $pathPrefix): Setup { @@ -75,7 +57,6 @@ public function setPathPrefix(string $pathPrefix): Setup /** * Gets the path prefix - * @return string|null */ public function getPathPrefix(): ?string { @@ -84,8 +65,6 @@ public function getPathPrefix(): ?string /** * Set the filename - * @param string $fileName - * @return $this */ public function setFilename(string $fileName): Setup { @@ -95,7 +74,6 @@ public function setFilename(string $fileName): Setup /** * Gets the filename - * @return string|null */ public function getFilename(): ?string { @@ -104,8 +82,6 @@ public function getFilename(): ?string /** * Sets the module - * @param string $module - * @return $this */ public function setModule(string $module): Setup { @@ -115,7 +91,6 @@ public function setModule(string $module): Setup /** * Gets the module - * @return string|null */ public function getModule(): ?string { @@ -124,8 +99,6 @@ public function getModule(): ?string /** * Sets the exception message - * @param string $exceptionMessage - * @return $this */ public function setExceptionMessage(string $exceptionMessage): Setup { @@ -135,7 +108,6 @@ public function setExceptionMessage(string $exceptionMessage): Setup /** * Gets the exception message - * @return string */ public function getExceptionMessage(): string { @@ -144,8 +116,6 @@ public function getExceptionMessage(): string /** * Set the hierarchy - * @param bool $hierarchy - * @return $this */ public function setHierarchy(bool $hierarchy): Setup { @@ -155,7 +125,6 @@ public function setHierarchy(bool $hierarchy): Setup /** * Gets the hierarchy - * @return bool */ public function getHierarchy(): bool { diff --git a/src/Logger/Adapters/DailyAdapter.php b/src/Logger/Adapters/DailyAdapter.php index 9047a3c53..79aa8b366 100644 --- a/src/Logger/Adapters/DailyAdapter.php +++ b/src/Logger/Adapters/DailyAdapter.php @@ -32,7 +32,6 @@ class DailyAdapter implements ReportableInterface use LoggerTrait; /** - * @param array $params * @throws BaseException * @throws LoggerException * @throws DiException @@ -47,8 +46,6 @@ public function __construct(array $params) /** * Initialize the adapter for Daily logs - * @param array $params - * @return void * @throws LoggerException */ protected function initialize(array $params): void diff --git a/src/Logger/Adapters/MessageAdapter.php b/src/Logger/Adapters/MessageAdapter.php index 27d57e4bf..615a33ca5 100644 --- a/src/Logger/Adapters/MessageAdapter.php +++ b/src/Logger/Adapters/MessageAdapter.php @@ -25,13 +25,10 @@ class MessageAdapter implements ReportableInterface { /** - * @param string $level * @param $message - * @param array|null $context - * @return void * @throws DebugBarException */ - public function report(string $level, $message, ?array $context = []) + public function report(string $level, $message, ?array $context = []): void { $tab = $context['tab'] ?? Debugger::MESSAGES; diff --git a/src/Logger/Adapters/SingleAdapter.php b/src/Logger/Adapters/SingleAdapter.php index 62cfe7d19..2091a62de 100644 --- a/src/Logger/Adapters/SingleAdapter.php +++ b/src/Logger/Adapters/SingleAdapter.php @@ -32,7 +32,6 @@ class SingleAdapter implements ReportableInterface use LoggerTrait; /** - * @param array $params * @throws BaseException * @throws LoggerException * @throws DiException @@ -47,8 +46,6 @@ public function __construct(array $params) /** * Initialize the adapter for Single log file - * @param array $params - * @return void * @throws LoggerException */ protected function initialize(array $params): void diff --git a/src/Logger/Contracts/ReportableInterface.php b/src/Logger/Contracts/ReportableInterface.php index a483680f6..46ebeb56b 100644 --- a/src/Logger/Contracts/ReportableInterface.php +++ b/src/Logger/Contracts/ReportableInterface.php @@ -22,9 +22,7 @@ interface ReportableInterface { /** * Reports the message - * @param string $level * @param mixed $message - * @param array|null $context */ public function report(string $level, $message, ?array $context = []); diff --git a/src/Logger/Exceptions/LoggerException.php b/src/Logger/Exceptions/LoggerException.php index f22d8c596..cf730358f 100644 --- a/src/Logger/Exceptions/LoggerException.php +++ b/src/Logger/Exceptions/LoggerException.php @@ -25,10 +25,6 @@ */ class LoggerException extends BaseException { - /** - * @param string $name - * @return LoggerException - */ public static function logPathIsNotDirectory(string $name): self { return new self( @@ -37,10 +33,6 @@ public static function logPathIsNotDirectory(string $name): self ); } - /** - * @param string $name - * @return LoggerException - */ public static function logPathIsNotFile(string $name): self { return new self( diff --git a/src/Logger/Factories/LoggerFactory.php b/src/Logger/Factories/LoggerFactory.php index b340149c2..5c936f172 100644 --- a/src/Logger/Factories/LoggerFactory.php +++ b/src/Logger/Factories/LoggerFactory.php @@ -44,11 +44,9 @@ class LoggerFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Logger * @throws BaseException * @throws ConfigException * @throws DiException @@ -81,11 +79,6 @@ public static function get(?string $adapter = null): Logger return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Logger - */ private static function createInstance(string $adapterClass, string $adapter): Logger { return $adapter === Logger::MESSAGE @@ -94,8 +87,6 @@ private static function createInstance(string $adapterClass, string $adapter): L } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Logger/Helpers/logger.php b/src/Logger/Helpers/logger.php index 7ac80c358..6bff8a876 100644 --- a/src/Logger/Helpers/logger.php +++ b/src/Logger/Helpers/logger.php @@ -19,8 +19,6 @@ use Quantum\Logger\Logger; /** - * @param string|null $adapter - * @return Logger * @throws BaseException * @throws ConfigException * @throws DiException @@ -34,14 +32,12 @@ function logger(?string $adapter = null): Logger /** * Reports error * @param $var - * @param array $context - * @return void * @throws ConfigException * @throws DiException * @throws ReflectionException * @throws BaseException */ -function error($var, array $context = []) +function error($var, array $context = []): void { LoggerFactory::get()->error($var, $context); } @@ -49,14 +45,12 @@ function error($var, array $context = []) /** * Reports warning * @param $var - * @param array $context - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function warning($var, array $context = []) +function warning($var, array $context = []): void { LoggerFactory::get()->warning($var, $context); } @@ -64,14 +58,12 @@ function warning($var, array $context = []) /** * Reports notice * @param $var - * @param array $context - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function notice($var, array $context = []) +function notice($var, array $context = []): void { LoggerFactory::get()->notice($var, $context); } @@ -79,14 +71,12 @@ function notice($var, array $context = []) /** * Reports info * @param $var - * @param array $context - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function info($var, array $context = []) +function info($var, array $context = []): void { LoggerFactory::get()->info($var, $context); } @@ -94,14 +84,12 @@ function info($var, array $context = []) /** * Reports debug * @param $var - * @param array $context - * @return void * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function debug($var, array $context = []) +function debug($var, array $context = []): void { LoggerFactory::get()->debug($var, $context); } diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 29c4889f0..8600e1916 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -39,22 +39,13 @@ class Logger implements LoggerInterface */ public const MESSAGE = 'message'; - /** - * @var ReportableInterface - */ - private $adapter; + private ReportableInterface $adapter; - /** - * @param ReportableInterface $adapter - */ public function __construct(ReportableInterface $adapter) { $this->adapter = $adapter; } - /** - * @return ReportableInterface - */ public function getAdapter(): ReportableInterface { return $this->adapter; @@ -63,7 +54,7 @@ public function getAdapter(): ReportableInterface /** * @inheritDoc */ - public function emergency($message, array $context = []) + public function emergency($message, array $context = []): void { $this->log(LogLevel::EMERGENCY, $message, $context); } @@ -71,7 +62,7 @@ public function emergency($message, array $context = []) /** * @inheritDoc */ - public function alert($message, array $context = []) + public function alert($message, array $context = []): void { $this->log(LogLevel::ALERT, $message, $context); } @@ -79,7 +70,7 @@ public function alert($message, array $context = []) /** * @inheritDoc */ - public function critical($message, array $context = []) + public function critical($message, array $context = []): void { $this->log(LogLevel::CRITICAL, $message, $context); } @@ -87,7 +78,7 @@ public function critical($message, array $context = []) /** * @inheritDoc */ - public function error($message, array $context = []) + public function error($message, array $context = []): void { $this->log(LogLevel::ERROR, $message, $context); } @@ -95,7 +86,7 @@ public function error($message, array $context = []) /** * @inheritDoc */ - public function warning($message, array $context = []) + public function warning($message, array $context = []): void { $this->log(LogLevel::WARNING, $message, $context); } @@ -103,7 +94,7 @@ public function warning($message, array $context = []) /** * @inheritDoc */ - public function notice($message, array $context = []) + public function notice($message, array $context = []): void { $this->log(LogLevel::NOTICE, $message, $context); } @@ -111,7 +102,7 @@ public function notice($message, array $context = []) /** * @inheritDoc */ - public function info($message, array $context = []) + public function info($message, array $context = []): void { $this->log(LogLevel::INFO, $message, $context); } @@ -119,7 +110,7 @@ public function info($message, array $context = []) /** * @inheritDoc */ - public function debug($message, array $context = []) + public function debug($message, array $context = []): void { $this->log(LogLevel::DEBUG, $message, $context); } @@ -127,7 +118,7 @@ public function debug($message, array $context = []) /** * @inheritDoc */ - public function log($level, $message, array $context = []) + public function log($level, $message, array $context = []): void { if (is_debug_mode() || LoggerConfig::getLogLevel($level) >= LoggerConfig::getAppLogLevel()) { $this->adapter->report($level, $message, $context); diff --git a/src/Logger/LoggerConfig.php b/src/Logger/LoggerConfig.php index b80aa40f9..89be469cc 100644 --- a/src/Logger/LoggerConfig.php +++ b/src/Logger/LoggerConfig.php @@ -39,15 +39,10 @@ class LoggerConfig */ public const DEFAULT_LOG_LEVEL = 'error'; - /** - * @var string - */ - private static $logLevel = self::DEFAULT_LOG_LEVEL; + private static string $logLevel = self::DEFAULT_LOG_LEVEL; /** * Set the application's log level. - * @param string $level - * @return void */ public static function setAppLogLevel(string $level): void { @@ -58,7 +53,6 @@ public static function setAppLogLevel(string $level): void /** * Get the integer value of the application's log level. - * @return int */ public static function getAppLogLevel(): int { @@ -67,8 +61,6 @@ public static function getAppLogLevel(): int /** * Get the integer log level for a given error type. - * @param string $errorType - * @return int */ public static function getLogLevel(string $errorType): int { diff --git a/src/Logger/Traits/LoggerTrait.php b/src/Logger/Traits/LoggerTrait.php index cf6c297b0..f87fda0e6 100644 --- a/src/Logger/Traits/LoggerTrait.php +++ b/src/Logger/Traits/LoggerTrait.php @@ -35,17 +35,13 @@ trait LoggerTrait /** * Initialize the logger - * @param array $params * @throws LoggerException */ abstract protected function initialize(array $params): void; /** * Reports a log message - * @param string $level * @param $message - * @param array|null $context - * @return void */ public function report(string $level, $message, ?array $context = []): void { @@ -54,10 +50,7 @@ public function report(string $level, $message, ?array $context = []): void /** * Formats the log message - * @param string $level * @param $message - * @param array|null $context - * @return string */ protected function formatMessage(string $level, $message, ?array $context = []): string { diff --git a/src/Mailer/Adapters/MailgunAdapter.php b/src/Mailer/Adapters/MailgunAdapter.php index e86c4854d..539747301 100644 --- a/src/Mailer/Adapters/MailgunAdapter.php +++ b/src/Mailer/Adapters/MailgunAdapter.php @@ -27,34 +27,19 @@ class MailgunAdapter implements MailerInterface { use MailerTrait; - /** - * @var string - */ - public $name = 'Mailgun'; - - /** - * @var HttpClient - */ - protected $httpClient; + public string $name = 'Mailgun'; /** * @var string */ private $apiKey; - /** - * @var string - */ - private $apiUrl = 'https://api.mailgun.net/v3/'; + private string $apiUrl = 'https://api.mailgun.net/v3/'; - /** - * @var array - */ - private $data = []; + private array $data = []; /** * MailgunAdapter constructor - * @param array $params */ public function __construct(array $params) { @@ -67,7 +52,7 @@ public function __construct(array $params) /** * Prepares the data */ - private function prepare() + private function prepare(): void { $this->data['from'] = $this->from['name'] . ' ' . $this->from['email']; @@ -93,9 +78,6 @@ private function prepare() } } - /** - * @return bool - */ private function sendEmail(): bool { try { diff --git a/src/Mailer/Adapters/MandrillAdapter.php b/src/Mailer/Adapters/MandrillAdapter.php index 60284ef2a..634c99d18 100644 --- a/src/Mailer/Adapters/MandrillAdapter.php +++ b/src/Mailer/Adapters/MandrillAdapter.php @@ -32,24 +32,12 @@ class MandrillAdapter implements MailerInterface */ public $name = 'Mandrill'; - /** - * @var HttpClient - */ - protected $httpClient; - - /** - * @var string - */ - private $apiUrl = 'https://mandrillapp.com/api/1.0/messages/send.json'; + private string $apiUrl = 'https://mandrillapp.com/api/1.0/messages/send.json'; - /** - * @var array - */ - private $data = []; + private array $data = []; /** * MandrillAdapter constructor - * @param array $params */ public function __construct(array $params) { @@ -61,7 +49,7 @@ public function __construct(array $params) /** * Prepares the data */ - private function prepare() + private function prepare(): void { $message = []; @@ -90,9 +78,6 @@ private function prepare() $this->data['message'] = $message; } - /** - * @return bool - */ private function sendEmail(): bool { try { diff --git a/src/Mailer/Adapters/SendgridAdapter.php b/src/Mailer/Adapters/SendgridAdapter.php index b7f0af01e..5f62b456d 100644 --- a/src/Mailer/Adapters/SendgridAdapter.php +++ b/src/Mailer/Adapters/SendgridAdapter.php @@ -27,34 +27,19 @@ class SendgridAdapter implements MailerInterface { use MailerTrait; - /** - * @var string - */ - public $name = 'Sendgrid'; - - /** - * @var HttpClient - */ - protected $httpClient; + public string $name = 'Sendgrid'; /** * @var string */ private $apiKey; - /** - * @var string - */ - private $apiUrl = 'https://api.sendgrid.com/v3/mail/send'; + private string $apiUrl = 'https://api.sendgrid.com/v3/mail/send'; - /** - * @var array - */ - private $data = []; + private array $data = []; /** * SendgridAdapter constructor - * @param array $params */ public function __construct(array $params) { @@ -66,7 +51,7 @@ public function __construct(array $params) /** * Prepares the data */ - public function prepare() + public function prepare(): void { $this->data['from'] = $this->from; @@ -94,9 +79,6 @@ public function prepare() } } - /** - * @return bool - */ private function sendEmail(): bool { try { diff --git a/src/Mailer/Adapters/SendinblueAdapter.php b/src/Mailer/Adapters/SendinblueAdapter.php index 1407697ee..e30f4d0bf 100644 --- a/src/Mailer/Adapters/SendinblueAdapter.php +++ b/src/Mailer/Adapters/SendinblueAdapter.php @@ -27,34 +27,19 @@ class SendinblueAdapter implements MailerInterface { use MailerTrait; - /** - * @var string - */ - public $name = 'Sendinblue'; - - /** - * @var HttpClient - */ - protected $httpClient; + public string $name = 'Sendinblue'; /** * @var string */ private $apiKey; - /** - * @var string - */ - private $apiUrl = 'https://api.sendinblue.com/v3/smtp/email'; + private string $apiUrl = 'https://api.sendinblue.com/v3/smtp/email'; - /** - * @var array - */ - private $data = []; + private array $data = []; /** * SendinblueAdapter constructor - * @param array $params */ public function __construct(array $params) { @@ -66,7 +51,7 @@ public function __construct(array $params) /** * Prepares the data */ - private function prepare() + private function prepare(): void { $this->data['sender'] = $this->from; $this->data['to'] = $this->addresses; @@ -86,9 +71,6 @@ private function prepare() } } - /** - * @return bool - */ private function sendEmail(): bool { try { diff --git a/src/Mailer/Adapters/SmtpAdapter.php b/src/Mailer/Adapters/SmtpAdapter.php index 0cd69b7e3..c58475ed8 100644 --- a/src/Mailer/Adapters/SmtpAdapter.php +++ b/src/Mailer/Adapters/SmtpAdapter.php @@ -29,49 +29,10 @@ class SmtpAdapter implements MailerInterface { use MailerTrait; - /** - * @var string - */ - public $name = 'SMTP'; - - /** - * @var PHPMailer - */ - protected $mailer; - - /** - * Reply To addresses - * @var array - */ - protected $replyToAddresses = []; - - /** - * CC addresses - * @var array - */ - protected $ccAddresses = []; - - /** - * BCC addresses - * @var array - */ - protected $bccAddresses = []; - - /** - * Email attachments - * @var array - */ - protected $attachments = []; - - /** - * Email attachments created from string - * @var array - */ - protected $stringAttachments = []; + public string $name = 'SMTP'; /** * SmtpAdapter constructor - * @param array $params */ public function __construct(array $params) { @@ -84,7 +45,7 @@ public function __construct(array $params) if (config()->get('debug')) { $this->mailer->SMTPDebug = SMTP::DEBUG_SERVER; - $this->mailer->Debugoutput = function ($message) { + $this->mailer->Debugoutput = function ($message): void { warning($message, ['tab' => Debugger::MAILS]); }; } @@ -92,9 +53,6 @@ public function __construct(array $params) /** * Sets "Reply-To" address - * @param string $email - * @param string|null $name - * @return $this */ public function setReplay(string $email, ?string $name = null): SmtpAdapter { @@ -108,7 +66,6 @@ public function setReplay(string $email, ?string $name = null): SmtpAdapter /** * Gets "Reply-To" addresses - * @return array */ public function getReplays(): array { @@ -117,9 +74,6 @@ public function getReplays(): array /** * Sets "CC" address - * @param string $email - * @param string|null $name - * @return $this */ public function setCC(string $email, ?string $name = null): SmtpAdapter { @@ -133,7 +87,6 @@ public function setCC(string $email, ?string $name = null): SmtpAdapter /** * Gets "CC" addresses - * @return array */ public function getCCs(): array { @@ -142,9 +95,6 @@ public function getCCs(): array /** * Sets "BCC" address - * @param string $email - * @param string|null $name - * @return $this */ public function setBCC(string $email, ?string $name = null): SmtpAdapter { @@ -158,7 +108,6 @@ public function setBCC(string $email, ?string $name = null): SmtpAdapter /** * Get "BCC" addresses - * @return array */ public function getBCCs(): array { @@ -167,8 +116,6 @@ public function getBCCs(): array /** * Sets attachments from the path on the filesystem - * @param string $attachment - * @return $this */ public function setAttachment(string $attachment): SmtpAdapter { @@ -179,7 +126,6 @@ public function setAttachment(string $attachment): SmtpAdapter /** * Gets the attachments - * @return array */ public function getAttachments(): array { @@ -188,9 +134,6 @@ public function getAttachments(): array /** * Sets attachment from the string - * @param string $content - * @param string $filename - * @return $this */ public function setStringAttachment(string $content, string $filename): SmtpAdapter { @@ -204,7 +147,6 @@ public function setStringAttachment(string $content, string $filename): SmtpAdap /** * Gets the string attachments - * @return array */ public function getStringAttachments(): array { @@ -213,9 +155,8 @@ public function getStringAttachments(): array /** * Setups the SMTP - * @param array $params */ - private function setupSmtp(array $params) + private function setupSmtp(array $params): void { $this->mailer->isSMTP(); $this->mailer->SMTPAuth = true; @@ -230,7 +171,7 @@ private function setupSmtp(array $params) * Prepares the data * @throws Exception */ - private function prepare() + private function prepare(): void { $this->mailer->setFrom($this->from['email'], $this->from['name']); @@ -258,28 +199,23 @@ private function prepare() /** * Fills the php mailer properties - * @param string $method - * @param array $fields */ - private function fillProperties(string $method, array $fields = []) + private function fillProperties(string $method, array $fields = []): void { - if ($fields !== []) { - foreach ($fields as $field) { - if (is_string($field)) { - $this->mailer->$method($field); - } else { - $valOne = current($field); - next($field); - $valTwo = current($field); - $this->mailer->$method($valOne, $valTwo); - reset($field); - } + foreach ($fields as $field) { + if (is_string($field)) { + $this->mailer->$method($field); + } else { + $valOne = current($field); + next($field); + $valTwo = current($field); + $this->mailer->$method($valOne, $valTwo); + reset($field); } } } /** - * @return bool * @throws \PHPMailer\PHPMailer\Exception */ private function sendEmail(): bool diff --git a/src/Mailer/Contracts/MailerInterface.php b/src/Mailer/Contracts/MailerInterface.php index e9506a4c3..00b8ddb98 100644 --- a/src/Mailer/Contracts/MailerInterface.php +++ b/src/Mailer/Contracts/MailerInterface.php @@ -22,62 +22,47 @@ interface MailerInterface { /** * Sets the 'From' email and the name - * @param string $email - * @param string|null $name - * @return MailerInterface */ public function setFrom(string $email, ?string $name = null): MailerInterface; /** * Gets the 'From' email and the name - * @return array */ public function getFrom(): array; /** * Sets 'To' addresses - * @param string $email - * @param string|null $name - * @return MailerInterface */ public function setAddress(string $email, ?string $name = null): MailerInterface; /** * Gets 'To' addresses - * @return array */ public function getAddresses(): array; /** * Sets the subject - * @param string|null $subject - * @return MailerInterface */ public function setSubject(?string $subject): MailerInterface; /** * Gets the subject - * @return string|null */ public function getSubject(): ?string; /** * Sets the template - * @param string $templatePath - * @return MailerInterface */ public function setTemplate(string $templatePath): MailerInterface; /** * Gets the template - * @return string|null */ public function getTemplate(): ?string; /** * Sets the body * @param string|array $message - * @return MailerInterface */ public function setBody($message): MailerInterface; @@ -89,7 +74,6 @@ public function getBody(); /** * Sends an email - * @return bool */ public function send(): bool; } diff --git a/src/Mailer/Factories/MailerFactory.php b/src/Mailer/Factories/MailerFactory.php index b1f799e3c..1f7b86e67 100644 --- a/src/Mailer/Factories/MailerFactory.php +++ b/src/Mailer/Factories/MailerFactory.php @@ -47,11 +47,9 @@ class MailerFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Mailer * @throws BaseException * @throws ConfigException * @throws DiException @@ -74,19 +72,12 @@ public static function get(?string $adapter = null): Mailer return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Mailer - */ private static function createInstance(string $adapterClass, string $adapter): Mailer { return new Mailer(new $adapterClass(config()->get('mailer.' . $adapter))); } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Mailer/Helpers/mailer.php b/src/Mailer/Helpers/mailer.php index 1544ea737..cefe5453e 100644 --- a/src/Mailer/Helpers/mailer.php +++ b/src/Mailer/Helpers/mailer.php @@ -19,8 +19,6 @@ use Quantum\Mailer\Mailer; /** - * @param string|null $adapter - * @return Mailer * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Mailer/MailTrap.php b/src/Mailer/MailTrap.php index 0a769d2c3..620fb7e10 100644 --- a/src/Mailer/MailTrap.php +++ b/src/Mailer/MailTrap.php @@ -31,14 +31,8 @@ */ class MailTrap { - /** - * @var FileSystem - */ private FileSystem $fs; - /** - * @var MessageParser - */ private MessageParser $parser; /** @@ -46,14 +40,8 @@ class MailTrap */ private $message; - /** - * @var MailTrap|null - */ private static ?MailTrap $instance = null; - /** - * @var string - */ private string $emailsDirectory; /** @@ -71,7 +59,6 @@ private function __construct() /** * Get Instance - * @return MailTrap */ public static function getInstance(): MailTrap { @@ -84,9 +71,6 @@ public static function getInstance(): MailTrap /** * Saves the message on the local file - * @param string $filename - * @param string $content - * @return bool */ public function saveMessage(string $filename, string $content): bool { @@ -99,8 +83,6 @@ public function saveMessage(string $filename, string $content): bool /** * Gets the parsed email - * @param string $filename - * @return $this * @throws BaseException */ public function parseMessage(string $filename): MailTrap @@ -117,7 +99,6 @@ public function parseMessage(string $filename): MailTrap /** * Gets the parsed message ID - * @return string|null */ public function getParsedMessageId(): ?string { @@ -126,7 +107,6 @@ public function getParsedMessageId(): ?string /** * Gets the parsed X Mailer - * @return string|null */ public function getParsedXMailer(): ?string { @@ -135,7 +115,6 @@ public function getParsedXMailer(): ?string /** * Gets the parsed mime version - * @return string|null */ public function getParsedMimeVersion(): ?string { @@ -144,7 +123,6 @@ public function getParsedMimeVersion(): ?string /** * Gets the parsed content type of the email - * @return string|null */ public function getParsedContentType(): ?string { @@ -153,7 +131,6 @@ public function getParsedContentType(): ?string /** * Gets the parsed date - * @return string|null */ public function getParsedDate(): ?string { @@ -162,7 +139,6 @@ public function getParsedDate(): ?string /** * Gets the parsed 'To' addresses - * @return array */ public function getParsedToAddresses(): array { @@ -172,7 +148,6 @@ public function getParsedToAddresses(): array /** * Gets the parsed 'From' address - * @return string|null */ public function getParsedFromAddress(): ?string { @@ -181,7 +156,6 @@ public function getParsedFromAddress(): ?string /** * Gets the parsed 'CC' addresses - * @return array */ public function getParsedCcAddresses(): array { @@ -191,7 +165,6 @@ public function getParsedCcAddresses(): array /** * Gets the parsed 'BCC' addresses - * @return array */ public function getParsedBccAddresses(): array { @@ -201,7 +174,6 @@ public function getParsedBccAddresses(): array /** * Gets the 'Reply To' addresses - * @return array */ public function getParsedReplyToAddresses(): array { @@ -211,7 +183,6 @@ public function getParsedReplyToAddresses(): array /** * Gets the parsed subject - * @return string|null */ public function getParsedSubject(): ?string { @@ -220,7 +191,6 @@ public function getParsedSubject(): ?string /** * Gets the parsed body - * @return string */ public function getParsedBody(): string { @@ -241,7 +211,6 @@ public function getParsedBody(): string /** * Gets the parsed attachments - * @return array|null */ public function getParsedAttachments(): ?array { diff --git a/src/Mailer/Mailer.php b/src/Mailer/Mailer.php index af4bf5bf7..553e4d7bf 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -60,30 +60,19 @@ class Mailer */ public const SENDINBLUE = 'sendinblue'; - /** - * @var MailerInterface - */ - private $adapter; + private MailerInterface $adapter; - /** - * @param MailerInterface $adapter - */ public function __construct(MailerInterface $adapter) { $this->adapter = $adapter; } - /** - * @return MailerInterface - */ public function getAdapter(): MailerInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Mailer/Traits/MailerTrait.php b/src/Mailer/Traits/MailerTrait.php index 552189be6..584288bff 100644 --- a/src/Mailer/Traits/MailerTrait.php +++ b/src/Mailer/Traits/MailerTrait.php @@ -31,84 +31,63 @@ trait MailerTrait { /** * From address and name - * @var array */ - private $from = []; + private array $from = []; /** * To addresses - * @var array */ - private $addresses = []; + private array $addresses = []; /** * Email subject - * @var string|null */ - private $subject = null; + private ?string $subject = null; /** * Email body * @var string|array|null */ - private $message = null; + private $message; - /** - * @var string - */ - private static $messageId = null; + private static ?string $messageId = null; /** * Template path - * @var string|null */ - private $templatePath = null; + private ?string $templatePath = null; - /** - * @var HttpClient - */ - protected $httpClient; + protected ?HttpClient $httpClient = null; - /** - * @var PHPMailer - */ - protected $mailer; + protected ?PHPMailer $mailer = null; /** * Reply To addresses - * @var array */ - protected $replyToAddresses = []; + protected array $replyToAddresses = []; /** * CC addresses - * @var array */ - protected $ccAddresses = []; + protected array $ccAddresses = []; /** * BCC addresses - * @var array */ - protected $bccAddresses = []; + protected array $bccAddresses = []; /** * Email attachments - * @var array */ - protected $attachments = []; + protected array $attachments = []; /** * Email attachments created from string - * @var array */ - protected $stringAttachments = []; + protected array $stringAttachments = []; /** * Sets the 'From' email and the name - * @param string $email - * @param string|null $name - * @return MailerInterface */ public function setFrom(string $email, ?string $name = null): MailerInterface { @@ -119,7 +98,6 @@ public function setFrom(string $email, ?string $name = null): MailerInterface /** * Gets 'From' email and the "name" - * @return array */ public function getFrom(): array { @@ -128,9 +106,6 @@ public function getFrom(): array /** * Sets 'To' addresses - * @param string $email - * @param string|null $name - * @return MailerInterface */ public function setAddress(string $email, ?string $name = null): MailerInterface { @@ -144,7 +119,6 @@ public function setAddress(string $email, ?string $name = null): MailerInterface /** * Gets 'To' addresses - * @return array */ public function getAddresses(): array { @@ -153,8 +127,6 @@ public function getAddresses(): array /** * Sets the subject - * @param string|null $subject - * @return MailerInterface */ public function setSubject(?string $subject): MailerInterface { @@ -173,8 +145,6 @@ public function getSubject(): ?string /** * Sets the template - * @param string $templatePath - * @return MailerInterface */ public function setTemplate(string $templatePath): MailerInterface { @@ -184,7 +154,6 @@ public function setTemplate(string $templatePath): MailerInterface /** * Gets the template - * @return string|null */ public function getTemplate(): ?string { @@ -194,7 +163,6 @@ public function getTemplate(): ?string /** * Sets the body * @param string|array $message - * @return MailerInterface */ public function setBody($message): MailerInterface { @@ -234,7 +202,6 @@ public function send(): bool /** * Gets the message ID - * @return string|null * @throws Exception */ public function getMessageId(): ?string @@ -254,7 +221,6 @@ public function getMessageId(): ?string } /** - * @return bool * @throws \PHPMailer\PHPMailer\Exception * @throws Exception */ @@ -269,7 +235,6 @@ private function saveEmail(): bool /** * Create message body from email template - * @return string */ private function createFromTemplate(): string { @@ -287,7 +252,6 @@ private function createFromTemplate(): string /** * Gets the complete message - * @return string * @throws Exception */ private function getMessageContent(): string @@ -301,7 +265,6 @@ private function getMessageContent(): string /** * Generates the message content - * @return string * @throws Exception */ private function generateMessage(): string @@ -326,15 +289,13 @@ private function generateMessage(): string $message .= 'Content-Type: text/html; charset=UTF-8' . PHP_EOL . PHP_EOL; - $message .= $this->message . PHP_EOL; - - return $message; + return $message . ($this->message . PHP_EOL); } /** * Resets the fields */ - private function resetFields() + private function resetFields(): void { $this->from = []; $this->addresses = []; diff --git a/src/Middleware/Exceptions/MiddlewareException.php b/src/Middleware/Exceptions/MiddlewareException.php index b1b021be6..3d8b99478 100644 --- a/src/Middleware/Exceptions/MiddlewareException.php +++ b/src/Middleware/Exceptions/MiddlewareException.php @@ -25,10 +25,6 @@ */ class MiddlewareException extends BaseException { - /** - * @param string $name - * @return MiddlewareException - */ public static function middlewareNotFound(string $name): self { return new self( diff --git a/src/Middleware/MiddlewareManager.php b/src/Middleware/MiddlewareManager.php index b2db8c71c..af652e2b6 100644 --- a/src/Middleware/MiddlewareManager.php +++ b/src/Middleware/MiddlewareManager.php @@ -27,19 +27,14 @@ class MiddlewareManager { /** * Middlewares queue - * @var array */ private array $middlewares = []; /** * Current module - * @var string|null */ private ?string $module; - /** - * @param MatchedRoute $matchedRoute - */ public function __construct(MatchedRoute $matchedRoute) { $route = $matchedRoute->getRoute(); @@ -50,9 +45,6 @@ public function __construct(MatchedRoute $matchedRoute) /** * Apply Middlewares - * @param Request $request - * @param Response $response - * @return array * @throws MiddlewareException */ public function applyMiddlewares(Request $request, Response $response): array @@ -63,7 +55,7 @@ public function applyMiddlewares(Request $request, Response $response): array $currentMiddleware = $this->getMiddleware($request, $response); - [$request, $response] = $currentMiddleware->apply($request, $response, function ($request, $response) { + [$request, $response] = $currentMiddleware->apply($request, $response, function ($request, $response): array { next($this->middlewares); return [$request, $response]; }); @@ -73,9 +65,6 @@ public function applyMiddlewares(Request $request, Response $response): array /** * Loads and gets the current middleware instance - * @param Request $request - * @param Response $response - * @return QtMiddleware * @throws MiddlewareException */ private function getMiddleware(Request $request, Response $response): QtMiddleware diff --git a/src/Middleware/QtMiddleware.php b/src/Middleware/QtMiddleware.php index 839b59b0a..8a0ad602c 100644 --- a/src/Middleware/QtMiddleware.php +++ b/src/Middleware/QtMiddleware.php @@ -29,9 +29,6 @@ abstract class QtMiddleware * * Applies the middleware * - * @param Request $request - * @param Response $response - * @param Closure $next * @return mixed */ abstract public function apply(Request $request, Response $response, Closure $next); diff --git a/src/Migration/Exceptions/MigrationException.php b/src/Migration/Exceptions/MigrationException.php index a6677ffd1..57e4f439d 100644 --- a/src/Migration/Exceptions/MigrationException.php +++ b/src/Migration/Exceptions/MigrationException.php @@ -27,9 +27,6 @@ */ class MigrationException extends BaseException { - /** - * @return MigrationException - */ public static function wrongDirection(): self { return new self( @@ -38,10 +35,6 @@ public static function wrongDirection(): self ); } - /** - * @param string $action - * @return MigrationException - */ public static function unsupportedAction(string $action): self { return new self( @@ -50,9 +43,6 @@ public static function unsupportedAction(string $action): self ); } - /** - * @return MigrationException - */ public static function nothingToMigrate(): self { return new self( diff --git a/src/Migration/MigrationManager.php b/src/Migration/MigrationManager.php index 5513a3b7b..e4c178a3f 100644 --- a/src/Migration/MigrationManager.php +++ b/src/Migration/MigrationManager.php @@ -54,29 +54,14 @@ class MigrationManager */ public const DRIVERS = ['mysql', 'pgsql', 'sqlite']; - /** - * @var array - */ private array $migrations = []; - /** - * @var TableFactory - */ private TableFactory $tableFactory; - /** - * @var string - */ private string $migrationFolder; - /** - * @var FileSystem - */ private FileSystem $fs; - /** - * @var Database - */ private Database $db; /** @@ -103,9 +88,6 @@ public function __construct() /** * Generates new migration file - * @param string $table - * @param string $action - * @return string * @throws MigrationException * @throws LangException */ @@ -126,9 +108,6 @@ public function generateMigration(string $table, string $action): string /** * Applies migrations - * @param string $direction - * @param int|null $step - * @return int|null * @throws BaseException * @throws ConfigException * @throws DatabaseException @@ -146,7 +125,7 @@ public function applyMigrations(string $direction, ?int $step = null): ?int switch ($direction) { case self::UPGRADE: - $migrated = $this->upgrade($step); + $migrated = $this->upgrade(); break; case self::DOWNGRADE: $migrated = $this->downgrade($step); @@ -160,27 +139,21 @@ public function applyMigrations(string $direction, ?int $step = null): ?int /** * Runs up migrations - * @param int|null $step - * @return int * @throws DatabaseException * @throws LangException * @throws MigrationException */ - private function upgrade(?int $step = null): int + private function upgrade(): int { if (!$this->tableFactory->checkTableExists(MigrationTable::TABLE)) { $migrationTable = new MigrationTable(); $migrationTable->up($this->tableFactory); } - - $this->prepareUpMigrations($step); - + $this->prepareUpMigrations(); if (empty($this->migrations)) { throw MigrationException::nothingToMigrate(); } - $migratedEntries = []; - foreach ($this->migrations as $migrationFile) { $this->fs->require($migrationFile, true); @@ -192,16 +165,12 @@ private function upgrade(?int $step = null): int $migratedEntries[] = $migrationClassName; } - $this->addMigratedEntries($migratedEntries); - return count($migratedEntries); } /** * Runs down migrations - * @param int|null $step - * @return int * @throws DatabaseException * @throws LangException * @throws MigrationException @@ -239,20 +208,17 @@ private function downgrade(?int $step): int /** * Prepares up migrations - * @param int|null $step * @throws MigrationException * @throws DatabaseException * */ - private function prepareUpMigrations(?int $step = null) + private function prepareUpMigrations(): void { $migratedEntries = $this->getMigratedEntries(); $migrationFiles = $this->getMigrationFiles(); - if ($migratedEntries === [] && $migrationFiles === []) { throw MigrationException::nothingToMigrate(); } - foreach ($migrationFiles as $timestamp => $migrationFile) { foreach ($migratedEntries as $migratedEntry) { if (pathinfo($migrationFile, PATHINFO_FILENAME) == $migratedEntry['migration']) { @@ -262,17 +228,15 @@ private function prepareUpMigrations(?int $step = null) $this->migrations[$timestamp] = $migrationFile; } - ksort($this->migrations); } /** * Prepares down migrations - * @param int|null $step * @throws DatabaseException * @throws MigrationException */ - private function prepareDownMigrations(?int $step = null) + private function prepareDownMigrations(?int $step = null): void { $migratedEntries = $this->getMigratedEntries(); @@ -294,7 +258,6 @@ private function prepareDownMigrations(?int $step = null) /** * Gets migration files - * @return array */ private function getMigrationFiles(): array { @@ -314,7 +277,6 @@ private function getMigrationFiles(): array /** * Gets migrated entries from migrations table - * @return array * @throws DatabaseException */ private function getMigratedEntries(): array @@ -324,10 +286,9 @@ private function getMigratedEntries(): array /** * Adds migrated entries to migrations table - * @param array $entries * @throws DatabaseException */ - private function addMigratedEntries(array $entries) + private function addMigratedEntries(array $entries): void { foreach ($entries as $entry) { Database::execute('INSERT INTO ' . MigrationTable::TABLE . '(migration) VALUES(:migration)', ['migration' => $entry]); @@ -336,10 +297,9 @@ private function addMigratedEntries(array $entries) /** * Removes migrated entries from migrations table - * @param array $entries * @throws DatabaseException */ - private function removeMigratedEntries(array $entries) + private function removeMigratedEntries(array $entries): void { foreach ($entries as $entry) { Database::execute('DELETE FROM ' . MigrationTable::TABLE . ' WHERE migration=:migration', ['migration' => $entry]); diff --git a/src/Migration/MigrationTable.php b/src/Migration/MigrationTable.php index 0b571969e..868371f98 100644 --- a/src/Migration/MigrationTable.php +++ b/src/Migration/MigrationTable.php @@ -31,11 +31,9 @@ class MigrationTable extends QtMigration /** * Creates the migrations table - * @param TableFactory|null $tableFactory - * @return void * @throws DatabaseException */ - public function up(?TableFactory $tableFactory) + public function up(?TableFactory $tableFactory): void { $table = $tableFactory->create(self::TABLE); $table->addColumn('id', Type::INT, 11)->autoIncrement(); @@ -45,11 +43,9 @@ public function up(?TableFactory $tableFactory) /** * Drops the migrations table - * @param TableFactory|null $tableFactory - * @return void * @throws DatabaseException */ - public function down(?TableFactory $tableFactory) + public function down(?TableFactory $tableFactory): void { $tableFactory->drop(self::TABLE); } diff --git a/src/Migration/QtMigration.php b/src/Migration/QtMigration.php index dfc2b4267..35e735c19 100644 --- a/src/Migration/QtMigration.php +++ b/src/Migration/QtMigration.php @@ -24,13 +24,11 @@ abstract class QtMigration { /** * Upgrades with the specified migration class - * @param TableFactory|null $tableFactory */ abstract public function up(?TableFactory $tableFactory); /** * Downgrades with the specified migration class - * @param TableFactory|null $tableFactory */ abstract public function down(?TableFactory $tableFactory); } diff --git a/src/Migration/Templates/MigrationTemplate.php b/src/Migration/Templates/MigrationTemplate.php index 5777ba6e1..963abf165 100644 --- a/src/Migration/Templates/MigrationTemplate.php +++ b/src/Migration/Templates/MigrationTemplate.php @@ -22,9 +22,6 @@ class MigrationTemplate { /** * Create migration template - * @param string $className - * @param string $tableName - * @return string */ public static function create(string $className, string $tableName): string { @@ -52,9 +49,6 @@ public function down(?TableFactory $tableFactory) /** * Alter migration template - * @param string $className - * @param string $tableName - * @return string */ public static function alter(string $className, string $tableName): string { @@ -81,9 +75,6 @@ public function down(?TableFactory $tableFactory) /** * Rename migration template - * @param string $className - * @param string $tableName - * @return string */ public static function rename(string $className, string $tableName): string { @@ -110,9 +101,6 @@ public function down(?TableFactory $tableFactory) /** * Drop migration template - * @param string $className - * @param string $tableName - * @return string */ public static function drop(string $className, string $tableName): string { diff --git a/src/Model/DbModel.php b/src/Model/DbModel.php index 31d8f2cb7..409433d34 100644 --- a/src/Model/DbModel.php +++ b/src/Model/DbModel.php @@ -44,26 +44,21 @@ abstract class DbModel extends Model { /** * Database table - * @var string */ public string $table = ''; /** * Primary key column - * @var string */ public string $idColumn = 'id'; /** * ORM instance (Idiorm or SleekDB) - * @var DbalInterface|null */ protected ?DbalInterface $ormInstance = null; /** * Set ORM instance - * @param DbalInterface $ormInstance - * @return void */ public function setOrmInstance(DbalInterface $ormInstance): void { @@ -72,7 +67,6 @@ public function setOrmInstance(DbalInterface $ormInstance): void /** * Get ORM instance - * @return DbalInterface * @throws ModelException */ public function getOrmInstance(): DbalInterface @@ -84,9 +78,6 @@ public function getOrmInstance(): DbalInterface return $this->ormInstance; } - /** - * @return array - */ public function relations(): array { return []; @@ -94,8 +85,6 @@ public function relations(): array /** * Finds the record by primary key and returns a new model instance - * @param int $id - * @return DbModel|null * @throws BaseException */ public function findOne(int $id): ?DbModel @@ -107,9 +96,7 @@ public function findOne(int $id): ?DbModel /** * Finds the record by given column and value and returns a new model instance - * @param string $column * @param mixed $value - * @return DbModel|null * @throws BaseException */ public function findOneBy(string $column, $value): ?DbModel @@ -121,7 +108,6 @@ public function findOneBy(string $column, $value): ?DbModel /** * Gets the first record and returns a new model instance - * @return DbModel|null * @throws BaseException */ public function first(): ?DbModel @@ -133,13 +119,12 @@ public function first(): ?DbModel /** * Fetch multiple results - * @return ModelCollection * @throws BaseException */ public function get(): ModelCollection { $models = array_map( - fn ($item) => wrapToModel($item, static::class), + fn (?DbalInterface $item): ?DbModel => wrapToModel($item, static::class), $this->getOrmInstance()->get() ); @@ -148,9 +133,6 @@ public function get(): ModelCollection /** * Paginates the result - * @param int $perPage - * @param int $currentPage - * @return Paginator * @throws BaseException * @throws PaginatorException */ @@ -177,7 +159,6 @@ public function create(): self /** * Save model - * @return bool * @throws ModelException */ public function save(): bool @@ -197,7 +178,6 @@ public function save(): bool /** * Delete model - * @return bool * @throws ModelException */ public function delete(): bool @@ -206,7 +186,6 @@ public function delete(): bool } /** - * @param array $data * @return $this */ public function hydrateFromOrm(array $data): self @@ -216,8 +195,6 @@ public function hydrateFromOrm(array $data): self } /** - * @param string $method - * @param array $args * @return mixed * @throws ModelException */ @@ -252,7 +229,6 @@ public function __sleep() /** * Sync model attributes into ORM - * @return void * @throws ModelException */ protected function syncAttributesToOrm(): void @@ -268,10 +244,6 @@ protected function syncAttributesToOrm(): void } } - /** - * @param string $key - * @return bool - */ protected function shouldFill(string $key): bool { if ($key === $this->idColumn) { @@ -283,7 +255,6 @@ protected function shouldFill(string $key): bool /** * Syncs primary key from ORM to model attributes - * @return void * @throws ModelException */ private function syncPrimaryKeyFromOrm(): void diff --git a/src/Model/Exceptions/ModelException.php b/src/Model/Exceptions/ModelException.php index 6626c0491..667b95489 100644 --- a/src/Model/Exceptions/ModelException.php +++ b/src/Model/Exceptions/ModelException.php @@ -25,10 +25,6 @@ */ class ModelException extends BaseException { - /** - * @param string $name - * @return ModelException - */ public static function inappropriateProperty(string $name): self { return new self( @@ -37,11 +33,6 @@ public static function inappropriateProperty(string $name): self ); } - /** - * @param string $modelName - * @param string $tableName - * @return ModelException - */ public static function wrongRelation(string $modelName, string $tableName): self { return new self( @@ -50,11 +41,6 @@ public static function wrongRelation(string $modelName, string $tableName): self ); } - /** - * @param string $modelName - * @param string $relatedModelName - * @return ModelException - */ public static function relationTypeMissing(string $modelName, string $relatedModelName): self { return new self( @@ -63,11 +49,6 @@ public static function relationTypeMissing(string $modelName, string $relatedMod ); } - /** - * @param string $modelName - * @param string $relatedModelName - * @return ModelException - */ public static function missingRelationKeys(string $modelName, string $relatedModelName): self { return new self( @@ -76,11 +57,6 @@ public static function missingRelationKeys(string $modelName, string $relatedMod ); } - /** - * @param string $modelName - * @param string $foreignKey - * @return ModelException - */ public static function missingForeignKeyValue(string $modelName, string $foreignKey): self { return new self( @@ -89,10 +65,6 @@ public static function missingForeignKeyValue(string $modelName, string $foreign ); } - /** - * @param string $relationType - * @return ModelException - */ public static function unsupportedRelationType(string $relationType): self { return new self( @@ -101,9 +73,6 @@ public static function unsupportedRelationType(string $relationType): self ); } - /** - * @return ModelException - */ public static function ormIsNotSet(): self { return new self( diff --git a/src/Model/Factories/ModelFactory.php b/src/Model/Factories/ModelFactory.php index 1af091328..800054c3f 100644 --- a/src/Model/Factories/ModelFactory.php +++ b/src/Model/Factories/ModelFactory.php @@ -28,8 +28,6 @@ class ModelFactory { /** * Gets the Model - * @param string $modelClass - * @return Model * @throws ModelException */ public static function get(string $modelClass): Model @@ -61,12 +59,6 @@ public static function get(string $modelClass): Model /** * Creates anonymous dynamic model - * @param string $table - * @param string $modelName - * @param string $idColumn - * @param array $foreignKeys - * @param array $hidden - * @return DbModel */ public static function createDynamicModel( string $table, @@ -90,14 +82,6 @@ public static function createDynamicModel( return $model; } - /** - * @param string $table - * @param string $modelName - * @param string $idColumn - * @param array $foreignKeys - * @param array $hidden - * @return DbalInterface - */ protected static function createOrmInstance( string $table, string $modelName, diff --git a/src/Model/Helpers/model.php b/src/Model/Helpers/model.php index da27a7014..3af5a4498 100644 --- a/src/Model/Helpers/model.php +++ b/src/Model/Helpers/model.php @@ -32,12 +32,6 @@ function model(string $modelClass): Model /** * Creates anonymous dynamic model - * @param string $table - * @param string $modelName - * @param string $idColumn - * @param array $foreignKeys - * @param array $hidden - * @return DbModel */ function dynamicModel( string $table, @@ -57,9 +51,6 @@ function dynamicModel( /** * Wraps the orm instance into model - * @param DbalInterface|null $ormInstance - * @param string $modelClass - * @return DbModel|null * @throws ModelException */ function wrapToModel(?DbalInterface $ormInstance, string $modelClass): ?DbModel diff --git a/src/Model/Model.php b/src/Model/Model.php index 13087bd71..a1926bdfa 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -24,25 +24,21 @@ abstract class Model { /** * Internal attributes - * @var array */ protected array $attributes = []; /** * Models fillable properties - * @var array */ protected array $fillable = []; /** * Models hidden properties * Used by DBAL and plain models - * @var array */ public array $hidden = []; /** - * @param string $key * @param $value * @return $this|mixed|null */ @@ -58,7 +54,6 @@ public function prop(string $key, $value = null) /** * Fill object properties - * @param array $props * @return $this * @throws ModelException */ @@ -77,7 +72,6 @@ public function fill(array $props): self /** * Converts to array - * @return array */ public function asArray(): array { @@ -93,7 +87,6 @@ public function asArray(): array /** * Checks if model is empty - * @return bool */ public function isEmpty(): bool { @@ -101,7 +94,6 @@ public function isEmpty(): bool } /** - * @param string $key * @return $this|mixed|null */ public function __get(string $key) @@ -110,37 +102,23 @@ public function __get(string $key) } /** - * @param string $key * @param $value - * @return void */ public function __set(string $key, $value): void { $this->prop($key, $value); } - /** - * @param string $key - * @return bool - */ public function __isset(string $key): bool { return isset($this->attributes[$key]); } - /** - * @param string $key - * @return void - */ public function __unset(string $key): void { unset($this->attributes[$key]); } - /** - * @param string $key - * @return bool - */ protected function shouldFill(string $key): bool { return in_array($key, $this->fillable, true); diff --git a/src/Model/ModelCollection.php b/src/Model/ModelCollection.php index 153926b08..2ced7a603 100644 --- a/src/Model/ModelCollection.php +++ b/src/Model/ModelCollection.php @@ -31,18 +31,11 @@ class ModelCollection implements Countable, IteratorAggregate */ private array $models = []; - /** - * @var iterable - */ private iterable $originalModels; - /** - * @var bool - */ private bool $modelsProcessed = false; /** - * @param iterable $models * @throws BaseException */ public function __construct(iterable $models = []) @@ -57,7 +50,6 @@ public function __construct(iterable $models = []) /** * Add a model to the collection * @param Model $model - * @return self * @throws BaseException */ public function add(Model $model): self @@ -78,14 +70,13 @@ public function add(Model $model): self /** * Remove a model from the collection * @param Model $model - * @return self * @throws BaseException */ public function remove(Model $model): self { $this->processModels(); - $this->models = array_filter($this->models, fn ($m) => $m !== $model); + $this->models = array_filter($this->models, fn (Model $m): bool => $m !== $model); $this->originalModels = $this->models; @@ -105,7 +96,6 @@ public function all(): array /** * Get the count of models in the collection - * @return int * @throws BaseException */ public function count(): int @@ -141,7 +131,6 @@ public function last(): ?Model /** * Check if the collection is empty - * @return bool * @throws BaseException */ public function isEmpty(): bool @@ -151,7 +140,6 @@ public function isEmpty(): bool /** * Get an iterator for the collection - * @return Generator * @throws BaseException */ public function getIterator(): Generator @@ -172,7 +160,7 @@ public function getIterator(): Generator * Process models from original source into the internal array * @throws BaseException */ - private function processModels() + private function processModels(): void { if ($this->modelsProcessed) { return; @@ -191,7 +179,6 @@ private function processModels() /** * Validate that an item is a Model instance * @param $model - * @return void * @throws BaseException */ private function validateModel($model): void diff --git a/src/Model/Traits/HasTimestamps.php b/src/Model/Traits/HasTimestamps.php index cde40ad82..136418d71 100644 --- a/src/Model/Traits/HasTimestamps.php +++ b/src/Model/Traits/HasTimestamps.php @@ -24,25 +24,21 @@ trait HasTimestamps { /** * Column name for created timestamp - * @var string */ public string $createdAt = 'created_at'; /** * Column name for updated timestamp - * @var string */ public string $updatedAt = 'updated_at'; /** * Timestamp storage type: datetime|unix - * @var string */ public string $timestampType = 'datetime'; /** * Determine whether the current model is new (insert) or existing (update). - * @return bool */ protected function isNewRecord(): bool { @@ -67,7 +63,6 @@ protected function nowTimestampValue() /** * Get timestamp type. - * @return string */ protected function getTimestampType(): string { @@ -80,7 +75,6 @@ protected function getTimestampType(): string /** * Get "created at" column name. - * @return string */ protected function getCreatedAtColumn(): string { @@ -93,7 +87,6 @@ protected function getCreatedAtColumn(): string /** * Get "updated at" column name. - * @return string */ protected function getUpdatedAtColumn(): string { @@ -106,7 +99,6 @@ protected function getUpdatedAtColumn(): string /** * Touch timestamps on save - * @return void */ protected function touchTimestamps(): void { diff --git a/src/Model/Traits/SoftDeletes.php b/src/Model/Traits/SoftDeletes.php index 82cb39cdf..1a616e708 100644 --- a/src/Model/Traits/SoftDeletes.php +++ b/src/Model/Traits/SoftDeletes.php @@ -27,14 +27,10 @@ */ trait SoftDeletes { - /** - * @var bool - */ protected bool $includeTrashed = false; /** * Soft delete the model by setting the deleted_at timestamp. - * @return bool * @throws ModelException */ public function delete(): bool @@ -45,7 +41,6 @@ public function delete(): bool /** * Restore a soft deleted model. - * @return bool * @throws ModelException */ public function restore(): bool @@ -56,7 +51,6 @@ public function restore(): bool /** * Force delete the model from the database. - * @return bool * @throws ModelException */ public function forceDelete(): bool @@ -91,7 +85,6 @@ public function onlyTrashed(): self /** * Get all non-deleted records unless withTrashed is called. - * @return ModelCollection * @throws BaseException */ public function get(): ModelCollection @@ -103,9 +96,6 @@ public function get(): ModelCollection /** * Paginate non-deleted records unless withTrashed is called. - * @param int $perPage - * @param int $currentPage - * @return Paginator * @throws BaseException * @throws PaginatorException */ @@ -118,7 +108,6 @@ public function paginate(int $perPage, int $currentPage = 1): Paginator /** * Count all non-deleted records unless withTrashed() is called. - * @return int * @throws ModelException */ public function count(): int @@ -130,8 +119,6 @@ public function count(): int /** * Find one record by its ID, excluding soft deleted unless withTrashed() is called. - * @param int $id - * @return DbModel|null * @throws BaseException */ public function findOne(int $id): ?DbModel @@ -143,9 +130,7 @@ public function findOne(int $id): ?DbModel /** * Find one record by column and value, excluding soft deleted unless withTrashed() is called. - * @param string $column * @param $value - * @return DbModel|null * @throws BaseException */ public function findOneBy(string $column, $value): ?DbModel @@ -157,7 +142,6 @@ public function findOneBy(string $column, $value): ?DbModel /** * Get the first record, excluding soft deleted unless withTrashed() is called. - * @return DbModel|null * @throws BaseException */ public function first(): ?DbModel @@ -193,7 +177,6 @@ protected function getSoftDeleteTimestampValue() /** * Get the column name used for soft deletes. - * @return string */ protected function getDeletedAtColumn(): string { diff --git a/src/Module/Exceptions/ModuleException.php b/src/Module/Exceptions/ModuleException.php index 7cfbb1437..694dc20d7 100644 --- a/src/Module/Exceptions/ModuleException.php +++ b/src/Module/Exceptions/ModuleException.php @@ -24,10 +24,6 @@ */ class ModuleException extends \Exception { - /** - * @param string $name - * @return ModuleException - */ public static function moduleRoutesNotFound(string $name): self { return new self( @@ -36,9 +32,6 @@ public static function moduleRoutesNotFound(string $name): self ); } - /** - * @return ModuleException - */ public static function moduleConfigNotFound(): self { return new self( @@ -47,9 +40,6 @@ public static function moduleConfigNotFound(): self ); } - /** - * @return ModuleException - */ public static function moduleCreationIncomplete(): self { return new self( @@ -58,10 +48,6 @@ public static function moduleCreationIncomplete(): self ); } - /** - * @param string $name - * @return ModuleException - */ public static function missingModuleTemplate(string $name): self { return new self( @@ -70,9 +56,6 @@ public static function missingModuleTemplate(string $name): self ); } - /** - * @return ModuleException - */ public static function missingModuleDirectory(): self { return new self( @@ -81,10 +64,6 @@ public static function missingModuleDirectory(): self ); } - /** - * @param string $name - * @return ModuleException - */ public static function moduleAlreadyExists(string $name): self { return new self( diff --git a/src/Module/ModuleLoader.php b/src/Module/ModuleLoader.php index 017d08db1..1470e14c5 100644 --- a/src/Module/ModuleLoader.php +++ b/src/Module/ModuleLoader.php @@ -32,27 +32,15 @@ */ class ModuleLoader { - /** - * @var array - */ private static array $moduleDependencies = []; - /** - * @var array - */ private static array $moduleConfigs = []; /** @var array */ private static array $moduleRouteClosures = []; - /** - * @var FileSystem - */ private FileSystem $fs; - /** - * @var ModuleLoader|null - */ private static ?ModuleLoader $instance = null; /** @@ -67,9 +55,6 @@ private function __construct() Di::registerDependencies($this->loadModulesDependencies()); } - /** - * @return ModuleLoader - */ public static function getInstance(): ModuleLoader { if (self::$instance === null) { @@ -80,7 +65,6 @@ public static function getInstance(): ModuleLoader } /** - * @return array * @throws ModuleException * @throws RouteException */ @@ -104,8 +88,6 @@ public function loadModulesRoutes(): array } /** - * @param string $module - * @return Closure * @throws ModuleException * @throws RouteException */ @@ -131,7 +113,6 @@ private function getModuleRouteDefinitions(string $module): Closure } /** - * @return array * @throws ModuleException */ public function loadModulesDependencies(): array @@ -149,10 +130,6 @@ public function loadModulesDependencies(): array return $modulesDependencies; } - /** - * @param string $module - * @return array - */ public function getModuleDependencies(string $module): array { if (!isset(self::$moduleDependencies[$module])) { @@ -173,7 +150,7 @@ public function getModuleDependencies(string $module): array /** * @throws ModuleException */ - private function loadModuleConfig() + private function loadModuleConfig(): void { $configPath = App::getBaseDir() . DS . 'shared' . DS . 'config' . DS . 'modules.php'; @@ -185,7 +162,6 @@ private function loadModuleConfig() } /** - * @return array * @throws ModuleException */ public function getModuleConfigs(): array @@ -197,10 +173,6 @@ public function getModuleConfigs(): array return self::$moduleConfigs; } - /** - * @param array $options - * @return bool - */ private function isModuleEnabled(array $options): bool { return (bool) ($options['enabled'] ?? false); diff --git a/src/Module/ModuleManager.php b/src/Module/ModuleManager.php index 28fa6fd40..cb7b71137 100644 --- a/src/Module/ModuleManager.php +++ b/src/Module/ModuleManager.php @@ -32,56 +32,25 @@ class ModuleManager { public const DEFAULT_TEMPLATE = 'DemoWeb'; - /** - * @var FileSystem - */ protected FileSystem $fs; - /** - * @var bool - */ protected bool $optionEnabled; - /** - * @var string - */ private string $moduleName; - /** - * @var string - */ private string $template; - /** - * @var string - */ private string $modulePath; - /** - * @var string - */ private string $assetsPath; - /** - * @var string - */ private string $templatePath; - /** - * @var bool - */ private bool $withAssets; - /** - * @var string - */ private string $modulesConfigPath; /** - * @param string $moduleName - * @param string $template - * @param bool $enabled - * @param bool $withAssets * @throws BaseException * @throws DiException * @throws ConfigException @@ -103,9 +72,6 @@ public function __construct(string $moduleName, string $template, bool $enabled, $this->modulesConfigPath = base_dir() . DS . 'shared' . DS . 'config' . DS . 'modules.php'; } - /** - * @return string - */ public function getModuleName(): string { return $this->moduleName; @@ -116,7 +82,7 @@ public function getModuleName(): string * @throws ExceptionInterface * @throws Exception */ - public function addModuleConfig() + public function addModuleConfig(): void { if (!$this->fs->isDirectory($this->modulePath)) { throw ModuleException::missingModuleDirectory(); @@ -138,7 +104,7 @@ public function addModuleConfig() /** * @throws Exception */ - public function writeContents() + public function writeContents(): void { if (!$this->fs->isDirectory(modules_dir())) { $this->fs->makeDirectory(modules_dir()); @@ -156,9 +122,6 @@ public function writeContents() } /** - * @param string $src - * @param string $dst - * @return array * @throws Exception */ private function copyDirectoryWithTemplates(string $src, string $dst): array @@ -167,9 +130,6 @@ private function copyDirectoryWithTemplates(string $src, string $dst): array } /** - * @param string $src - * @param string $dst - * @return array * @throws Exception */ private function copyAssets(string $src, string $dst): array @@ -178,11 +138,6 @@ private function copyAssets(string $src, string $dst): array } /** - * @param string $src - * @param string $dst - * @param bool $processTemplates - * @param array $copiedFiles - * @return array * @throws Exception */ private function copyDirectory(string $src, string $dst, bool $processTemplates, array $copiedFiles = []): array @@ -216,11 +171,7 @@ private function copyDirectory(string $src, string $dst, bool $processTemplates, return $copiedFiles; } - /** - * @param string $srcPath - * @param string $dstPath - */ - private function processTemplates(string $srcPath, string &$dstPath) + private function processTemplates(string $srcPath, string &$dstPath): void { $dstPath = str_replace('.php.tpl', '.php', $dstPath); $content = $this->fs->get($srcPath); @@ -228,10 +179,6 @@ private function processTemplates(string $srcPath, string &$dstPath) $this->fs->put($dstPath, $processedContent); } - /** - * @param string $content - * @return string - */ private function replacePlaceholders(string $content): string { $placeholders = [ @@ -242,10 +189,6 @@ private function replacePlaceholders(string $content): string return str_replace(array_keys($placeholders), array_values($placeholders), $content); } - /** - * @param string $module - * @return array - */ private function getModuleOptions(string $module): array { return [ @@ -255,8 +198,6 @@ private function getModuleOptions(string $module): array } /** - * @param array $moduleConfigs - * @return void * @throws ExceptionInterface */ private function updateModuleConfigFile(array $moduleConfigs): void @@ -267,10 +208,6 @@ private function updateModuleConfigFile(array $moduleConfigs): void ); } - /** - * @param array $copiedFiles - * @return bool - */ protected function verifyModuleFilesCreated(array $copiedFiles): bool { foreach ($copiedFiles as $file) { diff --git a/src/Paginator/Adapters/ArrayPaginator.php b/src/Paginator/Adapters/ArrayPaginator.php index 16f661452..cd74b969b 100644 --- a/src/Paginator/Adapters/ArrayPaginator.php +++ b/src/Paginator/Adapters/ArrayPaginator.php @@ -25,16 +25,8 @@ class ArrayPaginator implements PaginatorInterface { use PaginatorTrait; - /** - * @var array - */ - private $items; + private array $items; - /** - * @param array $items - * @param int $perPage - * @param int $page - */ public function __construct(array $items, int $perPage, int $page = 1) { $this->initialize($perPage, $page); diff --git a/src/Paginator/Adapters/ModelPaginator.php b/src/Paginator/Adapters/ModelPaginator.php index d22af1103..44618036a 100644 --- a/src/Paginator/Adapters/ModelPaginator.php +++ b/src/Paginator/Adapters/ModelPaginator.php @@ -19,6 +19,7 @@ use Quantum\App\Exceptions\BaseException; use Quantum\Model\ModelCollection; use Quantum\Model\DbModel; +use Quantum\Model\Model; /** * Class ModelPaginator @@ -28,21 +29,10 @@ class ModelPaginator implements PaginatorInterface { use PaginatorTrait; - /** - * @var string - */ private string $modelClass; - /** - * @var DbModel - */ private DbModel $model; - /** - * @param DbModel $model - * @param int $perPage - * @param int $page - */ public function __construct(DbModel $model, int $perPage, int $page = 1) { $this->initialize($perPage, $page); @@ -64,7 +54,7 @@ public function data(): ModelCollection ->get(); if ($this->modelClass != '@anonymous') { - $result = array_map(fn ($item) => wrapToModel($item->getOrmInstance(), $this->modelClass), iterator_to_array($result)); + $result = array_map(fn ($item): ?DbModel => wrapToModel($item->getOrmInstance(), $this->modelClass), iterator_to_array($result)); } return new ModelCollection($result); @@ -74,7 +64,7 @@ public function data(): ModelCollection * @inheritDoc * @throws BaseException */ - public function firstItem() + public function firstItem(): ?Model { $data = $this->data(); @@ -89,7 +79,7 @@ public function firstItem() * @inheritDoc * @throws BaseException */ - public function lastItem() + public function lastItem(): ?Model { $data = $this->data(); diff --git a/src/Paginator/Contracts/PaginatorInterface.php b/src/Paginator/Contracts/PaginatorInterface.php index 53119f317..b6469113a 100644 --- a/src/Paginator/Contracts/PaginatorInterface.php +++ b/src/Paginator/Contracts/PaginatorInterface.php @@ -40,87 +40,66 @@ public function lastItem(); /** * Get current page number - * @return int */ public function currentPageNumber(): int; /** * Get previous page number - * @return int|null */ public function previousPageNumber(): ?int; /** * Get next page number - * @return int|null */ public function nextPageNumber(): ?int; /** * Get last page number - * @return int */ public function lastPageNumber(): int; /** * Get current page link - * @param bool $withBaseUrl - * @return string|null */ public function currentPageLink(bool $withBaseUrl = false): ?string; /** * Get first page link - * @param bool $withBaseUrl - * @return string|null */ public function firstPageLink(bool $withBaseUrl = false): ?string; /** * Get previous page link - * @param bool $withBaseUrl - * @return string|null */ public function previousPageLink(bool $withBaseUrl = false): ?string; /** * Get next page link - * @param bool $withBaseUrl - * @return string|null */ public function nextPageLink(bool $withBaseUrl = false): ?string; /** * Get last page link - * @param bool $withBaseUrl - * @return string|null */ public function lastPageLink(bool $withBaseUrl = false): ?string; /** * Get items per page - * @return int */ public function perPage(): int; /** * Get total items count - * @return int */ public function total(): int; /** * Get all page links - * @param bool $withBaseUrl - * @return array */ public function links(bool $withBaseUrl = false): array; /** * Get pagination HTML - * @param bool $withBaseUrl - * @param int|null $pageItemsCount - * @return string|null */ public function getPagination(bool $withBaseUrl = false, ?int $pageItemsCount = null): ?string; } diff --git a/src/Paginator/Exceptions/PaginatorException.php b/src/Paginator/Exceptions/PaginatorException.php index 2f9ee904e..272506f4e 100644 --- a/src/Paginator/Exceptions/PaginatorException.php +++ b/src/Paginator/Exceptions/PaginatorException.php @@ -26,9 +26,7 @@ class PaginatorException extends BaseException { /** - * @param string $type * @param $missingParam - * @return PaginatorException */ public static function missingRequiredParams(string $type, $missingParam): self { diff --git a/src/Paginator/Factories/PaginatorFactory.php b/src/Paginator/Factories/PaginatorFactory.php index ad7155206..71d7cc107 100644 --- a/src/Paginator/Factories/PaginatorFactory.php +++ b/src/Paginator/Factories/PaginatorFactory.php @@ -52,9 +52,6 @@ class PaginatorFactory /** * Creates a new paginator instance using the selected adapter type. - * @param string $type - * @param array $params - * @return Paginator * @throws BaseException * @throws PaginatorException */ @@ -77,9 +74,6 @@ public static function create(string $type, array $params): Paginator /** * Validates that all required parameters are present. - * @param string $type - * @param array $params - * @return void * @throws PaginatorException */ private static function validateRequiredParams(string $type, array $params): void @@ -93,9 +87,6 @@ private static function validateRequiredParams(string $type, array $params): voi /** * Builds the list of arguments in the correct order for adapter instantiation. - * @param string $type - * @param array $params - * @return array */ private static function buildConstructorArgs(string $type, array $params): array { diff --git a/src/Paginator/Paginator.php b/src/Paginator/Paginator.php index 29747858e..07f8f9423 100644 --- a/src/Paginator/Paginator.php +++ b/src/Paginator/Paginator.php @@ -50,14 +50,8 @@ class Paginator */ public const MODEL = 'model'; - /** - * @var PaginatorInterface - */ - private $adapter; + private PaginatorInterface $adapter; - /** - * @param PaginatorInterface $adapter - */ public function __construct(PaginatorInterface $adapter) { $this->adapter = $adapter; @@ -65,7 +59,6 @@ public function __construct(PaginatorInterface $adapter) /** * Get the adapter instance - * @return PaginatorInterface */ public function getAdapter(): PaginatorInterface { @@ -73,8 +66,6 @@ public function getAdapter(): PaginatorInterface } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Paginator/Traits/PaginatorTrait.php b/src/Paginator/Traits/PaginatorTrait.php index 0a3cb983f..c6a5982c1 100644 --- a/src/Paginator/Traits/PaginatorTrait.php +++ b/src/Paginator/Traits/PaginatorTrait.php @@ -14,7 +14,11 @@ namespace Quantum\Paginator\Traits; +use Quantum\Config\Exceptions\ConfigException; +use Quantum\Lang\Exceptions\LangException; use Quantum\Paginator\Enums\Pagination; +use Quantum\Di\Exceptions\DiException; +use ReflectionException; /** * Trait PaginatorTrait @@ -22,29 +26,17 @@ */ trait PaginatorTrait { - /** - * @var string - */ protected string $baseUrl; - /** - * @var int - */ protected int $total; - /** - * @var int - */ protected int $perPage; - /** - * @var int - */ protected int $page; /** - * @param int $perPage - * @param int $page + * @throws DiException + * @throws ReflectionException */ protected function initialize(int $perPage, int $page = 1): void { @@ -54,8 +46,7 @@ protected function initialize(int $perPage, int $page = 1): void } /** - * Get total number of items - * @return int + * Get the total number of items */ public function total(): int { @@ -63,8 +54,7 @@ public function total(): int } /** - * Get current page number - * @return int + * Get the current page number */ public function currentPageNumber(): int { @@ -73,7 +63,6 @@ public function currentPageNumber(): int /** * Get previous page number - * @return int|null */ public function previousPageNumber(): ?int { @@ -90,7 +79,6 @@ public function previousPageNumber(): ?int /** * Get next page number - * @return int|null */ public function nextPageNumber(): ?int { @@ -107,7 +95,6 @@ public function nextPageNumber(): ?int /** * Get last page number - * @return int */ public function lastPageNumber(): int { @@ -115,9 +102,7 @@ public function lastPageNumber(): int } /** - * Get current page link - * @param bool $withBaseUrl - * @return string|null + * Get the current page link */ public function currentPageLink(bool $withBaseUrl = false): ?string { @@ -126,8 +111,6 @@ public function currentPageLink(bool $withBaseUrl = false): ?string /** * Get first page link - * @param bool $withBaseUrl - * @return string|null */ public function firstPageLink(bool $withBaseUrl = false): ?string { @@ -136,8 +119,6 @@ public function firstPageLink(bool $withBaseUrl = false): ?string /** * Get previous page link - * @param bool $withBaseUrl - * @return string|null */ public function previousPageLink(bool $withBaseUrl = false): ?string { @@ -146,8 +127,6 @@ public function previousPageLink(bool $withBaseUrl = false): ?string /** * Get next page link - * @param bool $withBaseUrl - * @return string|null */ public function nextPageLink(bool $withBaseUrl = false): ?string { @@ -156,8 +135,6 @@ public function nextPageLink(bool $withBaseUrl = false): ?string /** * Get last page link - * @param bool $withBaseUrl - * @return string|null */ public function lastPageLink(bool $withBaseUrl = false): ?string { @@ -166,7 +143,6 @@ public function lastPageLink(bool $withBaseUrl = false): ?string /** * Get items per page - * @return int */ public function perPage(): int { @@ -175,8 +151,6 @@ public function perPage(): int /** * Get all page links - * @param bool $withBaseUrl - * @return array */ public function links(bool $withBaseUrl = false): array { @@ -191,9 +165,7 @@ public function links(bool $withBaseUrl = false): array /** * Get pagination HTML - * @param bool $withBaseUrl - * @param int|null $pageItemsCount - * @return string|null + * @throws ConfigException|DiException|LangException|ReflectionException */ public function getPagination(bool $withBaseUrl = false, ?int $pageItemsCount = null): ?string { @@ -233,8 +205,7 @@ public function getPagination(bool $withBaseUrl = false, ?int $pageItemsCount = /** * Get the URI for pagination - * @param bool $withBaseUrl - * @return string + * @throws DiException|ReflectionException */ protected function getUri(bool $withBaseUrl = false): string { @@ -253,9 +224,7 @@ protected function getUri(bool $withBaseUrl = false): string /** * Get page link - * @param int|null $pageNumber - * @param bool $withBaseUrl - * @return string|null + * @throws DiException|ReflectionException */ protected function getPageLink(?int $pageNumber, bool $withBaseUrl = false): ?string { @@ -268,62 +237,56 @@ protected function getPageLink(?int $pageNumber, bool $withBaseUrl = false): ?st /** * Get next page item HTML - * @param string|null $nextPageLink - * @return string + * @throws DiException|ReflectionException|ConfigException|LangException */ protected function getNextPageItem(?string $nextPageLink): string { - $link = ''; + $link = []; if (!in_array($nextPageLink, [null, '', '0'], true)) { - $link = '
  • ' . t('common.pagination.next') . '
  • '; + $link[] = '
  • ' . t('common.pagination.next') . '
  • '; } - return $link; + return implode('', $link); } /** - * Get previous page item HTML + * * @param string|null $previousPageLink * @return string */ + /** + * Get previous page item HTML + * @throws ConfigException|DiException|LangException|ReflectionException + */ protected function getPreviousPageItem(?string $previousPageLink): string { - $link = ''; + $link = []; if (!in_array($previousPageLink, [null, '', '0'], true)) { - $link = '
  • ' . t('common.pagination.prev') . '
  • '; + $link[] = '
  • ' . t('common.pagination.prev') . '
  • '; } - return $link; + return implode('', $link); } /** * Get items links HTML - * @param int $startPage - * @param int $endPage - * @param int $currentPage - * @param array $links - * @return string */ protected function getItemsLinks(int $startPage, int $endPage, int $currentPage, array $links): string { - $pagination = ''; + $pagination = []; for ($i = $startPage; $i <= $endPage; $i++) { $active = $i === $currentPage ? 'class="' . Pagination::PAGINATION_CLASS_ACTIVE . '"' : ''; - $pagination .= '
  • ' . $i . '
  • '; + $pagination[] = '
  • ' . $i . '
  • '; } - return $pagination; + return implode('', $pagination); } /** * Calculate start and end pages - * @param int $currentPage - * @param int $totalPages - * @param int $pageItemsCount - * @return array */ protected function calculateStartEndPages(int $currentPage, int $totalPages, int $pageItemsCount): array { @@ -335,41 +298,35 @@ protected function calculateStartEndPages(int $currentPage, int $totalPages, int /** * Add first page link HTML - * @param int $startPage - * @return string */ protected function addFirstPageLink(int $startPage): string { - $pagination = ''; + $pagination = []; if ($startPage > 1) { - $pagination .= '
  • ' . Pagination::FIRST_PAGE_NUMBER . '
  • '; + $pagination[] = '
  • ' . Pagination::FIRST_PAGE_NUMBER . '
  • '; if ($startPage > 2) { - $pagination .= '
  • ...
  • '; + $pagination[] = '
  • ...
  • '; } } - return $pagination; + return implode('', $pagination); } /** * Add last page link HTML - * @param int $endPage - * @param int $totalPages - * @param array $links - * @return string */ protected function addLastPageLink(int $endPage, int $totalPages, array $links): string { - $pagination = ''; + $pagination = []; if ($endPage < $totalPages) { if ($endPage < $totalPages - 1) { - $pagination .= '
  • ...
  • '; + $pagination[] = '
  • ...
  • '; } - $pagination .= '
  • ' . $totalPages . '
  • '; + $pagination[] = '
  • ' . $totalPages . '
  • '; } - return $pagination; + return implode('', $pagination); } } diff --git a/src/Renderer/Adapters/HtmlAdapter.php b/src/Renderer/Adapters/HtmlAdapter.php index 802974cc4..9320dfd4f 100644 --- a/src/Renderer/Adapters/HtmlAdapter.php +++ b/src/Renderer/Adapters/HtmlAdapter.php @@ -29,18 +29,11 @@ */ class HtmlAdapter implements TemplateRendererInterface { - /** - * @var FileSystem - */ protected FileSystem $fs; - /** - * @var array|null - */ protected ?array $configs; /** - * @param array|null $configs * @throws BaseException * @throws DiException * @throws ReflectionException @@ -55,9 +48,6 @@ public function __construct(?array $configs = []) /** * Renders the view - * @param string $view - * @param array $params - * @return string * @throws BaseException */ public function render(string $view, array $params = []): string @@ -81,8 +71,6 @@ public function render(string $view, array $params = []): string } /** - * @param string $view - * @return string * @throws DiException * @throws ReflectionException */ diff --git a/src/Renderer/Adapters/TwigAdapter.php b/src/Renderer/Adapters/TwigAdapter.php index a957be44b..3f273a4ce 100644 --- a/src/Renderer/Adapters/TwigAdapter.php +++ b/src/Renderer/Adapters/TwigAdapter.php @@ -35,18 +35,11 @@ */ class TwigAdapter implements TemplateRendererInterface { - /** - * @var FileSystem - */ protected FileSystem $fs; - /** - * @var array|null - */ protected ?array $configs; /** - * @param array|null $configs * @throws BaseException * @throws DiException * @throws ReflectionException @@ -61,15 +54,7 @@ public function __construct(?array $configs = []) /** * Renders the view - * @param string $view - * @param array $params - * @return string - * @throws DiException - * @throws LoaderError - * @throws ReflectionException - * @throws RendererException - * @throws RuntimeError - * @throws SyntaxError + * @throws DiException|LoaderError|ReflectionException|RendererException|RuntimeError|SyntaxError */ public function render(string $view, array $params = []): string { @@ -83,11 +68,7 @@ public function render(string $view, array $params = []): string } /** - * @param string $view - * @return FilesystemLoader - * @throws RendererException - * @throws DiException - * @throws ReflectionException + * @throws RendererException|DiException|ReflectionException */ private function getLoader(string $view): FilesystemLoader { @@ -105,10 +86,7 @@ private function getLoader(string $view): FilesystemLoader throw RendererException::fileNotFound($view); } - /** - * @param Environment $twig - */ - private function addFunctionsToTwig(Environment $twig) + private function addFunctionsToTwig(Environment $twig): void { $definedFunctions = get_defined_functions(); $allDefinedFunctions = array_merge($definedFunctions['internal'], $definedFunctions['user']); diff --git a/src/Renderer/Contracts/TemplateRendererInterface.php b/src/Renderer/Contracts/TemplateRendererInterface.php index 59bd48d6c..58b37344f 100644 --- a/src/Renderer/Contracts/TemplateRendererInterface.php +++ b/src/Renderer/Contracts/TemplateRendererInterface.php @@ -22,9 +22,6 @@ interface TemplateRendererInterface { /** * Renders the template - * @param string $view - * @param array $params - * @return string */ public function render(string $view, array $params = []): string; } diff --git a/src/Renderer/Factories/RendererFactory.php b/src/Renderer/Factories/RendererFactory.php index 0fd246637..8d2540461 100644 --- a/src/Renderer/Factories/RendererFactory.php +++ b/src/Renderer/Factories/RendererFactory.php @@ -41,11 +41,9 @@ class RendererFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Renderer * @throws BaseException * @throws ConfigException * @throws DiException @@ -68,19 +66,12 @@ public static function get(?string $adapter = null): Renderer return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Renderer - */ private static function createInstance(string $adapterClass, string $adapter): Renderer { return new Renderer(new $adapterClass(config()->get('view.' . $adapter))); } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 8a9d9f0e4..df3718f5b 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -35,30 +35,19 @@ class Renderer */ public const TWIG = 'twig'; - /** - * @var TemplateRendererInterface - */ - private $adapter; + private TemplateRendererInterface $adapter; - /** - * @param TemplateRendererInterface $adapter - */ public function __construct(TemplateRendererInterface $adapter) { $this->adapter = $adapter; } - /** - * @return TemplateRendererInterface - */ public function getAdapter(): TemplateRendererInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/ResourceCache/ViewCache.php b/src/ResourceCache/ViewCache.php index acac8c1db..7451bbd15 100644 --- a/src/ResourceCache/ViewCache.php +++ b/src/ResourceCache/ViewCache.php @@ -14,6 +14,7 @@ namespace Quantum\ResourceCache; +use Quantum\Loader\Exceptions\LoaderException; use Quantum\ResourceCache\Exceptions\ResourceCacheException; use Quantum\Database\Exceptions\DatabaseException; use Quantum\Session\Exceptions\SessionException; @@ -21,6 +22,7 @@ use Quantum\Config\Exceptions\ConfigException; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Storage\FileSystem; use Quantum\Http\Response; use Quantum\Loader\Setup; use ReflectionException; @@ -33,35 +35,20 @@ */ class ViewCache { - /** - * @var string - */ - private $cacheDir; + private ?string $cacheDir = null; /** * @var int */ private $ttl = 300; - /** - * @var bool - */ - private $isEnabled; + private bool $isEnabled; - /** - * @var bool - */ - private $minification = false; + private bool $minification = false; - /** - * @var object - */ - private $fs; + private FileSystem $fs; - /** - * @var ViewCache - */ - private static $instance = null; + private static ?ViewCache $instance = null; public static function getInstance(): ViewCache { @@ -84,11 +71,9 @@ public function __construct() } /** - * @throws ReflectionException - * @throws ConfigException - * @throws DiException + * @throws ConfigException|DiException|LoaderException|ReflectionException */ - public function setup() + public function setup(): void { if (!config()->has('view_cache')) { config()->import(new Setup('config', 'view_cache')); @@ -106,9 +91,6 @@ public function setup() } /** - * @param string $uri - * @param Response $response - * @return bool * @throws BaseException * @throws ConfigException * @throws DatabaseException @@ -127,9 +109,6 @@ public function serveCachedView(string $uri, Response $response): bool } /** - * @param string $key - * @param string $content - * @return $this * @throws BaseException * @throws ConfigException * @throws DiException @@ -147,8 +126,6 @@ public function set(string $key, string $content): ViewCache } /** - * @param string $key - * @return string|null * @throws BaseException * @throws ConfigException * @throws DatabaseException @@ -166,8 +143,6 @@ public function get(string $key): ?string } /** - * @param string $key - * @return void * @throws BaseException * @throws ConfigException * @throws DiException @@ -183,8 +158,6 @@ public function delete(string $key): void } /** - * @param string $key - * @return bool * @throws BaseException * @throws ConfigException * @throws DiException @@ -196,36 +169,21 @@ public function exists(string $key): bool return $this->fs->exists($cacheFile) && !$this->isExpired($cacheFile); } - /** - * @return bool - */ public function isEnabled(): bool { return $this->isEnabled; } - /** - * @param bool $state - * @return void - */ public function enableCaching(bool $state): void { $this->isEnabled = $state; } - /** - * @param int $ttl - * @return void - */ public function setTtl(int $ttl): void { $this->ttl = $ttl; } - /** - * @param bool $state - * @return void - */ public function enableMinification(bool $state): void { $this->minification = $state; @@ -233,9 +191,8 @@ public function enableMinification(bool $state): void /** * @param $cacheFile - * @return bool */ - private function isExpired($cacheFile): bool + private function isExpired(string $cacheFile): bool { if (time() > ($this->fs->lastModified($cacheFile) + $this->ttl)) { $this->fs->remove($cacheFile); @@ -245,9 +202,6 @@ private function isExpired($cacheFile): bool return false; } - /** - * @return string - */ private function getCacheDir(): string { $configCacheDir = config()->get('view_cache.cache_dir', 'cache'); @@ -262,8 +216,6 @@ private function getCacheDir(): string } /** - * @param string $key - * @return string * @throws ConfigException * @throws DiException * @throws ReflectionException @@ -275,8 +227,6 @@ private function getCacheFile(string $key): string } /** - * @param string $content - * @return string * @throws BaseException */ private function minify(string $content): string @@ -288,9 +238,6 @@ private function minify(string $content): string return (new HtmlMin())->minify($content); } - /** - * @return bool - */ protected function htmlMinifierExists(): bool { return class_exists(HtmlMin::class); diff --git a/src/Router/Exceptions/RouteException.php b/src/Router/Exceptions/RouteException.php index 2dff4592d..cd5b97c07 100644 --- a/src/Router/Exceptions/RouteException.php +++ b/src/Router/Exceptions/RouteException.php @@ -25,9 +25,6 @@ */ class RouteException extends BaseException { - /** - * @return self - */ public static function noHttpMethods(): self { return new self( @@ -36,9 +33,6 @@ public static function noHttpMethods(): self ); } - /** - * @return self - */ public static function closureWithController(): self { return new self( @@ -47,9 +41,6 @@ public static function closureWithController(): self ); } - /** - * @return self - */ public static function incompleteControllerRoute(): self { return new self( @@ -58,10 +49,6 @@ public static function incompleteControllerRoute(): self ); } - /** - * @param string $module - * @return self - */ public static function moduleRoutesNotClosure(string $module): self { return new self( @@ -70,9 +57,6 @@ public static function moduleRoutesNotClosure(string $module): self ); } - /** - * @return self - */ public static function nestedGroups(): self { return new self( @@ -81,9 +65,6 @@ public static function nestedGroups(): self ); } - /** - * @return self - */ public static function middlewaresOutsideRoute(): self { return new self( @@ -92,10 +73,6 @@ public static function middlewaresOutsideRoute(): self ); } - /** - * @param string $name - * @return self - */ public static function nonUniqueNameInModule(string $name): self { return new self( @@ -104,9 +81,6 @@ public static function nonUniqueNameInModule(string $name): self ); } - /** - * @return self - */ public static function controllerWithoutModule(): self { return new self( @@ -115,9 +89,6 @@ public static function controllerWithoutModule(): self ); } - /** - * @return self - */ public static function cacheableOutsideRoute(): self { return new self( @@ -126,9 +97,6 @@ public static function cacheableOutsideRoute(): self ); } - /** - * @return self - */ public static function closureHandlerMissing(): self { return new self( @@ -137,11 +105,6 @@ public static function closureHandlerMissing(): self ); } - /** - * @param string $action - * @param string $controller - * @return self - */ public static function actionNotFound(string $action, string $controller): self { return new self( @@ -153,9 +116,6 @@ public static function actionNotFound(string $action, string $controller): self ); } - /** - * @return RouteException - */ public static function notClosure(): self { return new self( @@ -164,9 +124,6 @@ public static function notClosure(): self ); } - /** - * @return RouteException - */ public static function nameBeforeDefinition(): self { return new self( @@ -175,10 +132,6 @@ public static function nameBeforeDefinition(): self ); } - /** - * @param string $name - * @return RouteException - */ public static function paramNameNotAvailable(string $name): self { return new self( @@ -187,9 +140,6 @@ public static function paramNameNotAvailable(string $name): self ); } - /** - * @return RouteException - */ public static function paramNameNotValid(): self { return new self( diff --git a/src/Router/Helpers/router.php b/src/Router/Helpers/router.php index d3c64aa13..698374d6a 100644 --- a/src/Router/Helpers/router.php +++ b/src/Router/Helpers/router.php @@ -21,7 +21,6 @@ /** * Gets current route middlewares - * @return array|null * @throws DiException|ReflectionException */ function current_middlewares(): ?array @@ -34,7 +33,6 @@ function current_middlewares(): ?array /** * Gets current route module - * @return string|null * @throws DiException|ReflectionException */ function current_module(): ?string @@ -47,7 +45,6 @@ function current_module(): ?string /** * Gets current route controller - * @return string|null * @throws DiException|ReflectionException */ function current_controller(): ?string @@ -60,7 +57,6 @@ function current_controller(): ?string /** * Gets current route action - * @return string|null * @throws DiException|ReflectionException */ function current_action(): ?string @@ -73,7 +69,6 @@ function current_action(): ?string /** * Gets current route callback - * @return Closure|null * @throws DiException|ReflectionException */ function route_callback(): ?Closure @@ -86,7 +81,6 @@ function route_callback(): ?Closure /** * Gets current route DSL pattern - * @return string|null * @throws DiException|ReflectionException */ function current_route(): ?string @@ -99,7 +93,6 @@ function current_route(): ?string /** * Gets current route complied pattern - * @return string * @throws DiException|ReflectionException */ function route_pattern(): string @@ -112,7 +105,6 @@ function route_pattern(): string /** * Gets current route parameters - * @return array * @throws DiException|ReflectionException */ function route_params(): array @@ -125,7 +117,6 @@ function route_params(): array /** * Gets route parameter by name - * @param string $name * @return mixed|null * @throws DiException|ReflectionException */ @@ -137,7 +128,6 @@ function route_param(string $name) /** * Gets current route method - * @return string * @throws DiException|ReflectionException */ function route_method(): string @@ -148,7 +138,6 @@ function route_method(): string /** * Gets the current route uri - * @return string|null * @throws DiException|ReflectionException */ function route_uri(): ?string @@ -159,7 +148,6 @@ function route_uri(): ?string /** * Gets the current route cache settings - * @return array|null * @throws DiException|ReflectionException */ function route_cache_settings(): ?array @@ -172,7 +160,6 @@ function route_cache_settings(): ?array /** * Gets the current route name - * @return string|null * @throws DiException|ReflectionException */ function route_name(): ?string @@ -185,7 +172,6 @@ function route_name(): ?string /** * Gets the current route name - * @return string|null * @throws DiException|ReflectionException */ function route_prefix(): ?string @@ -198,9 +184,6 @@ function route_prefix(): ?string /** * Finds the route by name in given module scope - * @param string $name - * @param string $module - * @return Route|null * @throws DiException|ReflectionException */ function find_route_by_name(string $name, string $module): ?Route @@ -226,9 +209,6 @@ function find_route_by_name(string $name, string $module): ?Route /** * Checks the existence of the route group by name in given module scope - * @param string $name - * @param string $module - * @return bool * @throws DiException|ReflectionException */ function route_group_exists(string $name, string $module): bool @@ -254,7 +234,6 @@ function route_group_exists(string $name, string $module): bool /** * Gets the module base namespace depending on env - * @return string */ function module_base_namespace(): string { diff --git a/src/Router/MatchedRoute.php b/src/Router/MatchedRoute.php index 026f0dcb8..f4435dd92 100644 --- a/src/Router/MatchedRoute.php +++ b/src/Router/MatchedRoute.php @@ -21,20 +21,10 @@ */ final class MatchedRoute { - /** - * @var Route - */ private Route $route; - /** - * @var array - */ private array $params; - /** - * @param Route $route - * @param array $params - */ public function __construct(Route $route, array $params) { $this->route = $route; @@ -43,7 +33,6 @@ public function __construct(Route $route, array $params) /** * Return the original route definition. - * @return Route */ public function getRoute(): Route { @@ -52,7 +41,6 @@ public function getRoute(): Route /** * Return parameters extracted from the URI at match time. - * @return array */ public function getParams(): array { diff --git a/src/Router/PatternCompiler.php b/src/Router/PatternCompiler.php index 7ed4341b3..ba0d05544 100644 --- a/src/Router/PatternCompiler.php +++ b/src/Router/PatternCompiler.php @@ -31,16 +31,10 @@ class PatternCompiler ':any' => '[^\/]', ]; - /** - * @var array - */ protected array $params = []; /** * Check whether the given URI matches the route pattern and store extracted params. - * @param Route $route - * @param string $uri - * @return bool * @throws RouteException */ public function match(Route $route, string $uri): bool @@ -61,8 +55,6 @@ public function match(Route $route, string $uri): bool /** * Compile route pattern into regex and param metadata. - * @param Route $route - * @return array * @throws RouteException */ public function compile(Route $route): array @@ -72,7 +64,7 @@ public function compile(Route $route): array $pattern = '(\/)?'; $params = []; - $lastIndex = (int) array_key_last($segments); + $lastIndex = array_key_last($segments); foreach ($segments as $index => $segment) { $segmentParam = $this->getSegmentParam($segment, $index, $lastIndex); @@ -102,7 +94,6 @@ public function compile(Route $route): array /** * Return parameters extracted from the last successful match. - * @return array */ public function getParams(): array { @@ -111,9 +102,6 @@ public function getParams(): array /** * Build the final named parameter map from regex matches and param metadata. - * @param array $params - * @param array $matches - * @return array */ protected function extractParams(array $params, array $matches): array { @@ -131,10 +119,6 @@ protected function extractParams(array $params, array $matches): array /** * Detect and build parameter definition for a single route segment if present. - * @param string $segment - * @param int $index - * @param int $lastIndex - * @return array * @throws RouteException */ protected function getSegmentParam(string $segment, int $index, int $lastIndex): array @@ -150,11 +134,6 @@ protected function getSegmentParam(string $segment, int $index, int $lastIndex): /** * Generate the regex pattern and name for a matched parameter segment. - * @param array $match - * @param string $expr - * @param int $index - * @param int $lastIndex - * @return array * @throws RouteException */ protected function getParamPattern(array $match, string $expr, int $index, int $lastIndex): array @@ -187,9 +166,6 @@ protected function getParamPattern(array $match, string $expr, int $index, int $ /** * Resolve and validate the parameter name from a segment match. - * @param array $match - * @param int $index - * @return string * @throws RouteException */ protected function getParamName(array $match, int $index): string @@ -209,9 +185,6 @@ protected function getParamName(array $match, int $index): string /** * Ensure the parameter name is unique within the route pattern. - * @param array $params - * @param string $name - * @return void * @throws RouteException */ protected function checkParamName(array $params, string $name): void @@ -225,11 +198,6 @@ protected function checkParamName(array $params, string $name): void /** * Adjust the accumulated route regex before appending the last segment pattern. - * @param string $routePattern - * @param array $segmentParam - * @param int $index - * @param int $lastIndex - * @return string */ protected function normalizePattern( string $routePattern, @@ -250,8 +218,6 @@ protected function normalizePattern( /** * Escape forward slashes in a regex fragment safely. - * @param string $str - * @return string */ protected function escape(string $str): string { diff --git a/src/Router/Route.php b/src/Router/Route.php index cc7f17c2a..0a0e0e9df 100644 --- a/src/Router/Route.php +++ b/src/Router/Route.php @@ -24,72 +24,31 @@ */ final class Route { - /** - * @var array - */ protected array $methods; - /** - * @var string - */ protected string $pattern; - /** - * @var string|null - */ protected ?string $controller; - /** - * @var string|null - */ protected ?string $action; - /** - * @var Closure|null - */ protected ?Closure $closure; - /** - * @var string|null - */ protected ?string $name = null; - /** - * @var string|null - */ protected ?string $module = null; - /** - * @var array - */ protected array $middlewares = []; - /** - * @var string|null - */ protected ?string $group = null; - /** - * @var string|null - */ protected ?string $prefix = null; - /** - * @var array|null - */ protected ?array $cache = null; - /** - * @var string|null - */ protected ?string $compiledPattern = null; /** - * @param array $methods - * @param string $pattern - * @param string|null $controller - * @param string|null $action - * @param Closure|null $closure * @throws RouteException */ public function __construct( @@ -97,7 +56,7 @@ public function __construct( string $pattern, ?string $controller, ?string $action, - Closure $closure = null + ?Closure $closure = null ) { if ($methods === []) { throw RouteException::noHttpMethods(); @@ -124,7 +83,6 @@ public function __construct( /** * Check whether this route is handled by a closure. - * @return bool */ public function isClosure(): bool { @@ -133,8 +91,6 @@ public function isClosure(): bool /** * Configure response caching settings for this route. - * @param bool $enabled - * @param int|null $ttl * @return $this */ public function cache(bool $enabled, ?int $ttl = null): self @@ -149,7 +105,6 @@ public function cache(bool $enabled, ?int $ttl = null): self /** * Return caching configuration for this route. - * @return array|null */ public function getCache(): ?array { @@ -158,7 +113,6 @@ public function getCache(): ?array /** * Store compiled regex pattern for this route. - * @param string $pattern * @return $this */ public function setCompiledPattern(string $pattern): self @@ -169,7 +123,6 @@ public function setCompiledPattern(string $pattern): self /** * Return compiled regex pattern if set. - * @return string|null */ public function getCompiledPattern(): ?string { @@ -178,7 +131,6 @@ public function getCompiledPattern(): ?string /** * Assign group name to this route. - * @param string|null $group * @return $this */ public function group(?string $group): self @@ -189,7 +141,6 @@ public function group(?string $group): self /** * Return group name. - * @return string|null */ public function getGroup(): ?string { @@ -198,7 +149,6 @@ public function getGroup(): ?string /** * Return URL prefix. - * @param string|null $prefix * @return $this */ public function prefix(?string $prefix): self @@ -207,9 +157,6 @@ public function prefix(?string $prefix): self return $this; } - /** - * @return string|null - */ public function getPrefix(): ?string { return $this->prefix; @@ -217,7 +164,6 @@ public function getPrefix(): ?string /** * Assign unique route name. - * @param string $name * @return $this */ public function name(string $name): self @@ -228,7 +174,6 @@ public function name(string $name): self /** * Add middleware(s) with group-aware stacking order. - * @param array $middlewares * @return $this */ public function addMiddlewares(array $middlewares): self @@ -248,7 +193,6 @@ public function addMiddlewares(array $middlewares): self /** * Assign module name to this route. - * @param string|null $module * @return $this */ public function module(?string $module): self @@ -259,8 +203,6 @@ public function module(?string $module): self /** * Check whether HTTP method is allowed for this route. - * @param string $method - * @return bool */ public function allowsMethod(string $method): bool { @@ -269,7 +211,6 @@ public function allowsMethod(string $method): bool /** * Return allowed HTTP methods. - * @return array */ public function getMethods(): array { @@ -278,7 +219,6 @@ public function getMethods(): array /** * Return route pattern string. - * @return string */ public function getPattern(): string { @@ -287,7 +227,6 @@ public function getPattern(): string /** * Return route closure handler if defined. - * @return Closure|null */ public function getClosure(): ?Closure { @@ -296,7 +235,6 @@ public function getClosure(): ?Closure /** * Return controller class name. - * @return string|null */ public function getController(): ?string { @@ -305,7 +243,6 @@ public function getController(): ?string /** * Return controller action name. - * @return string|null */ public function getAction(): ?string { @@ -314,7 +251,6 @@ public function getAction(): ?string /** * Return route name. - * @return string|null */ public function getName(): ?string { @@ -323,7 +259,6 @@ public function getName(): ?string /** * Return middleware list. - * @return array */ public function getMiddlewares(): array { @@ -332,7 +267,6 @@ public function getMiddlewares(): array /** * Return middleware list. - * @return string|null */ public function getModule(): ?string { @@ -341,7 +275,6 @@ public function getModule(): ?string /** * Export route definition as array. - * @return array */ public function toArray(): array { diff --git a/src/Router/RouteBuilder.php b/src/Router/RouteBuilder.php index 825d685c8..43d8f00d7 100644 --- a/src/Router/RouteBuilder.php +++ b/src/Router/RouteBuilder.php @@ -24,49 +24,22 @@ */ final class RouteBuilder { - /** - * @var RouteCollection - */ private RouteCollection $collection; - /** - * @var PatternCompiler - */ private PatternCompiler $patternCompiler; - /** - * @var Route|null - */ private ?Route $currentRoute = null; - /** - * @var string|null - */ private ?string $currentModule = null; - /** - * @var string|null - */ private ?string $currentPrefix = null; - /** - * @var bool - */ private bool $inGroup = false; - /** - * @var string|null - */ private ?string $currentGroupName = null; - /** - * @var array - */ private array $groupRoutes = []; - /** - * @var array - */ private array $groupMiddlewares = []; /** @@ -83,9 +56,6 @@ public function __construct() /** * Execute DSL and return final RouteCollection - * @param array $moduleRouteClosures - * @param array $moduleConfigs - * @return RouteCollection * @throws RouteException */ public function build(array $moduleRouteClosures, array $moduleConfigs): RouteCollection @@ -112,18 +82,15 @@ public function build(array $moduleRouteClosures, array $moduleConfigs): RouteCo /** * Define a route with multiple HTTP methods. - * @param string $path - * @param string $methods * @param $handler * @param string|null $action - * @return self * @throws RouteException */ public function add(string $path, string $methods, $handler, string $action = null): self { $methodList = array_filter( array_map('trim', explode('|', $methods)), - static fn ($m) => $m !== '' + static fn ($m): bool => $m !== '' ); return $this->addRoute($methodList, $path, $handler, $action); @@ -131,10 +98,8 @@ public function add(string $path, string $methods, $handler, string $action = nu /** * Define a GET route. - * @param string $path * @param $handler * @param string|null $action - * @return self * @throws RouteException */ public function get(string $path, $handler, string $action = null): self @@ -144,10 +109,8 @@ public function get(string $path, $handler, string $action = null): self /** * Define a POST route. - * @param string $path * @param $handler * @param string|null $action - * @return self * @throws RouteException */ public function post(string $path, $handler, string $action = null): self @@ -157,10 +120,8 @@ public function post(string $path, $handler, string $action = null): self /** * Define a PUT route. - * @param string $path * @param $handler * @param string|null $action - * @return self * @throws RouteException */ public function put(string $path, $handler, string $action = null): self @@ -170,10 +131,8 @@ public function put(string $path, $handler, string $action = null): self /** * Define a DELETE route. - * @param string $path * @param $handler * @param string|null $action - * @return self * @throws RouteException */ public function delete(string $path, $handler, string $action = null): self @@ -183,8 +142,6 @@ public function delete(string $path, $handler, string $action = null): self /** * Group routes under a shared name and configuration. - * @param string $name - * @param callable $callback * @return $this * @throws RouteException */ @@ -219,7 +176,6 @@ public function group(string $name, callable $callback): self /** * Apply middlewares to the current route or group. - * @param array $middlewares * @return $this * @throws RouteException */ @@ -253,7 +209,6 @@ public function middlewares(array $middlewares): self /** * Assign a unique name to the current route. - * @param string $name * @return $this * @throws RouteException */ @@ -280,8 +235,6 @@ public function name(string $name): self /** * Enable or disable caching for the current route or group. - * @param bool $enabled - * @param int|null $ttl * @return $this * @throws RouteException */ @@ -314,11 +267,7 @@ public function cacheable(bool $enabled, ?int $ttl = null): self /** * Create and register a Route instance. - * @param array $methods - * @param string $path * @param $handler - * @param string|null $action - * @return self * @throws RouteException */ private function addRoute( @@ -363,8 +312,7 @@ private function addRoute( $methods, $pattern, $handler, - $action, - null + $action ); } @@ -388,8 +336,6 @@ private function addRoute( /** * Resolve path using the current prefix. - * @param string $path - * @return string */ private function resolvePath(string $path): string { diff --git a/src/Router/RouteCollection.php b/src/Router/RouteCollection.php index 2d5ff3b63..6c1f2e427 100644 --- a/src/Router/RouteCollection.php +++ b/src/Router/RouteCollection.php @@ -28,8 +28,6 @@ final class RouteCollection /** * Add a route to the collection. - * @param Route $route - * @return void */ public function add(Route $route): void { @@ -47,7 +45,6 @@ public function all(): array /** * Return total number of routes. - * @return int */ public function count(): int { diff --git a/src/Router/RouteDispatcher.php b/src/Router/RouteDispatcher.php index 32344da07..d8068709f 100644 --- a/src/Router/RouteDispatcher.php +++ b/src/Router/RouteDispatcher.php @@ -17,7 +17,6 @@ use Quantum\Router\Exceptions\RouteException; use Quantum\Csrf\Exceptions\CsrfException; use Quantum\Di\Exceptions\DiException; -use Quantum\Http\Response; use Quantum\Http\Request; use ReflectionException; use Quantum\Csrf\Csrf; @@ -31,13 +30,9 @@ final class RouteDispatcher { /** * Dispatch a matched route. - * @param MatchedRoute $matched - * @param Request $request - * @param Response $response - * @return void * @throws ReflectionException|CsrfException|DiException|RouteException */ - public function dispatch(MatchedRoute $matched, Request $request, Response $response): void + public function dispatch(MatchedRoute $matched, Request $request): void { $route = $matched->getRoute(); $params = $matched->getParams(); @@ -67,8 +62,6 @@ public function dispatch(MatchedRoute $matched, Request $request, Response $resp /** * Resolve controller callable from the route definition. - * @param Route $route - * @return array * @throws RouteException */ private function resolveControllerCallable(Route $route): array @@ -91,9 +84,6 @@ private function resolveControllerCallable(Route $route): array /** * Invoke a callable with parameters resolved via DI autowiring. - * @param callable $callable - * @param array $params - * @return void * @throws DiException|ReflectionException */ private function invoke(callable $callable, array $params): void @@ -106,10 +96,6 @@ private function invoke(callable $callable, array $params): void /** * Invoke a controller lifecycle hook if it exists. - * @param object $controller - * @param string $hook - * @param array $params - * @return void * @throws DiException|ReflectionException */ private function callHook(object $controller, string $hook, array $params): void @@ -121,9 +107,6 @@ private function callHook(object $controller, string $hook, array $params): void /** * Verify CSRF token if controller requires it and request method applies. - * @param object|null $controller - * @param Request $request - * @return void * @throws CsrfException */ private function verifyCsrf(?object $controller, Request $request): void diff --git a/src/Router/RouteFinder.php b/src/Router/RouteFinder.php index b15e95f6f..dad7cfdc4 100644 --- a/src/Router/RouteFinder.php +++ b/src/Router/RouteFinder.php @@ -23,19 +23,10 @@ */ final class RouteFinder { - /** - * @var PatternCompiler - */ private PatternCompiler $patternCompiler; - /** - * @var RouteCollection - */ private RouteCollection $routes; - /** - * @param RouteCollection $routes - */ public function __construct(RouteCollection $routes) { $this->patternCompiler = new PatternCompiler(); @@ -44,8 +35,6 @@ public function __construct(RouteCollection $routes) /** * Find the first route that matches request method and URI. - * @param Request $request - * @return MatchedRoute|null * @throws Exceptions\RouteException */ public function find(Request $request): ?MatchedRoute diff --git a/src/Service/Factories/ServiceFactory.php b/src/Service/Factories/ServiceFactory.php index be65ca4cb..e6cc3b7c2 100644 --- a/src/Service/Factories/ServiceFactory.php +++ b/src/Service/Factories/ServiceFactory.php @@ -29,9 +29,6 @@ class ServiceFactory { /** * Creates and initiates the service once - * @param string $serviceClass - * @param array $args - * @return QtService * @throws BaseException * @throws DiException * @throws ReflectionException @@ -50,9 +47,6 @@ public static function get(string $serviceClass, array $args = []): QtService /** * Creates new service instance - * @param string $serviceClass - * @param array $args - * @return QtService * @throws BaseException * @throws DiException * @throws ReflectionException @@ -67,8 +61,6 @@ public static function create(string $serviceClass, array $args = []): QtService /** * Validates the service class - * @param string $serviceClass - * @return void * @throws ServiceException * @throws BaseException */ diff --git a/src/Service/Helpers/service.php b/src/Service/Helpers/service.php index 62f0fe72d..fb377fbe8 100644 --- a/src/Service/Helpers/service.php +++ b/src/Service/Helpers/service.php @@ -21,7 +21,6 @@ /** * Gets or creates service instance * @param class-string $serviceClass - * @param bool $singleton * @return T * @throws BaseException * @throws DiException @@ -29,7 +28,6 @@ * @throws ServiceException * @template T of QtService */ - function service(string $serviceClass, bool $singleton = false): QtService { return $singleton ? ServiceFactory::get($serviceClass) : ServiceFactory::create($serviceClass); diff --git a/src/Service/QtService.php b/src/Service/QtService.php index 578cd7dfc..62351cf2f 100644 --- a/src/Service/QtService.php +++ b/src/Service/QtService.php @@ -25,8 +25,6 @@ class QtService { /** * Handles the missing methods of the service - * @param string $method - * @param array $arguments * @throws BaseException */ public function __call(string $method, array $arguments) diff --git a/src/Session/Adapters/Database/DatabaseHandler.php b/src/Session/Adapters/Database/DatabaseHandler.php index 913fdcae4..72361a97a 100644 --- a/src/Session/Adapters/Database/DatabaseHandler.php +++ b/src/Session/Adapters/Database/DatabaseHandler.php @@ -23,14 +23,10 @@ */ class DatabaseHandler implements SessionHandlerInterface { - /** - * @var DbalInterface - */ private DbalInterface $sessionModel; /** * DatabaseHandler constructor. - * @param DbalInterface $sessionModel */ public function __construct(DbalInterface $sessionModel) { diff --git a/src/Session/Adapters/Database/DatabaseSessionAdapter.php b/src/Session/Adapters/Database/DatabaseSessionAdapter.php index efc42cf54..6defdd5d0 100644 --- a/src/Session/Adapters/Database/DatabaseSessionAdapter.php +++ b/src/Session/Adapters/Database/DatabaseSessionAdapter.php @@ -14,6 +14,7 @@ namespace Quantum\Session\Adapters\Database; +use Quantum\Model\Exceptions\ModelException; use Quantum\Session\Contracts\SessionStorageInterface; use Quantum\Session\Exceptions\SessionException; use Quantum\Model\Factories\ModelFactory; @@ -34,19 +35,16 @@ class DatabaseSessionAdapter implements SessionStorageInterface /** * Session params - * @var array */ - private static $params = []; + private static ?array $params = []; /** * Session storage - * @var array $storage */ - private static $storage = []; + private static array $storage = []; /** - * @param array|null $params - * @throws SessionException + * @throws SessionException|ModelException */ public function __construct(?array $params = null) { @@ -54,9 +52,7 @@ public function __construct(?array $params = null) } /** - * @param array|null $params - * @return void - * @throws SessionException + * @throws SessionException|ModelException */ protected function initializeSession(?array $params = null): void { diff --git a/src/Session/Adapters/Native/NativeSessionAdapter.php b/src/Session/Adapters/Native/NativeSessionAdapter.php index 3f8c4f8ce..c3bf703d3 100644 --- a/src/Session/Adapters/Native/NativeSessionAdapter.php +++ b/src/Session/Adapters/Native/NativeSessionAdapter.php @@ -33,18 +33,15 @@ class NativeSessionAdapter implements SessionStorageInterface /** * Session params - * @var array */ - private static $params = []; + private static ?array $params = []; /** * Session storage - * @var array $storage */ - private static $storage = []; + private static array $storage = []; /** - * @param array|null $params * @throws SessionException */ public function __construct(?array $params = null) @@ -53,8 +50,6 @@ public function __construct(?array $params = null) } /** - * @param array|null $params - * @return void * @throws SessionException */ protected function initializeSession(?array $params = null): void diff --git a/src/Session/Contracts/SessionStorageInterface.php b/src/Session/Contracts/SessionStorageInterface.php index 74ecba340..d968ee4d0 100644 --- a/src/Session/Contracts/SessionStorageInterface.php +++ b/src/Session/Contracts/SessionStorageInterface.php @@ -24,27 +24,23 @@ interface SessionStorageInterface extends StorageInterface { /** * Gets flash value by given key - * @param string $key * @return mixed|string|null */ public function getFlash(string $key); /** * Sets flash value by given key - * @param string $key * @param mixed $value */ public function setFlash(string $key, $value); /** * Gets the session ID - * @return string|null */ public function getId(): ?string; /** * Update the current session id with a newly generated one - * @return bool */ public function regenerateId(): bool; } diff --git a/src/Session/Exceptions/SessionException.php b/src/Session/Exceptions/SessionException.php index 4e6324f94..29bf98524 100644 --- a/src/Session/Exceptions/SessionException.php +++ b/src/Session/Exceptions/SessionException.php @@ -25,9 +25,6 @@ */ class SessionException extends BaseException { - /** - * @return SessionException - */ public static function sessionNotStarted(): self { return new self( @@ -36,9 +33,6 @@ public static function sessionNotStarted(): self ); } - /** - * @return SessionException - */ public static function sessionNotDestroyed(): self { return new self( diff --git a/src/Session/Factories/SessionFactory.php b/src/Session/Factories/SessionFactory.php index 86a892628..499aed484 100644 --- a/src/Session/Factories/SessionFactory.php +++ b/src/Session/Factories/SessionFactory.php @@ -41,11 +41,9 @@ class SessionFactory /** * @var array */ - private static $instances = []; + private static array $instances = []; /** - * @param string|null $adapter - * @return Session * @throws BaseException * @throws ConfigException * @throws DiException @@ -68,19 +66,12 @@ public static function get(?string $adapter = null): Session return self::$instances[$adapter]; } - /** - * @param string $adapterClass - * @param string $adapter - * @return Session - */ private static function createInstance(string $adapterClass, string $adapter): Session { return new Session(new $adapterClass(config()->get('session.' . $adapter))); } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string diff --git a/src/Session/Helpers/session.php b/src/Session/Helpers/session.php index def03ad0f..d1318931d 100644 --- a/src/Session/Helpers/session.php +++ b/src/Session/Helpers/session.php @@ -19,8 +19,6 @@ use Quantum\Session\Session; /** - * @param string|null $adapter - * @return Session * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Session/Session.php b/src/Session/Session.php index 144b3876f..d48bcdb1f 100644 --- a/src/Session/Session.php +++ b/src/Session/Session.php @@ -44,30 +44,19 @@ class Session */ public const DATABASE = 'database'; - /** - * @var SessionStorageInterface - */ - private $adapter; + private SessionStorageInterface $adapter; - /** - * @param SessionStorageInterface $adapter - */ public function __construct(SessionStorageInterface $adapter) { $this->adapter = $adapter; } - /** - * @return SessionStorageInterface - */ public function getAdapter(): SessionStorageInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Session/Traits/SessionTrait.php b/src/Session/Traits/SessionTrait.php index 155513915..baf6dc781 100644 --- a/src/Session/Traits/SessionTrait.php +++ b/src/Session/Traits/SessionTrait.php @@ -15,6 +15,7 @@ namespace Quantum\Session\Traits; use Quantum\Session\Exceptions\SessionException; +use Quantum\Model\Exceptions\ModelException; /** * Traits SessionTrait @@ -55,7 +56,7 @@ public function get(string $key) /** * @inheritDoc */ - public function set(string $key, $value) + public function set(string $key, $value): void { self::$storage[$key] = crypto_encode($value); } @@ -87,7 +88,7 @@ public function setFlash(string $key, $value) /** * @inheritDoc */ - public function delete(string $key) + public function delete(string $key): void { if ($this->has($key)) { unset(self::$storage[$key]); @@ -97,7 +98,7 @@ public function delete(string $key) /** * @inheritDoc */ - public function flush() + public function flush(): void { self::$storage = []; session_destroy(); @@ -113,7 +114,7 @@ public function getId(): ?string /** * @inheritDoc - * @throws SessionException + * @throws SessionException|ModelException */ public function regenerateId(): bool { diff --git a/src/Storage/Adapters/Dropbox/DropboxApp.php b/src/Storage/Adapters/Dropbox/DropboxApp.php index 5eedb5e28..761abe752 100644 --- a/src/Storage/Adapters/Dropbox/DropboxApp.php +++ b/src/Storage/Adapters/Dropbox/DropboxApp.php @@ -103,32 +103,16 @@ class DropboxApp implements CloudAppInterface */ public const INVALID_TOKEN_ERROR_CODE = 401; - /** - * @var HttpClient - */ - private $httpClient; + private HttpClient $httpClient; - /** - * @var string - */ - private $appKey; + private string $appKey; - /** - * @var string - */ - private $appSecret; + private string $appSecret; - /** - * @var TokenServiceInterface - */ - private $tokenService; + private TokenServiceInterface $tokenService; /** * DropboxApp constructor - * @param string $appKey - * @param string $appSecret - * @param TokenServiceInterface $tokenService - * @param HttpClient $httpClient */ public function __construct(string $appKey, string $appSecret, TokenServiceInterface $tokenService, HttpClient $httpClient) { @@ -140,9 +124,6 @@ public function __construct(string $appKey, string $appSecret, TokenServiceInter /** * Gets the auth URL - * @param string $redirectUrl - * @param string $tokenAccessType - * @return string * @throws BaseException * @throws CryptorException * @throws DatabaseException @@ -162,9 +143,6 @@ public function getAuthUrl(string $redirectUrl, string $tokenAccessType = 'offli /** * Fetch tokens - * @param string $code - * @param string $redirectUrl - * @return object|null * @throws BaseException * @throws HttpException * @throws LangException @@ -190,8 +168,6 @@ public function fetchTokens(string $code, string $redirectUrl): ?object /** * Fetches the access token by refresh token - * @param string $refreshToken - * @return string * @throws BaseException * @throws HttpException * @throws LangException @@ -216,8 +192,6 @@ private function fetchAccessTokenByRefreshToken(string $refreshToken): string /** * Sends rpc request - * @param string $endpoint - * @param array|null $params * @return mixed|null * @throws Exception */ @@ -233,9 +207,6 @@ public function rpcRequest(string $endpoint, ?array $params = []) /** * Sends content request - * @param string $endpoint - * @param array $params - * @param string $content * @return mixed|null * @throws Exception */ @@ -252,8 +223,6 @@ public function contentRequest(string $endpoint, array $params, string $content /** * Gets the normalized path - * @param string $name - * @return array */ public function path(string $name): array { @@ -262,9 +231,6 @@ public function path(string $name): array /** * Checks if the access token need refresh - * @param int $code - * @param object|null $message - * @return bool */ private function accessTokenNeedsRefresh(int $code, ?object $message = null): bool { diff --git a/src/Storage/Adapters/Dropbox/DropboxFileSystemAdapter.php b/src/Storage/Adapters/Dropbox/DropboxFileSystemAdapter.php index ee706727b..131eeaac2 100644 --- a/src/Storage/Adapters/Dropbox/DropboxFileSystemAdapter.php +++ b/src/Storage/Adapters/Dropbox/DropboxFileSystemAdapter.php @@ -23,14 +23,8 @@ */ class DropboxFileSystemAdapter implements FilesystemAdapterInterface { - /** - * @var DropboxApp - */ - private $dropboxApp; + private DropboxApp $dropboxApp; - /** - * @param DropboxApp $dropboxApp - */ public function __construct(DropboxApp $dropboxApp) { $this->dropboxApp = $dropboxApp; diff --git a/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php b/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php index d7ebe7889..3fdf54a63 100644 --- a/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php +++ b/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php @@ -71,32 +71,16 @@ class GoogleDriveApp implements CloudAppInterface */ public const INVALID_TOKEN_ERROR_CODE = 401; - /** - * @var HttpClient - */ - private $httpClient; + private HttpClient $httpClient; - /** - * @var string - */ - private $appKey; + private string $appKey; - /** - * @var string - */ - private $appSecret; + private string $appSecret; - /** - * @var TokenServiceInterface - */ - private $tokenService; + private TokenServiceInterface $tokenService; /** * GoogleDriveApp constructor - * @param string $appKey - * @param string $appSecret - * @param TokenServiceInterface $tokenService - * @param HttpClient $httpClient */ public function __construct(string $appKey, string $appSecret, TokenServiceInterface $tokenService, HttpClient $httpClient) { @@ -108,9 +92,6 @@ public function __construct(string $appKey, string $appSecret, TokenServiceInter /** * Gets Auth URL - * @param string $redirectUrl - * @param string $accessType - * @return string * @throws BaseException * @throws CryptorException * @throws DatabaseException @@ -131,9 +112,6 @@ public function getAuthUrl(string $redirectUrl, string $accessType = 'offline'): /** * Fetch tokens - * @param string $code - * @param string $redirectUrl - * @return object|null * @throws Exception */ public function fetchTokens(string $code, string $redirectUrl = ''): ?object @@ -155,8 +133,6 @@ public function fetchTokens(string $code, string $redirectUrl = ''): ?object /** * Fetches the access token by refresh token - * @param string $refreshToken - * @return string * @throws Exception */ private function fetchAccessTokenByRefreshToken(string $refreshToken): string @@ -177,10 +153,7 @@ private function fetchAccessTokenByRefreshToken(string $refreshToken): string /** * Sends rpc request - * @param string $url * @param mixed $params - * @param string $method - * @param string $contentType * @return mixed|null * @throws Exception */ @@ -199,9 +172,6 @@ public function rpcRequest(string $url, $params = [], string $method = 'POST', s /** * Gets file information - * @param string $fileId - * @param bool $media - * @param array $params * @return mixed|null * @throws Exception */ @@ -213,9 +183,6 @@ public function getFileInfo(string $fileId, bool $media = false, array $params = /** * Checks if the access token need refresh - * @param int $code - * @param object|null $message - * @return bool */ private function accessTokenNeedsRefresh(int $code, ?object $message = null): bool { diff --git a/src/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php b/src/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php index b9920b093..7f7fe3b75 100644 --- a/src/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php +++ b/src/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php @@ -23,14 +23,8 @@ */ class GoogleDriveFileSystemAdapter implements FilesystemAdapterInterface { - /** - * @var GoogleDriveApp - */ - private $googleDriveApp; + private GoogleDriveApp $googleDriveApp; - /** - * @param GoogleDriveApp $googleDriveApp - */ public function __construct(GoogleDriveApp $googleDriveApp) { $this->googleDriveApp = $googleDriveApp; diff --git a/src/Storage/Adapters/Local/LocalFileSystemAdapter.php b/src/Storage/Adapters/Local/LocalFileSystemAdapter.php index 0842037c1..4c0c0b207 100644 --- a/src/Storage/Adapters/Local/LocalFileSystemAdapter.php +++ b/src/Storage/Adapters/Local/LocalFileSystemAdapter.php @@ -24,8 +24,6 @@ class LocalFileSystemAdapter implements LocalFilesystemAdapterInterface { /** - * @param string $dirname - * @param string|null $parentId * @inheritDoc */ public function makeDirectory(string $dirname, ?string $parentId = null): bool @@ -55,7 +53,6 @@ public function get(string $filename) /** * Reads and returns the content of a file as JSON. - * @param string $filename * @return false|mixed */ public function getJson(string $filename) @@ -72,9 +69,6 @@ public function getJson(string $filename) } /** - * @param string $filename - * @param string $content - * @param string|null $parentId * @inheritDoc */ public function put(string $filename, string $content, ?string $parentId = null) @@ -222,7 +216,7 @@ public function getLines(string $filename, int $offset = 0, ?int $length = null) */ public function fileNameWithExtension(string $path): string { - return (string) pathinfo($path, PATHINFO_BASENAME); + return pathinfo($path, PATHINFO_BASENAME); } /** @@ -230,7 +224,7 @@ public function fileNameWithExtension(string $path): string */ public function fileName(string $path): string { - return (string) pathinfo($path, PATHINFO_FILENAME); + return pathinfo($path, PATHINFO_FILENAME); } /** @@ -238,7 +232,7 @@ public function fileName(string $path): string */ public function extension(string $path): string { - return (string) pathinfo($path, PATHINFO_EXTENSION); + return pathinfo($path, PATHINFO_EXTENSION); } /** diff --git a/src/Storage/Contracts/CloudAppInterface.php b/src/Storage/Contracts/CloudAppInterface.php index 5911d33b1..03342aabd 100644 --- a/src/Storage/Contracts/CloudAppInterface.php +++ b/src/Storage/Contracts/CloudAppInterface.php @@ -22,12 +22,6 @@ */ interface CloudAppInterface { - /** - * @param string $appKey - * @param string $appSecret - * @param TokenServiceInterface $tokenService - * @param HttpClient $httpClient - */ public function __construct( string $appKey, string $appSecret, @@ -37,10 +31,7 @@ public function __construct( /** * Send request - * @param string $url * @param array|string|null $data - * @param array $headers - * @param string $method * @return mixed */ public function sendRequest( diff --git a/src/Storage/Contracts/FilesystemAdapterInterface.php b/src/Storage/Contracts/FilesystemAdapterInterface.php index 69e004482..d900d0f26 100644 --- a/src/Storage/Contracts/FilesystemAdapterInterface.php +++ b/src/Storage/Contracts/FilesystemAdapterInterface.php @@ -22,104 +22,76 @@ interface FilesystemAdapterInterface { /** * Makes a new directory - * @param string $dirname - * @param string|null $parentId - * @return bool */ public function makeDirectory(string $dirname, ?string $parentId = null): bool; /** * Removes the directory - * @param string $dirname - * @return bool */ public function removeDirectory(string $dirname): bool; /** * Gets the file content - * @param string $filename * @return string|false */ public function get(string $filename); /** * Puts the content into the file - * @param string $filename - * @param string $content - * @param string|null $parentId * @return int|false */ public function put(string $filename, string $content, ?string $parentId = null); /** * Appends the content at the end of the file - * @param string $filename - * @param string $content * @return int|false */ public function append(string $filename, string $content); /** * Renames the file - * @param string $oldName - * @param string $newName - * @return bool */ public function rename(string $oldName, string $newName): bool; /** * Copy the file to destination - * @param string $source - * @param string $dest - * @return bool */ public function copy(string $source, string $dest): bool; /** * File Exists - * @param string $filename - * @return bool */ public function exists(string $filename): bool; /** * Gets the file size - * @param string $filename * @return int|false */ public function size(string $filename); /** * Gets file modification time - * @param string $filename * @return int|false */ public function lastModified(string $filename); /** * Removes the file - * @param string $filename - * @return bool */ public function remove(string $filename): bool; /** * Is File - * @param string $filename - * @return bool */ public function isFile(string $filename): bool; /** * Is Directory - * @param string $dirname - * @return bool */ public function isDirectory(string $dirname): bool; /** * Lists the files inside the directory - * @param string $dirname * @return array|bool */ public function listDirectory(string $dirname); diff --git a/src/Storage/Contracts/LocalFilesystemAdapterInterface.php b/src/Storage/Contracts/LocalFilesystemAdapterInterface.php index 800a0b0c7..091808415 100644 --- a/src/Storage/Contracts/LocalFilesystemAdapterInterface.php +++ b/src/Storage/Contracts/LocalFilesystemAdapterInterface.php @@ -22,68 +22,48 @@ interface LocalFilesystemAdapterInterface extends FilesystemAdapterInterface { /** * Find path names matching a pattern - * @param string $pattern - * @param int $flags * @return array|false */ public function glob(string $pattern, int $flags = 0); /** * Is Readable - * @param string $filename - * @return bool */ public function isReadable(string $filename): bool; /** * Is Writable - * @param string $filename - * @return bool */ public function isWritable(string $filename): bool; /** * Gets the content between given lines - * @param string $filename - * @param int $offset - * @param int|null $length - * @return array */ public function getLines(string $filename, int $offset = 0, ?int $length = null): array; /** * Gets the filename with extension - * @param string $path - * @return string */ public function fileNameWithExtension(string $path): string; /** * Gets the file name - * @param string $path - * @return string */ public function fileName(string $path): string; /** * Gets the file extension - * @param string $path - * @return string */ public function extension(string $path): string; /** * Includes the required file - * @param string $file - * @param bool $once * @return mixed */ public function require(string $file, bool $once = false); /** * Includes a file - * @param string $file - * @param bool $once * @return mixed */ public function include(string $file, bool $once = false); diff --git a/src/Storage/Contracts/TokenServiceInterface.php b/src/Storage/Contracts/TokenServiceInterface.php index ecebb79a4..bb13ad96b 100644 --- a/src/Storage/Contracts/TokenServiceInterface.php +++ b/src/Storage/Contracts/TokenServiceInterface.php @@ -20,21 +20,10 @@ */ interface TokenServiceInterface { - /** - * @return string - */ public function getAccessToken(): string; - /** - * @return string - */ public function getRefreshToken(): string; - /** - * @param string $accessToken - * @param string|null $refreshToken - * @return bool - */ public function saveTokens(string $accessToken, ?string $refreshToken = null): bool; } diff --git a/src/Storage/Exceptions/FileSystemException.php b/src/Storage/Exceptions/FileSystemException.php index 7eee0ef2d..bc3aefb83 100644 --- a/src/Storage/Exceptions/FileSystemException.php +++ b/src/Storage/Exceptions/FileSystemException.php @@ -25,10 +25,6 @@ */ class FileSystemException extends BaseException { - /** - * @param string $name - * @return FileSystemException - */ public static function directoryNotExists(string $name): self { return new self( @@ -37,10 +33,6 @@ public static function directoryNotExists(string $name): self ); } - /** - * @param string $name - * @return FileSystemException - */ public static function directoryNotWritable(string $name): self { return new self( @@ -49,10 +41,6 @@ public static function directoryNotWritable(string $name): self ); } - /** - * @param string $path - * @return FileSystemException - */ public static function fileAlreadyExists(string $path): self { return new self( diff --git a/src/Storage/Exceptions/FileUploadException.php b/src/Storage/Exceptions/FileUploadException.php index fc15391f7..dc93d7ba1 100644 --- a/src/Storage/Exceptions/FileUploadException.php +++ b/src/Storage/Exceptions/FileUploadException.php @@ -26,10 +26,6 @@ */ class FileUploadException extends BaseException { - /** - * @param string $name - * @return FileUploadException - */ public static function fileTypeNotAllowed(string $name): self { return new self( @@ -38,10 +34,6 @@ public static function fileTypeNotAllowed(string $name): self ); } - /** - * @param string $name - * @return FileUploadException - */ public static function incorrectMimeTypesConfig(string $name): self { return new self( diff --git a/src/Storage/Factories/FileSystemFactory.php b/src/Storage/Factories/FileSystemFactory.php index d8eecee5d..cec9b531c 100644 --- a/src/Storage/Factories/FileSystemFactory.php +++ b/src/Storage/Factories/FileSystemFactory.php @@ -55,14 +55,9 @@ class FileSystemFactory FileSystem::GDRIVE => GoogleDriveApp::class, ]; - /** - * @var array - */ private static array $instances = []; /** - * @param string|null $adapter - * @return FileSystem * @throws BaseException * @throws DiException * @throws ReflectionException @@ -86,9 +81,6 @@ public static function get(?string $adapter = null): FileSystem } /** - * @param string $adapterClass - * @param string $adapter - * @return FileSystem * @throws BaseException * @throws DiException * @throws ReflectionException @@ -102,8 +94,6 @@ private static function createInstance(string $adapterClass, string $adapter): F } /** - * @param string $adapter - * @return string * @throws BaseException */ private static function getAdapterClass(string $adapter): string @@ -116,8 +106,6 @@ private static function getAdapterClass(string $adapter): string } /** - * @param string $adapter - * @return CloudAppInterface|null * @throws BaseException * @throws DiException * @throws ReflectionException @@ -140,8 +128,6 @@ private static function createCloudApp(string $adapter): ?CloudAppInterface } /** - * @param string $adapter - * @return TokenServiceInterface * @throws BaseException * @throws DiException * @throws ReflectionException diff --git a/src/Storage/FileSystem.php b/src/Storage/FileSystem.php index b242058f3..5101705c4 100644 --- a/src/Storage/FileSystem.php +++ b/src/Storage/FileSystem.php @@ -61,30 +61,19 @@ class FileSystem */ public const GDRIVE = 'gdrive'; - /** - * @var FilesystemAdapterInterface - */ - private $adapter; + private FilesystemAdapterInterface $adapter; - /** - * @param FilesystemAdapterInterface $adapter - */ public function __construct(FilesystemAdapterInterface $adapter) { $this->adapter = $adapter; } - /** - * @return FilesystemAdapterInterface - */ public function getAdapter(): FilesystemAdapterInterface { return $this->adapter; } /** - * @param string $method - * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Storage/Helpers/fs.php b/src/Storage/Helpers/fs.php index 9222c5687..e7d602b95 100644 --- a/src/Storage/Helpers/fs.php +++ b/src/Storage/Helpers/fs.php @@ -20,8 +20,6 @@ /** * Gets the FileSystem handler - * @param string|null $adapter - * @return FileSystem * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Storage/UploadedFile.php b/src/Storage/UploadedFile.php index f0919719b..eb821837e 100644 --- a/src/Storage/UploadedFile.php +++ b/src/Storage/UploadedFile.php @@ -40,55 +40,46 @@ class UploadedFile extends SplFileInfo { /** * Local File System - * @var LocalFilesystemAdapterInterface */ protected LocalFilesystemAdapterInterface $localFileSystem; /** * Remove File System - * @var FilesystemAdapterInterface|null */ protected ?FilesystemAdapterInterface $remoteFileSystem = null; /** * Original file name provided by client - * @var string|null */ protected ?string $originalName = null; /** * File name (without extension) - * @var string|null */ protected ?string $name = null; /** * File extension - * @var string|null */ protected ?string $extension = null; /** * File mime type - * @var string|null */ protected ?string $mimetype = null; /** * ImageResize function name - * @var string|null */ protected ?string $imageModifierFuncName = null; /** * ImageResize function arguments - * @var array */ protected array $params = []; /** * Upload error code messages - * @var array */ protected array $errorMessages = [ 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', @@ -102,7 +93,6 @@ class UploadedFile extends SplFileInfo /** * Allowed mime types => allowed extensions map - * @var array */ protected array $allowedMimeTypes = [ 'image/jpeg' => ['jpg', 'jpeg'], @@ -112,12 +102,10 @@ class UploadedFile extends SplFileInfo /** * Upload error code - * @var int */ protected int $errorCode; /** - * @param array $meta * @throws BaseException * @throws ConfigException * @throws DiException @@ -146,9 +134,6 @@ public function __construct(array $meta) /** * Sets the allowed mime types => extensions map - * @param array $allowedMimeTypes - * @param bool $merge - * @return $this */ public function setAllowedMimeTypes(array $allowedMimeTypes, bool $merge = true): UploadedFile { @@ -158,7 +143,6 @@ public function setAllowedMimeTypes(array $allowedMimeTypes, bool $merge = true) /** * Get name - * @return string */ public function getName(): string { @@ -171,8 +155,6 @@ public function getName(): string /** * Set name (without extension) - * @param string $name - * @return $this */ public function setName(string $name): UploadedFile { @@ -182,8 +164,6 @@ public function setName(string $name): UploadedFile /** * Sets the remote file system adapter - * @param FilesystemAdapterInterface $remoteFileSystem - * @return $this */ public function setRemoteFileSystem(FilesystemAdapterInterface $remoteFileSystem): UploadedFile { @@ -193,7 +173,6 @@ public function setRemoteFileSystem(FilesystemAdapterInterface $remoteFileSystem /** * Gets the remote file system adapter - * @return FilesystemAdapterInterface|null */ public function getRemoteFileSystem(): ?FilesystemAdapterInterface { @@ -202,7 +181,6 @@ public function getRemoteFileSystem(): ?FilesystemAdapterInterface /** * Get file extension (without leading dot) - * @return string */ public function getExtension(): string { @@ -215,7 +193,6 @@ public function getExtension(): string /** * Get file name with extension - * @return string */ public function getNameWithExtension(): string { @@ -224,7 +201,6 @@ public function getNameWithExtension(): string /** * Get mime type - * @return string */ public function getMimeType(): string { @@ -241,7 +217,6 @@ public function getMimeType(): string /** * Get md5 - * @return string */ public function getMd5(): string { @@ -250,7 +225,6 @@ public function getMd5(): string /** * Get image dimensions - * @return array * @throws FileUploadException */ public function getDimensions(): array @@ -269,9 +243,6 @@ public function getDimensions(): array /** * Save the uploaded file - * @param string $dest - * @param bool $overwrite - * @return bool * @throws BaseException * @throws FileSystemException * @throws FileUploadException @@ -321,9 +292,6 @@ public function save(string $dest, bool $overwrite = false): bool /** * Sets modification function on image - * @param string $funcName - * @param array $params - * @return $this * @throws BaseException * @throws FileUploadException * @throws LangException @@ -346,7 +314,6 @@ public function modify(string $funcName, array $params): UploadedFile /** * Gets the error code - * @return int */ public function getErrorCode(): int { @@ -355,7 +322,6 @@ public function getErrorCode(): int /** * Gets the error message from code - * @return string */ public function getErrorMessage(): string { @@ -364,7 +330,6 @@ public function getErrorMessage(): string /** * Tells whether the file was uploaded - * @return bool */ public function isUploaded(): bool { @@ -374,7 +339,6 @@ public function isUploaded(): bool /** * Checks if the given file is image * @param $filePath - * @return bool */ public function isImage($filePath): bool { @@ -383,8 +347,6 @@ public function isImage($filePath): bool /** * Moves an uploaded file to a new location - * @param string $filePath - * @return bool */ protected function moveUploadedFile(string $filePath): bool { @@ -399,9 +361,6 @@ protected function moveUploadedFile(string $filePath): bool /** * Validates upload against allowed mime types => extensions map - * @param string $extension - * @param string $mimeType - * @return bool */ protected function allowed(string $extension, string $mimeType): bool { @@ -446,9 +405,6 @@ protected function loadAllowedMimeTypesFromConfig(): void /** * Sets the allowed mime types => extensions map - * @param array $allowedMimeTypes - * @param bool $merge - * @return void */ protected function setAllowedMimeTypesMap(array $allowedMimeTypes, bool $merge = true): void { diff --git a/src/Tracer/ErrorHandler.php b/src/Tracer/ErrorHandler.php index b24c3ec65..b52e93107 100644 --- a/src/Tracer/ErrorHandler.php +++ b/src/Tracer/ErrorHandler.php @@ -60,14 +60,8 @@ class ErrorHandler E_RECOVERABLE_ERROR => 'error', ]; - /** - * @var Logger - */ - private $logger; + private ?Logger $logger = null; - /** - * @var ErrorHandler|null - */ private static ?ErrorHandler $instance = null; private function __construct() @@ -80,9 +74,6 @@ private function __clone() // Prevent cloning } - /** - * @return ErrorHandler - */ public static function getInstance(): ErrorHandler { if (self::$instance === null) { @@ -92,10 +83,7 @@ public static function getInstance(): ErrorHandler return self::$instance; } - /** - * @param Logger $logger - */ - public function setup(Logger $logger) + public function setup(Logger $logger): void { $this->logger = $logger; @@ -104,24 +92,18 @@ public function setup(Logger $logger) } /** - * @param $severity - * @param $message - * @param $file - * @param $line * @throws ErrorException */ - public function handleError($severity, $message, $file, $line) + public function handleError(int $severity, string $message, string $file, int $line): bool { if ((error_reporting() & $severity) === 0) { - return; + return false; } throw new ErrorException($message, 0, $severity, $file, $line); } /** - * @param Throwable $throwable - * @return void * @throws BaseException * @throws ConfigException * @throws DiException @@ -138,10 +120,6 @@ public function handleException(Throwable $throwable): void } } - /** - * @param Throwable $throwable - * @return void - */ private function handleCliException(Throwable $throwable): void { $output = new ConsoleOutput(); @@ -149,8 +127,6 @@ private function handleCliException(Throwable $throwable): void } /** - * @param Throwable $throwable - * @return void * @throws BaseException * @throws ConfigException * @throws DiException @@ -177,11 +153,6 @@ private function handleWebException(Throwable $throwable): void Response::send(); } - /** - * @param Throwable $e - * @param string $errorType - * @return void - */ private function logError(Throwable $e, string $errorType): void { $logMethod = method_exists($this->logger, $errorType) ? $errorType : 'error'; @@ -191,8 +162,6 @@ private function logError(Throwable $e, string $errorType): void /** * Composes the stack trace - * @param Throwable $e - * @return array * @throws BaseException * @throws ConfigException * @throws DiException @@ -223,10 +192,6 @@ private function composeStackTrace(Throwable $e): array /** * Gets the source code where the error happens - * @param string $filename - * @param int $lineNumber - * @param string $className - * @return string * @throws BaseException * @throws ConfigException * @throws DiException @@ -252,18 +217,11 @@ private function getSourceCode(string $filename, int $lineNumber, string $classN $code .= $this->formatLineItem($currentLineNumber, $line, $lineNumber, $className); } - $code .= ''; - - return $code; + return $code . ''; } /** * Formats the line item - * @param int $currentLineNumber - * @param string $line - * @param int $lineNumber - * @param string $className - * @return string */ private function formatLineItem(int $currentLineNumber, string $line, int $lineNumber, string $className): string { @@ -280,8 +238,6 @@ private function formatLineItem(int $currentLineNumber, string $line, int $lineN /** * Gets the error type based on the exception class - * @param Throwable $e - * @return string */ private function getErrorType(Throwable $e): string { diff --git a/src/Transformer/Helpers/transformer.php b/src/Transformer/Helpers/transformer.php index 1f3097412..af2018df5 100644 --- a/src/Transformer/Helpers/transformer.php +++ b/src/Transformer/Helpers/transformer.php @@ -17,9 +17,6 @@ /** * Transforms the data by given transformer signature - * @param array $data - * @param TransformerInterface $transformer - * @return array */ function transform(array $data, TransformerInterface $transformer): array { diff --git a/src/Transformer/Transformer.php b/src/Transformer/Transformer.php index ca376de44..b9acac93b 100644 --- a/src/Transformer/Transformer.php +++ b/src/Transformer/Transformer.php @@ -24,9 +24,6 @@ class Transformer { /** * Applies the transformer on each item of the array - * @param array $data - * @param TransformerInterface $transformer - * @return array */ public static function transform(array $data, TransformerInterface $transformer): array { diff --git a/src/Validation/Rule.php b/src/Validation/Rule.php index 2dfe892c0..84faf4355 100644 --- a/src/Validation/Rule.php +++ b/src/Validation/Rule.php @@ -62,8 +62,6 @@ class Rule { /** - * @param string $name - * @param array $params * @return array[] */ public static function __callStatic(string $name, array $params): array diff --git a/src/Validation/Traits/File.php b/src/Validation/Traits/File.php index deb31ac37..0320e7954 100644 --- a/src/Validation/Traits/File.php +++ b/src/Validation/Traits/File.php @@ -25,10 +25,6 @@ trait File { /** * Validates file size - * @param UploadedFile $file - * @param int $maxSize - * @param int|null $minSize - * @return bool */ public function fileSize(UploadedFile $file, int $maxSize, ?int $minSize = null): bool { @@ -40,9 +36,6 @@ public function fileSize(UploadedFile $file, int $maxSize, ?int $minSize = null) /** * Validates file mime type - * @param UploadedFile $file - * @param string ...$mimeTypes - * @return bool */ public function fileMimeType(UploadedFile $file, string ...$mimeTypes): bool { @@ -51,9 +44,6 @@ public function fileMimeType(UploadedFile $file, string ...$mimeTypes): bool /** * Validates file extension - * @param UploadedFile $file - * @param string ...$extensions - * @return bool */ public function fileExtension(UploadedFile $file, string ...$extensions): bool { @@ -62,10 +52,6 @@ public function fileExtension(UploadedFile $file, string ...$extensions): bool /** * Validates image dimensions - * @param UploadedFile $file - * @param int|null $width - * @param int|null $height - * @return bool * @throws FileUploadException */ public function imageDimensions(UploadedFile $file, ?int $width = null, ?int $height = null): bool diff --git a/src/Validation/Traits/General.php b/src/Validation/Traits/General.php index 57f3e27d6..f2f07b074 100644 --- a/src/Validation/Traits/General.php +++ b/src/Validation/Traits/General.php @@ -32,8 +32,6 @@ trait General { /** * Checks Field Required - * @param string $value - * @return bool */ protected function required(string $value): bool { @@ -42,8 +40,6 @@ protected function required(string $value): bool /** * Checks Email - * @param string $value - * @return bool */ protected function email(string $value): bool { @@ -52,8 +48,6 @@ protected function email(string $value): bool /** * Checks for a valid credit card number - * @param string $value - * @return bool */ protected function creditCard(string $value): bool { @@ -86,8 +80,6 @@ protected function creditCard(string $value): bool /** * Checks for a valid IBAN - * @param string $value - * @return bool */ protected function iban(string $value): bool { @@ -112,8 +104,6 @@ protected function iban(string $value): bool /** * Checks for a valid format human name - * @param string $value - * @return bool */ protected function name(string $value): bool { @@ -122,8 +112,6 @@ protected function name(string $value): bool /** * Checks that the provided string is a likely street address. - * @param string $value - * @return bool */ protected function streetAddress(string $value): bool { @@ -136,8 +124,6 @@ protected function streetAddress(string $value): bool /** * Validates the phone number // 555-555-5555 , 5555425555, 555 555 5555, 1(519) 555-4444, 1 (519) 555-4422, +1-555-555-5555 - * @param string $value - * @return bool */ protected function phoneNumber(string $value): bool { @@ -148,9 +134,6 @@ protected function phoneNumber(string $value): bool /** * Determines if the provided input is a valid date - * @param string $value - * @param string|null $format - * @return bool */ protected function date(string $value, ?string $format = null): bool { @@ -168,9 +151,6 @@ protected function date(string $value, ?string $format = null): bool /** * Ensures the value starts with a certain character / set of character - * @param string $value - * @param string|null $text - * @return bool */ protected function starts(string $value, ?string $text = null): bool { @@ -179,9 +159,6 @@ protected function starts(string $value, ?string $text = null): bool /** * Custom regex validator - * @param string $value - * @param string $pattern - * @return bool */ protected function regex(string $value, string $pattern): bool { @@ -190,8 +167,6 @@ protected function regex(string $value, string $pattern): bool /** * Validates JSON string - * @param string $value - * @return bool */ protected function jsonString(string $value): bool { @@ -202,9 +177,6 @@ protected function jsonString(string $value): bool /** * Validates same value for both fields - * @param string $value - * @param string $otherField - * @return bool */ protected function same(string $value, string $otherField): bool { @@ -214,9 +186,6 @@ protected function same(string $value, string $otherField): bool /** * Validates uniqueness * @param $value - * @param string $className - * @param string $columnName - * @return bool * @throws BaseException * @throws ModelException */ @@ -233,9 +202,6 @@ protected function unique($value, string $className, string $columnName): bool /** * Validates record existence * @param $value - * @param string $className - * @param string $columnName - * @return bool * @throws BaseException * @throws ModelException */ @@ -251,8 +217,6 @@ protected function exists($value, string $className, string $columnName): bool /** * Check Captcha - * @param string $value - * @return bool * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Validation/Traits/Length.php b/src/Validation/Traits/Length.php index 2a743ba13..b473110e8 100644 --- a/src/Validation/Traits/Length.php +++ b/src/Validation/Traits/Length.php @@ -22,9 +22,6 @@ trait Length { /** * Checks the min Length - * @param string $value - * @param int $minLength - * @return bool */ protected function minLen(string $value, int $minLength): bool { @@ -33,9 +30,6 @@ protected function minLen(string $value, int $minLength): bool /** * Checks the max Length - * @param string $value - * @param int $maxLength - * @return bool */ protected function maxLen(string $value, int $maxLength): bool { @@ -44,9 +38,6 @@ protected function maxLen(string $value, int $maxLength): bool /** * Checks the exact length - * @param string $value - * @param int $exactLength - * @return bool */ protected function exactLen(string $value, int $exactLength): bool { diff --git a/src/Validation/Traits/Lists.php b/src/Validation/Traits/Lists.php index 4288feb2c..54fd3eb2e 100644 --- a/src/Validation/Traits/Lists.php +++ b/src/Validation/Traits/Lists.php @@ -22,9 +22,6 @@ trait Lists { /** * Validates that the field value is contained within a given string. - * @param string $value - * @param string $haystack - * @return bool */ protected function contains(string $value, string $haystack): bool { @@ -36,30 +33,24 @@ protected function contains(string $value, string $haystack): bool /** * Verifies that a value is contained within the pre-defined value set. - * @param string $value - * @param string ...$list - * @return bool */ protected function containsList(string $value, string ...$list): bool { $value = trim(strtolower($value)); - $list = array_map(fn ($item) => trim(strtolower($item)), $list); + $list = array_map(fn (string $item) => trim(strtolower($item)), $list); return in_array($value, $list); } /** * Verifies that a value is not contained within the pre-defined value set. - * @param string $value - * @param string ...$list - * @return bool */ protected function doesntContainsList(string $value, string ...$list): bool { $value = trim(strtolower($value)); - $list = array_map(fn ($item) => trim(strtolower($item)), $list); + $list = array_map(fn (string $item) => trim(strtolower($item)), $list); return !in_array($value, $list); } diff --git a/src/Validation/Traits/Resource.php b/src/Validation/Traits/Resource.php index 429337b4e..4a002c058 100644 --- a/src/Validation/Traits/Resource.php +++ b/src/Validation/Traits/Resource.php @@ -22,8 +22,6 @@ trait Resource { /** * Checks for valid URL or subdomain - * @param string $value - * @return bool */ protected function url(string $value): bool { @@ -32,8 +30,6 @@ protected function url(string $value): bool /** * Checks to see if the url exists - * @param string $value - * @return bool */ protected function urlExists(string $value): bool { @@ -56,8 +52,6 @@ protected function urlExists(string $value): bool /** * Checks for valid IP address - * @param string $value - * @return bool */ protected function ip(string $value): bool { @@ -66,8 +60,6 @@ protected function ip(string $value): bool /** * Checks for valid IPv4 address - * @param string $value - * @return bool */ protected function ipv4(string $value): bool { @@ -76,8 +68,6 @@ protected function ipv4(string $value): bool /** * Checks for valid IPv6 address - * @param string $value - * @return bool */ protected function ipv6(string $value): bool { diff --git a/src/Validation/Traits/Type.php b/src/Validation/Traits/Type.php index 2f9b5d24a..5315183dc 100644 --- a/src/Validation/Traits/Type.php +++ b/src/Validation/Traits/Type.php @@ -22,8 +22,6 @@ trait Type { /** * Checks the alpha characters - * @param string $value - * @return bool */ protected function alpha(string $value): bool { @@ -32,8 +30,6 @@ protected function alpha(string $value): bool /** * Checks the alpha and numeric characters - * @param string $value - * @return bool */ protected function alphaNumeric(string $value): bool { @@ -42,8 +38,6 @@ protected function alphaNumeric(string $value): bool /** * Checks the alpha and dash characters - * @param string $value - * @return bool */ protected function alphaDash(string $value): bool { @@ -52,8 +46,6 @@ protected function alphaDash(string $value): bool /** * Checks the alphanumeric and space characters - * @param string $value - * @return bool */ protected function alphaSpace(string $value): bool { @@ -62,8 +54,6 @@ protected function alphaSpace(string $value): bool /** * Checks the numeric value - * @param string $value - * @return bool */ protected function numeric(string $value): bool { @@ -72,8 +62,6 @@ protected function numeric(string $value): bool /** * Checks the integer value - * @param string $value - * @return bool */ protected function integer(string $value): bool { @@ -82,8 +70,6 @@ protected function integer(string $value): bool /** * Checks the float value - * @param string $value - * @return bool */ protected function float(string $value): bool { @@ -93,7 +79,6 @@ protected function float(string $value): bool /** * Checks the boolean value * @param $value - * @return bool */ protected function boolean($value): bool { @@ -104,9 +89,7 @@ protected function boolean($value): bool /** * Determines if the provided numeric value is lower to a specific value - * @param string $value * @param $minValue - * @return bool */ protected function minNumeric(string $value, $minValue): bool { @@ -115,9 +98,7 @@ protected function minNumeric(string $value, $minValue): bool /** * Determines if the provided numeric value is higher to a specific value - * @param string $value * @param $maxValue - * @return bool */ protected function maxNumeric(string $value, $maxValue): bool { diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index ac9ac9546..c51e63acb 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -43,19 +43,16 @@ class Validator /** * Rules - * @var array */ private array $rules = []; /** * Validation Errors - * @var array */ private array $errors = []; /** * Request data - * @var array */ private array $data = []; @@ -67,10 +64,9 @@ class Validator /** * Add rules for a single field - * @param string $field * @param array $rules Format: [['ruleName' => param], ...] */ - public function setRule(string $field, array $rules) + public function setRule(string $field, array $rules): void { foreach ($rules as $rule) { $ruleName = key($rule); @@ -92,10 +88,9 @@ public function setRules(array $rules): void /** * Update a single rule for a field if exists - * @param string $field * @param array $rule Format: ['ruleName' => param] */ - public function updateRule(string $field, array $rule) + public function updateRule(string $field, array $rule): void { $ruleName = key($rule); $ruleParam = current($rule); @@ -104,9 +99,7 @@ public function updateRule(string $field, array $rule) /** * Delete a rule or all rules for a given field - * @param string $field * @param string|null $rule Specific rule to delete; if null deletes all rules for field - * @return void */ public function deleteRule(string $field, ?string $rule = null): void { @@ -127,7 +120,6 @@ public function deleteRule(string $field, ?string $rule = null): void /** * Flush all rules and errors - * @return void */ public function flushRules(): void { @@ -137,7 +129,6 @@ public function flushRules(): void /** * Validate given data against defined rules - * @param array $data * @return bool True if valid, false otherwise */ public function isValid(array $data): bool @@ -184,7 +175,6 @@ public function isValid(array $data): bool * Add a custom validation rule * @param string $rule Rule name * @param Closure $function Callback function with signature function($value, $param): bool - * @return void */ public function addRule(string $rule, Closure $function): void { @@ -197,7 +187,6 @@ public function addRule(string $rule, Closure $function): void /** * Gets validation errors with translations - * @return array * @throws ConfigException * @throws DiException * @throws LangException @@ -227,10 +216,7 @@ public function getErrors(): array /** * Adds an error for a field and rule - * @param string $field - * @param string $rule * @param mixed|null $param - * @return void */ protected function addError(string $field, string $rule, $param = null): void { @@ -243,7 +229,6 @@ protected function addError(string $field, string $rule, $param = null): void /** * Flush all errors - * @return void */ public function flushErrors(): void { @@ -252,10 +237,8 @@ public function flushErrors(): void /** * Executes user defined rule - * @param string $rule * @param $value * @param mixed ...$params - * @return bool */ protected function executeCustomRule(string $rule, $value, ...$params): bool { @@ -269,8 +252,6 @@ protected function executeCustomRule(string $rule, $value, ...$params): bool } /** - * @param string $field - * @param string $ruleName * @param $ruleParam */ private function setOrUpdateRule(string $field, string $ruleName, $ruleParam): void diff --git a/src/View/Exceptions/ViewException.php b/src/View/Exceptions/ViewException.php index a516b78cc..6c52eeea2 100644 --- a/src/View/Exceptions/ViewException.php +++ b/src/View/Exceptions/ViewException.php @@ -25,9 +25,6 @@ */ class ViewException extends BaseException { - /** - * @return ViewException - */ public static function noLayoutSet(): self { return new self( @@ -36,9 +33,6 @@ public static function noLayoutSet(): self ); } - /** - * @return ViewException - */ public static function viewNotRendered(): self { return new self( diff --git a/src/View/Factories/ViewFactory.php b/src/View/Factories/ViewFactory.php index 9c080ede5..e9855afb4 100644 --- a/src/View/Factories/ViewFactory.php +++ b/src/View/Factories/ViewFactory.php @@ -34,13 +34,11 @@ class ViewFactory { /** * Instance of QtView - * @var QtView|null */ private static ?QtView $instance = null; /** * QtView instance - * @return QtView * @throws DebugBarException * @throws DiException * @throws BaseException diff --git a/src/View/Helpers/view.php b/src/View/Helpers/view.php index dbb1ef00c..04a953f87 100644 --- a/src/View/Helpers/view.php +++ b/src/View/Helpers/view.php @@ -12,6 +12,7 @@ * @since 3.0.0 */ +use League\CommonMark\Exception\CommonMarkException; use Quantum\Config\Exceptions\ConfigException; use Quantum\View\Exceptions\ViewException; use League\CommonMark\CommonMarkConverter; @@ -24,7 +25,6 @@ /** * Rendered view - * @return string|null * @throws BaseException * @throws ConfigException * @throws DebugBarException @@ -39,9 +39,6 @@ function view(): ?string /** * Rendered partial - * @param string $partial - * @param array $args - * @return string * @throws BaseException * @throws ConfigException * @throws DebugBarException @@ -55,7 +52,6 @@ function partial(string $partial, array $args = []): string /** * Gets the param passed to view - * @param string $key * @return mixed|null * @throws BaseException * @throws ConfigException @@ -71,7 +67,6 @@ function view_param(string $key) /** * Creates a raw param * @param $value - * @return RawParam */ function raw_param($value): RawParam { @@ -80,7 +75,6 @@ function raw_param($value): RawParam /** * Rendered debug bar - * @return string|null * @throws DebugBarException */ function debugbar(): ?string @@ -95,9 +89,7 @@ function debugbar(): ?string } /** - * @param string $content - * @param bool $sanitize - * @return string + * @throws CommonMarkException */ function markdown_to_html(string $content, bool $sanitize = false): string { @@ -111,7 +103,7 @@ function markdown_to_html(string $content, bool $sanitize = false): string $html = $converter->convertToHtml($content); - if ($purifier instanceof \HTMLPurifier) { + if ($purifier instanceof HTMLPurifier) { return $purifier->purify($html); } diff --git a/src/View/QtView.php b/src/View/QtView.php index 729cd243c..77cb42934 100644 --- a/src/View/QtView.php +++ b/src/View/QtView.php @@ -22,9 +22,9 @@ use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; use Quantum\ResourceCache\ViewCache; -use Quantum\Renderer\Renderer; use Quantum\Asset\AssetManager; use Quantum\Debugger\Debugger; +use Quantum\Renderer\Renderer; use ReflectionException; use Psr\Log\LogLevel; @@ -34,56 +34,34 @@ */ class QtView { - /** - * @var Renderer - */ private Renderer $renderer; - /** - * @var AssetManager - */ private AssetManager $assetManager; - /** - * @var Debugger - */ private Debugger $debugger; - /** - * @var ViewCache - */ private ViewCache $viewCache; /** * Layout file - * @var string|null */ private ?string $layoutFile = null; /** * Rendered view - * @var string|null */ private ?string $viewContent = null; /** * Assets to be included - * @var array */ private array $assets = []; /** * View params - * @var array */ private array $params = []; - /** - * @param Renderer $renderer - * @param AssetManager $assetManager - * @param Debugger $debugger - * @param ViewCache $viewCache - */ public function __construct( Renderer $renderer, AssetManager $assetManager, @@ -98,10 +76,8 @@ public function __construct( /** * Sets a layout - * @param string|null $layoutFile - * @param array $assets */ - public function setLayout(?string $layoutFile, array $assets = []) + public function setLayout(?string $layoutFile, array $assets = []): void { $this->layoutFile = $layoutFile; @@ -112,7 +88,6 @@ public function setLayout(?string $layoutFile, array $assets = []) /** * Gets the layout - * @return string|null */ public function getLayout(): ?string { @@ -121,27 +96,23 @@ public function getLayout(): ?string /** * Sets view parameter - * @param string $key * @param mixed $value */ - public function setParam(string $key, $value) + public function setParam(string $key, $value): void { $this->params[$key] = $value; } /** - * @param string $key * @param $value - * @return void */ - public function setRawParam(string $key, $value) + public function setRawParam(string $key, $value): void { $this->params[$key] = new RawParam($value); } /** * Gets the view parameter - * @param string $key * @return mixed|null */ public function getParam(string $key) @@ -157,9 +128,8 @@ public function getParam(string $key) /** * Sets multiple view parameters - * @param array $params */ - public function setParams(array $params) + public function setParams(array $params): void { foreach ($params as $key => $value) { $this->setParam($key, $value); @@ -168,31 +138,22 @@ public function setParams(array $params) /** * Gets all view parameters - * @return array */ public function getParams(): array { - - $params = array_map(function ($param) { - return ($param instanceof RawParam) ? $param->getValue() : $param; - }, $this->params); - - return $params; + return array_map(fn ($param) => ($param instanceof RawParam) ? $param->getValue() : $param, $this->params); } /** * Flushes the view params */ - public function flushParams() + public function flushParams(): void { $this->params = []; } /** * Renders the view. - * @param string $viewFile - * @param array $params - * @return string|null * @throws AssetException * @throws BaseException * @throws ConfigException @@ -235,9 +196,6 @@ public function render(string $viewFile, array $params = []): ?string /** * Renders partial view. - * @param string $viewFile - * @param array $params - * @return string */ public function renderPartial(string $viewFile, array $params = []): string { @@ -250,7 +208,6 @@ public function renderPartial(string $viewFile, array $params = []): string /** * Gets the rendered view. - * @return string|null * @throws ViewException */ public function getView(): ?string @@ -264,8 +221,6 @@ public function getView(): ?string /** * Renders the view - * @param string $viewFile - * @return string */ private function renderFile(string $viewFile): string { @@ -308,20 +263,12 @@ private function xssFilter($params) return $params; } - /** - * @param string $value - * @return string - */ private function sanitizeHtml(string $value): string { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } - /** - * @param string $viewFile - * @return void - */ - private function updateDebugger(string $viewFile) + private function updateDebugger(string $viewFile): void { $routesCell = $this->debugger->getStoreCell(Debugger::ROUTES); $currentData = current($routesCell)[LogLevel::INFO] ?? []; diff --git a/tests/Helpers/functions.php b/tests/Helpers/functions.php index fbeb2c637..ab608e89e 100644 --- a/tests/Helpers/functions.php +++ b/tests/Helpers/functions.php @@ -1,6 +1,6 @@ flush(); } - public function testConsoleAppAdapterStartSuccessfully() + public function testConsoleAppAdapterStartSuccessfully(): void { $_SERVER['argv'] = ['qt', 'list', '--quiet']; @@ -46,7 +46,7 @@ public function testConsoleAppAdapterStartSuccessfully() $this->assertEquals(0, $result); } - public function testConsoleAppAdapterStartFails() + public function testConsoleAppAdapterStartFails(): void { $_SERVER['argv'] = ['qt', 'unknown', '--quiet']; diff --git a/tests/Unit/App/Adapters/WebAppAdapterTest.php b/tests/Unit/App/Adapters/WebAppAdapterTest.php index e24ad37ed..4ce612469 100644 --- a/tests/Unit/App/Adapters/WebAppAdapterTest.php +++ b/tests/Unit/App/Adapters/WebAppAdapterTest.php @@ -10,7 +10,7 @@ class WebAppAdapterTest extends TestCase { - private $webAppAdapter; + private WebAppAdapter $webAppAdapter; public function setUp(): void { @@ -25,7 +25,7 @@ public function tearDown(): void Di::reset(); } - public function testWebAppAdapterStartSuccessfully() + public function testWebAppAdapterStartSuccessfully(): void { $request = Di::get(Request::class); $request->create('GET', '/test/am/tests'); @@ -37,7 +37,7 @@ public function testWebAppAdapterStartSuccessfully() $this->assertEquals(0, $result); } - public function testWebAppAdapterStartFails() + public function testWebAppAdapterStartFails(): void { $request = Di::get(Request::class); $request->create('POST', ''); @@ -49,7 +49,7 @@ public function testWebAppAdapterStartFails() $this->assertSame(0, $result); } - public function testWebAppAdapterHandlesPageNotFoundGracefully() + public function testWebAppAdapterHandlesPageNotFoundGracefully(): void { $request = Di::get(Request::class); $request->create('GET', '/non-existing-uri'); diff --git a/tests/Unit/App/AppTest.php b/tests/Unit/App/AppTest.php index 20cc4a669..28e26c5f2 100644 --- a/tests/Unit/App/AppTest.php +++ b/tests/Unit/App/AppTest.php @@ -31,7 +31,7 @@ public function tearDown(): void config()->flush(); } - public function testAppGetAdapter() + public function testAppGetAdapter(): void { $app = new App(new WebAppAdapter()); @@ -48,7 +48,7 @@ public function testAppGetAdapter() $this->assertInstanceOf(AppInterface::class, $app->getAdapter()); } - public function testAppCallingValidMethod() + public function testAppCallingValidMethod(): void { $app = new App(new WebAppAdapter()); @@ -60,7 +60,7 @@ public function testAppCallingValidMethod() ob_end_clean(); } - public function testAppCallingInvalidMethod() + public function testAppCallingInvalidMethod(): void { $app = new App(new WebAppAdapter()); diff --git a/tests/Unit/App/Factories/AppFactoryTest.php b/tests/Unit/App/Factories/AppFactoryTest.php index 25e4f6d43..217e32873 100644 --- a/tests/Unit/App/Factories/AppFactoryTest.php +++ b/tests/Unit/App/Factories/AppFactoryTest.php @@ -17,7 +17,7 @@ public function setUp(): void parent::setUp(); } - public function testAppFactoryInstance() + public function testAppFactoryInstance(): void { $app = AppFactory::create(App::WEB, PROJECT_ROOT); @@ -29,7 +29,7 @@ public function tearDown(): void config()->flush(); } - public function testAppFactoryConsoleAdapter() + public function testAppFactoryConsoleAdapter(): void { $app = AppFactory::create(App::CONSOLE, PROJECT_ROOT); @@ -38,7 +38,7 @@ public function testAppFactoryConsoleAdapter() $this->assertInstanceOf(AppInterface::class, $app->getAdapter()); } - public function testAppFactoryWebAdapter() + public function testAppFactoryWebAdapter(): void { $app = AppFactory::create(App::WEB, PROJECT_ROOT); @@ -47,7 +47,7 @@ public function testAppFactoryWebAdapter() $this->assertInstanceOf(AppInterface::class, $app->getAdapter()); } - public function testAppFactoryInvalidAdapter() + public function testAppFactoryInvalidAdapter(): void { $this->expectException(AppException::class); @@ -56,7 +56,7 @@ public function testAppFactoryInvalidAdapter() AppFactory::create('invalid_type', PROJECT_ROOT); } - public function testAppFactoryReturnsSameInstance() + public function testAppFactoryReturnsSameInstance(): void { $app1 = AppFactory::create(App::WEB, PROJECT_ROOT); $app2 = AppFactory::create(App::WEB, PROJECT_ROOT); @@ -64,7 +64,7 @@ public function testAppFactoryReturnsSameInstance() $this->assertSame($app1, $app2); } - public function testAppFactoryDestroy() + public function testAppFactoryDestroy(): void { $app1 = AppFactory::create(App::WEB, PROJECT_ROOT); diff --git a/tests/Unit/App/Helpers/DirHelperTest.php b/tests/Unit/App/Helpers/DirHelperTest.php index 6e9bd9ec2..24d818bb3 100644 --- a/tests/Unit/App/Helpers/DirHelperTest.php +++ b/tests/Unit/App/Helpers/DirHelperTest.php @@ -11,49 +11,49 @@ public function setUp(): void parent::setUp(); } - public function testBaseDir() + public function testBaseDir(): void { $expectedBaseDir = dirname(__DIR__, 3) . DS . '_root'; $this->assertEquals($expectedBaseDir, base_dir()); } - public function testLogsDir() + public function testLogsDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'logs'; $this->assertEquals($expected, logs_dir()); } - public function testFrameworkDir() + public function testFrameworkDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'vendor' . DS . 'quantum' . DS . 'framework' . DS . 'src'; $this->assertEquals($expected, framework_dir()); } - public function testModulesDir() + public function testModulesDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'modules'; $this->assertEquals($expected, modules_dir()); } - public function testPublicDir() + public function testPublicDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'public'; $this->assertEquals($expected, public_dir()); } - public function testUploadsDir() + public function testUploadsDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'public' . DS . 'uploads'; $this->assertEquals($expected, uploads_dir()); } - public function testAssetsDir() + public function testAssetsDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'public' . DS . 'assets'; $this->assertEquals($expected, assets_dir()); } - public function testHooksDir() + public function testHooksDir(): void { $expected = dirname(__DIR__, 3) . DS . '_root' . DS . 'hooks'; $this->assertEquals($expected, hooks_dir()); diff --git a/tests/Unit/App/Helpers/MiscHelperTest.php b/tests/Unit/App/Helpers/MiscHelperTest.php index 824f54659..203f61464 100644 --- a/tests/Unit/App/Helpers/MiscHelperTest.php +++ b/tests/Unit/App/Helpers/MiscHelperTest.php @@ -11,14 +11,14 @@ public function setUp(): void parent::setUp(); } - public function testMessageHelper() + public function testMessageHelper(): void { $this->assertEquals('Hello John', _message('Hello {%1}', 'John')); $this->assertEquals('Hello John, greetings from Jenny', _message('Hello {%1}, greetings from {%2}', ['John', 'Jenny'])); } - public function testValidBase64() + public function testValidBase64(): void { $validBase64String = base64_encode('test'); @@ -29,14 +29,14 @@ public function testValidBase64() $this->assertFalse(valid_base64($invalidBase64String)); } - public function testRandomNumber() + public function testRandomNumber(): void { $this->assertIsInt(random_number()); $this->assertIsInt(random_number(5)); } - public function testSlugify() + public function testSlugify(): void { $this->assertEquals('text-with-spaces', slugify('Text with spaces')); diff --git a/tests/Unit/App/Helpers/UuidHelperTest.php b/tests/Unit/App/Helpers/UuidHelperTest.php index 89a764e04..de97b91ff 100644 --- a/tests/Unit/App/Helpers/UuidHelperTest.php +++ b/tests/Unit/App/Helpers/UuidHelperTest.php @@ -11,7 +11,7 @@ public function setUp(): void parent::setUp(); } - public function testUuidRandomGeneratesValidUuidV4() + public function testUuidRandomGeneratesValidUuidV4(): void { $this->assertMatchesRegularExpression( '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i', @@ -20,7 +20,7 @@ public function testUuidRandomGeneratesValidUuidV4() ); } - public function testUuidOrderedGeneratesValidUuidV1() + public function testUuidOrderedGeneratesValidUuidV1(): void { $this->assertMatchesRegularExpression( '/^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i', @@ -29,12 +29,12 @@ public function testUuidOrderedGeneratesValidUuidV1() ); } - public function testUuidRandomIsUnique() + public function testUuidRandomIsUnique(): void { $this->assertNotEquals(uuid_random(), uuid_random(), 'Two random UUIDs should be different'); } - public function testUuidOrderedIsChronologicallyIncreasing() + public function testUuidOrderedIsChronologicallyIncreasing(): void { $uuid1 = uuid_ordered(); usleep(10); diff --git a/tests/Unit/AppTestCase.php b/tests/Unit/AppTestCase.php index e2bce7587..cdd00f170 100644 --- a/tests/Unit/AppTestCase.php +++ b/tests/Unit/AppTestCase.php @@ -83,8 +83,7 @@ protected function testRequest( [$method], $uri, 'TestController', - 'testAction', - null + 'testAction' ); $route->module('Test'); diff --git a/tests/Unit/Archive/Adapters/PharAdapterTest.php b/tests/Unit/Archive/Adapters/PharAdapterTest.php index 7172f18ad..1c09c5fae 100644 --- a/tests/Unit/Archive/Adapters/PharAdapterTest.php +++ b/tests/Unit/Archive/Adapters/PharAdapterTest.php @@ -7,8 +7,8 @@ class PharAdapterTest extends AppTestCase { - private $pharArchive; - private $archiveName; + private PharAdapter $pharArchive; + private string $archiveName; public function setUp(): void { @@ -27,7 +27,7 @@ public function tearDown(): void } } - public function testAddEmptyDirToPhar() + public function testAddEmptyDirToPhar(): void { $this->assertTrue($this->pharArchive->addEmptyDir('directoryOne')); @@ -36,7 +36,7 @@ public function testAddEmptyDirToPhar() $this->assertDirectoryExists("phar://{$this->archiveName}/directoryOne"); } - public function testAddFileToPhar() + public function testAddFileToPhar(): void { $this->assertFalse($this->pharArchive->offsetExists('app.conf')); @@ -52,7 +52,7 @@ public function testAddFileToPhar() $this->assertFileExists("phar://{$this->archiveName}/app.conf"); } - public function testAddFromStringToPhar() + public function testAddFromStringToPhar(): void { $this->assertTrue($this->pharArchive->addFromString('custom.text', 'Just a sample text')); @@ -61,7 +61,7 @@ public function testAddFromStringToPhar() $this->assertStringEqualsFile("phar://{$this->archiveName}/custom.text", 'Just a sample text'); } - public function testAddMultipleFilesToPhar() + public function testAddMultipleFilesToPhar(): void { $this->assertTrue($this->pharArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -73,7 +73,7 @@ public function testAddMultipleFilesToPhar() $this->assertTrue($this->pharArchive->offsetExists('session.conf')); } - public function testPharCount() + public function testPharCount(): void { $this->assertTrue($this->pharArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -83,7 +83,7 @@ public function testPharCount() $this->assertEquals(2, $this->pharArchive->count()); } - public function testExtractToFromPhar() + public function testExtractToFromPhar(): void { $content = 'Just a sample text'; @@ -98,7 +98,7 @@ public function testExtractToFromPhar() $this->fs->remove(base_dir() . DS . 'sample.txt'); } - public function testDeleteFileFromPhar() + public function testDeleteFileFromPhar(): void { $this->pharArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -118,7 +118,7 @@ public function testDeleteFileFromPhar() $this->assertEquals(2, $this->pharArchive->count()); } - public function testDeleteMultipleFilesUsingNameFromPhar() + public function testDeleteMultipleFilesUsingNameFromPhar(): void { $this->pharArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', diff --git a/tests/Unit/Archive/Adapters/ZipAdapterTest.php b/tests/Unit/Archive/Adapters/ZipAdapterTest.php index a61db4c7e..5d3837ab8 100644 --- a/tests/Unit/Archive/Adapters/ZipAdapterTest.php +++ b/tests/Unit/Archive/Adapters/ZipAdapterTest.php @@ -7,8 +7,8 @@ class ZipAdapterTest extends AppTestCase { - private $zipArchive; - private $archiveName; + private ZipAdapter $zipArchive; + private string $archiveName; public function setUp(): void { @@ -28,7 +28,7 @@ public function tearDown(): void } } - public function testAddEmptyDirToZip() + public function testAddEmptyDirToZip(): void { $this->assertFalse($this->zipArchive->offsetExists('directoryOne')); @@ -37,7 +37,7 @@ public function testAddEmptyDirToZip() $this->assertTrue($this->zipArchive->offsetExists('directoryOne')); } - public function testAddFileToZip() + public function testAddFileToZip(): void { $this->assertFalse($this->zipArchive->offsetExists('app.conf')); @@ -51,14 +51,14 @@ public function testAddFileToZip() $this->assertTrue($this->zipArchive->offsetExists('app.conf')); } - public function testAddFromStringToZip() + public function testAddFromStringToZip(): void { $this->assertTrue($this->zipArchive->addFromString('custom.text', 'Just a sample text')); $this->assertTrue($this->zipArchive->offsetExists('custom.text')); } - public function testAddMultipleFilesToZip() + public function testAddMultipleFilesToZip(): void { $this->assertTrue($this->zipArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -70,7 +70,7 @@ public function testAddMultipleFilesToZip() $this->assertTrue($this->zipArchive->offsetExists('session.conf')); } - public function testZipCount() + public function testZipCount(): void { $this->assertTrue($this->zipArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -80,7 +80,7 @@ public function testZipCount() $this->assertEquals(2, $this->zipArchive->count()); } - public function testExtractToFromZip() + public function testExtractToFromZip(): void { $content = 'Just a sample text'; @@ -95,7 +95,7 @@ public function testExtractToFromZip() $this->fs->remove(base_dir() . DS . 'sample.txt'); } - public function testDeleteFileFromZip() + public function testDeleteFileFromZip(): void { $this->zipArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', @@ -115,7 +115,7 @@ public function testDeleteFileFromZip() $this->assertEquals(2, $this->zipArchive->count()); } - public function testDeleteMultipleFilesFromZip() + public function testDeleteMultipleFilesFromZip(): void { $this->zipArchive->addMultipleFiles([ 'app.conf' => base_dir() . DS . 'shared' . DS . 'config' . DS . 'app.php', diff --git a/tests/Unit/Archive/ArchiveTest.php b/tests/Unit/Archive/ArchiveTest.php index 2ef49c4a1..88e0aa4a7 100644 --- a/tests/Unit/Archive/ArchiveTest.php +++ b/tests/Unit/Archive/ArchiveTest.php @@ -16,7 +16,7 @@ public function setUp(): void parent::setUp(); } - public function testArchiveGetAdapter() + public function testArchiveGetAdapter(): void { $archive = new Archive(new PharAdapter()); @@ -31,7 +31,7 @@ public function testArchiveGetAdapter() $this->assertInstanceOf(ArchiveInterface::class, $archive->getAdapter()); } - public function testArchiveCallingValidMethod() + public function testArchiveCallingValidMethod(): void { $pharAdapter = new PharAdapter(); $pharAdapter->setName('test.phar'); @@ -43,7 +43,7 @@ public function testArchiveCallingValidMethod() $this->assertEquals(0, $archive->count()); } - public function testArchiveCallingInvalidMethod() + public function testArchiveCallingInvalidMethod(): void { $pharAdapter = new PharAdapter(); $pharAdapter->setName('test.phar'); diff --git a/tests/Unit/Archive/Factories/ArchiveFactoryTest.php b/tests/Unit/Archive/Factories/ArchiveFactoryTest.php index 12d99188f..3d9700b24 100644 --- a/tests/Unit/Archive/Factories/ArchiveFactoryTest.php +++ b/tests/Unit/Archive/Factories/ArchiveFactoryTest.php @@ -17,14 +17,14 @@ public function setUp(): void parent::setUp(); } - public function testArchiveFactoryInstance() + public function testArchiveFactoryInstance(): void { $archive = ArchiveFactory::get(); $this->assertInstanceOf(Archive::class, $archive); } - public function testArchiveFactoryPharAdapter() + public function testArchiveFactoryPharAdapter(): void { $archive = ArchiveFactory::get(); @@ -33,7 +33,7 @@ public function testArchiveFactoryPharAdapter() $this->assertInstanceOf(ArchiveInterface::class, $archive->getAdapter()); } - public function testArchiveFactoryZipAdapter() + public function testArchiveFactoryZipAdapter(): void { $archive = ArchiveFactory::get(Archive::ZIP); @@ -42,7 +42,7 @@ public function testArchiveFactoryZipAdapter() $this->assertInstanceOf(ArchiveInterface::class, $archive->getAdapter()); } - public function testArchiveFactoryInvalidAdapter() + public function testArchiveFactoryInvalidAdapter(): void { $this->expectException(ArchiveException::class); @@ -51,7 +51,7 @@ public function testArchiveFactoryInvalidAdapter() ArchiveFactory::get('invalid_type'); } - public function testArchiveFactoryReturnsSameInstance() + public function testArchiveFactoryReturnsSameInstance(): void { $archive1 = ArchiveFactory::get(); $archive2 = ArchiveFactory::get(); diff --git a/tests/Unit/Asset/AssetManagerTest.php b/tests/Unit/Asset/AssetManagerTest.php index 55e0258d3..bf922e899 100644 --- a/tests/Unit/Asset/AssetManagerTest.php +++ b/tests/Unit/Asset/AssetManagerTest.php @@ -8,7 +8,7 @@ class AssetManagerTest extends AppTestCase { - private $assetManager; + private AssetManager $assetManager; public function setUp(): void { @@ -19,7 +19,7 @@ public function setUp(): void $this->assetManager = AssetManager::getInstance(); } - public function testRegisterPublishDump() + public function testRegisterPublishDump(): void { $this->assetManager->register([ new Asset(Asset::CSS, 'css/style.css'), @@ -69,7 +69,7 @@ public function testRegisterPublishDump() ob_get_clean(); } - public function testAssetGetTag() + public function testAssetGetTag(): void { $this->assetManager->registerAsset(new Asset(Asset::JS, 'js/jquery.js', 'jQuery')); @@ -79,7 +79,7 @@ public function testAssetGetTag() ); } - public function testAssetUrl() + public function testAssetUrl(): void { $this->assertEquals( 'http://mydomain.com/assets/icons/person.png', diff --git a/tests/Unit/Asset/AssetTest.php b/tests/Unit/Asset/AssetTest.php index caca09735..28db18594 100644 --- a/tests/Unit/Asset/AssetTest.php +++ b/tests/Unit/Asset/AssetTest.php @@ -7,7 +7,7 @@ class AssetTest extends AppTestCase { - private $asset; + private Asset $asset; public function setUp(): void { @@ -19,34 +19,34 @@ public function setUp(): void } - public function testAssetType() + public function testAssetType(): void { $this->assertEquals(Asset::JS, $this->asset->getType()); } - public function testAssetPath() + public function testAssetPath(): void { $this->assertEquals('scripts/jquery.js', $this->asset->getPath()); } - public function testAssetName() + public function testAssetName(): void { $this->assertEquals('jQuery', $this->asset->getName()); } - public function testAssetPosition() + public function testAssetPosition(): void { $this->assertEquals(-1, $this->asset->getPosition()); } - public function testAssetAttributes() + public function testAssetAttributes(): void { $this->assertIsArray($this->asset->getAttributes()); $this->assertCount(0, $this->asset->getAttributes()); } - public function testAssetUrl() + public function testAssetUrl(): void { $this->assertEquals( 'http://mydomain.com/assets/scripts/jquery.js', @@ -54,7 +54,7 @@ public function testAssetUrl() ); } - public function testAssetTag() + public function testAssetTag(): void { $this->assertEquals( '' . PHP_EOL, diff --git a/tests/Unit/Asset/Helpers/AssetHelperFunctionsTest.php b/tests/Unit/Asset/Helpers/AssetHelperFunctionsTest.php index bff977bf3..c48dbbcdd 100644 --- a/tests/Unit/Asset/Helpers/AssetHelperFunctionsTest.php +++ b/tests/Unit/Asset/Helpers/AssetHelperFunctionsTest.php @@ -15,12 +15,12 @@ public function setUp(): void $this->setPrivateProperty(AssetManager::class, 'instance', null); } - public function testAssetHelper() + public function testAssetHelper(): void { $this->assertInstanceOf(AssetManager::class, asset()); } - public function testAssetUrl() + public function testAssetUrl(): void { config()->set('app.base_url', 'http://mydomain.com'); @@ -29,7 +29,7 @@ public function testAssetUrl() $this->assertSame('http://mydomain.com/assets/js/script.js', asset()->url('js/script.js')); } - public function testPublishedAssets() + public function testPublishedAssets(): void { config()->set('base_url', 'http://mydomain.com'); diff --git a/tests/Unit/Auth/Adapters/JwtAuthAdapterTest.php b/tests/Unit/Auth/Adapters/JwtAuthAdapterTest.php index 67799d5d1..16d7fd70f 100644 --- a/tests/Unit/Auth/Adapters/JwtAuthAdapterTest.php +++ b/tests/Unit/Auth/Adapters/JwtAuthAdapterTest.php @@ -12,7 +12,7 @@ class JwtAuthAdapterTest extends AuthTestCase { - private $jwtAuth; + private JwtAuthAdapter $jwtAuth; public function setUp(): void { @@ -44,12 +44,12 @@ public function tearDown(): void $this->jwtAuth->signout(); } - public function testApiAdapterConstructor() + public function testApiAdapterConstructor(): void { $this->assertInstanceOf(JwtAuthAdapter::class, $this->jwtAuth); } - public function testApiSigninIncorrectCredentials() + public function testApiSigninIncorrectCredentials(): void { $this->expectException(AuthException::class); @@ -58,7 +58,7 @@ public function testApiSigninIncorrectCredentials() $this->jwtAuth->signin('admin@qt.com', '111111'); } - public function testApiSigninCorrectCredentials() + public function testApiSigninCorrectCredentials(): void { config()->set('TWO_FA', false); @@ -69,7 +69,7 @@ public function testApiSigninCorrectCredentials() $this->assertArrayHasKey('refresh_token', $this->jwtAuth->signin('admin@qt.com', 'qwerty')); } - public function testApiSignOut() + public function testApiSignOut(): void { $this->jwtAuth->signin('admin@qt.com', 'qwerty'); @@ -80,7 +80,7 @@ public function testApiSignOut() $this->assertFalse($this->jwtAuth->check()); } - public function testApiUser() + public function testApiUser(): void { $this->jwtAuth->signin('admin@qt.com', 'qwerty'); @@ -95,7 +95,7 @@ public function testApiUser() $this->assertNull($this->jwtAuth->user()); } - public function testApiCheck() + public function testApiCheck(): void { $this->assertFalse($this->jwtAuth->check()); @@ -108,7 +108,7 @@ public function testApiCheck() $this->assertFalse($this->jwtAuth->check()); } - public function testApiSignupAndSigninWithoutActivation() + public function testApiSignupAndSigninWithoutActivation(): void { $this->expectException(AuthException::class); @@ -119,7 +119,7 @@ public function testApiSignupAndSigninWithoutActivation() $this->assertTrue($this->jwtAuth->signin('guest@qt.com', '123456')); } - public function testApiSignupAndActivateAccount() + public function testApiSignupAndActivateAccount(): void { $user = $this->jwtAuth->signup($this->guestUser); @@ -132,9 +132,9 @@ public function testApiSignupAndActivateAccount() $this->assertArrayHasKey('refresh_token', $this->jwtAuth->signin('guest@qt.com', '123456')); } - public function testApiForgetReset() + public function testApiForgetReset(): void { - $resetToken = $this->jwtAuth->forget('admin@qt.com', 'tpl'); + $resetToken = $this->jwtAuth->forget('admin@qt.com'); $this->jwtAuth->reset($resetToken, '123456789'); @@ -145,7 +145,7 @@ public function testApiForgetReset() $this->assertArrayHasKey('refresh_token', $this->jwtAuth->signin('admin@qt.com', '123456789')); } - public function testApiVerifyOtp() + public function testApiVerifyOtp(): void { config()->set('auth.two_fa', true); @@ -160,7 +160,7 @@ public function testApiVerifyOtp() $this->assertArrayHasKey('refresh_token', $tokens); } - public function testApiSigninWithoutVerification() + public function testApiSigninWithoutVerification(): void { config()->set('auth.two_fa', false); @@ -171,7 +171,7 @@ public function testApiSigninWithoutVerification() $this->assertArrayHasKey('refresh_token', $this->jwtAuth->signin('admin@qt.com', 'qwerty')); } - public function testApiSigninWithVerification() + public function testApiSigninWithVerification(): void { config()->set('auth.two_fa', true); @@ -180,7 +180,7 @@ public function testApiSigninWithVerification() $this->assertIsString($this->jwtAuth->signin('admin@qt.com', 'qwerty')); } - public function testApiResendOtp() + public function testApiResendOtp(): void { config()->set('auth.two_fa', true); @@ -191,7 +191,7 @@ public function testApiResendOtp() $this->assertIsString($this->jwtAuth->resendOtp($otp_token)); } - public function testApiRefreshUser() + public function testApiRefreshUser(): void { $this->jwtAuth->signin('admin@qt.com', 'qwerty'); diff --git a/tests/Unit/Auth/Adapters/SessionAuthAdapterTest.php b/tests/Unit/Auth/Adapters/SessionAuthAdapterTest.php index 749b936bd..4eb866667 100644 --- a/tests/Unit/Auth/Adapters/SessionAuthAdapterTest.php +++ b/tests/Unit/Auth/Adapters/SessionAuthAdapterTest.php @@ -11,7 +11,7 @@ class SessionAuthAdapterTest extends AuthTestCase { - private $sessionAuth; + private SessionAuthAdapter $sessionAuth; public function setUp(): void { @@ -33,12 +33,12 @@ public function tearDown(): void $this->sessionAuth->signout(); } - public function testWebAdapterConstructor() + public function testWebAdapterConstructor(): void { $this->assertInstanceOf(SessionAuthAdapter::class, $this->sessionAuth); } - public function testWebSigninIncorrectCredentials() + public function testWebSigninIncorrectCredentials(): void { $this->expectException(AuthException::class); @@ -47,14 +47,14 @@ public function testWebSigninIncorrectCredentials() $this->sessionAuth->signin('admin@qt.com', '111111'); } - public function testWebSigninCorrectCredentials() + public function testWebSigninCorrectCredentials(): void { $this->assertTrue($this->sessionAuth->signin('admin@qt.com', 'qwerty')); $this->assertTrue($this->sessionAuth->signin('admin@qt.com', 'qwerty', true)); } - public function testWebSigninWithRemember() + public function testWebSigninWithRemember(): void { $this->sessionAuth->signin('admin@qt.com', 'qwerty', true); @@ -63,7 +63,7 @@ public function testWebSigninWithRemember() $this->assertTrue($this->sessionAuth->check()); } - public function testWebSignout() + public function testWebSignout(): void { $this->assertFalse($this->sessionAuth->check()); @@ -76,7 +76,7 @@ public function testWebSignout() $this->assertFalse($this->sessionAuth->check()); } - public function testWebUser() + public function testWebUser(): void { $this->sessionAuth->signin('admin@qt.com', 'qwerty'); @@ -87,7 +87,7 @@ public function testWebUser() $this->assertEquals('admin', $this->sessionAuth->user()->getFieldValue('role')); } - public function testWebCheck() + public function testWebCheck(): void { $this->assertFalse($this->sessionAuth->check()); @@ -96,7 +96,7 @@ public function testWebCheck() $this->assertTrue($this->sessionAuth->check()); } - public function testWebSignupAndSigninWithoutActivation() + public function testWebSignupAndSigninWithoutActivation(): void { $this->expectException(AuthException::class); @@ -108,7 +108,7 @@ public function testWebSignupAndSigninWithoutActivation() $this->assertTrue($this->sessionAuth->signin('guest@qt.com', '123456')); } - public function testWebSignupAndActivateAccount() + public function testWebSignupAndActivateAccount(): void { $user = $this->sessionAuth->signup($this->guestUser); @@ -117,7 +117,7 @@ public function testWebSignupAndActivateAccount() $this->assertTrue($this->sessionAuth->signin('guest@qt.com', '123456')); } - public function testWebForgetReset() + public function testWebForgetReset(): void { $resetToken = $this->sessionAuth->forget('admin@qt.com'); @@ -126,7 +126,7 @@ public function testWebForgetReset() $this->assertTrue($this->sessionAuth->signin('admin@qt.com', '123456789')); } - public function testWebVerifyOtp() + public function testWebVerifyOtp(): void { config()->set('auth.two_fa', true); @@ -137,7 +137,7 @@ public function testWebVerifyOtp() $this->assertTrue($this->sessionAuth->verifyOtp(123456789, $otp_token)); } - public function testWebSigninWithoutVerification() + public function testWebSigninWithoutVerification(): void { config()->set('auth.two_fa', false); @@ -146,7 +146,7 @@ public function testWebSigninWithoutVerification() $this->assertTrue($this->sessionAuth->signin('admin@qt.com', 'qwerty')); } - public function testWebSigninWithVerification() + public function testWebSigninWithVerification(): void { config()->set('auth.two_fa', true); @@ -155,7 +155,7 @@ public function testWebSigninWithVerification() $this->assertIsString($this->sessionAuth->signin('admin@qt.com', 'qwerty')); } - public function testWebResendOtp() + public function testWebResendOtp(): void { config()->set('auth.two_fa', true); @@ -166,7 +166,7 @@ public function testWebResendOtp() $this->assertIsString($this->sessionAuth->resendOtp($otp_token)); } - public function testWebRefreshUser() + public function testWebRefreshUser(): void { $this->sessionAuth->signin('admin@qt.com', 'qwerty'); diff --git a/tests/Unit/Auth/AuthTest.php b/tests/Unit/Auth/AuthTest.php index 7bd6bebdc..b8e62ee0d 100644 --- a/tests/Unit/Auth/AuthTest.php +++ b/tests/Unit/Auth/AuthTest.php @@ -4,15 +4,15 @@ use Quantum\Auth\Contracts\AuthenticatableInterface; use Quantum\Auth\Adapters\SessionAuthAdapter; -use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\Auth\Exceptions\AuthException; +use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\Jwt\JwtToken; use Quantum\Hasher\Hasher; use Quantum\Auth\Auth; class AuthTest extends AuthTestCase { - private $jwt; + private JwtToken $jwt; public function setUp(): void { @@ -30,7 +30,7 @@ public function setUp(): void ]); } - public function testAuthGetAdapter() + public function testAuthGetAdapter(): void { $auth = new Auth(new SessionAuthAdapter($this->authService, $this->mailer, new Hasher())); @@ -41,7 +41,7 @@ public function testAuthGetAdapter() $this->assertInstanceOf(AuthenticatableInterface::class, $auth->getAdapter()); } - public function testAuthCallingValidMethod() + public function testAuthCallingValidMethod(): void { $auth = new Auth(new JwtAuthAdapter($this->authService, $this->mailer, new Hasher(), $this->jwt)); @@ -56,7 +56,7 @@ public function testAuthCallingValidMethod() $this->assertArrayHasKey('refresh_token', $auth->signin('admin@qt.com', 'qwerty')); } - public function testAuthCallingInvalidMethod() + public function testAuthCallingInvalidMethod(): void { $auth = new Auth(new JwtAuthAdapter($this->authService, $this->mailer, new Hasher(), $this->jwt)); diff --git a/tests/Unit/Auth/AuthTestCase.php b/tests/Unit/Auth/AuthTestCase.php index 0a1422404..5706fdc4a 100644 --- a/tests/Unit/Auth/AuthTestCase.php +++ b/tests/Unit/Auth/AuthTestCase.php @@ -90,7 +90,7 @@ public function setUp(): void $this->authService->shouldReceive('userSchema')->andReturn($this->userSchema); - $this->authService->shouldReceive('get')->andReturnUsing(function ($field, $value) { + $this->authService->shouldReceive('get')->andReturnUsing(function ($field, $value): ?\Quantum\Auth\User { foreach (self::$users as $userData) { if (in_array($value, $userData)) { return (new User())->setData($userData); @@ -123,7 +123,7 @@ public function setUp(): void return $user; }); - $this->authService->shouldReceive('add')->andReturnUsing(function ($data) { + $this->authService->shouldReceive('add')->andReturnUsing(function ($data): \Quantum\Auth\User { $user = new User(); diff --git a/tests/Unit/Auth/Factories/AuthFactoryTest.php b/tests/Unit/Auth/Factories/AuthFactoryTest.php index f6d304021..120ba75dd 100644 --- a/tests/Unit/Auth/Factories/AuthFactoryTest.php +++ b/tests/Unit/Auth/Factories/AuthFactoryTest.php @@ -18,35 +18,35 @@ public function setUp(): void $this->setPrivateProperty(AuthFactory::class, 'instances', []); } - public function testAuthFactoryInstance() + public function testAuthFactoryInstance(): void { $auth = AuthFactory::get(); $this->assertInstanceOf(Auth::class, $auth); } - public function testAuthFactoryDefaultAuthAdapter() + public function testAuthFactoryDefaultAuthAdapter(): void { $auth = AuthFactory::get(); $this->assertInstanceOf(SessionAuthAdapter::class, $auth->getAdapter()); } - public function testAuthFactorySessionAuthAdapter() + public function testAuthFactorySessionAuthAdapter(): void { $auth = AuthFactory::get(Auth::SESSION); $this->assertInstanceOf(SessionAuthAdapter::class, $auth->getAdapter()); } - public function testAuthFactoryJwtAuthAdapter() + public function testAuthFactoryJwtAuthAdapter(): void { $auth = AuthFactory::get(Auth::JWT); $this->assertInstanceOf(JwtAuthAdapter::class, $auth->getAdapter()); } - public function testAuthFactoryInvalidTypeAdapter() + public function testAuthFactoryInvalidTypeAdapter(): void { config()->set('auth.default', 'invalid'); @@ -57,7 +57,7 @@ public function testAuthFactoryInvalidTypeAdapter() AuthFactory::get(); } - public function testAuthFactoryReturnsSameInstance() + public function testAuthFactoryReturnsSameInstance(): void { $auth1 = AuthFactory::get(Auth::SESSION); $auth2 = AuthFactory::get(Auth::SESSION); diff --git a/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php b/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php index fd752a71d..9eae1d7ce 100644 --- a/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php +++ b/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php @@ -9,21 +9,21 @@ class AuthHelperFunctionsTest extends AppTestCase { - public function testAuthHelperGetDefaultAuth() + public function testAuthHelperGetDefaultAuth(): void { $this->assertInstanceOf(Auth::class, auth()); $this->assertInstanceOf(SessionAuthAdapter::class, auth()->getAdapter()); } - public function testAuthHelperGetSessionAuth() + public function testAuthHelperGetSessionAuth(): void { $this->assertInstanceOf(Auth::class, auth(Auth::SESSION)); $this->assertInstanceOf(SessionAuthAdapter::class, auth(Auth::SESSION)->getAdapter()); } - public function testAuthHelperGetJwtAuth() + public function testAuthHelperGetJwtAuth(): void { $this->assertInstanceOf(Auth::class, auth(Auth::JWT)); diff --git a/tests/Unit/Auth/UserTest.php b/tests/Unit/Auth/UserTest.php index b1d18a133..df9312f49 100644 --- a/tests/Unit/Auth/UserTest.php +++ b/tests/Unit/Auth/UserTest.php @@ -7,9 +7,9 @@ class UserTest extends TestCase { - private $user; + private User $user; - private $fields = [ + private array $fields = [ 'id' => ['name' => 'id', 'visible' => false], 'firstname' => ['name' => 'firstname', 'visible' => true], 'lastname' => ['name' => 'lastname', 'visible' => true], @@ -28,7 +28,7 @@ public function tearDown(): void unset($this->user); } - public function testSetGetData() + public function testSetGetData(): void { $userData = ['username' => 'johny@mail.com', 'firstname' => 'Johnny', 'lastname' => 'B']; @@ -37,14 +37,14 @@ public function testSetGetData() $this->assertEquals($userData, $this->user->getData()); } - public function testSetGetFields() + public function testSetGetFields(): void { $this->user->setFields($this->fields); $this->assertEquals(array_keys($this->user->getData()), $this->user->getFields()); } - public function testGetFieldsFromSetData() + public function testGetFieldsFromSetData(): void { $userData = ['username' => 'johny@mail.com', 'firstname' => 'Johnny', 'lastname' => 'B']; @@ -53,7 +53,7 @@ public function testGetFieldsFromSetData() $this->assertEquals(array_keys($userData), $this->user->getFields()); } - public function testHasField() + public function testHasField(): void { $this->assertFalse($this->user->hasField('username')); @@ -74,7 +74,7 @@ public function testHasField() $this->assertTrue($this->user->hasField('role')); } - public function testSetGetFieldValue() + public function testSetGetFieldValue(): void { $this->assertNull($this->user->getFieldValue('email')); diff --git a/tests/Unit/Cache/Adapters/DatabaseAdapterTest.php b/tests/Unit/Cache/Adapters/DatabaseAdapterTest.php index b5b9f6678..473425a84 100644 --- a/tests/Unit/Cache/Adapters/DatabaseAdapterTest.php +++ b/tests/Unit/Cache/Adapters/DatabaseAdapterTest.php @@ -9,7 +9,7 @@ class DatabaseAdapterTest extends AppTestCase { - private $databaseCache; + private DatabaseAdapter $databaseCache; public function setUp(): void { @@ -39,7 +39,7 @@ public function tearDown(): void SleekDbal::disconnect(); } - public function testDatabaseAdapterSetGetDelete() + public function testDatabaseAdapterSetGetDelete(): void { $this->assertNull($this->databaseCache->get('test')); @@ -59,7 +59,7 @@ public function testDatabaseAdapterSetGetDelete() $this->assertNull($this->databaseCache->get('test')); } - public function testDatabaseAdapterHas() + public function testDatabaseAdapterHas(): void { $this->assertFalse($this->databaseCache->has('test')); @@ -68,7 +68,7 @@ public function testDatabaseAdapterHas() $this->assertTrue($this->databaseCache->has('test')); } - public function testDatabaseAdapterGetMultiple() + public function testDatabaseAdapterGetMultiple(): void { $cacheItems = $this->databaseCache->getMultiple(['test1', 'test2']); @@ -99,7 +99,7 @@ public function testDatabaseAdapterGetMultiple() $this->assertEquals('Test one', $cacheItems['test1']); } - public function testDatabaseAdapterSetMultiple() + public function testDatabaseAdapterSetMultiple(): void { $this->assertFalse($this->databaseCache->has('test1')); @@ -116,7 +116,7 @@ public function testDatabaseAdapterSetMultiple() $this->assertEquals('Test value two', $this->databaseCache->get('test2')); } - public function testDatabaseAdapterDeleteMultiple() + public function testDatabaseAdapterDeleteMultiple(): void { $this->databaseCache->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -131,7 +131,7 @@ public function testDatabaseAdapterDeleteMultiple() $this->assertFalse($this->databaseCache->has('test2')); } - public function testDatabaseAdapterClear() + public function testDatabaseAdapterClear(): void { $this->databaseCache->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -146,7 +146,7 @@ public function testDatabaseAdapterClear() $this->assertFalse($this->databaseCache->has('test2')); } - public function testDatabaseAdapterExpired() + public function testDatabaseAdapterExpired(): void { $params = [ 'prefix' => 'test', diff --git a/tests/Unit/Cache/Adapters/FileAdapterTest.php b/tests/Unit/Cache/Adapters/FileAdapterTest.php index 90753e326..04bb355d4 100644 --- a/tests/Unit/Cache/Adapters/FileAdapterTest.php +++ b/tests/Unit/Cache/Adapters/FileAdapterTest.php @@ -7,7 +7,7 @@ class FileAdapterTest extends AppTestCase { - private $fileCache; + private FileAdapter $fileCache; public function setUp(): void { @@ -27,7 +27,7 @@ public function tearDown(): void $this->fileCache->clear(); } - public function testFileAdapterSetGetDelete() + public function testFileAdapterSetGetDelete(): void { $this->assertNull($this->fileCache->get('test')); @@ -46,7 +46,7 @@ public function testFileAdapterSetGetDelete() $this->assertNull($this->fileCache->get('test')); } - public function testFileAdapterHas() + public function testFileAdapterHas(): void { $this->assertFalse($this->fileCache->has('test')); @@ -55,7 +55,7 @@ public function testFileAdapterHas() $this->assertTrue($this->fileCache->has('test')); } - public function testFileAdapterGetMultiple() + public function testFileAdapterGetMultiple(): void { $cacheItems = $this->fileCache->getMultiple(['test1', 'test2']); @@ -76,7 +76,7 @@ public function testFileAdapterGetMultiple() $this->assertEquals('Default value for all', $cacheItems['test1']); } - public function testFileAdapterSetMultiple() + public function testFileAdapterSetMultiple(): void { $this->assertFalse($this->fileCache->has('test1')); @@ -93,7 +93,7 @@ public function testFileAdapterSetMultiple() $this->assertEquals('Test value two', $this->fileCache->get('test2')); } - public function testFileAdapterDeleteMultiple() + public function testFileAdapterDeleteMultiple(): void { $this->fileCache->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -108,7 +108,7 @@ public function testFileAdapterDeleteMultiple() $this->assertFalse($this->fileCache->has('test2')); } - public function testFileAdapterClear() + public function testFileAdapterClear(): void { $this->fileCache->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -123,7 +123,7 @@ public function testFileAdapterClear() $this->assertFalse($this->fileCache->has('test2')); } - public function testFileAdapterExpired() + public function testFileAdapterExpired(): void { $params = [ 'prefix' => 'test', diff --git a/tests/Unit/Cache/Adapters/MemcachedAdapterTest.php b/tests/Unit/Cache/Adapters/MemcachedAdapterTest.php index 4dc06a3fc..5d17901df 100644 --- a/tests/Unit/Cache/Adapters/MemcachedAdapterTest.php +++ b/tests/Unit/Cache/Adapters/MemcachedAdapterTest.php @@ -7,7 +7,7 @@ class MemcachedAdapterTest extends AppTestCase { - private $memCached; + private MemcachedAdapter $memCached; public function setUp(): void { @@ -28,7 +28,7 @@ public function tearDown(): void $this->memCached->clear(); } - public function testMemcachedAdapterSetGetDelete() + public function testMemcachedAdapterSetGetDelete(): void { $this->assertNull($this->memCached->get('test')); @@ -48,7 +48,7 @@ public function testMemcachedAdapterSetGetDelete() $this->assertNull($this->memCached->get('test')); } - public function testMemcachedAdapterHas() + public function testMemcachedAdapterHas(): void { $this->assertFalse($this->memCached->has('test')); @@ -57,7 +57,7 @@ public function testMemcachedAdapterHas() $this->assertTrue($this->memCached->has('test')); } - public function testMemcachedAdapterGetMultiple() + public function testMemcachedAdapterGetMultiple(): void { $cacheItems = $this->memCached->getMultiple(['test1', 'test2']); @@ -88,7 +88,7 @@ public function testMemcachedAdapterGetMultiple() $this->assertEquals('Test one', $cacheItems['test1']); } - public function testMemcachedAdapterSetMultiple() + public function testMemcachedAdapterSetMultiple(): void { $this->assertFalse($this->memCached->has('test1')); @@ -105,7 +105,7 @@ public function testMemcachedAdapterSetMultiple() $this->assertEquals('Test value two', $this->memCached->get('test2')); } - public function testMemcachedAdapterDeleteMultiple() + public function testMemcachedAdapterDeleteMultiple(): void { $this->memCached->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -120,7 +120,7 @@ public function testMemcachedAdapterDeleteMultiple() $this->assertFalse($this->memCached->has('test2')); } - public function testMemcachedAdapterClear() + public function testMemcachedAdapterClear(): void { $this->memCached->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -135,7 +135,7 @@ public function testMemcachedAdapterClear() $this->assertFalse($this->memCached->has('test2')); } - public function testMemcachedAdapterExpired() + public function testMemcachedAdapterExpired(): void { $params = [ 'prefix' => 'test', diff --git a/tests/Unit/Cache/Adapters/RedisAdapterTest.php b/tests/Unit/Cache/Adapters/RedisAdapterTest.php index 2e80ffaa7..79c69977f 100644 --- a/tests/Unit/Cache/Adapters/RedisAdapterTest.php +++ b/tests/Unit/Cache/Adapters/RedisAdapterTest.php @@ -7,7 +7,7 @@ class RedisAdapterTest extends AppTestCase { - private $redis; + private RedisAdapter $redis; public function setUp(): void { @@ -28,7 +28,7 @@ public function tearDown(): void $this->redis->clear(); } - public function testRedisAdapterSetGetDelete() + public function testRedisAdapterSetGetDelete(): void { $this->assertNull($this->redis->get('test')); @@ -48,7 +48,7 @@ public function testRedisAdapterSetGetDelete() $this->assertNull($this->redis->get('test')); } - public function testRedisAdapterHas() + public function testRedisAdapterHas(): void { $this->assertFalse($this->redis->has('test')); @@ -57,7 +57,7 @@ public function testRedisAdapterHas() $this->assertTrue($this->redis->has('test')); } - public function testRedisAdapterGetMultiple() + public function testRedisAdapterGetMultiple(): void { $cacheItems = $this->redis->getMultiple(['test1', 'test2']); @@ -88,7 +88,7 @@ public function testRedisAdapterGetMultiple() $this->assertEquals('Test one', $cacheItems['test1']); } - public function testRedisAdapterSetMultiple() + public function testRedisAdapterSetMultiple(): void { $this->assertFalse($this->redis->has('test1')); @@ -105,7 +105,7 @@ public function testRedisAdapterSetMultiple() $this->assertEquals('Test value two', $this->redis->get('test2')); } - public function testRedisAdapterDeleteMultiple() + public function testRedisAdapterDeleteMultiple(): void { $this->redis->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -120,7 +120,7 @@ public function testRedisAdapterDeleteMultiple() $this->assertFalse($this->redis->has('test2')); } - public function testRedisAdapterClear() + public function testRedisAdapterClear(): void { $this->redis->setMultiple(['test1' => 'Test value one', 'test2' => 'Test value two']); @@ -135,7 +135,7 @@ public function testRedisAdapterClear() $this->assertFalse($this->redis->has('test2')); } - public function testRedisAdapterExpired() + public function testRedisAdapterExpired(): void { $params = [ 'prefix' => 'test', diff --git a/tests/Unit/Cache/CacheTest.php b/tests/Unit/Cache/CacheTest.php index 5372f582c..77f6c91a4 100644 --- a/tests/Unit/Cache/CacheTest.php +++ b/tests/Unit/Cache/CacheTest.php @@ -15,7 +15,7 @@ public function setUp(): void parent::setUp(); } - public function testCacheGetAdapter() + public function testCacheGetAdapter(): void { $params = [ 'prefix' => 'test', @@ -30,7 +30,7 @@ public function testCacheGetAdapter() $this->assertInstanceOf(CacheInterface::class, $cache->getAdapter()); } - public function testCacheCallingValidMethod() + public function testCacheCallingValidMethod(): void { $params = [ 'prefix' => 'test', @@ -45,7 +45,7 @@ public function testCacheCallingValidMethod() $this->assertNull($cache->get('test')); } - public function testCacheCallingInvalidMethod() + public function testCacheCallingInvalidMethod(): void { $params = [ 'prefix' => 'test', diff --git a/tests/Unit/Cache/Factories/CacheFactoryTest.php b/tests/Unit/Cache/Factories/CacheFactoryTest.php index 99fe2a6ae..053884752 100644 --- a/tests/Unit/Cache/Factories/CacheFactoryTest.php +++ b/tests/Unit/Cache/Factories/CacheFactoryTest.php @@ -20,49 +20,49 @@ public function setUp(): void $this->setPrivateProperty(CacheFactory::class, 'instances', []); } - public function testCacheFactoryInstance() + public function testCacheFactoryInstance(): void { $cache = CacheFactory::get(); $this->assertInstanceOf(Cache::class, $cache); } - public function testCacheFactoryDefaultAdapter() + public function testCacheFactoryDefaultAdapter(): void { $cache = CacheFactory::get(); $this->assertInstanceOf(FileAdapter::class, $cache->getAdapter()); } - public function testCacheFactoryFileAdapter() + public function testCacheFactoryFileAdapter(): void { $cache = CacheFactory::get(Cache::FILE); $this->assertInstanceOf(FileAdapter::class, $cache->getAdapter()); } - public function testCacheFactoryDatabaseAdapter() + public function testCacheFactoryDatabaseAdapter(): void { $cache = CacheFactory::get(Cache::DATABASE); $this->assertInstanceOf(DatabaseAdapter::class, $cache->getAdapter()); } - public function testCacheFactoryMemcachedAdapter() + public function testCacheFactoryMemcachedAdapter(): void { $cache = CacheFactory::get(Cache::MEMCACHED); $this->assertInstanceOf(MemcachedAdapter::class, $cache->getAdapter()); } - public function testCacheFactoryRedisAdapter() + public function testCacheFactoryRedisAdapter(): void { $cache = CacheFactory::get(Cache::REDIS); $this->assertInstanceOf(RedisAdapter::class, $cache->getAdapter()); } - public function testCacheFactoryInvalidTypeAdapter() + public function testCacheFactoryInvalidTypeAdapter(): void { $this->expectException(CacheException::class); @@ -71,7 +71,7 @@ public function testCacheFactoryInvalidTypeAdapter() CacheFactory::get('invalid_type'); } - public function testCacheFactoryReturnsSameInstance() + public function testCacheFactoryReturnsSameInstance(): void { $cache1 = CacheFactory::get(Cache::FILE); $cache2 = CacheFactory::get(Cache::FILE); diff --git a/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php b/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php index 65dd188cf..9016d5764 100644 --- a/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php +++ b/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php @@ -11,35 +11,35 @@ class CacheHelperFunctionsTest extends AppTestCase { - public function testCacheHelperGetDefaultCache() + public function testCacheHelperGetDefaultCache(): void { $this->assertInstanceOf(Cache::class, cache()); $this->assertInstanceOf(FileAdapter::class, cache()->getAdapter()); } - public function testCacheHelperGetFileCache() + public function testCacheHelperGetFileCache(): void { $this->assertInstanceOf(Cache::class, cache(Cache::FILE)); $this->assertInstanceOf(FileAdapter::class, cache(Cache::FILE)->getAdapter()); } - public function testCacheHelperGetDatabaseCache() + public function testCacheHelperGetDatabaseCache(): void { $this->assertInstanceOf(Cache::class, cache(Cache::DATABASE)); $this->assertInstanceOf(DatabaseAdapter::class, cache(Cache::DATABASE)->getAdapter()); } - public function testCacheHelperGetMemcachedCache() + public function testCacheHelperGetMemcachedCache(): void { $this->assertInstanceOf(Cache::class, cache(Cache::MEMCACHED)); $this->assertInstanceOf(MemcachedAdapter::class, cache(Cache::MEMCACHED)->getAdapter()); } - public function testCacheHelperGetRedisCache() + public function testCacheHelperGetRedisCache(): void { $this->assertInstanceOf(Cache::class, cache(Cache::REDIS)); diff --git a/tests/Unit/Captcha/Adapters/HcaptchaAdapterTest.php b/tests/Unit/Captcha/Adapters/HcaptchaAdapterTest.php index 6f6fc06b5..6d0b80bba 100644 --- a/tests/Unit/Captcha/Adapters/HcaptchaAdapterTest.php +++ b/tests/Unit/Captcha/Adapters/HcaptchaAdapterTest.php @@ -12,10 +12,10 @@ class HcaptchaAdapterTest extends AppTestCase { public $httpClientMock; - private $secretKey = '10000000-ffff-ffff-ffff-000000000001'; - private $siteKey = '0x0000000000000000000000000000000000000000'; + private string $secretKey = '10000000-ffff-ffff-ffff-000000000001'; + private string $siteKey = '0x0000000000000000000000000000000000000000'; - private $adapter; + private HcaptchaAdapter $adapter; public function setUp(): void { @@ -35,14 +35,14 @@ public function tearDown(): void Mockery::close(); } - public function testHcaptchaAdapterInstance() + public function testHcaptchaAdapterInstance(): void { $this->assertInstanceOf(CaptchaInterface::class, $this->adapter); $this->assertInstanceOf(HcaptchaAdapter::class, $this->adapter); } - public function testHcaptchaSetGetType() + public function testHcaptchaSetGetType(): void { $this->assertNull($this->adapter->getType()); @@ -61,7 +61,7 @@ public function testHcaptchaSetGetType() $this->adapter->setType('test'); } - public function testHcaptchaVisibleAddToForm() + public function testHcaptchaVisibleAddToForm(): void { $this->adapter->setType(CaptchaInterface::CAPTCHA_VISIBLE); @@ -71,7 +71,7 @@ public function testHcaptchaVisibleAddToForm() ); } - public function testHcaptchaInvisibleAddToForm() + public function testHcaptchaInvisibleAddToForm(): void { $this->adapter->setType(CaptchaInterface::CAPTCHA_INVISIBLE); @@ -98,7 +98,7 @@ function onSubmit (){ $this->assertSame($expected, $actual); } - public function testHcaptchaVerifySuccess() + public function testHcaptchaVerifySuccess(): void { $this->httpClientMock @@ -126,7 +126,7 @@ public function testHcaptchaVerifySuccess() $this->assertTrue($result); } - public function testHcaptchaVerifyFailure() + public function testHcaptchaVerifyFailure(): void { $this->httpClientMock ->shouldReceive('createRequest') diff --git a/tests/Unit/Captcha/Adapters/RecaptchaAdapterTest.php b/tests/Unit/Captcha/Adapters/RecaptchaAdapterTest.php index 7d1708d76..934a3d70c 100644 --- a/tests/Unit/Captcha/Adapters/RecaptchaAdapterTest.php +++ b/tests/Unit/Captcha/Adapters/RecaptchaAdapterTest.php @@ -13,10 +13,10 @@ class RecaptchaAdapterTest extends AppTestCase { public $httpClientMock; - private $secretKey = '10000000-ffff-ffff-ffff-000000000001'; - private $siteKey = '0x0000000000000000000000000000000000000000'; + private string $secretKey = '10000000-ffff-ffff-ffff-000000000001'; + private string $siteKey = '0x0000000000000000000000000000000000000000'; - private $adapter; + private RecaptchaAdapter $adapter; public function setUp(): void { @@ -36,14 +36,14 @@ public function tearDown(): void Mockery::close(); } - public function testRecaptchaAdapterInstance() + public function testRecaptchaAdapterInstance(): void { $this->assertInstanceOf(CaptchaInterface::class, $this->adapter); $this->assertInstanceOf(RecaptchaAdapter::class, $this->adapter); } - public function testRecaptchaSetGetType() + public function testRecaptchaSetGetType(): void { $this->assertNull($this->adapter->getType()); @@ -62,7 +62,7 @@ public function testRecaptchaSetGetType() $this->adapter->setType('test'); } - public function testRecaptchaVisibleAddToForm() + public function testRecaptchaVisibleAddToForm(): void { $this->adapter->setType(CaptchaInterface::CAPTCHA_VISIBLE); @@ -72,7 +72,7 @@ public function testRecaptchaVisibleAddToForm() ); } - public function testRecaptchaInvisibleAddToForm() + public function testRecaptchaInvisibleAddToForm(): void { $this->adapter->setType(CaptchaInterface::CAPTCHA_INVISIBLE); @@ -99,7 +99,7 @@ function onSubmit (){ $this->assertSame($expected, $actual); } - public function testRecaptchaVerifySuccess() + public function testRecaptchaVerifySuccess(): void { $this->httpClientMock @@ -127,7 +127,7 @@ public function testRecaptchaVerifySuccess() $this->assertTrue($result); } - public function testRecaptchaVerifyFailure() + public function testRecaptchaVerifyFailure(): void { $this->httpClientMock ->shouldReceive('createRequest') diff --git a/tests/Unit/Captcha/CaptchaTest.php b/tests/Unit/Captcha/CaptchaTest.php index 7dded928a..4edf5f2dd 100644 --- a/tests/Unit/Captcha/CaptchaTest.php +++ b/tests/Unit/Captcha/CaptchaTest.php @@ -16,7 +16,7 @@ public function setUp(): void parent::setUp(); } - public function testCaptchaGetAdapter() + public function testCaptchaGetAdapter(): void { $params = [ 'type' => 'visible', @@ -31,7 +31,7 @@ public function testCaptchaGetAdapter() $this->assertInstanceOf(CaptchaInterface::class, $captcha->getAdapter()); } - public function testCaptchaCallingValidMethod() + public function testCaptchaCallingValidMethod(): void { $params = [ 'type' => 'visible', @@ -44,7 +44,7 @@ public function testCaptchaCallingValidMethod() $this->assertEquals('visible', $captcha->getType()); } - public function testCacheCallingInvalidMethod() + public function testCacheCallingInvalidMethod(): void { $params = [ 'type' => 'visible', diff --git a/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php b/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php index 181055303..78fd1c74e 100644 --- a/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php +++ b/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php @@ -18,35 +18,35 @@ public function setUp(): void $this->setPrivateProperty(CaptchaFactory::class, 'instances', []); } - public function testCaptchaFactoryInstance() + public function testCaptchaFactoryInstance(): void { $captcha = CaptchaFactory::get(); $this->assertInstanceOf(Captcha::class, $captcha); } - public function testCacheFactoryDefaultAdapter() + public function testCacheFactoryDefaultAdapter(): void { $captcha = CaptchaFactory::get(); $this->assertInstanceOf(RecaptchaAdapter::class, $captcha->getAdapter()); } - public function testCacheFactoryRecaptchaAdapter() + public function testCacheFactoryRecaptchaAdapter(): void { $captcha = CaptchaFactory::get(Captcha::RECAPTCHA); $this->assertInstanceOf(RecaptchaAdapter::class, $captcha->getAdapter()); } - public function testCacheFactoryHcaptchaAdapter() + public function testCacheFactoryHcaptchaAdapter(): void { $captcha = CaptchaFactory::get(Captcha::HCAPTCHA); $this->assertInstanceOf(HcaptchaAdapter::class, $captcha->getAdapter()); } - public function testCacheFactoryInvalidTypeAdapter() + public function testCacheFactoryInvalidTypeAdapter(): void { $this->expectException(CaptchaException::class); @@ -55,7 +55,7 @@ public function testCacheFactoryInvalidTypeAdapter() CaptchaFactory::get('invalid_type'); } - public function testAuthFactoryReturnsSameInstance() + public function testAuthFactoryReturnsSameInstance(): void { $captcha1 = CaptchaFactory::get(Captcha::RECAPTCHA); $captcha2 = CaptchaFactory::get(Captcha::RECAPTCHA); diff --git a/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php b/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php index 3948233b9..5ab5929f1 100644 --- a/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php +++ b/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php @@ -9,21 +9,21 @@ class CaptchaHelperFunctionsTest extends AppTestCase { - public function testCaptchaHelperGetDefaultCaptchaAdapter() + public function testCaptchaHelperGetDefaultCaptchaAdapter(): void { $this->assertInstanceOf(Captcha::class, captcha()); $this->assertInstanceOf(RecaptchaAdapter::class, captcha()->getAdapter()); } - public function testCaptchaHelperGetRecaptchaAdapter() + public function testCaptchaHelperGetRecaptchaAdapter(): void { $this->assertInstanceOf(Captcha::class, captcha(Captcha::RECAPTCHA)); $this->assertInstanceOf(RecaptchaAdapter::class, captcha(Captcha::RECAPTCHA)->getAdapter()); } - public function testCaptchaHelperGetHcaptchaAdapter() + public function testCaptchaHelperGetHcaptchaAdapter(): void { $this->assertInstanceOf(Captcha::class, captcha(Captcha::HCAPTCHA)); diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php index 911aa284d..68315e2f4 100644 --- a/tests/Unit/Config/ConfigTest.php +++ b/tests/Unit/Config/ConfigTest.php @@ -18,7 +18,7 @@ public function setUp(): void config()->flush(); } - public function testConfigLoad() + public function testConfigLoad(): void { $config = Config::getInstance(); @@ -31,7 +31,7 @@ public function testConfigLoad() $this->assertInstanceOf(Data::class, $config->all()); } - public function testConfigImport() + public function testConfigImport(): void { $config = Config::getInstance(); @@ -46,7 +46,7 @@ public function testConfigImport() $this->assertEquals('sqlite', $config->get('database.default')); } - public function testImportingNonExistingConfigFile() + public function testImportingNonExistingConfigFile(): void { $this->expectException(LoaderException::class); @@ -55,7 +55,7 @@ public function testImportingNonExistingConfigFile() Config::getInstance()->import(new Setup('config', 'somefile')); } - public function testCollisionAtImporting() + public function testCollisionAtImporting(): void { $config = Config::getInstance(); @@ -68,7 +68,7 @@ public function testCollisionAtImporting() $config->import(new Setup('config', 'app')); } - public function testConfigHas() + public function testConfigHas(): void { $config = Config::getInstance(); @@ -81,7 +81,7 @@ public function testConfigHas() $this->assertFalse($config->has('app.none')); } - public function testConfigGet() + public function testConfigGet(): void { $config = Config::getInstance(); @@ -94,7 +94,7 @@ public function testConfigGet() $this->assertNull($config->get('not-exists')); } - public function testConfigSet() + public function testConfigSet(): void { $config = Config::getInstance(); @@ -113,7 +113,7 @@ public function testConfigSet() $this->assertEquals('Nested Value', $config->get('other.nested')); } - public function testConfigDelete() + public function testConfigDelete(): void { $config = Config::getInstance(); @@ -128,7 +128,7 @@ public function testConfigDelete() $this->assertNull($config->get('app.test')); } - public function testConfigFlush() + public function testConfigFlush(): void { $config = Config::getInstance(); diff --git a/tests/Unit/Config/Helpers/ConfigHelperFunctionsTest.php b/tests/Unit/Config/Helpers/ConfigHelperFunctionsTest.php index 149c17392..e9f38957d 100644 --- a/tests/Unit/Config/Helpers/ConfigHelperFunctionsTest.php +++ b/tests/Unit/Config/Helpers/ConfigHelperFunctionsTest.php @@ -7,12 +7,12 @@ class ConfigHelperFunctionsTest extends AppTestCase { - public function testConfigHelper() + public function testConfigHelper(): void { $this->assertInstanceOf(Config::class, config()); } - public function testConfigHelperFunctions() + public function testConfigHelperFunctions(): void { $this->assertFalse(config()->has('not-exists')); diff --git a/tests/Unit/Console/CommandDiscoveryTest.php b/tests/Unit/Console/CommandDiscoveryTest.php index 194e4db6d..45283dc64 100644 --- a/tests/Unit/Console/CommandDiscoveryTest.php +++ b/tests/Unit/Console/CommandDiscoveryTest.php @@ -8,7 +8,7 @@ class CommandDiscoveryTest extends AppTestCase { - public function testDiscoverCoreCommands() + public function testDiscoverCoreCommands(): void { $commandsDirectory = base_dir() . DIRECTORY_SEPARATOR . 'shared' diff --git a/tests/Unit/Console/Commands/CronRunCommandTest.php b/tests/Unit/Console/Commands/CronRunCommandTest.php index 721cffffb..97c957274 100644 --- a/tests/Unit/Console/Commands/CronRunCommandTest.php +++ b/tests/Unit/Console/Commands/CronRunCommandTest.php @@ -13,8 +13,8 @@ */ class CronRunCommandTest extends AppTestCase { - private $cronDirectory; - private $lockDirectory; + private string $cronDirectory; + private string $lockDirectory; public function setUp(): void { @@ -51,12 +51,12 @@ public function tearDown(): void $this->cleanupDirectory($this->lockDirectory); } - public function testCommandExecutesSuccessfully() + public function testCommandExecutesSuccessfully(): void { $this->createTaskFile('test-task.php', [ 'name' => 'test-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -71,7 +71,7 @@ public function testCommandExecutesSuccessfully() $this->assertStringContainsString('Execution Summary', $output); } - public function testCommandWithNoTasks() + public function testCommandWithNoTasks(): void { $emptyDir = $this->cronDirectory . '-empty'; $this->cleanupDirectory($emptyDir); @@ -87,12 +87,12 @@ public function testCommandWithNoTasks() $this->assertStringContainsString('No tasks found', $output); } - public function testCommandWithSpecificTask() + public function testCommandWithSpecificTask(): void { $this->createTaskFile('specific-task.php', [ 'name' => 'specific-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -109,12 +109,12 @@ public function testCommandWithSpecificTask() $this->assertStringContainsString('Running task: specific-task', $output); } - public function testCommandWithForceOption() + public function testCommandWithForceOption(): void { $this->createTaskFile('force-task.php', [ 'name' => 'force-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -129,7 +129,7 @@ public function testCommandWithForceOption() $this->assertEquals(0, $tester->getStatusCode()); } - public function testCommandWithNonExistentTask() + public function testCommandWithNonExistentTask(): void { $command = new CronRunCommand(); $tester = new CommandTester($command); @@ -144,19 +144,19 @@ public function testCommandWithNonExistentTask() $this->assertStringContainsString('not found', $output); } - public function testCommandDisplaysStatistics() + public function testCommandDisplaysStatistics(): void { $this->createTaskFile('task1.php', [ 'name' => 'task-1', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); $this->createTaskFile('task2.php', [ 'name' => 'task-2', 'expression' => '0 0 1 1 *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -172,7 +172,7 @@ public function testCommandDisplaysStatistics() $this->assertStringContainsString('Skipped:', $output); } - public function testCommandHandlesTaskFailure() + public function testCommandHandlesTaskFailure(): void { $this->createTaskFile('failing-task.php', [ 'name' => 'failing-task', @@ -190,12 +190,12 @@ public function testCommandHandlesTaskFailure() $this->assertStringContainsString('Failed: 1', $output); } - public function testCommandShortOptions() + public function testCommandShortOptions(): void { $this->createTaskFile('short-option-task.php', [ 'name' => 'short-option-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -212,12 +212,12 @@ public function testCommandShortOptions() $this->assertStringContainsString('short-option-task', $output); } - public function testCommandUsesConfiguredPath() + public function testCommandUsesConfiguredPath(): void { $this->createTaskFile('config-task.php', [ 'name' => 'config-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -237,12 +237,12 @@ public function testCommandUsesConfiguredPath() $this->assertStringContainsString('Execution Summary', $output); } - public function testCommandReportsLockedTasks() + public function testCommandReportsLockedTasks(): void { $this->createTaskFile('locked-task.php', [ 'name' => 'locked-task', 'expression' => '* * * * *', - 'callback' => function () { + 'callback' => function (): void { }, ]); @@ -260,7 +260,7 @@ public function testCommandReportsLockedTasks() $lock->release(); } - public function testCommandHandlesUnexpectedError() + public function testCommandHandlesUnexpectedError(): void { $invalidTask = $this->cronDirectory . DS . 'invalid-task.php'; file_put_contents($invalidTask, "tester = new CommandTester($this->command); } - public function testQtCommandMetadataIsConfigured() + public function testQtCommandMetadataIsConfigured(): void { $this->assertSame('test:dummy', $this->command->getName()); @@ -35,7 +35,7 @@ public function testQtCommandMetadataIsConfigured() $this->assertSame('Used only for core command discovery tests', $this->command->getHelp()); } - public function testQtCommandArgumentsAndOptionsAreRegistered() + public function testQtCommandArgumentsAndOptionsAreRegistered(): void { $definition = $this->command->getDefinition(); @@ -44,7 +44,7 @@ public function testQtCommandArgumentsAndOptionsAreRegistered() $this->assertTrue($definition->hasOption('force')); } - public function testGetArgumentAndOption() + public function testGetArgumentAndOption(): void { $this->tester->execute([ 'uuid' => '12345', diff --git a/tests/Unit/Cookie/CookieTest.php b/tests/Unit/Cookie/CookieTest.php index 51643fff9..192e02908 100644 --- a/tests/Unit/Cookie/CookieTest.php +++ b/tests/Unit/Cookie/CookieTest.php @@ -7,9 +7,9 @@ class CookieTest extends AppTestCase { - private $cookie; + private Cookie $cookie; - private $storage = []; + private array $storage = []; public function setUp(): void { @@ -23,12 +23,12 @@ public function tearDown(): void $this->cookie->flush(); } - public function testCookieConstructor() + public function testCookieConstructor(): void { $this->assertInstanceOf(Cookie::class, $this->cookie); } - public function testCookieAll() + public function testCookieAll(): void { $this->assertEmpty($this->cookie->all()); @@ -43,7 +43,7 @@ public function testCookieAll() $this->assertArrayHasKey('test', $this->cookie->all()); } - public function testCookieGetSetHasDelete() + public function testCookieGetSetHasDelete(): void { $this->assertNull($this->cookie->get('auth')); @@ -62,7 +62,7 @@ public function testCookieGetSetHasDelete() $this->assertNull($this->cookie->get('auth')); } - public function testCookieFlush() + public function testCookieFlush(): void { $this->cookie->set('test', 'Test data'); diff --git a/tests/Unit/Cookie/Helpers/CookieHelperFunctionsTest.php b/tests/Unit/Cookie/Helpers/CookieHelperFunctionsTest.php index 6423e6d8e..b40d3e17c 100644 --- a/tests/Unit/Cookie/Helpers/CookieHelperFunctionsTest.php +++ b/tests/Unit/Cookie/Helpers/CookieHelperFunctionsTest.php @@ -7,12 +7,12 @@ class CookieHelperFunctionsTest extends AppTestCase { - public function testCookieHelper() + public function testCookieHelper(): void { $this->assertInstanceOf(Cookie::class, cookie()); } - public function testCookieMethodsViaHelper() + public function testCookieMethodsViaHelper(): void { $this->assertFalse(cookie()->has('test')); diff --git a/tests/Unit/Cron/CronExceptionTest.php b/tests/Unit/Cron/CronExceptionTest.php index ab70024c5..693acbd6a 100644 --- a/tests/Unit/Cron/CronExceptionTest.php +++ b/tests/Unit/Cron/CronExceptionTest.php @@ -7,43 +7,43 @@ class CronExceptionTest extends TestCase { - public function testTaskNotFound() + public function testTaskNotFound(): void { $exception = CronException::taskNotFound('my-task'); $this->assertEquals('Cron task "my-task" not found', $exception->getMessage()); } - public function testInvalidExpression() + public function testInvalidExpression(): void { $exception = CronException::invalidExpression('invalid-expr'); $this->assertEquals('Invalid cron expression: invalid-expr', $exception->getMessage()); } - public function testLockAcquireFailed() + public function testLockAcquireFailed(): void { $exception = CronException::lockAcquireFailed('my-task'); $this->assertEquals('Failed to acquire lock for task "my-task"', $exception->getMessage()); } - public function testTaskExecutionFailed() + public function testTaskExecutionFailed(): void { $exception = CronException::taskExecutionFailed('my-task', 'Connection timeout'); $this->assertEquals('Task "my-task" execution failed: Connection timeout', $exception->getMessage()); } - public function testInvalidTaskFile() + public function testInvalidTaskFile(): void { $exception = CronException::invalidTaskFile('invalid-file.php'); $this->assertEquals('Invalid task file "invalid-file.php": must return array or CronTask instance', $exception->getMessage()); } - public function testCronDirectoryNotFound() + public function testCronDirectoryNotFound(): void { $exception = CronException::cronDirectoryNotFound('/path/to/cron'); $this->assertEquals('Cron directory not found: /path/to/cron', $exception->getMessage()); } - public function testLockDirectoryNotWritable() + public function testLockDirectoryNotWritable(): void { $exception = CronException::lockDirectoryNotWritable('/path/to/lock'); $this->assertEquals('Lock directory is not writable: /path/to/lock', $exception->getMessage()); diff --git a/tests/Unit/Cron/CronHelperTest.php b/tests/Unit/Cron/CronHelperTest.php index 357410169..cfac605df 100644 --- a/tests/Unit/Cron/CronHelperTest.php +++ b/tests/Unit/Cron/CronHelperTest.php @@ -21,27 +21,27 @@ public function setUp(): void } } - public function testCronConfig() + public function testCronConfig(): void { $this->assertEquals('/default/path', cron_config('path')); $this->assertEquals('default-val', cron_config('non-existent', 'default-val')); } - public function testCronManagerHelper() + public function testCronManagerHelper(): void { $manager = cron_manager('/custom/path'); $this->assertInstanceOf(CronManager::class, $manager); } - public function testCronTaskHelper() + public function testCronTaskHelper(): void { - $task = cron_task('my-task', '* * * * *', function () { + $task = cron_task('my-task', '* * * * *', function (): void { }); $this->assertInstanceOf(CronTask::class, $task); $this->assertEquals('my-task', $task->getName()); } - public function testScheduleHelper() + public function testScheduleHelper(): void { $schedule = schedule('my-task'); $this->assertInstanceOf(Schedule::class, $schedule); diff --git a/tests/Unit/Cron/CronLockTest.php b/tests/Unit/Cron/CronLockTest.php index fa4a8aea7..3d8a56d08 100644 --- a/tests/Unit/Cron/CronLockTest.php +++ b/tests/Unit/Cron/CronLockTest.php @@ -12,7 +12,7 @@ */ class CronLockTest extends AppTestCase { - private $lockDirectory; + private string $lockDirectory; public function setUp(): void { @@ -35,7 +35,7 @@ public function tearDown(): void $this->cleanupDirectory($this->lockDirectory); } - public function testConstructorCreatesLockDirectory() + public function testConstructorCreatesLockDirectory(): void { $lock = new CronLock('test-task', $this->lockDirectory); @@ -43,7 +43,7 @@ public function testConstructorCreatesLockDirectory() $lock->release(); } - public function testAcquireLock() + public function testAcquireLock(): void { $lock = new CronLock('test-task', $this->lockDirectory); @@ -51,7 +51,7 @@ public function testAcquireLock() $lock->release(); } - public function testCannotAcquireLockedTask() + public function testCannotAcquireLockedTask(): void { $lock1 = new CronLock('test-task', $this->lockDirectory); $lock1->acquire(); @@ -63,7 +63,7 @@ public function testCannotAcquireLockedTask() $lock1->release(); } - public function testReleaseLock() + public function testReleaseLock(): void { $lock = new CronLock('test-task', $this->lockDirectory); $lock->acquire(); @@ -72,7 +72,7 @@ public function testReleaseLock() $this->assertFalse($lock->isLocked()); } - public function testReleaseWithoutAcquireDoesNotDeleteForeignLock() + public function testReleaseWithoutAcquireDoesNotDeleteForeignLock(): void { $lockPath = $this->lockDirectory . DS . 'foreign-task.lock'; mkdir($this->lockDirectory, 0777, true); @@ -85,7 +85,7 @@ public function testReleaseWithoutAcquireDoesNotDeleteForeignLock() @unlink($lockPath); } - public function testIsLocked() + public function testIsLocked(): void { $lock1 = new CronLock('test-task', $this->lockDirectory); @@ -101,7 +101,7 @@ public function testIsLocked() $this->assertFalse($lock2->isLocked()); } - public function testMultipleTasksCanHaveSeparateLocks() + public function testMultipleTasksCanHaveSeparateLocks(): void { $lock1 = new CronLock('task-1', $this->lockDirectory); $lock2 = new CronLock('task-2', $this->lockDirectory); @@ -113,7 +113,7 @@ public function testMultipleTasksCanHaveSeparateLocks() $lock2->release(); } - public function testRefreshUpdatesTimestamp() + public function testRefreshUpdatesTimestamp(): void { $lock = new CronLock('refresh-task', $this->lockDirectory); $lock->acquire(); @@ -130,7 +130,7 @@ public function testRefreshUpdatesTimestamp() $lock->release(); } - public function testTaskNameIsSanitized() + public function testTaskNameIsSanitized(): void { $lock = new CronLock('../bad name', $this->lockDirectory); $this->assertTrue($lock->acquire()); @@ -142,7 +142,7 @@ public function testTaskNameIsSanitized() @unlink($expectedPath); } - public function testStaleLocksAreCleanedUp() + public function testStaleLocksAreCleanedUp(): void { $lockPath = $this->lockDirectory . DS . 'stale-task.lock'; $this->cleanupDirectory($this->lockDirectory); @@ -154,7 +154,7 @@ public function testStaleLocksAreCleanedUp() $this->assertFalse(file_exists($lockPath)); } - public function testCleanupSkipsActiveLocks() + public function testCleanupSkipsActiveLocks(): void { $lockPath = $this->lockDirectory . DS . 'active.lock'; $this->cleanupDirectory($this->lockDirectory); @@ -177,7 +177,7 @@ public function testCleanupSkipsActiveLocks() $this->assertFileDoesNotExist($lockPath); } - public function testConfigurableLockDirectoryIsUsed() + public function testConfigurableLockDirectoryIsUsed(): void { $customDirectory = base_dir() . DS . 'runtime' . DS . 'cron-custom-locks'; $this->cleanupDirectory($customDirectory); @@ -197,7 +197,7 @@ public function testConfigurableLockDirectoryIsUsed() $this->cleanupDirectory($customDirectory); } - public function testCronLockRefresh() + public function testCronLockRefresh(): void { $lock = new CronLock('refresh-task', $this->lockDirectory); $this->assertFalse($lock->refresh()); // Not owned yet @@ -207,7 +207,7 @@ public function testCronLockRefresh() $lock->release(); } - public function testCronLockSanitization() + public function testCronLockSanitization(): void { $lock = new CronLock(' Space Task / \\ ', $this->lockDirectory); $this->assertStringContainsString('Space_Task', $this->getPrivateProperty($lock, 'lockFile')); @@ -216,7 +216,7 @@ public function testCronLockSanitization() $this->assertStringContainsString('default.lock', $this->getPrivateProperty($lock2, 'lockFile')); } - public function testCronLockDirectoryRecursion() + public function testCronLockDirectoryRecursion(): void { $nestedDir = $this->lockDirectory . DS . 'a' . DS . 'b' . DS . 'c'; $lock = new CronLock('nested-task', $nestedDir); @@ -226,7 +226,7 @@ public function testCronLockDirectoryRecursion() $lock->release(); } - public function testCronLockEmptyDirectoryThrowsException() + public function testCronLockEmptyDirectoryThrowsException(): void { $this->expectException(CronException::class); new CronLock('task', ''); diff --git a/tests/Unit/Cron/CronManagerTest.php b/tests/Unit/Cron/CronManagerTest.php index 0835d0d92..5e5ff186d 100644 --- a/tests/Unit/Cron/CronManagerTest.php +++ b/tests/Unit/Cron/CronManagerTest.php @@ -12,8 +12,8 @@ */ class CronManagerTest extends AppTestCase { - private $cronDirectory; - private static $executedTasks = []; + private string $cronDirectory; + private static array $executedTasks = []; public function setUp(): void { @@ -43,7 +43,7 @@ public function setUp(): void ]); } - public function testLoadTasksFromDirectory() + public function testLoadTasksFromDirectory(): void { $this->createTaskFile('task1.php', [ 'name' => 'task-1', @@ -65,7 +65,7 @@ public function testLoadTasksFromDirectory() $this->assertArrayHasKey('task-2', $tasks); } - public function testLoadTasksWithObjectFormat() + public function testLoadTasksWithObjectFormat(): void { $taskContent = 'assertArrayHasKey('object-task', $tasks); } - public function testLoadTasksWithEmptyDirectory() + public function testLoadTasksWithEmptyDirectory(): void { $manager = new CronManager($this->cronDirectory); $manager->loadTasks(); @@ -91,7 +91,7 @@ public function testLoadTasksWithEmptyDirectory() $this->assertCount(0, $manager->getTasks()); } - public function testRunDueTasksExecutesOnlyDueTasks() + public function testRunDueTasksExecutesOnlyDueTasks(): void { $this->createTaskFile('due-task.php', [ 'name' => 'due-task', @@ -114,7 +114,7 @@ public function testRunDueTasksExecutesOnlyDueTasks() $this->assertEquals(1, $stats['skipped']); } - public function testRunTaskByName() + public function testRunTaskByName(): void { $this->createTaskFile('specific-task.php', [ 'name' => 'specific-task', @@ -128,7 +128,7 @@ public function testRunTaskByName() $this->assertContains('specific-task', self::$executedTasks); } - public function testRunTaskByNameThrowsExceptionForNonExistentTask() + public function testRunTaskByNameThrowsExceptionForNonExistentTask(): void { $this->expectException(CronException::class); $this->expectExceptionMessage('not found'); @@ -137,7 +137,7 @@ public function testRunTaskByNameThrowsExceptionForNonExistentTask() $manager->runTaskByName('non-existent-task'); } - public function testRunDueTasksWithForceIgnoresLocks() + public function testRunDueTasksWithForceIgnoresLocks(): void { $this->createTaskFile('locked-task.php', [ 'name' => 'locked-task', @@ -151,13 +151,11 @@ public function testRunDueTasksWithForceIgnoresLocks() $manager->runDueTasks(true); $manager->runDueTasks(true); - $occurrences = array_filter(self::$executedTasks, function ($task) { - return $task === 'locked-task'; - }); + $occurrences = array_filter(self::$executedTasks, fn ($task): bool => $task === 'locked-task'); $this->assertCount(2, $occurrences); } - public function testTaskExecutionFailureIsHandled() + public function testTaskExecutionFailureIsHandled(): void { $this->createTaskFile('failing-task.php', [ 'name' => 'failing-task', @@ -172,7 +170,7 @@ public function testTaskExecutionFailureIsHandled() $this->assertEquals(1, $stats['failed']); } - public function testGetStatsReturnsCorrectStatistics() + public function testGetStatsReturnsCorrectStatistics(): void { $this->createTaskFile('task1.php', [ 'name' => 'task-1', @@ -194,7 +192,7 @@ public function testGetStatsReturnsCorrectStatistics() $this->assertEquals(0, $stats['locked']); } - public function testInvalidTaskFileThrowsException() + public function testInvalidTaskFileThrowsException(): void { $this->expectException(CronException::class); $this->expectExceptionMessage('Invalid task file'); @@ -205,7 +203,7 @@ public function testInvalidTaskFileThrowsException() $manager->loadTasks(); } - public function testCronDirectoryCanBeConfigured() + public function testCronDirectoryCanBeConfigured(): void { $configuredDir = base_dir() . DS . 'cron-configured'; $this->cleanupDirectory($configuredDir); @@ -230,7 +228,7 @@ public function testCronDirectoryCanBeConfigured() $this->cleanupDirectory($configuredDir); } - public function testCronDirectoryNotFoundThrowsException() + public function testCronDirectoryNotFoundThrowsException(): void { $this->expectException(CronException::class); $this->expectExceptionMessage('not found'); @@ -239,7 +237,7 @@ public function testCronDirectoryNotFoundThrowsException() $manager->loadTasks(); } - public function testTaskExecutionFailureIsRecorded() + public function testTaskExecutionFailureIsRecorded(): void { $this->createTaskFile('failing-task.php', [ 'name' => 'failing-task', @@ -255,7 +253,7 @@ public function testTaskExecutionFailureIsRecorded() private function createTaskFile(string $filename, array $definition, ?string $directory = null): void { - $directory = $directory ?? $this->cronDirectory; + $directory ??= $this->cronDirectory; $body = $definition['body'] ?? "\\Quantum\\Tests\\Unit\\Cron\\CronManagerTest::recordExecution('{$definition['name']}');"; $content = "assertEquals('test-task', $task->getName()); $this->assertEquals('* * * * *', $task->getExpression()); } - public function testConstructorWithInvalidExpression() + public function testConstructorWithInvalidExpression(): void { $this->expectException(CronException::class); $this->expectExceptionMessage('Invalid cron expression'); - new CronTask('test-task', 'invalid', function () { + new CronTask('test-task', 'invalid', function (): void { }); } - public function testShouldRunEveryMinute() + public function testShouldRunEveryMinute(): void { - $task = new CronTask('test-task', '* * * * *', function () { + $task = new CronTask('test-task', '* * * * *', function (): void { }); $this->assertTrue($task->shouldRun()); } - public function testShouldNotRunFutureTask() + public function testShouldNotRunFutureTask(): void { // Task scheduled for next year - $task = new CronTask('test-task', '0 0 1 1 *', function () { + $task = new CronTask('test-task', '0 0 1 1 *', function (): void { }); $this->assertFalse($task->shouldRun()); } - public function testHandleExecutesCallback() + public function testHandleExecutesCallback(): void { $executed = false; - $task = new CronTask('test-task', '* * * * *', function () use (&$executed) { + $task = new CronTask('test-task', '* * * * *', function () use (&$executed): void { $executed = true; }); @@ -60,11 +60,11 @@ public function testHandleExecutesCallback() $this->assertTrue($executed); } - public function testHandleWithCallbackArguments() + public function testHandleWithCallbackArguments(): void { $result = null; - $task = new CronTask('test-task', '* * * * *', function () use (&$result) { + $task = new CronTask('test-task', '* * * * *', function () use (&$result): void { $result = 'executed'; }); @@ -73,9 +73,9 @@ public function testHandleWithCallbackArguments() $this->assertEquals('executed', $result); } - public function testGetNextRunDate() + public function testGetNextRunDate(): void { - $task = new CronTask('test-task', '0 0 * * *', function () { + $task = new CronTask('test-task', '0 0 * * *', function (): void { }); $nextRun = $task->getNextRunDate(); @@ -84,9 +84,9 @@ public function testGetNextRunDate() $this->assertGreaterThan(new \DateTime(), $nextRun); } - public function testGetPreviousRunDate() + public function testGetPreviousRunDate(): void { - $task = new CronTask('test-task', '0 0 * * *', function () { + $task = new CronTask('test-task', '0 0 * * *', function (): void { }); $previousRun = $task->getPreviousRunDate(); @@ -95,19 +95,19 @@ public function testGetPreviousRunDate() $this->assertLessThan(new \DateTime(), $previousRun); } - public function testComplexCronExpression() + public function testComplexCronExpression(): void { // Every 5 minutes - $task = new CronTask('test-task', '*/5 * * * *', function () { + $task = new CronTask('test-task', '*/5 * * * *', function (): void { }); $this->assertEquals('*/5 * * * *', $task->getExpression()); } - public function testWeeklyCronExpression() + public function testWeeklyCronExpression(): void { // Every Monday at 9 AM - $task = new CronTask('test-task', '0 9 * * 1', function () { + $task = new CronTask('test-task', '0 9 * * 1', function (): void { }); $this->assertEquals('0 9 * * 1', $task->getExpression()); diff --git a/tests/Unit/Cron/ScheduleTest.php b/tests/Unit/Cron/ScheduleTest.php index b4ce75335..dedf7cb6c 100644 --- a/tests/Unit/Cron/ScheduleTest.php +++ b/tests/Unit/Cron/ScheduleTest.php @@ -9,214 +9,214 @@ class ScheduleTest extends TestCase { - private $schedule; + private Schedule $schedule; public function setUp(): void { $this->schedule = new Schedule('test-task'); } - public function testEveryMinute() + public function testEveryMinute(): void { $this->schedule->everyMinute(); $this->assertEquals('* * * * *', $this->schedule->getExpression()); } - public function testEveryFiveMinutes() + public function testEveryFiveMinutes(): void { $this->schedule->everyFiveMinutes(); $this->assertEquals('*/5 * * * *', $this->schedule->getExpression()); } - public function testEveryTenMinutes() + public function testEveryTenMinutes(): void { $this->schedule->everyTenMinutes(); $this->assertEquals('*/10 * * * *', $this->schedule->getExpression()); } - public function testEveryFifteenMinutes() + public function testEveryFifteenMinutes(): void { $this->schedule->everyFifteenMinutes(); $this->assertEquals('*/15 * * * *', $this->schedule->getExpression()); } - public function testEveryThirtyMinutes() + public function testEveryThirtyMinutes(): void { $this->schedule->everyThirtyMinutes(); $this->assertEquals('*/30 * * * *', $this->schedule->getExpression()); } - public function testHourly() + public function testHourly(): void { $this->schedule->hourly(); $this->assertEquals('0 * * * *', $this->schedule->getExpression()); } - public function testHourlyAt() + public function testHourlyAt(): void { $this->schedule->hourlyAt(15); $this->assertEquals('15 * * * *', $this->schedule->getExpression()); } - public function testEveryTwoHours() + public function testEveryTwoHours(): void { $this->schedule->everyTwoHours(); $this->assertEquals('0 */2 * * *', $this->schedule->getExpression()); } - public function testEveryThreeHours() + public function testEveryThreeHours(): void { $this->schedule->everyThreeHours(); $this->assertEquals('0 */3 * * *', $this->schedule->getExpression()); } - public function testEveryFourHours() + public function testEveryFourHours(): void { $this->schedule->everyFourHours(); $this->assertEquals('0 */4 * * *', $this->schedule->getExpression()); } - public function testEverySixHours() + public function testEverySixHours(): void { $this->schedule->everySixHours(); $this->assertEquals('0 */6 * * *', $this->schedule->getExpression()); } - public function testDaily() + public function testDaily(): void { $this->schedule->daily(); $this->assertEquals('0 0 * * *', $this->schedule->getExpression()); } - public function testDailyAt() + public function testDailyAt(): void { $this->schedule->dailyAt('13:30'); $this->assertEquals('30 13 * * *', $this->schedule->getExpression()); } - public function testTwiceDaily() + public function testTwiceDaily(): void { $this->schedule->twiceDaily(4, 16); $this->assertEquals('0 4,16 * * *', $this->schedule->getExpression()); } - public function testWeekly() + public function testWeekly(): void { $this->schedule->weekly(); $this->assertEquals('0 0 * * 0', $this->schedule->getExpression()); } - public function testWeeklyOn() + public function testWeeklyOn(): void { $this->schedule->weeklyOn(1, '15:45'); $this->assertEquals('45 15 * * 1', $this->schedule->getExpression()); } - public function testMonthly() + public function testMonthly(): void { $this->schedule->monthly(); $this->assertEquals('0 0 1 * *', $this->schedule->getExpression()); } - public function testMonthlyOn() + public function testMonthlyOn(): void { $this->schedule->monthlyOn(15, '10:00'); $this->assertEquals('0 10 15 * *', $this->schedule->getExpression()); } - public function testTwiceMonthly() + public function testTwiceMonthly(): void { $this->schedule->twiceMonthly(1, 15, '12:00'); $this->assertEquals('0 12 1,15 * *', $this->schedule->getExpression()); } - public function testQuarterly() + public function testQuarterly(): void { $this->schedule->quarterly(); $this->assertEquals('0 0 1 1-12/3 *', $this->schedule->getExpression()); } - public function testYearly() + public function testYearly(): void { $this->schedule->yearly(); $this->assertEquals('0 0 1 1 *', $this->schedule->getExpression()); } - public function testWeekdays() + public function testWeekdays(): void { $this->schedule->weekdays(); $this->assertEquals('0 0 * * 1-5', $this->schedule->getExpression()); } - public function testWeekends() + public function testWeekends(): void { $this->schedule->weekends(); $this->assertEquals('0 0 * * 0,6', $this->schedule->getExpression()); } - public function testMondays() + public function testMondays(): void { $this->schedule->mondays(); $this->assertEquals('0 0 * * 1', $this->schedule->getExpression()); } - public function testTuesdays() + public function testTuesdays(): void { $this->schedule->tuesdays(); $this->assertEquals('0 0 * * 2', $this->schedule->getExpression()); } - public function testWednesdays() + public function testWednesdays(): void { $this->schedule->wednesdays(); $this->assertEquals('0 0 * * 3', $this->schedule->getExpression()); } - public function testThursdays() + public function testThursdays(): void { $this->schedule->thursdays(); $this->assertEquals('0 0 * * 4', $this->schedule->getExpression()); } - public function testFridays() + public function testFridays(): void { $this->schedule->fridays(); $this->assertEquals('0 0 * * 5', $this->schedule->getExpression()); } - public function testSaturdays() + public function testSaturdays(): void { $this->schedule->saturdays(); $this->assertEquals('0 0 * * 6', $this->schedule->getExpression()); } - public function testSundays() + public function testSundays(): void { $this->schedule->sundays(); $this->assertEquals('0 0 * * 0', $this->schedule->getExpression()); } - public function testDaysWithArray() + public function testDaysWithArray(): void { $this->schedule->days([1, 3, 5]); $this->assertEquals('0 0 * * 1,3,5', $this->schedule->getExpression()); } - public function testAtOverridesTime() + public function testAtOverridesTime(): void { $this->schedule->weeklyOn(1)->at('14:30'); $this->assertEquals('30 14 * * 1', $this->schedule->getExpression()); } - public function testCronSchedulesCustomExpression() + public function testCronSchedulesCustomExpression(): void { $this->schedule->cron('1 2 3 4 5'); $this->assertEquals('1 2 3 4 5', $this->schedule->getExpression()); } - public function testBuildSetsTask() + public function testBuildSetsTask(): void { - $callback = function () { + $callback = function (): void { }; $task = $this->schedule->everyMinute()->call($callback)->build(); @@ -225,16 +225,16 @@ public function testBuildSetsTask() $this->assertEquals('* * * * *', $task->getExpression()); } - public function testBuildThrowsExceptionWhenCallbackMissing() + public function testBuildThrowsExceptionWhenCallbackMissing(): void { $this->expectException(CronException::class); $this->expectExceptionMessage("Task 'test-task' must have a callback. Use call() method."); $this->schedule->everyMinute()->build(); } - public function testBuildThrowsExceptionWhenScheduleMissing() + public function testBuildThrowsExceptionWhenScheduleMissing(): void { - $callback = function () { + $callback = function (): void { }; $this->expectException(CronException::class); $this->expectExceptionMessage("Task 'test-task' must have a schedule. Use methods like daily(), hourly(), etc."); diff --git a/tests/Unit/Csrf/CsrfTest.php b/tests/Unit/Csrf/CsrfTest.php index 38bc17602..010856c6f 100644 --- a/tests/Unit/Csrf/CsrfTest.php +++ b/tests/Unit/Csrf/CsrfTest.php @@ -10,9 +10,9 @@ class CsrfTest extends AppTestCase { - private $csrf; - private $request; - private $key = '#321dMd3QS15%'; + private Csrf $csrf; + private Request $request; + private string $key = '#321dMd3QS15%'; public function setUp(): void { @@ -23,7 +23,7 @@ public function setUp(): void $this->csrf = Csrf::getInstance(); } - public function testGenerateToken() + public function testGenerateToken(): void { $token = $this->csrf->generateToken($this->key); @@ -36,7 +36,7 @@ public function testGenerateToken() $this->assertEquals($token, session()->has(Csrf::TOKEN_KEY)); } - public function testCheckTokenSuccess() + public function testCheckTokenSuccess(): void { $token = $this->csrf->generateToken($this->key); @@ -49,7 +49,7 @@ public function testCheckTokenSuccess() $this->assertTrue($this->csrf->checkToken($this->request)); } - public function testCheckTokenMissing() + public function testCheckTokenMissing(): void { $this->csrf->generateToken($this->key); @@ -62,7 +62,7 @@ public function testCheckTokenMissing() $this->assertTrue($this->csrf->checkToken($this->request)); } - public function testCheckTokenMismatch() + public function testCheckTokenMismatch(): void { $this->csrf->generateToken($this->key); diff --git a/tests/Unit/Csrf/Helpers/CsrfHelperFunctionsTest.php b/tests/Unit/Csrf/Helpers/CsrfHelperFunctionsTest.php index 154a80b2d..167eea029 100644 --- a/tests/Unit/Csrf/Helpers/CsrfHelperFunctionsTest.php +++ b/tests/Unit/Csrf/Helpers/CsrfHelperFunctionsTest.php @@ -8,12 +8,12 @@ class CsrfHelperFunctionsTest extends AppTestCase { - public function testCsrfHelper() + public function testCsrfHelper(): void { $this->assertInstanceOf(Csrf::class, csrf()); } - public function testCsrfToken() + public function testCsrfToken(): void { $request = new Request(); diff --git a/tests/Unit/Database/Adapters/DatabaseSeeder.php b/tests/Unit/Database/Adapters/DatabaseSeeder.php index fa30c56d5..07e3632bd 100644 --- a/tests/Unit/Database/Adapters/DatabaseSeeder.php +++ b/tests/Unit/Database/Adapters/DatabaseSeeder.php @@ -10,17 +10,18 @@ use Quantum\Tests\_root\shared\Models\TestEventModel; use Quantum\Tests\_root\shared\Models\TestNotesModel; use Quantum\Tests\_root\shared\Models\TestUserModel; +use Quantum\Model\Model; class DatabaseSeeder { - private $userModel; - private $profileModel; - private $userProfessionModel; - private $eventModel; - private $userEventModel; - private $userMeetingModel; - private $ticketModel; - private $noteModel; + private Model $userModel; + private Model $profileModel; + private Model $userProfessionModel; + private Model $eventModel; + private Model $userEventModel; + private Model $userMeetingModel; + private Model $ticketModel; + private Model $noteModel; public function __construct() { diff --git a/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTest.php b/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTest.php index 983d6331d..3ae3f09fe 100644 --- a/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTest.php @@ -6,14 +6,14 @@ class IdiormDbalTest extends IdiormDbalTestCase { - public function testIdiormConstructor() + public function testIdiormConstructor(): void { $userModel = new IdiormDbal('users'); $this->assertInstanceOf(IdiormDbal::class, $userModel); } - public function testIdiormGetTable() + public function testIdiormGetTable(): void { $userModel = new IdiormDbal('users'); diff --git a/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTestCase.php b/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTestCase.php index b4d0b3311..56d4f221d 100644 --- a/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTestCase.php +++ b/tests/Unit/Database/Adapters/Idiorm/IdiormDbalTestCase.php @@ -9,7 +9,7 @@ abstract class IdiormDbalTestCase extends AppTestCase { - private $tables = [ + private array $tables = [ 'users', 'user_professions', 'events', @@ -43,7 +43,7 @@ public function tearDown(): void IdiormDbal::disconnect(); } - private function createTables() + private function createTables(): void { $this->createUserTable(); $this->createProfileTable(); @@ -56,14 +56,14 @@ private function createTables() $this->createNotesTable(); } - private function deleteTables() + private function deleteTables(): void { foreach ($this->tables as $table) { IdiormDbal::execute("DROP TABLE IF EXISTS $table"); } } - private function createUserTable() + private function createUserTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS users ( id INTEGER PRIMARY KEY, @@ -72,7 +72,7 @@ private function createUserTable() )'); } - private function createProfileTable() + private function createProfileTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY, @@ -85,7 +85,7 @@ private function createProfileTable() )'); } - private function createEventsTable() + private function createEventsTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS events ( id INTEGER PRIMARY KEY, @@ -95,7 +95,7 @@ private function createEventsTable() )'); } - private function createUserEventTable() + private function createUserEventTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS user_events ( id INTEGER PRIMARY KEY, @@ -106,7 +106,7 @@ private function createUserEventTable() )'); } - private function createUserProfessionTable() + private function createUserProfessionTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS user_professions ( id INTEGER PRIMARY KEY, @@ -115,7 +115,7 @@ private function createUserProfessionTable() )'); } - private function createUserMeetingsTable() + private function createUserMeetingsTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS user_meetings ( id INTEGER PRIMARY KEY, @@ -125,7 +125,7 @@ private function createUserMeetingsTable() )'); } - private function createTicketsTable() + private function createTicketsTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS tickets ( id INTEGER PRIMARY KEY, @@ -135,7 +135,7 @@ private function createTicketsTable() )'); } - private function createNotesTable() + private function createNotesTable(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS notes ( id INTEGER PRIMARY KEY, diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/CriteriaIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/CriteriaIdiormTest.php index ff42967ac..98defd587 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/CriteriaIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/CriteriaIdiormTest.php @@ -7,7 +7,7 @@ class CriteriaIdiormTest extends IdiormDbalTestCase { - public function testIdiormCriteriaEquals() + public function testIdiormCriteriaEquals(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -18,7 +18,7 @@ public function testIdiormCriteriaEquals() $this->assertEquals('Doe', $user->prop('lastname')); } - public function testIdiormCriteriaNotEquals() + public function testIdiormCriteriaNotEquals(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -27,7 +27,7 @@ public function testIdiormCriteriaNotEquals() $this->assertEquals('Jane', $user->prop('firstname')); } - public function testIdiormCriteriaGreaterAndGreaterOrEqual() + public function testIdiormCriteriaGreaterAndGreaterOrEqual(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -42,7 +42,7 @@ public function testIdiormCriteriaGreaterAndGreaterOrEqual() $this->assertCount(2, $users); } - public function testIdiormCriteriaSmallerAndSmallerOrEqual() + public function testIdiormCriteriaSmallerAndSmallerOrEqual(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -57,7 +57,7 @@ public function testIdiormCriteriaSmallerAndSmallerOrEqual() $this->assertCount(1, $users); } - public function testIdiormCriteriaInAndNotIn() + public function testIdiormCriteriaInAndNotIn(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -78,7 +78,7 @@ public function testIdiormCriteriaInAndNotIn() $this->assertEquals('Jane', $users[0]->prop('firstname')); } - public function testIdiormCriteriaLikeAndNotLike() + public function testIdiormCriteriaLikeAndNotLike(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -105,7 +105,7 @@ public function testIdiormCriteriaLikeAndNotLike() $this->assertEquals('Jane', $users[0]->prop('firstname')); } - public function testIdiormCriteriaNullAndNotNull() + public function testIdiormCriteriaNullAndNotNull(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -124,7 +124,7 @@ public function testIdiormCriteriaNullAndNotNull() $this->assertEquals('Jane', $users[1]->prop('firstname')); } - public function testIdiormCriteriaWithFunction() + public function testIdiormCriteriaWithFunction(): void { $now = '2035-01-01 00:00:00'; @@ -137,7 +137,7 @@ public function testIdiormCriteriaWithFunction() $this->assertEquals('2040-02-14 10:15:12', $events[0]->prop('started_at')); } - public function testIdiormCriteriaColumnsEqual() + public function testIdiormCriteriaColumnsEqual(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -151,7 +151,7 @@ public function testIdiormCriteriaColumnsEqual() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormMultipleAndCriterias() + public function testIdiormMultipleAndCriterias(): void { $eventsModel = new IdiormDbal('events'); @@ -166,7 +166,7 @@ public function testIdiormMultipleAndCriterias() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormMultipleOrCriterias() + public function testIdiormMultipleOrCriterias(): void { $eventsModel = new IdiormDbal('events'); @@ -181,7 +181,7 @@ public function testIdiormMultipleOrCriterias() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormAndOrCriterias() + public function testIdiormAndOrCriterias(): void { $eventsModel = new IdiormDbal('events'); @@ -195,7 +195,7 @@ public function testIdiormAndOrCriterias() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormHaving() + public function testIdiormHaving(): void { $eventsModel = new IdiormDbal('events'); @@ -213,7 +213,7 @@ public function testIdiormHaving() $this->assertEquals('Ireland', $events[0]->prop('country')); } - public function testIdiormIsNull() + public function testIdiormIsNull(): void { $eventsModel = new IdiormDbal('events'); @@ -226,7 +226,7 @@ public function testIdiormIsNull() $this->assertEquals('Music', $events[1]->prop('title')); } - public function testIdiormIsNotNull() + public function testIdiormIsNotNull(): void { $eventsModel = new IdiormDbal('events'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/JoinIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/JoinIdiormTest.php index cc6076fca..9be2546e4 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/JoinIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/JoinIdiormTest.php @@ -51,7 +51,7 @@ public function relations(): array class JoinIdiormTest extends IdiormDbalTestCase { - public function testIdiormJoinAndInnerJoin() + public function testIdiormJoinAndInnerJoin(): void { $userModel = new IdiormDbal('users'); @@ -70,7 +70,7 @@ public function testIdiormJoinAndInnerJoin() $this->assertEquals(1, $events[0]->prop('event_id')); } - public function testIdiormMultipleJoins() + public function testIdiormMultipleJoins(): void { $userModel = new IdiormDbal('users'); @@ -84,7 +84,7 @@ public function testIdiormMultipleJoins() $this->assertEquals('Dance', $result[0]->prop('title')); } - public function testIdiormJoinWithCondition() + public function testIdiormJoinWithCondition(): void { $userModel = new IdiormDbal('users'); @@ -98,7 +98,7 @@ public function testIdiormJoinWithCondition() } /** Right join can not be tested this time because the sqlite does not support it */ - public function testIdiormLeftJoinAndRightJoin() + public function testIdiormLeftJoinAndRightJoin(): void { $userModel = new IdiormDbal('user_events'); @@ -115,7 +115,7 @@ public function testIdiormLeftJoinAndRightJoin() $this->assertNull($events[count($events) - 1]->prop('id')); } - public function testIdiormJoinToHasOne() + public function testIdiormJoinToHasOne(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -149,7 +149,7 @@ public function testIdiormJoinToHasOne() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormJoinToBelongsTo() + public function testIdiormJoinToBelongsTo(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -183,7 +183,7 @@ public function testIdiormJoinToBelongsTo() $this->assertIsArray($user); } - public function testIdiormJoinToFromSameTable() + public function testIdiormJoinToFromSameTable(): void { $userModel = ModelFactory::get(TestUserModel::class); $userProfessionModel = ModelFactory::get(TestUserProfessionModel::class); @@ -218,7 +218,7 @@ public function testIdiormJoinToFromSameTable() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormJoinToWithTableSwitch() + public function testIdiormJoinToWithTableSwitch(): void { $userModel = ModelFactory::get(TestUserModel::class); $meetingModel = ModelFactory::get(TestUserMeetingModel::class); @@ -266,7 +266,7 @@ public function testIdiormJoinToWithTableSwitch() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormJoiningViaPivotModel() + public function testIdiormJoiningViaPivotModel(): void { $userModel = ModelFactory::get(TestUserModel::class); $userEventModel = ModelFactory::get(TestUserEventModel::class); @@ -309,7 +309,7 @@ public function testIdiormJoiningViaPivotModel() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormJoinToWithCriteria() + public function testIdiormJoinToWithCriteria(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -345,7 +345,7 @@ public function testIdiormJoinToWithCriteria() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormSelectFieldsAtJoin() + public function testIdiormSelectFieldsAtJoin(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -384,7 +384,7 @@ public function testIdiormSelectFieldsAtJoin() $this->assertEquals($expectedQuery, IdiormDbal::lastQuery()); } - public function testIdiormThrowsExceptionForWrongRelation() + public function testIdiormThrowsExceptionForWrongRelation(): void { $this->expectException(ModelException::class); @@ -397,7 +397,7 @@ public function testIdiormThrowsExceptionForWrongRelation() $eventModel->joinTo($ticketModel)->get(); } - public function testIdiormJoinThrowsExceptionWhenRelationKeysMissing() + public function testIdiormJoinThrowsExceptionWhenRelationKeysMissing(): void { $this->expectException(ModelException::class); $this->expectExceptionMessage('Relation type is missing for model `' . BrokenProfileMissingTypeModel::class . '`'); @@ -407,7 +407,7 @@ public function testIdiormJoinThrowsExceptionWhenRelationKeysMissing() ->get(); } - public function testIdiormJoinThrowsExceptionForUnsupportedRelationType() + public function testIdiormJoinThrowsExceptionForUnsupportedRelationType(): void { $this->expectException(ModelException::class); $this->expectExceptionMessage('Relation type `SIDEWAYS` is not supported'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/ModelIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/ModelIdiormTest.php index 6f3fad288..6a59cee48 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/ModelIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/ModelIdiormTest.php @@ -7,7 +7,7 @@ class ModelIdiormTest extends IdiormDbalTestCase { - public function testIdiormCreateNewRecord() + public function testIdiormCreateNewRecord(): void { $eventsModel = new IdiormDbal('events'); @@ -35,7 +35,7 @@ public function testIdiormCreateNewRecord() } - public function testIdiormUpdateExistingRecord() + public function testIdiormUpdateExistingRecord(): void { $eventsModel = new IdiormDbal('events'); @@ -54,7 +54,7 @@ public function testIdiormUpdateExistingRecord() $this->assertEquals('Climbing', $event->prop('title')); } - public function testIdiormDeleteRecord() + public function testIdiormDeleteRecord(): void { $eventModel = new IdiormDbal('events'); @@ -73,7 +73,7 @@ public function testIdiormDeleteRecord() $this->assertNull($event->prop('title')); } - public function testIdiormDeleteMany() + public function testIdiormDeleteMany(): void { $eventsModel = new IdiormDbal('events'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/QueryIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/QueryIdiormTest.php index 703040b2f..92859548d 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/QueryIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/QueryIdiormTest.php @@ -11,7 +11,7 @@ */ class QueryIdiormTest extends IdiormDbalTestCase { - public function testIdiormExecute() + public function testIdiormExecute(): void { $eventModel = new IdiormDbal('events'); @@ -26,7 +26,7 @@ public function testIdiormExecute() $this->assertEquals('Singing', $event->prop('title')); } - public function testIdiormQuery() + public function testIdiormQuery(): void { $events = IdiormDbal::query( 'SELECT * FROM events WHERE started_at BETWEEN :date_from AND :date_to ORDER BY started_at DESC', @@ -44,7 +44,7 @@ public function testIdiormQuery() } /** Works only if debug set to true */ - public function testIdiormLastQuery() + public function testIdiormLastQuery(): void { IdiormDbal::connect(['driver' => 'sqlite', 'database' => ':memory:']); @@ -55,7 +55,7 @@ public function testIdiormLastQuery() $this->assertEquals("SELECT * FROM `events` WHERE `country` = 'Ireland'", IdiormDbal::lastQuery()); } - public function testIdiormLastStatement() + public function testIdiormLastStatement(): void { IdiormDbal::connect(['driver' => 'sqlite', 'database' => ':memory:']); @@ -66,7 +66,7 @@ public function testIdiormLastStatement() $this->assertEquals('SELECT * FROM `events` WHERE `country` = ?', $eventModel::lastStatement()->queryString); } - public function testIdiormQueryLog() + public function testIdiormQueryLog(): void { $eventModel = new IdiormDbal('events'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/ReducerIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/ReducerIdiormTest.php index 6686d13ed..aaa4e30d2 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/ReducerIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/ReducerIdiormTest.php @@ -7,7 +7,7 @@ class ReducerIdiormTest extends IdiormDbalTestCase { - public function testIdiormSelect() + public function testIdiormSelect(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -24,7 +24,7 @@ public function testIdiormSelect() $this->assertEquals('Doe', $user->prop('surname')); } - public function testIdiormOrderBy() + public function testIdiormOrderBy(): void { $eventsModel = new IdiormDbal('events'); @@ -35,7 +35,7 @@ public function testIdiormOrderBy() $this->assertEquals('Music', $events[count($events) - 1]->prop('title')); } - public function testIdiormGroupBy() + public function testIdiormGroupBy(): void { $eventsModel = new IdiormDbal('events'); @@ -50,7 +50,7 @@ public function testIdiormGroupBy() $this->assertCount(5, $events); } - public function testIdiormLimitAndOffset() + public function testIdiormLimitAndOffset(): void { $eventsModel = new IdiormDbal('events'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/ResultIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/ResultIdiormTest.php index 0b5a79a18..d071b4b28 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/ResultIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/ResultIdiormTest.php @@ -7,7 +7,7 @@ class ResultIdiormTest extends IdiormDbalTestCase { - public function testIdiormGet() + public function testIdiormGet(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -20,7 +20,7 @@ public function testIdiormGet() $this->assertEquals('Jane', $users[1]->prop('firstname')); } - public function testIdiormFindOne() + public function testIdiormFindOne(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -31,7 +31,7 @@ public function testIdiormFindOne() $this->assertEquals('Doe', $user->prop('lastname')); } - public function testIdiormFindOneBy() + public function testIdiormFindOneBy(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -42,7 +42,7 @@ public function testIdiormFindOneBy() $this->assertEquals('45', $user->prop('age')); } - public function testIdiormFirst() + public function testIdiormFirst(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -63,7 +63,7 @@ public function testIdiormFirst() $this->assertEquals('45', $user->prop('age')); } - public function testIdiormCount() + public function testIdiormCount(): void { $userProfileModel = new IdiormDbal('profiles'); @@ -74,7 +74,7 @@ public function testIdiormCount() $this->assertEquals(2, $userCount); } - public function testIdiormAsArray() + public function testIdiormAsArray(): void { $userProfileModel = new IdiormDbal('profiles'); diff --git a/tests/Unit/Database/Adapters/Idiorm/Statements/TransactionIdiormTest.php b/tests/Unit/Database/Adapters/Idiorm/Statements/TransactionIdiormTest.php index ba430a32d..1d3d02c32 100644 --- a/tests/Unit/Database/Adapters/Idiorm/Statements/TransactionIdiormTest.php +++ b/tests/Unit/Database/Adapters/Idiorm/Statements/TransactionIdiormTest.php @@ -11,7 +11,7 @@ */ class TransactionIdiormTest extends IdiormDbalTestCase { - public function testBeginTransactionAndRollback() + public function testBeginTransactionAndRollback(): void { IdiormDbal::beginTransaction(); @@ -30,7 +30,7 @@ public function testBeginTransactionAndRollback() $this->assertEmpty($result); } - public function testBeginTransactionAndCommit() + public function testBeginTransactionAndCommit(): void { IdiormDbal::beginTransaction(); diff --git a/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTest.php b/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTest.php index 40de7e9a4..311685239 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTest.php @@ -6,14 +6,14 @@ class SleekDbalTest extends SleekDbalTestCase { - public function testSleekConstructor() + public function testSleekConstructor(): void { $userModel = new SleekDbal('users'); $this->assertInstanceOf(SleekDbal::class, $userModel); } - public function testSleekGetTable() + public function testSleekGetTable(): void { $userModel = new SleekDbal('users'); diff --git a/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTestCase.php b/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTestCase.php index 49fcefff7..6e87bc1e6 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTestCase.php +++ b/tests/Unit/Database/Adapters/Sleekdb/SleekDbalTestCase.php @@ -10,7 +10,7 @@ abstract class SleekDbalTestCase extends AppTestCase { - private $tables = [ + private array $tables = [ 'users', 'profiles', 'user_professions', diff --git a/tests/Unit/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php b/tests/Unit/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php index e49eeed83..2b45beec6 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php @@ -8,7 +8,7 @@ class CriteriaSleekTest extends SleekDbalTestCase { public $userProfileModel; - public function testSleekCriteriaEquals() + public function testSleekCriteriaEquals(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -19,7 +19,7 @@ public function testSleekCriteriaEquals() $this->assertEquals('Doe', $user->prop('lastname')); } - public function testSleekCriteriaNotEquals() + public function testSleekCriteriaNotEquals(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -30,7 +30,7 @@ public function testSleekCriteriaNotEquals() $this->assertEquals('Du', $user->prop('lastname')); } - public function testSleekCriteriaGreaterAndGreaterOrEqual() + public function testSleekCriteriaGreaterAndGreaterOrEqual(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -45,7 +45,7 @@ public function testSleekCriteriaGreaterAndGreaterOrEqual() $this->assertCount(2, $users); } - public function testSleekCriteriaSmallerAndSmallerOrEqual() + public function testSleekCriteriaSmallerAndSmallerOrEqual(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -60,7 +60,7 @@ public function testSleekCriteriaSmallerAndSmallerOrEqual() $this->assertCount(1, $users); } - public function testSleekCriteriaInAndNotIn() + public function testSleekCriteriaInAndNotIn(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -81,7 +81,7 @@ public function testSleekCriteriaInAndNotIn() $this->assertEquals('Jane', $users[0]->firstname); } - public function testSleekCriteriaLikeAndNotLike() + public function testSleekCriteriaLikeAndNotLike(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -108,7 +108,7 @@ public function testSleekCriteriaLikeAndNotLike() $this->assertEquals('Jane', $users[0]->firstname); } - public function testSleekCriteriaBetweenAndNotBetween() + public function testSleekCriteriaBetweenAndNotBetween(): void { $this->userProfileModel = new SleekDbal('profiles'); @@ -127,7 +127,7 @@ public function testSleekCriteriaBetweenAndNotBetween() $this->assertEquals('John', $users[0]->firstname); } - public function testSleekMultipleAndCriterias() + public function testSleekMultipleAndCriterias(): void { $eventsModel = new SleekDbal('events'); @@ -144,7 +144,7 @@ public function testSleekMultipleAndCriterias() } - public function testSleekMultipleOrCriterias() + public function testSleekMultipleOrCriterias(): void { $eventsModel = new SleekDbal('events'); @@ -159,7 +159,7 @@ public function testSleekMultipleOrCriterias() $this->assertCount(5, $events); } - public function testSleekAndOrCriterias() + public function testSleekAndOrCriterias(): void { $eventsModel = new SleekDbal('events'); @@ -173,7 +173,7 @@ public function testSleekAndOrCriterias() $this->assertCount(1, $events); } - public function testSleekHaving() + public function testSleekHaving(): void { $eventsModel = new SleekDbal('events'); @@ -186,7 +186,7 @@ public function testSleekHaving() $this->assertCount(1, $events); } - public function testSleekIsNull() + public function testSleekIsNull(): void { $eventsModel = new SleekDbal('events'); @@ -199,7 +199,7 @@ public function testSleekIsNull() $this->assertEquals('Music', $events[1]->prop('title')); } - public function testSleekIsNotNull() + public function testSleekIsNotNull(): void { $eventsModel = new SleekDbal('events'); diff --git a/tests/Unit/Database/Adapters/Sleekdb/Statements/JoinSleekTest.php b/tests/Unit/Database/Adapters/Sleekdb/Statements/JoinSleekTest.php index 2cae42fbf..c5031a67c 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/Statements/JoinSleekTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/Statements/JoinSleekTest.php @@ -50,7 +50,7 @@ public function relations(): array class JoinSleekTest extends SleekDbalTestCase { - public function testSleekJoinToHasOne() + public function testSleekJoinToHasOne(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -74,7 +74,7 @@ public function testSleekJoinToHasOne() $this->assertArrayHasKey('country', $profile); } - public function testSleekJoinToBelongsTo() + public function testSleekJoinToBelongsTo(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -99,7 +99,7 @@ public function testSleekJoinToBelongsTo() ); } - public function testSleekSameLevelJoinToHasMany() + public function testSleekSameLevelJoinToHasMany(): void { $userModel = ModelFactory::get(TestUserModel::class); @@ -119,7 +119,7 @@ public function testSleekSameLevelJoinToHasMany() $this->assertIsArray($users->first()->prop('user_meetings')); } - public function testSleekNestedLevelJoinToHasMany() + public function testSleekNestedLevelJoinToHasMany(): void { $userModel = ModelFactory::get(TestUserModel::class); @@ -148,7 +148,7 @@ public function testSleekNestedLevelJoinToHasMany() $this->assertArrayHasKey('notes', $users->first()->prop('user_meetings')[0]['tickets'][0]); } - public function testSleekJoiningViaPivotModel() + public function testSleekJoiningViaPivotModel(): void { $userModel = ModelFactory::get(TestUserModel::class); $userEventModel = ModelFactory::get(TestUserEventModel::class); @@ -194,7 +194,7 @@ public function testSleekJoiningViaPivotModel() $this->assertArrayHasKey('started_at', $eventRecord); } - public function testSleekMixedLevelJoinToWithCriteria() + public function testSleekMixedLevelJoinToWithCriteria(): void { $userModel = ModelFactory::get(TestUserModel::class); $profileModel = ModelFactory::get(TestProfileModel::class); @@ -227,7 +227,7 @@ public function testSleekMixedLevelJoinToWithCriteria() $this->assertIsArray($users->first()->prop('user_meetings')[0]['tickets']); } - public function testSleekSelectFieldsAtJoin() + public function testSleekSelectFieldsAtJoin(): void { $userModel = ModelFactory::get(TestUserModel::class); $userProfessionModel = ModelFactory::get(TestUserProfessionModel::class); @@ -240,7 +240,7 @@ public function testSleekSelectFieldsAtJoin() $this->assertEquals('Writer', $users->first()->profession); } - public function testSleekJoinThrowsExceptionForWrongRelation() + public function testSleekJoinThrowsExceptionForWrongRelation(): void { $this->expectException(ModelException::class); @@ -253,7 +253,7 @@ public function testSleekJoinThrowsExceptionForWrongRelation() $eventModel->joinTo($noteModel)->get(); } - public function testSleekJoinThrowsExceptionForMissingForeignKey() + public function testSleekJoinThrowsExceptionForMissingForeignKey(): void { $this->expectException(ModelException::class); $this->expectExceptionMessage('Foreign key `user_id` is missing in model `' . TestProfileModel::class . '`'); @@ -273,7 +273,7 @@ public function testSleekJoinThrowsExceptionForMissingForeignKey() ->get(); } - public function testSleekJoinThrowsExceptionWhenRelationKeysMissing() + public function testSleekJoinThrowsExceptionWhenRelationKeysMissing(): void { $this->expectException(ModelException::class); $this->expectExceptionMessage('Relation type is missing for model `' . BrokenProfileMissingTypeModel::class . '`'); @@ -283,7 +283,7 @@ public function testSleekJoinThrowsExceptionWhenRelationKeysMissing() ->get(); } - public function testSleekJoinThrowsExceptionForUnsupportedRelationType() + public function testSleekJoinThrowsExceptionForUnsupportedRelationType(): void { $this->expectException(ModelException::class); $this->expectExceptionMessage('Relation type `SIDEWAYS` is not supported'); diff --git a/tests/Unit/Database/Adapters/Sleekdb/Statements/ModelSleekTest.php b/tests/Unit/Database/Adapters/Sleekdb/Statements/ModelSleekTest.php index 72847390f..7928702c7 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/Statements/ModelSleekTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/Statements/ModelSleekTest.php @@ -7,7 +7,7 @@ class ModelSleekTest extends SleekDbalTestCase { - public function testSleekCreateNewRecord() + public function testSleekCreateNewRecord(): void { $eventsModel = new SleekDbal('events'); @@ -35,7 +35,7 @@ public function testSleekCreateNewRecord() } - public function testSleekUpdateExistingRecord() + public function testSleekUpdateExistingRecord(): void { $eventsModel = new SleekDbal('events'); @@ -54,7 +54,7 @@ public function testSleekUpdateExistingRecord() $this->assertEquals('Climbing', $event->prop('title')); } - public function testSleekDeleteRecord() + public function testSleekDeleteRecord(): void { $eventModel = new SleekDbal('events'); @@ -73,7 +73,7 @@ public function testSleekDeleteRecord() $this->assertNull($event->prop('title')); } - public function testSleekDeleteMany() + public function testSleekDeleteMany(): void { $eventsModel = new SleekDbal('events'); diff --git a/tests/Unit/Database/Adapters/Sleekdb/Statements/ReducerSleekTest.php b/tests/Unit/Database/Adapters/Sleekdb/Statements/ReducerSleekTest.php index 84093d385..ff50a3480 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/Statements/ReducerSleekTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/Statements/ReducerSleekTest.php @@ -7,7 +7,7 @@ class ReducerSleekTest extends SleekDbalTestCase { - public function testSleekSelect() + public function testSleekSelect(): void { $userProfileModel = new SleekDbal('profiles'); @@ -15,7 +15,7 @@ public function testSleekSelect() $this->assertCount(2, $user->asArray()); - $userModel = new SleekDbal('users'); + new SleekDbal('users'); $user = $userProfileModel ->select('id', ['firstname' => 'name'], ['lastname' => 'surname'], 'age') @@ -27,7 +27,7 @@ public function testSleekSelect() $this->assertEquals('Doe', $user[0]->surname); } - public function testSleekGroupBy() + public function testSleekGroupBy(): void { $eventsModel = new SleekDbal('events'); @@ -42,7 +42,7 @@ public function testSleekGroupBy() $this->assertCount(5, $events); } - public function testSleekOrderBy() + public function testSleekOrderBy(): void { $eventsModel = new SleekDbal('events'); @@ -53,7 +53,7 @@ public function testSleekOrderBy() $this->assertEquals('Art', $events[count($events) - 1]->title); } - public function testSleekLimitAndOffset() + public function testSleekLimitAndOffset(): void { $eventsModel = new SleekDbal('events'); diff --git a/tests/Unit/Database/Adapters/Sleekdb/Statements/ResultSleekTest.php b/tests/Unit/Database/Adapters/Sleekdb/Statements/ResultSleekTest.php index ce1bc5c9b..bcf3f83fb 100644 --- a/tests/Unit/Database/Adapters/Sleekdb/Statements/ResultSleekTest.php +++ b/tests/Unit/Database/Adapters/Sleekdb/Statements/ResultSleekTest.php @@ -7,7 +7,7 @@ class ResultSleekTest extends SleekDbalTestCase { - private $userProfileModel; + private SleekDbal $userProfileModel; public function setUp(): void { @@ -16,7 +16,7 @@ public function setUp(): void $this->userProfileModel = new SleekDbal('profiles'); } - public function testSleekGet() + public function testSleekGet(): void { $users = $this->userProfileModel->get(); @@ -29,7 +29,7 @@ public function testSleekGet() $this->assertNotNull($users[0]->lastname); } - public function testSleekFindOne() + public function testSleekFindOne(): void { $user = $this->userProfileModel->findOne(1); @@ -38,7 +38,7 @@ public function testSleekFindOne() $this->assertEquals('Doe', $user->prop('lastname')); } - public function testSleekFindOneBy() + public function testSleekFindOneBy(): void { $user = $this->userProfileModel->findOneBy('firstname', 'John'); @@ -47,7 +47,7 @@ public function testSleekFindOneBy() $this->assertEquals('45', $user->prop('age')); } - public function testSleekFirst() + public function testSleekFirst(): void { $user = $this->userProfileModel->criteria('age', '>', 40)->first(); @@ -66,7 +66,7 @@ public function testSleekFirst() $this->assertEquals('35', $user->prop('age')); } - public function testSleekCount() + public function testSleekCount(): void { $this->assertIsInt($this->userProfileModel->count()); @@ -77,7 +77,7 @@ public function testSleekCount() $this->assertEquals(1, $this->userProfileModel->count()); } - public function testSleekAsArray() + public function testSleekAsArray(): void { $user = $this->userProfileModel->first(); diff --git a/tests/Unit/Database/DatabaseTest.php b/tests/Unit/Database/DatabaseTest.php index 117e0f8a3..dff5475f4 100644 --- a/tests/Unit/Database/DatabaseTest.php +++ b/tests/Unit/Database/DatabaseTest.php @@ -38,7 +38,7 @@ public function tearDown(): void Database::execute('DROP TABLE IF EXISTS profiles'); } - public function testDatabaseInstance() + public function testDatabaseInstance(): void { $db1 = Database::getInstance(); @@ -49,17 +49,17 @@ public function testDatabaseInstance() $this->assertSame($db1, $db2); } - public function testDatabaseGetConfigs() + public function testDatabaseGetConfigs(): void { $this->assertEquals(config()->get('database.sqlite'), Database::getInstance()->getConfigs()); } - public function testDatabaseGetOrmClass() + public function testDatabaseGetOrmClass(): void { $this->assertEquals(IdiormDbal::class, Database::getInstance()->getOrmClass()); } - public function testDatabaseRawQueries() + public function testDatabaseRawQueries(): void { $result = Database::query('SELECT * FROM profiles WHERE id=:id', ['id' => 1]); @@ -86,7 +86,7 @@ public function testDatabaseRawQueries() $this->assertIsArray(Database::queryLog()); } - public function testDatabaseTransactionMethods() + public function testDatabaseTransactionMethods(): void { Database::beginTransaction(); @@ -123,9 +123,9 @@ public function testDatabaseTransactionMethods() $this->assertEquals('Marley', $result[0]['lastname']); } - public function testDatabaseTransactionClosureSuccess() + public function testDatabaseTransactionClosureSuccess(): void { - $result = Database::transaction(function () { + $result = Database::transaction(function (): string { Database::execute('INSERT INTO profiles (firstname, lastname, age, country) VALUES (:firstname, :lastname, :age, :country)', [ 'firstname' => 'Charlie', @@ -146,10 +146,10 @@ public function testDatabaseTransactionClosureSuccess() $this->assertEquals('Brown', $rows[0]['lastname']); } - public function testDatabaseTransactionClosureFailure() + public function testDatabaseTransactionClosureFailure(): void { try { - Database::transaction(function () { + Database::transaction(function (): void { Database::execute('INSERT INTO profiles (firstname, lastname, age, country) VALUES (:firstname, :lastname, :age, :country)', [ 'firstname' => 'Eve', diff --git a/tests/Unit/Database/Factories/TableFactoryTest.php b/tests/Unit/Database/Factories/TableFactoryTest.php index 298e5b6b8..0bc6b7c67 100644 --- a/tests/Unit/Database/Factories/TableFactoryTest.php +++ b/tests/Unit/Database/Factories/TableFactoryTest.php @@ -12,7 +12,7 @@ class TableFactoryTest extends AppTestCase { - private $tableFactory; + private TableFactory $tableFactory; private $table; public function setUp(): void @@ -52,14 +52,14 @@ public function tearDown(): void Database::execute('DROP TABLE IF EXISTS profiles'); } - public function testCreateTable() + public function testCreateTable(): void { $table = $this->tableFactory->create('profiles'); $this->assertInstanceOf(Table::class, $table); } - public function testAttemptToCreateTableWhichAlreadyExists() + public function testAttemptToCreateTableWhichAlreadyExists(): void { Database::execute('CREATE TABLE profiles ( id INTEGER PRIMARY KEY, @@ -77,7 +77,7 @@ public function testAttemptToCreateTableWhichAlreadyExists() $this->tableFactory->create('profiles'); } - public function testGetTable() + public function testGetTable(): void { Database::execute('CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY, @@ -93,7 +93,7 @@ public function testGetTable() $this->assertInstanceOf(Table::class, $table); } - public function testAttemptToGetNonExistingTable() + public function testAttemptToGetNonExistingTable(): void { $this->expectException(DatabaseException::class); @@ -102,7 +102,7 @@ public function testAttemptToGetNonExistingTable() $table = $this->tableFactory->get('profiles'); } - public function testRenameTable() + public function testRenameTable(): void { Database::execute('CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY, @@ -116,7 +116,7 @@ public function testRenameTable() $this->assertTrue($this->tableFactory->rename('profiles', 'system_users')); } - public function testAttemptToRenameNonExistingTable() + public function testAttemptToRenameNonExistingTable(): void { $this->expectException(DatabaseException::class); @@ -125,7 +125,7 @@ public function testAttemptToRenameNonExistingTable() $this->tableFactory->rename('profiles', 'system_users'); } - public function testDropTable() + public function testDropTable(): void { Database::execute('CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY, @@ -139,7 +139,7 @@ public function testDropTable() $this->assertTrue($this->tableFactory->drop('profiles')); } - public function testAttemptToDropNonExistingTable() + public function testAttemptToDropNonExistingTable(): void { $this->expectException(DatabaseException::class); diff --git a/tests/Unit/Database/Schema/ColumnTest.php b/tests/Unit/Database/Schema/ColumnTest.php index e677adfa6..b182ee44c 100644 --- a/tests/Unit/Database/Schema/ColumnTest.php +++ b/tests/Unit/Database/Schema/ColumnTest.php @@ -8,12 +8,12 @@ class ColumnTest extends TestCase { - public function testColumnConstructor() + public function testColumnConstructor(): void { $this->assertInstanceOf(Column::class, new Column('test')); } - public function testColumnRename() + public function testColumnRename(): void { $column = new Column('test', Type::INT, 11); @@ -22,7 +22,7 @@ public function testColumnRename() $this->assertEquals('new_test', $column->get('newName')); } - public function testColumnGet() + public function testColumnGet(): void { $column = new Column('test', Type::INT, 11); @@ -33,7 +33,7 @@ public function testColumnGet() $this->assertEquals(11, $column->get(Column::CONSTRAINT)); } - public function testColumnAutoIncrement() + public function testColumnAutoIncrement(): void { $column = new Column('test', Type::INT, 11); @@ -44,7 +44,7 @@ public function testColumnAutoIncrement() $this->assertEquals('primary', $column->get('indexKey')); } - public function testColumnPrimaryKey() + public function testColumnPrimaryKey(): void { $column = new Column('test', Type::INT, 11); @@ -53,7 +53,7 @@ public function testColumnPrimaryKey() $this->assertEquals('primary', $column->get('indexKey')); } - public function testColumnIndexKey() + public function testColumnIndexKey(): void { $column = new Column('test', Type::INT, 11); @@ -64,7 +64,7 @@ public function testColumnIndexKey() $this->assertEquals('idx_name', $column->get('indexName')); } - public function testColumnUniqueKey() + public function testColumnUniqueKey(): void { $column = new Column('test', Type::INT, 11); @@ -75,7 +75,7 @@ public function testColumnUniqueKey() $this->assertEquals('idx_unique_name', $column->get('indexName')); } - public function testColumnFulltextKey() + public function testColumnFulltextKey(): void { $column = new Column('test', Type::INT, 11); @@ -86,7 +86,7 @@ public function testColumnFulltextKey() $this->assertEquals('idx_fulltext_name', $column->get('indexName')); } - public function testColumnSpatialKey() + public function testColumnSpatialKey(): void { $column = new Column('test', Type::INT, 11); @@ -97,7 +97,7 @@ public function testColumnSpatialKey() $this->assertEquals('idx_spatial_name', $column->get('indexName')); } - public function testAddOrRemoveColumnNullableProperty() + public function testAddOrRemoveColumnNullableProperty(): void { $column = new Column('test', Type::VARCHAR, 255); @@ -112,7 +112,7 @@ public function testAddOrRemoveColumnNullableProperty() $this->assertEquals('NOT NULL', $column->get(Column::NULLABLE)); } - public function testAddOrRemoveColumnDefaultValue() + public function testAddOrRemoveColumnDefaultValue(): void { $column = new Column('test', Type::INT, 11); @@ -127,7 +127,7 @@ public function testAddOrRemoveColumnDefaultValue() $this->assertNull($column->get(Column::DEFAULT)); } - public function testAddOrRemoveColumnAttribute() + public function testAddOrRemoveColumnAttribute(): void { $column = new Column('test', Type::INT, 11); @@ -146,7 +146,7 @@ public function testAddOrRemoveColumnAttribute() $this->assertNull($column->get(Column::ATTRIBUTE)); } - public function testAddOrRemoveColumnComment() + public function testAddOrRemoveColumnComment(): void { $column = new Column('test', Type::INT, 11); @@ -161,7 +161,7 @@ public function testAddOrRemoveColumnComment() $this->assertNull($column->get(Column::COMMENT)); } - public function testAfterColumn() + public function testAfterColumn(): void { $column = new Column('test', Type::INT, 11); diff --git a/tests/Unit/Database/Schema/TableTest.php b/tests/Unit/Database/Schema/TableTest.php index ed8f9d320..1fc92ec65 100644 --- a/tests/Unit/Database/Schema/TableTest.php +++ b/tests/Unit/Database/Schema/TableTest.php @@ -22,7 +22,7 @@ public function setUp(): void $db->shouldReceive('execute')->andReturn(true); } - public function testSetActionAndGetQuery() + public function testSetActionAndGetQuery(): void { $table = new Table('test'); $table->setAction(Table::RENAME, ['newName' => 'general']); @@ -32,12 +32,12 @@ public function testSetActionAndGetQuery() $this->assertEquals($expectedSql, $table->getSql()); } - public function testTableConstructor() + public function testTableConstructor(): void { $this->assertInstanceOf(Table::class, new Table('test')); } - public function testAddColumn() + public function testAddColumn(): void { $table = new Table('test'); $table->setAction(Table::CREATE); @@ -48,7 +48,7 @@ public function testAddColumn() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddColumnWithAttributes() + public function testAddColumnWithAttributes(): void { $table = new Table('test'); $table->setAction(Table::CREATE); @@ -59,7 +59,7 @@ public function testAddColumnWithAttributes() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddColumnWithIndexs() + public function testAddColumnWithIndexs(): void { $table = new Table('test'); $table->setAction(Table::CREATE); @@ -72,7 +72,7 @@ public function testAddColumnWithIndexs() $this->assertEquals($expectedSql, $table->getSql()); } - public function testModifyColumn() + public function testModifyColumn(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -83,7 +83,7 @@ public function testModifyColumn() $this->assertEquals($expectedSql, $table->getSql()); } - public function testModifyColumnWithAttributes() + public function testModifyColumnWithAttributes(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -94,7 +94,7 @@ public function testModifyColumnWithAttributes() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddColumnAndModifyColumn() + public function testAddColumnAndModifyColumn(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -106,7 +106,7 @@ public function testAddColumnAndModifyColumn() $this->assertEquals($expectedSql, $table->getSql()); } - public function testRenameColumn() + public function testRenameColumn(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -117,7 +117,7 @@ public function testRenameColumn() $this->assertEquals($expectedSql, $table->getSql()); } - public function testDropColumn() + public function testDropColumn(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -128,7 +128,7 @@ public function testDropColumn() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddIndex() + public function testAddIndex(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -139,7 +139,7 @@ public function testAddIndex() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddIndexWithName() + public function testAddIndexWithName(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -150,7 +150,7 @@ public function testAddIndexWithName() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAddingMultipleIndexes() + public function testAddingMultipleIndexes(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -162,7 +162,7 @@ public function testAddingMultipleIndexes() $this->assertEquals($expectedSql, $table->getSql()); } - public function testDropIndex() + public function testDropIndex(): void { $table = new Table('test'); $table->setAction(Table::ALTER); @@ -173,7 +173,7 @@ public function testDropIndex() $this->assertEquals($expectedSql, $table->getSql()); } - public function testAfterColumn() + public function testAfterColumn(): void { $table = new Table('test'); $table->setAction(Table::ALTER); diff --git a/tests/Unit/Debugger/DebuggerStoreTest.php b/tests/Unit/Debugger/DebuggerStoreTest.php index 2f498be59..c6aed57e5 100644 --- a/tests/Unit/Debugger/DebuggerStoreTest.php +++ b/tests/Unit/Debugger/DebuggerStoreTest.php @@ -7,7 +7,7 @@ class DebuggerStoreTest extends AppTestCase { - private $debuggerStore; + private DebuggerStore $debuggerStore; public function setUp(): void { @@ -19,7 +19,7 @@ public function tearDown(): void $this->debuggerStore->flush(); } - public function testDebuggerStoreInit() + public function testDebuggerStoreInit(): void { $this->debuggerStore->init(['key1', 'key2']); @@ -29,7 +29,7 @@ public function testDebuggerStoreInit() $this->assertEmpty($this->debuggerStore->get('key2')); } - public function testDebuggerStoreAll() + public function testDebuggerStoreAll(): void { $this->assertEquals([], $this->debuggerStore->all()); @@ -42,7 +42,7 @@ public function testDebuggerStoreAll() $this->assertArrayHasKey('key1', $all); } - public function testDebuggerStoreHas() + public function testDebuggerStoreHas(): void { $this->debuggerStore->init(['key1']); @@ -50,7 +50,7 @@ public function testDebuggerStoreHas() $this->assertFalse($this->debuggerStore->has('key2')); } - public function testDebuggerStoreSetAndGet() + public function testDebuggerStoreSetAndGet(): void { $this->debuggerStore->init(['key1']); $this->debuggerStore->set('key1', ['level1' => 'data']); @@ -64,7 +64,7 @@ public function testDebuggerStoreSetAndGet() $this->assertCount(2, $this->debuggerStore->get('key1')); } - public function testDebuggerStoreDelete() + public function testDebuggerStoreDelete(): void { $this->debuggerStore->init(['key1']); $this->debuggerStore->set('key1', ['level1' => 'data']); @@ -75,7 +75,7 @@ public function testDebuggerStoreDelete() $this->assertEmpty($this->debuggerStore->get('key1')); } - public function testFlush() + public function testFlush(): void { $debuggerStore = new DebuggerStore(); $debuggerStore->init(['key1', 'key2']); diff --git a/tests/Unit/Debugger/DebuggerTest.php b/tests/Unit/Debugger/DebuggerTest.php index b0e258a40..e1bcb4aa9 100644 --- a/tests/Unit/Debugger/DebuggerTest.php +++ b/tests/Unit/Debugger/DebuggerTest.php @@ -14,11 +14,11 @@ class DebuggerTest extends AppTestCase { - private $debugger; + private Debugger $debugger; private $debugBarMock; - private $debuggerStore; + private DebuggerStore $debuggerStore; public function setUp(): void { @@ -45,7 +45,7 @@ public function setUp(): void $this->debugger = Debugger::getInstance($this->debuggerStore, $this->debugBarMock, $collectors); } - public function testDebuggerIsEnabled() + public function testDebuggerIsEnabled(): void { config()->set('app.debug', true); $this->assertTrue($this->debugger->isEnabled()); @@ -54,7 +54,7 @@ public function testDebuggerIsEnabled() $this->assertFalse($this->debugger->isEnabled()); } - public function testDebuggerInitStore() + public function testDebuggerInitStore(): void { $this->debugger->initStore(); @@ -65,7 +65,7 @@ public function testDebuggerInitStore() $this->assertTrue($this->debuggerStore->has(Debugger::MAILS)); } - public function testDebuggerAddToStoreCell() + public function testDebuggerAddToStoreCell(): void { $this->debugger->addToStoreCell(Debugger::MESSAGES, LogLevel::INFO, 'Test message'); @@ -74,7 +74,7 @@ public function testDebuggerAddToStoreCell() $this->assertEquals(['info' => 'Test message'], $storedData[0]); } - public function testDebuggerGetStoreCell() + public function testDebuggerGetStoreCell(): void { $this->debugger->addToStoreCell(Debugger::MESSAGES, LogLevel::INFO, 'Test message'); @@ -83,7 +83,7 @@ public function testDebuggerGetStoreCell() $this->assertEquals(['info' => 'Test message'], $storedData[0]); } - public function testDebuggerClearStoreCell() + public function testDebuggerClearStoreCell(): void { $this->debugger->addToStoreCell(Debugger::MESSAGES, LogLevel::INFO, 'Test message'); $this->debugger->clearStoreCell(Debugger::MESSAGES); @@ -93,7 +93,7 @@ public function testDebuggerClearStoreCell() $this->assertEmpty($storedData); } - public function testDebuggerResetStore() + public function testDebuggerResetStore(): void { $this->debugger->initStore(); @@ -104,7 +104,7 @@ public function testDebuggerResetStore() $this->assertEmpty($this->debuggerStore->all()); } - public function testDebugbarRender() + public function testDebugbarRender(): void { $this->debugger->initStore(); diff --git a/tests/Unit/Di/DiTest.php b/tests/Unit/Di/DiTest.php index 377f659f5..f49efbca6 100644 --- a/tests/Unit/Di/DiTest.php +++ b/tests/Unit/Di/DiTest.php @@ -9,12 +9,12 @@ class TestDiController { - public function index(Request $request, Response $response, ViewFactory $view) + public function index(Request $request, Response $response, ViewFactory $view): void { // method body } - public function handleService(DummyServiceInterface $service) + public function handleService(DummyServiceInterface $service): DummyServiceInterface { return $service; } @@ -70,7 +70,7 @@ public function setUp(): void parent::setUp(); } - public function testDiRegisterDependency() + public function testDiRegisterDependency(): void { Di::register(Setup::class); @@ -103,7 +103,7 @@ public function testDiAttemptingToRegisterNonExistentAbstract(): void Di::register(DummyService::class, 'NonExistentInterface'); } - public function testDiIsRegistered() + public function testDiIsRegistered(): void { $this->assertFalse(Di::isRegistered(DummyService::class)); @@ -112,7 +112,7 @@ public function testDiIsRegistered() $this->assertTrue(Di::isRegistered(DummyService::class)); } - public function testDiAbstractToConcreteBinding() + public function testDiAbstractToConcreteBinding(): void { Di::register(DummyService::class, DummyServiceInterface::class); @@ -193,7 +193,7 @@ public function testDiSetOverridesRegisteredButNotResolved(): void $this->assertSame($instance, $resolved); } - public function testDiGetCoreDependencies() + public function testDiGetCoreDependencies(): void { $this->assertInstanceOf(Loader::class, Di::get(Loader::class)); @@ -202,7 +202,7 @@ public function testDiGetCoreDependencies() $this->assertInstanceOf(Response::class, Di::get(Response::class)); } - public function testDiAttemptingToGetNotRegisteredDependency() + public function testDiAttemptingToGetNotRegisteredDependency(): void { $this->assertInstanceOf(Loader::class, Di::get(Loader::class)); @@ -229,7 +229,7 @@ public function testDiCircularDependencyDetectedAtResolve(): void Di::create(CircularDependencyA::class); } - public function testDiGetReturnsSingleton() + public function testDiGetReturnsSingleton(): void { Di::register(DummyService::class); @@ -242,7 +242,7 @@ public function testDiGetReturnsSingleton() $this->assertSame($instance1, $instance2); } - public function testDiCreateReturnsNewInstance() + public function testDiCreateReturnsNewInstance(): void { Di::register(DummyService::class); @@ -255,7 +255,7 @@ public function testDiCreateReturnsNewInstance() $this->assertNotSame($instance1, $instance2); } - public function testDiAutowire() + public function testDiAutowire(): void { $params = Di::autowire([new TestDiController(), 'index']); @@ -265,7 +265,7 @@ public function testDiAutowire() $this->assertInstanceOf(ViewFactory::class, $params[2]); - $callback = function (Request $request, Response $response) { + $callback = function (Request $request, Response $response): void { // function body }; @@ -276,7 +276,7 @@ public function testDiAutowire() $this->assertInstanceOf(Response::class, $params[1]); } - public function testDiAutowireWithAbstract() + public function testDiAutowireWithAbstract(): void { Di::register(DummyService::class, DummyServiceInterface::class); @@ -289,7 +289,7 @@ public function testDiAutowireWithAbstract() $this->assertInstanceOf(DummyService::class, $params[0]); } - public function testDiReset() + public function testDiReset(): void { Di::register(DummyService::class); diff --git a/tests/Unit/Encryption/Adapters/AsymmetricEncryptionAdapterTest.php b/tests/Unit/Encryption/Adapters/AsymmetricEncryptionAdapterTest.php index c5b46f7de..0da31b41d 100644 --- a/tests/Unit/Encryption/Adapters/AsymmetricEncryptionAdapterTest.php +++ b/tests/Unit/Encryption/Adapters/AsymmetricEncryptionAdapterTest.php @@ -20,12 +20,12 @@ public function setUp(): void $this->adapter = new AsymmetricEncryptionAdapter(); } - public function testAsymmetricEncryptionAdapterGetInstance() + public function testAsymmetricEncryptionAdapterGetInstance(): void { $this->assertInstanceOf(AsymmetricEncryptionAdapter::class, $this->adapter); } - public function testAsymmetricEncryptionAdapterEncryptAndDecrypt() + public function testAsymmetricEncryptionAdapterEncryptAndDecrypt(): void { $encrypted = $this->adapter->encrypt($this->plainText); @@ -38,7 +38,7 @@ public function testAsymmetricEncryptionAdapterEncryptAndDecrypt() $this->assertEquals($this->plainText, $decrypted); } - public function testAsymmetricEncryptionAdapterWithoutPublicKey() + public function testAsymmetricEncryptionAdapterWithoutPublicKey(): void { $reflection = new ReflectionClass(AsymmetricEncryptionAdapter::class); $instanceProperty = $reflection->getProperty('publicKey'); @@ -53,7 +53,7 @@ public function testAsymmetricEncryptionAdapterWithoutPublicKey() $adapterInstance->encrypt('Some text'); } - public function testAsymmetricEncryptionAdapterDecryptWithoutPrivateKey() + public function testAsymmetricEncryptionAdapterDecryptWithoutPrivateKey(): void { $reflection = new ReflectionClass(AsymmetricEncryptionAdapter::class); $instanceProperty = $reflection->getProperty('privateKey'); diff --git a/tests/Unit/Encryption/Adapters/SymmetricEncryptionAdapterTest.php b/tests/Unit/Encryption/Adapters/SymmetricEncryptionAdapterTest.php index 795a8d71f..8561d4fa2 100644 --- a/tests/Unit/Encryption/Adapters/SymmetricEncryptionAdapterTest.php +++ b/tests/Unit/Encryption/Adapters/SymmetricEncryptionAdapterTest.php @@ -18,12 +18,12 @@ public function setUp(): void $this->adapter = new SymmetricEncryptionAdapter(); } - public function testSymmetricEncryptionAdapterGetInstance() + public function testSymmetricEncryptionAdapterGetInstance(): void { $this->assertInstanceOf(SymmetricEncryptionAdapter::class, $this->adapter); } - public function testSymmetricEncryptionAdapterEncryptAndDecrypt() + public function testSymmetricEncryptionAdapterEncryptAndDecrypt(): void { $encrypted = $this->adapter->encrypt($this->plainText); @@ -36,7 +36,7 @@ public function testSymmetricEncryptionAdapterEncryptAndDecrypt() $this->assertEquals($this->plainText, $decrypted); } - public function testSymmetricEncryptionDecryptThrowsExceptionOnInvalidData() + public function testSymmetricEncryptionDecryptThrowsExceptionOnInvalidData(): void { $this->expectException(CryptorException::class); diff --git a/tests/Unit/Encryption/CryptorTest.php b/tests/Unit/Encryption/CryptorTest.php index fc69f6282..0544504ac 100644 --- a/tests/Unit/Encryption/CryptorTest.php +++ b/tests/Unit/Encryption/CryptorTest.php @@ -16,7 +16,7 @@ public function setUp(): void parent::setUp(); } - public function testCryptorGetAdapter() + public function testCryptorGetAdapter(): void { $cryptor = new Cryptor(new SymmetricEncryptionAdapter()); @@ -31,7 +31,7 @@ public function testCryptorGetAdapter() $this->assertInstanceOf(EncryptionInterface::class, $cryptor->getAdapter()); } - public function testIsAsymmetric() + public function testIsAsymmetric(): void { $cryptor = new Cryptor(new SymmetricEncryptionAdapter()); @@ -42,7 +42,7 @@ public function testIsAsymmetric() $this->assertTrue($cryptor->isAsymmetric()); } - public function testCryptorCallingValidMethod() + public function testCryptorCallingValidMethod(): void { $cryptor = new Cryptor(new SymmetricEncryptionAdapter()); @@ -53,7 +53,7 @@ public function testCryptorCallingValidMethod() $this->assertEquals($plainText, $cryptor->decrypt($encrypted)); } - public function testCryptorCallingInvalidMethod() + public function testCryptorCallingInvalidMethod(): void { $cryptor = new Cryptor(new SymmetricEncryptionAdapter()); diff --git a/tests/Unit/Encryption/Factories/CryptorFactoryTest.php b/tests/Unit/Encryption/Factories/CryptorFactoryTest.php index 4ac0178a7..37bde4a71 100644 --- a/tests/Unit/Encryption/Factories/CryptorFactoryTest.php +++ b/tests/Unit/Encryption/Factories/CryptorFactoryTest.php @@ -17,14 +17,14 @@ public function setUp(): void parent::setUp(); } - public function testCryptorFactoryInstance() + public function testCryptorFactoryInstance(): void { $cryptor = CryptorFactory::get(); $this->assertInstanceOf(Cryptor::class, $cryptor); } - public function testCryptorFactorySymmetricAdapter() + public function testCryptorFactorySymmetricAdapter(): void { $cryptor = CryptorFactory::get(); @@ -33,7 +33,7 @@ public function testCryptorFactorySymmetricAdapter() $this->assertInstanceOf(EncryptionInterface::class, $cryptor->getAdapter()); } - public function testCryptorFactoryAsymmetricAdapter() + public function testCryptorFactoryAsymmetricAdapter(): void { $cryptor = CryptorFactory::get(Cryptor::ASYMMETRIC); @@ -42,7 +42,7 @@ public function testCryptorFactoryAsymmetricAdapter() $this->assertInstanceOf(EncryptionInterface::class, $cryptor->getAdapter()); } - public function testCryptorFactoryInvalidTypeAdapter() + public function testCryptorFactoryInvalidTypeAdapter(): void { $this->expectException(CryptorException::class); @@ -51,7 +51,7 @@ public function testCryptorFactoryInvalidTypeAdapter() CryptorFactory::get('invalid_type'); } - public function testCryptorFactoryReturnsSameInstance() + public function testCryptorFactoryReturnsSameInstance(): void { $cryptor1 = CryptorFactory::get(); $cryptor2 = CryptorFactory::get(); diff --git a/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php b/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php index 07875daaf..87a42ccfe 100644 --- a/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php +++ b/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php @@ -8,7 +8,7 @@ class CryptorHelperFunctionsTest extends AppTestCase { - public function testCryptoEncodeAndDecodeWithSymmetricEncryption() + public function testCryptoEncodeAndDecodeWithSymmetricEncryption(): void { $stringValue = 'simple string'; @@ -49,7 +49,7 @@ public function testCryptoEncodeAndDecodeWithSymmetricEncryption() } - public function testCryptoEncodeAndDecodeWithAsymmetricEncryption() + public function testCryptoEncodeAndDecodeWithAsymmetricEncryption(): void { $stringValue = 'simple string'; diff --git a/tests/Unit/Environment/EnvironmentTest.php b/tests/Unit/Environment/EnvironmentTest.php index a87951d59..71ac72b80 100644 --- a/tests/Unit/Environment/EnvironmentTest.php +++ b/tests/Unit/Environment/EnvironmentTest.php @@ -8,7 +8,7 @@ class EnvironmentTest extends AppTestCase { - private $env; + private Environment $env; public function setUp(): void { @@ -17,12 +17,12 @@ public function setUp(): void $this->env = Environment::getInstance(); } - public function testEnvironmentGetAppEnv() + public function testEnvironmentGetAppEnv(): void { $this->assertEquals('testing', $this->env->getAppEnv()); } - public function testEnvironmentGetValue() + public function testEnvironmentGetValue(): void { $this->assertNull($this->env->getValue('NON_EXISTING_KEY')); @@ -33,21 +33,21 @@ public function testEnvironmentGetValue() $this->assertEquals('XYZ1234567890ABCDEFG123456789HIGKLMNOPQRSTUVWXYZ0123456789abcdefgh', $this->env->getValue('APP_KEY')); } - public function testEnvironmentHasKey() + public function testEnvironmentHasKey(): void { $this->assertTrue($this->env->hasKey('APP_KEY')); $this->assertFalse($this->env->hasKey('NON_EXISTING_KEY')); } - public function testEnvironmentGetRow() + public function testEnvironmentGetRow(): void { $this->assertNull($this->env->getRow('NON_EXISTING_KEY')); $this->assertEquals('APP_KEY=XYZ1234567890ABCDEFG123456789HIGKLMNOPQRSTUVWXYZ0123456789abcdefgh', $this->env->getRow('APP_KEY')); } - public function testEnvironmentAddAndUpdateRow() + public function testEnvironmentAddAndUpdateRow(): void { $envFilePath = App::getBaseDir() . DS . '.env.testing'; $originalContent = $this->fs->get($envFilePath); diff --git a/tests/Unit/Environment/Helpers/EnvHelperTest.php b/tests/Unit/Environment/Helpers/EnvHelperTest.php index c933aa85d..420556847 100644 --- a/tests/Unit/Environment/Helpers/EnvHelperTest.php +++ b/tests/Unit/Environment/Helpers/EnvHelperTest.php @@ -6,7 +6,7 @@ class EnvHelperTest extends AppTestCase { - public function testGetEnvValue() + public function testGetEnvValue(): void { $this->assertNotNull(env('APP_KEY')); diff --git a/tests/Unit/Environment/Helpers/ServerHelperTest.php b/tests/Unit/Environment/Helpers/ServerHelperTest.php index a6464346b..520b2a0b3 100644 --- a/tests/Unit/Environment/Helpers/ServerHelperTest.php +++ b/tests/Unit/Environment/Helpers/ServerHelperTest.php @@ -14,7 +14,7 @@ public function setUp(): void $this->setPrivateProperty(Server::class, 'instance', null); } - public function testGetUserIpFromClientIp() + public function testGetUserIpFromClientIp(): void { $_SERVER['HTTP_CLIENT_IP'] = '192.168.1.1'; $_SERVER['HTTP_X_FORWARDED_FOR'] = null; @@ -23,7 +23,7 @@ public function testGetUserIpFromClientIp() $this->assertEquals('192.168.1.1', get_user_ip()); } - public function testGetUserIpFromXForwardedFor() + public function testGetUserIpFromXForwardedFor(): void { $_SERVER['HTTP_CLIENT_IP'] = null; $_SERVER['HTTP_X_FORWARDED_FOR'] = '203.0.113.5'; @@ -32,7 +32,7 @@ public function testGetUserIpFromXForwardedFor() $this->assertEquals('203.0.113.5', get_user_ip()); } - public function testGetUserIpFromRemoteAddr() + public function testGetUserIpFromRemoteAddr(): void { $_SERVER['HTTP_CLIENT_IP'] = null; $_SERVER['HTTP_X_FORWARDED_FOR'] = null; @@ -41,7 +41,7 @@ public function testGetUserIpFromRemoteAddr() $this->assertEquals('198.51.100.1', get_user_ip()); } - public function testGetAllHeaders() + public function testGetAllHeaders(): void { $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0'; $_SERVER['HTTP_ACCEPT'] = 'text/html'; diff --git a/tests/Unit/Environment/ServerTest.php b/tests/Unit/Environment/ServerTest.php index b216888e8..336398f06 100644 --- a/tests/Unit/Environment/ServerTest.php +++ b/tests/Unit/Environment/ServerTest.php @@ -14,7 +14,7 @@ public function setUp(): void $this->setPrivateProperty(Server::class, 'instance', null); } - public function testServerGetInstance() + public function testServerGetInstance(): void { $server1 = Server::getInstance(); $server2 = Server::getInstance(); @@ -22,7 +22,7 @@ public function testServerGetInstance() $this->assertSame($server1, $server2); } - public function testServerAll() + public function testServerAll(): void { $server = Server::getInstance(); $server->set('REQUEST_METHOD', 'GET'); @@ -37,7 +37,7 @@ public function testServerAll() $this->assertEquals('/test', $allServerData['REQUEST_URI']); } - public function testServerSetAndGet() + public function testServerSetAndGet(): void { $server = Server::getInstance(); @@ -52,7 +52,7 @@ public function testServerSetAndGet() $this->assertNull($server->get('NON_EXISTENT_KEY')); } - public function testServerUri() + public function testServerUri(): void { $server = Server::getInstance(); $server->set('REQUEST_URI', '/test/uri'); @@ -60,7 +60,7 @@ public function testServerUri() $this->assertEquals('/test/uri', $server->uri()); } - public function testServerQuery() + public function testServerQuery(): void { $server = Server::getInstance(); $server->set('QUERY_STRING', 'foo=bar'); @@ -68,7 +68,7 @@ public function testServerQuery() $this->assertEquals('foo=bar', $server->query()); } - public function testServerMethod() + public function testServerMethod(): void { $server = Server::getInstance(); $server->set('REQUEST_METHOD', 'PUT'); @@ -76,7 +76,7 @@ public function testServerMethod() $this->assertEquals('PUT', $server->method()); } - public function testServerProtocol() + public function testServerProtocol(): void { $server = Server::getInstance(); $server->set('HTTPS', 'on'); @@ -90,7 +90,7 @@ public function testServerProtocol() $this->assertEquals('http', $server->protocol()); } - public function testServerHost() + public function testServerHost(): void { $server = Server::getInstance(); $server->set('SERVER_NAME', 'localhost'); @@ -98,7 +98,7 @@ public function testServerHost() $this->assertEquals('localhost', $server->host()); } - public function testServerPort() + public function testServerPort(): void { $server = Server::getInstance(); $server->set('SERVER_PORT', '9000'); @@ -106,7 +106,7 @@ public function testServerPort() $this->assertEquals('9000', $server->port()); } - public function testServerContentType() + public function testServerContentType(): void { $server = Server::getInstance(); $server->set('CONTENT_TYPE', 'application/json; charset=utf-8'); @@ -115,7 +115,7 @@ public function testServerContentType() $this->assertEquals('application/json', $server->contentType(true)); } - public function testServerReferrer() + public function testServerReferrer(): void { $server = Server::getInstance(); $server->set('HTTP_REFERER', 'http://example.com'); @@ -123,7 +123,7 @@ public function testServerReferrer() $this->assertEquals('http://example.com', $server->referrer()); } - public function testServerAjax() + public function testServerAjax(): void { $server = Server::getInstance(); $server->set('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest'); @@ -135,7 +135,7 @@ public function testServerAjax() $this->assertFalse($server->ajax()); } - public function testServerGetUserIpFromRemoteAddr() + public function testServerGetUserIpFromRemoteAddr(): void { $server = Server::getInstance(); @@ -160,7 +160,7 @@ public function testServerGetUserIpFromRemoteAddr() $this->assertNull($server->ip()); } - public function testServerGetAllHeadersFromServerClass() + public function testServerGetAllHeadersFromServerClass(): void { $server = Server::getInstance(); @@ -182,7 +182,7 @@ public function testServerGetAllHeadersFromServerClass() $this->assertArrayNotHasKey('SERVER_NAME', $headers); } - public function testServerAcceptedLang() + public function testServerAcceptedLang(): void { $server = Server::getInstance(); diff --git a/tests/Unit/Hasher/HasherTest.php b/tests/Unit/Hasher/HasherTest.php index dee6b76f5..b2e149bde 100644 --- a/tests/Unit/Hasher/HasherTest.php +++ b/tests/Unit/Hasher/HasherTest.php @@ -7,9 +7,9 @@ class HasherTest extends AppTestCase { - private $hasher; - private $password = 'plaintext'; - private $otherPassword = 'other'; + private Hasher $hasher; + private string $password = 'plaintext'; + private string $otherPassword = 'other'; public function setUp(): void { @@ -18,7 +18,7 @@ public function setUp(): void $this->hasher = new Hasher(); } - public function testSetAndGetAlgorithm() + public function testSetAndGetAlgorithm(): void { $this->assertEquals(PASSWORD_BCRYPT, $this->hasher->getAlgorithm()); @@ -27,7 +27,7 @@ public function testSetAndGetAlgorithm() $this->assertEquals(PASSWORD_DEFAULT, $this->hasher->getAlgorithm()); } - public function testSetAndGetCost() + public function testSetAndGetCost(): void { $this->assertEquals(12, $this->hasher->getCost()); @@ -36,7 +36,7 @@ public function testSetAndGetCost() $this->assertEquals(14, $this->hasher->getCost()); } - public function testHashAndCheck() + public function testHashAndCheck(): void { $hashed = $this->hasher->hash($this->password); @@ -45,7 +45,7 @@ public function testHashAndCheck() $this->assertFalse($this->hasher->check($this->otherPassword, $hashed)); } - public function testNeedsRehash() + public function testNeedsRehash(): void { $this->hasher->setCost(10); @@ -62,7 +62,7 @@ public function testNeedsRehash() $this->assertTrue($this->hasher->needsRehash($hashed)); } - public function testInfo() + public function testInfo(): void { $hashed = $this->hasher->hash($this->password); diff --git a/tests/Unit/Hook/Helpers/HookHelperTest.php b/tests/Unit/Hook/Helpers/HookHelperTest.php index 17b1a2cbb..3eacea221 100644 --- a/tests/Unit/Hook/Helpers/HookHelperTest.php +++ b/tests/Unit/Hook/Helpers/HookHelperTest.php @@ -13,15 +13,15 @@ public function setUp(): void parent::setUp(); } - public function testHookHelperInstance() + public function testHookHelperInstance(): void { $this->assertInstanceOf(HookManager::class, hook()); } - public function testHookOnAndFire() + public function testHookOnAndFire(): void { $output = ''; - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'Data successfully saved'; }); @@ -30,10 +30,10 @@ public function testHookOnAndFire() $this->assertSame('Data successfully saved', $output); } - public function testHookFireWithArgument() + public function testHookFireWithArgument(): void { $output = ''; - hook()->on('SAVE', function ($data) use (&$output) { + hook()->on('SAVE', function (array $data) use (&$output): void { $output .= 'The file ' . $data['filename'] . ' was successfully saved'; }); @@ -42,14 +42,14 @@ public function testHookFireWithArgument() $this->assertSame('The file doc.pdf was successfully saved', $output); } - public function testHookMultipleListeners() + public function testHookMultipleListeners(): void { $output = ''; - hook()->on('SAVE', function ($data) use (&$output) { + hook()->on('SAVE', function (array $data) use (&$output): void { $output .= 'The file ' . $data['filename'] . ' was successfully saved' . PHP_EOL; }); - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'The email was successfully sent'; }); @@ -58,18 +58,18 @@ public function testHookMultipleListeners() $this->assertSame('The file doc.pdf was successfully saved' . PHP_EOL . 'The email was successfully sent', $output); } - public function testUnregisteredHookAtOn() + public function testUnregisteredHookAtOn(): void { $this->expectException(HookException::class); $this->expectExceptionMessage('The Hook `SOME_EVENT` was not registered.'); - hook()->on('SOME_EVENT', function () { + hook()->on('SOME_EVENT', function (): void { // No output needed }); } - public function testUnregisteredHookAtFire() + public function testUnregisteredHookAtFire(): void { $this->expectException(HookException::class); diff --git a/tests/Unit/Hook/HookManagerTest.php b/tests/Unit/Hook/HookManagerTest.php index 5c3cc921e..176665dc3 100644 --- a/tests/Unit/Hook/HookManagerTest.php +++ b/tests/Unit/Hook/HookManagerTest.php @@ -16,7 +16,7 @@ public function setUp(): void $this->setPrivateProperty(HookManager::class, 'store', []); } - public function testGetInstanceReturnsSameObject() + public function testGetInstanceReturnsSameObject(): void { $instance1 = HookManager::getInstance(); $instance2 = HookManager::getInstance(); @@ -25,10 +25,10 @@ public function testGetInstanceReturnsSameObject() $this->assertSame($instance1, $instance2); } - public function testOnAndFireOutputsCorrectly() + public function testOnAndFireOutputsCorrectly(): void { $output = ''; - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'Saved!'; }); @@ -37,12 +37,12 @@ public function testOnAndFireOutputsCorrectly() $this->assertSame('Saved!', $output); } - public function testFireWithArguments() + public function testFireWithArguments(): void { config()->set('hooks', ['NOTIFY']); $output = ''; - hook()->on('NOTIFY', function ($args) use (&$output) { + hook()->on('NOTIFY', function (array $args) use (&$output): void { $output .= 'Notified ' . $args['user']; }); @@ -51,14 +51,14 @@ public function testFireWithArguments() $this->assertSame('Notified John', $output); } - public function testMultipleListeners() + public function testMultipleListeners(): void { $output = ''; - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'A'; }); - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'B'; }); @@ -67,10 +67,10 @@ public function testMultipleListeners() $this->assertSame('AB', $output); } - public function testHookIsFiredOnlyOncePerListener() + public function testHookIsFiredOnlyOncePerListener(): void { $output = ''; - hook()->on('SAVE', function () use (&$output) { + hook()->on('SAVE', function () use (&$output): void { $output .= 'Once'; }); @@ -80,16 +80,16 @@ public function testHookIsFiredOnlyOncePerListener() $this->assertSame('Once', $output); } - public function testUnregisteredHookThrowsOnOn() + public function testUnregisteredHookThrowsOnOn(): void { $this->expectException(HookException::class); $this->expectExceptionMessage('The Hook `INVALID` was not registered.'); - hook()->on('INVALID', function () { + hook()->on('INVALID', function (): void { }); } - public function testUnregisteredHookThrowsOnFire() + public function testUnregisteredHookThrowsOnFire(): void { $this->expectException(HookException::class); $this->expectExceptionMessage('The Hook `INVALID` was not registered.'); @@ -97,9 +97,9 @@ public function testUnregisteredHookThrowsOnFire() hook()->fire('INVALID'); } - public function testGetRegisteredReturnsHookStore() + public function testGetRegisteredReturnsHookStore(): void { - hook()->on('SAVE', function () { + hook()->on('SAVE', function (): void { }); $store = HookManager::getRegistered(); diff --git a/tests/Unit/Http/Helpers/HttpHelperTest.php b/tests/Unit/Http/Helpers/HttpHelperTest.php index de224f2d9..c19f44db0 100644 --- a/tests/Unit/Http/Helpers/HttpHelperTest.php +++ b/tests/Unit/Http/Helpers/HttpHelperTest.php @@ -15,8 +15,8 @@ class HttpHelperTest extends AppTestCase { public $session; - private $request; - private $response; + private Request $request; + private Response $response; public function setUp(): void { @@ -34,7 +34,7 @@ public function tearDown(): void Request::flush(); } - public function testBaseUrlWithoutModulePrefix() + public function testBaseUrlWithoutModulePrefix(): void { config()->set('app.base_url', null); @@ -43,7 +43,7 @@ public function testBaseUrlWithoutModulePrefix() $this->assertEquals('https://example.com', base_url()); } - public function testBaseUrlWithModulePrefix() + public function testBaseUrlWithModulePrefix(): void { config()->set('app.base_url', null); @@ -53,8 +53,7 @@ public function testBaseUrlWithModulePrefix() ['GET'], '/signin', 'AdminController', - 'signin', - null + 'signin' ); $route->module('admin')->prefix('admin'); @@ -82,7 +81,7 @@ public function testBaseUrlWithModulePrefix() $this->assertEquals('https://testdomain.com/admin', $baseUrl); } - public function testCurrentUrl() + public function testCurrentUrl(): void { $this->request->create('GET', 'http://test.com/post/12'); @@ -97,7 +96,7 @@ public function testCurrentUrl() $this->assertEquals('http://test.com:8080/?firstname=John&lastname=Doe', current_url()); } - public function testRedirecting() + public function testRedirecting(): void { $this->assertFalse($this->response->hasHeader('Location')); @@ -112,7 +111,7 @@ public function testRedirecting() $this->assertEquals('/home', $this->response->getHeader('Location')); } - public function testRedirectWithOldData() + public function testRedirectWithOldData(): void { $this->session = SessionFactory::get(); diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php index b61c0cce4..f48e73846 100644 --- a/tests/Unit/Http/RequestTest.php +++ b/tests/Unit/Http/RequestTest.php @@ -19,7 +19,7 @@ public function tearDown(): void HttpRequest::flush(); } - public function testSetGetMethod() + public function testSetGetMethod(): void { $request = new Request(); @@ -32,7 +32,7 @@ public function testSetGetMethod() $this->assertEquals('POST', $request->getMethod()); } - public function testIsMethod() + public function testIsMethod(): void { $request = new Request(); @@ -51,7 +51,7 @@ public function testIsMethod() $this->assertTrue($request->isMethod('post')); } - public function testGetCsrfToken() + public function testGetCsrfToken(): void { $request = new Request(); diff --git a/tests/Unit/Http/ResponseTest.php b/tests/Unit/Http/ResponseTest.php index c5210da97..b4f5aed74 100644 --- a/tests/Unit/Http/ResponseTest.php +++ b/tests/Unit/Http/ResponseTest.php @@ -21,7 +21,7 @@ public function tearDown(): void Response::flush(); } - public function testResponseContentType() + public function testResponseContentType(): void { $response = new Response(); @@ -32,7 +32,7 @@ public function testResponseContentType() $this->assertEquals(ContentType::JSON, $response->getContentType()); } - public function testResponseRedirect() + public function testResponseRedirect(): void { $response = new Response(); diff --git a/tests/Unit/Http/Traits/Request/HttpRawInputTest.php b/tests/Unit/Http/Traits/Request/HttpRawInputTest.php index b33d0087f..62194452e 100644 --- a/tests/Unit/Http/Traits/Request/HttpRawInputTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRawInputTest.php @@ -19,7 +19,7 @@ public function tearDown(): void parent::tearDown(); } - public function testParseReturnsEmptyWhenNoBoundary() + public function testParseReturnsEmptyWhenNoBoundary(): void { Server::getInstance()->set('CONTENT_TYPE', null); @@ -28,7 +28,7 @@ public function testParseReturnsEmptyWhenNoBoundary() $this->assertEquals(['params' => [], 'files' => []], $result); } - public function testParseWithParameterBlock() + public function testParseWithParameterBlock(): void { $boundary = '----BoundaryTestParam'; $rawInput = "--$boundary\r\n" @@ -46,7 +46,7 @@ public function testParseWithParameterBlock() $this->assertEquals('JohnDoe', $result['params']['username']); } - public function testParseWithStreamBlock() + public function testParseWithStreamBlock(): void { $boundary = '----BoundaryStreamTest'; @@ -66,7 +66,7 @@ public function testParseWithStreamBlock() $this->assertEquals('stream-data', $result['params']['payload']); } - public function testParseWithFileBlock() + public function testParseWithFileBlock(): void { $boundary = '----BoundaryFileTest'; $fileContent = 'file-content'; diff --git a/tests/Unit/Http/Traits/Request/HttpRequestBodyTest.php b/tests/Unit/Http/Traits/Request/HttpRequestBodyTest.php index a40ae1e4c..cc3c809a0 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestBodyTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestBodyTest.php @@ -17,7 +17,7 @@ public function tearDown(): void Request::flush(); } - public function testRequestSetHasGetDelete() + public function testRequestSetHasGetDelete(): void { $request = new Request(); @@ -50,7 +50,7 @@ public function testRequestSetHasGetDelete() $this->assertEquals('

    Big text

    ', $content['message']); } - public function testRequestAll() + public function testRequestAll(): void { $request = new Request(); diff --git a/tests/Unit/Http/Traits/Request/HttpRequestFileTest.php b/tests/Unit/Http/Traits/Request/HttpRequestFileTest.php index 1de1a9630..3ffcdde0c 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestFileTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestFileTest.php @@ -19,7 +19,7 @@ public function tearDown(): void Request::flush(); } - public function testHasGetFile() + public function testHasGetFile(): void { $request = new Request(); @@ -60,7 +60,7 @@ public function testHasGetFile() $request->getFile('image'); } - public function testGetMultipleFiles() + public function testGetMultipleFiles(): void { $request = new Request(); diff --git a/tests/Unit/Http/Traits/Request/HttpRequestHeaderTest.php b/tests/Unit/Http/Traits/Request/HttpRequestHeaderTest.php index 69bdd5d4b..674577961 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestHeaderTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestHeaderTest.php @@ -22,7 +22,7 @@ public function tearDown(): void Server::getInstance()->flush(); } - public function testRequestHeaderSetHasGetDelete() + public function testRequestHeaderSetHasGetDelete(): void { $request = new Request(); @@ -39,7 +39,7 @@ public function testRequestHeaderSetHasGetDelete() $this->assertNotEquals('Custom', $request->get('X-CUSTOM')); } - public function testRequestHeaderAll() + public function testRequestHeaderAll(): void { $request = new Request(); @@ -52,7 +52,7 @@ public function testRequestHeaderAll() $this->assertIsArray($request->allHeaders()); } - public function testGetAuthorizationBearer() + public function testGetAuthorizationBearer(): void { $request = new Request(); @@ -67,7 +67,7 @@ public function testGetAuthorizationBearer() $this->assertEquals($bearerToken, $request->getAuthorizationBearer()); } - public function testGetBasicAuthCredentialsFromServer() + public function testGetBasicAuthCredentialsFromServer(): void { $request = new Request(); @@ -93,7 +93,7 @@ public function testGetBasicAuthCredentialsFromServer() unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } - public function testGetBasicAuthCredentialsFromHeader() + public function testGetBasicAuthCredentialsFromHeader(): void { $request = new Request(); @@ -116,7 +116,7 @@ public function testGetBasicAuthCredentialsFromHeader() $this->assertEquals($password, $result['password']); } - public function testIsAjaxReturnsTrueWhenHeaderIsSet() + public function testIsAjaxReturnsTrueWhenHeaderIsSet(): void { $request = new Request(); @@ -127,7 +127,7 @@ public function testIsAjaxReturnsTrueWhenHeaderIsSet() $this->assertTrue($request->isAjax()); } - public function testIsAjaxReturnsTrueFromServerWhenHeaderIsMissing() + public function testIsAjaxReturnsTrueFromServerWhenHeaderIsMissing(): void { $request = new Request(); @@ -138,7 +138,7 @@ public function testIsAjaxReturnsTrueFromServerWhenHeaderIsMissing() $this->assertTrue($request->isAjax()); } - public function testGetReferrer() + public function testGetReferrer(): void { $this->assertNull(Request::getReferrer()); diff --git a/tests/Unit/Http/Traits/Request/HttpRequestInternalTest.php b/tests/Unit/Http/Traits/Request/HttpRequestInternalTest.php index 47b6a37b3..973a1c6f4 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestInternalTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestInternalTest.php @@ -15,7 +15,7 @@ public function setUp(): void parent::setUp(); } - public function testCreateRequestSetsBasicServerParams() + public function testCreateRequestSetsBasicServerParams(): void { Request::create('GET', 'https://example.com/test/path?foo=bar'); @@ -31,7 +31,7 @@ public function testCreateRequestSetsBasicServerParams() $this->assertEquals('foo=bar', $server->get('QUERY_STRING')); } - public function testContentTypeIsMultipartWhenFilesProvided() + public function testContentTypeIsMultipartWhenFilesProvided(): void { $files = [ 'file' => [ @@ -48,21 +48,21 @@ public function testContentTypeIsMultipartWhenFilesProvided() $this->assertEquals('multipart/form-data', Server::getInstance()->get('CONTENT_TYPE')); } - public function testContentTypeIsFormUrlencodedWhenDataProvided() + public function testContentTypeIsFormUrlencodedWhenDataProvided(): void { Request::create('POST', 'http://localhost/form', ['key' => 'value']); $this->assertEquals('application/x-www-form-urlencoded', Server::getInstance()->get('CONTENT_TYPE')); } - public function testContentTypeIsTextHtmlWhenNoDataOrFiles() + public function testContentTypeIsTextHtmlWhenNoDataOrFiles(): void { Request::create('GET', 'http://localhost'); $this->assertEquals('text/html', Server::getInstance()->get('CONTENT_TYPE')); } - public function testRequestParamsAreSet() + public function testRequestParamsAreSet(): void { $data = ['foo' => 'bar']; @@ -71,7 +71,7 @@ public function testRequestParamsAreSet() $this->assertEquals('bar', HttpRequest::get('foo')); } - public function testUploadedFilesAreSet() + public function testUploadedFilesAreSet(): void { $files = [ 'document' => [ diff --git a/tests/Unit/Http/Traits/Request/HttpRequestQueryTest.php b/tests/Unit/Http/Traits/Request/HttpRequestQueryTest.php index 62115b293..3cdeb7760 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestQueryTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestQueryTest.php @@ -17,7 +17,7 @@ public function tearDown(): void Request::flush(); } - public function testSetGetQuery() + public function testSetGetQuery(): void { $request = new Request(); @@ -34,7 +34,7 @@ public function testSetGetQuery() $this->assertEquals('age=30&gender=male', $request->getQuery()); } - public function testSetGetQueryParam() + public function testSetGetQueryParam(): void { $request = new Request(); diff --git a/tests/Unit/Http/Traits/Request/HttpRequestRouteTest.php b/tests/Unit/Http/Traits/Request/HttpRequestRouteTest.php index 99f3b252d..1c8efcf10 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestRouteTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestRouteTest.php @@ -24,19 +24,18 @@ public function tearDown(): void parent::tearDown(); } - public function testGetMatchedRouteReturnsNullByDefault() + public function testGetMatchedRouteReturnsNullByDefault(): void { $this->assertNull(Request::getMatchedRoute()); } - public function testSetAndGetMatchedRoute() + public function testSetAndGetMatchedRoute(): void { $route = new Route( ['GET'], '/test', 'TestController', - 'tests', - null + 'tests' ); $matched = new MatchedRoute($route, ['id' => 1]); @@ -46,14 +45,13 @@ public function testSetAndGetMatchedRoute() $this->assertSame($matched, Request::getMatchedRoute()); } - public function testSetMatchedRouteToNullResetsState() + public function testSetMatchedRouteToNullResetsState(): void { $route = new Route( ['GET'], '/test', 'TestController', - 'tests', - null + 'tests' ); $matched = new MatchedRoute($route, []); diff --git a/tests/Unit/Http/Traits/Request/HttpRequestUrlTest.php b/tests/Unit/Http/Traits/Request/HttpRequestUrlTest.php index 4755add01..026ed0e7c 100644 --- a/tests/Unit/Http/Traits/Request/HttpRequestUrlTest.php +++ b/tests/Unit/Http/Traits/Request/HttpRequestUrlTest.php @@ -17,7 +17,7 @@ public function tearDown(): void Request::flush(); } - public function testSetGetProtocol() + public function testSetGetProtocol(): void { $request = new Request(); @@ -30,7 +30,7 @@ public function testSetGetProtocol() $this->assertEquals('http', $request->getProtocol()); } - public function testSetGetHost() + public function testSetGetHost(): void { $request = new Request(); @@ -43,7 +43,7 @@ public function testSetGetHost() $this->assertEquals('tester.com', $request->getHost()); } - public function testSetGetPort() + public function testSetGetPort(): void { $request = new Request(); @@ -56,7 +56,7 @@ public function testSetGetPort() $this->assertEquals('9000', $request->getPort()); } - public function testSetGetUri() + public function testSetGetUri(): void { $request = new Request(); @@ -69,7 +69,7 @@ public function testSetGetUri() $this->assertEquals('post/edit/12', $request->getUri()); } - public function testGetSegments() + public function testGetSegments(): void { $request = new Request(); diff --git a/tests/Unit/Http/Traits/Response/HttpResponseBodyTest.php b/tests/Unit/Http/Traits/Response/HttpResponseBodyTest.php index b49d09b69..e32beb606 100644 --- a/tests/Unit/Http/Traits/Response/HttpResponseBodyTest.php +++ b/tests/Unit/Http/Traits/Response/HttpResponseBodyTest.php @@ -17,7 +17,7 @@ public function tearDown(): void Response::flush(); } - public function testResponseSetHasGetAllDelete() + public function testResponseSetHasGetAllDelete(): void { $response = new Response(); @@ -42,7 +42,7 @@ public function testResponseSetHasGetAllDelete() $this->assertEquals('Jane', $response->get('name', 'Jane')); } - public function testResponseJsonContent() + public function testResponseJsonContent(): void { $response = new Response(); @@ -68,7 +68,7 @@ public function testResponseJsonContent() $this->assertEquals(200, $response->getStatusCode()); } - public function testResponseJsonP() + public function testResponseJsonP(): void { $response = new Response(); @@ -81,7 +81,7 @@ public function testResponseJsonP() $this->assertEquals('myfunc({"firstname":"John","lastname":"Doe"})', $response->getContent()); } - public function testResponseXmlContent() + public function testResponseXmlContent(): void { $response = new Response(); @@ -127,7 +127,7 @@ public function testResponseXmlContent() $this->assertEquals($xml, $response->getContent()); } - public function testResponseXmlWithNestedArray() + public function testResponseXmlWithNestedArray(): void { $response = new Response(); @@ -149,7 +149,7 @@ public function testResponseXmlWithNestedArray() $this->assertEquals($xml, $response->getContent()); } - public function testResponseXmlWithArguments() + public function testResponseXmlWithArguments(): void { $response = new Response(); @@ -171,7 +171,7 @@ public function testResponseXmlWithArguments() $this->assertEquals($xml, $response->getContent()); } - public function testResponseXmlWithCustomRoot() + public function testResponseXmlWithCustomRoot(): void { $response = new Response(); @@ -193,7 +193,7 @@ public function testResponseXmlWithCustomRoot() $this->assertEquals($xml, $response->getContent()); } - public function testResponseHtmlContent() + public function testResponseHtmlContent(): void { $response = new Response(); diff --git a/tests/Unit/Http/Traits/Response/HttpResponseHeaderTest.php b/tests/Unit/Http/Traits/Response/HttpResponseHeaderTest.php index dfffe8d70..71f61a8a9 100644 --- a/tests/Unit/Http/Traits/Response/HttpResponseHeaderTest.php +++ b/tests/Unit/Http/Traits/Response/HttpResponseHeaderTest.php @@ -13,7 +13,7 @@ public function setUp(): void } - public function testResponseHeaderSetHasGetAllDelete() + public function testResponseHeaderSetHasGetAllDelete(): void { $response = new Response(); diff --git a/tests/Unit/Http/Traits/Response/HttpResponseStatusTest.php b/tests/Unit/Http/Traits/Response/HttpResponseStatusTest.php index 3255ecd93..1f35302cf 100644 --- a/tests/Unit/Http/Traits/Response/HttpResponseStatusTest.php +++ b/tests/Unit/Http/Traits/Response/HttpResponseStatusTest.php @@ -12,7 +12,7 @@ public function setUp(): void parent::setUp(); } - public function testResponseStatus() + public function testResponseStatus(): void { $response = new Response(); @@ -25,7 +25,7 @@ public function testResponseStatus() $this->assertEquals('Moved Permanently', $response->getStatusText()); } - public function testHttpStatusGetText() + public function testHttpStatusGetText(): void { $response = new Response(); diff --git a/tests/Unit/HttpClient/HttpClientTest.php b/tests/Unit/HttpClient/HttpClientTest.php index ea24b7938..c0ed19cdb 100644 --- a/tests/Unit/HttpClient/HttpClientTest.php +++ b/tests/Unit/HttpClient/HttpClientTest.php @@ -28,7 +28,7 @@ public function tearDown(): void parent::tearDown(); } - public function testHttpClientGetSetMethod() + public function testHttpClientGetSetMethod(): void { $this->assertEquals('GET', $this->httpClient->getMethod()); @@ -41,7 +41,7 @@ public function testHttpClientGetSetMethod() $this->httpClient->setMethod('NOPE'); } - public function testHttpClientGetSetData() + public function testHttpClientGetSetData(): void { $this->assertNull($this->httpClient->getData()); @@ -52,7 +52,7 @@ public function testHttpClientGetSetData() $this->assertSame($data, $this->httpClient->getData()); } - public function testHttpClientIsMultiRequest() + public function testHttpClientIsMultiRequest(): void { $curl = Mockery::mock(Curl::class); @@ -71,14 +71,14 @@ public function testHttpClientIsMultiRequest() $this->assertTrue($this->httpClient->isMultiRequest()); } - public function testHttpClientRequestNotCreated() + public function testHttpClientRequestNotCreated(): void { $this->expectException(HttpClientException::class); $this->httpClient->start(); } - public function testHttpClientEnsureSingleRequestThrowsOnMulti() + public function testHttpClientEnsureSingleRequestThrowsOnMulti(): void { $multi = Mockery::mock(MultiCurl::class); @@ -91,7 +91,7 @@ public function testHttpClientEnsureSingleRequestThrowsOnMulti() $this->httpClient->getRequestHeaders(); } - public function testHttpClientSingleRequestResponseFlow() + public function testHttpClientSingleRequestResponseFlow(): void { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('setUrl')->once(); @@ -115,7 +115,7 @@ public function testHttpClientSingleRequestResponseFlow() $this->assertEquals('ok', $this->httpClient->getResponseBody()); } - public function testHttpClientPostRequestWithData() + public function testHttpClientPostRequestWithData(): void { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('setUrl')->once(); @@ -138,7 +138,7 @@ public function testHttpClientPostRequestWithData() $this->assertEquals('ok', $this->httpClient->getResponseBody()->status); } - public function testHttpClientSingleRequestError() + public function testHttpClientSingleRequestError(): void { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('setUrl')->once(); @@ -163,12 +163,12 @@ public function testHttpClientSingleRequestError() $this->assertEquals('DNS error', $errors['message']); } - public function testHttpClientMultiRequestResponseStructure() + public function testHttpClientMultiRequestResponseStructure(): void { $multi = Mockery::mock(MultiCurl::class); $multi->shouldReceive('complete') ->once() - ->andReturnUsing(function ($callback) { + ->andReturnUsing(function ($callback): void { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('isError')->andReturn(false); $curl->shouldReceive('getId')->andReturn(0); @@ -192,12 +192,12 @@ public function testHttpClientMultiRequestResponseStructure() $this->assertArrayHasKey('body', $response[0]); } - public function testHttpClientMultiRequestAggregatesErrors() + public function testHttpClientMultiRequestAggregatesErrors(): void { $multi = Mockery::mock(MultiCurl::class); $multi->shouldReceive('complete') ->once() - ->andReturnUsing(function ($callback) { + ->andReturnUsing(function ($callback): void { foreach ([0, 1] as $id) { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('isError')->andReturn(true); @@ -223,7 +223,7 @@ public function testHttpClientMultiRequestAggregatesErrors() $this->assertEquals(6, $errors[1]['code']); } - public function testHttpClientCreateAsyncMultiRequestRegistersCallbacks() + public function testHttpClientCreateAsyncMultiRequestRegistersCallbacks(): void { $success = fn () => null; $error = fn () => null; @@ -237,7 +237,7 @@ public function testHttpClientCreateAsyncMultiRequestRegistersCallbacks() $this->assertTrue($this->httpClient->isMultiRequest()); } - public function testHttpClientInfoAndUrl() + public function testHttpClientInfoAndUrl(): void { $curl = Mockery::mock(Curl::class); $curl->shouldReceive('setUrl')->once(); diff --git a/tests/Unit/JWToken/JWTokenTest.php b/tests/Unit/JWToken/JWTokenTest.php index d7fa31b8c..0d801d3a8 100644 --- a/tests/Unit/JWToken/JWTokenTest.php +++ b/tests/Unit/JWToken/JWTokenTest.php @@ -7,11 +7,11 @@ class JWTokenTest extends AppTestCase { - private $jwtToken; + private JwtToken $jwtToken; private $key = 'appkey'; - private $userData = [ + private array $userData = [ 'userId' => 'b08f86af-35da-48f2-8fab-cef3904660bd', 'userFirstName' => 'John', 'userLastName' => 'Doe', @@ -39,12 +39,12 @@ public function setUp(): void ->setClaims($claims); } - public function testCompose() + public function testCompose(): void { $this->assertStringMatchesFormat('%s.%s.%s', $this->jwtToken->compose()); } - public function testSetAlgorithm() + public function testSetAlgorithm(): void { $jwtEncoded = $this->jwtToken->setAlgorithm('HS512')->compose(); @@ -58,10 +58,10 @@ public function testSetAlgorithm() $this->assertNotEmpty($this->jwtToken->fetchPayload()); - $jwtEncoded = $this->jwtToken->setAlgorithm('HS512')->compose(); + $this->jwtToken->setAlgorithm('HS512')->compose(); } - public function testRetrieveFetchPayload() + public function testRetrieveFetchPayload(): void { $this->assertEmpty($this->jwtToken->fetchPayload()); @@ -72,7 +72,7 @@ public function testRetrieveFetchPayload() $this->assertNotEmpty($this->jwtToken->fetchPayload()); } - public function testSetFetchData() + public function testSetFetchData(): void { $this->assertNull($this->jwtToken->fetchData()); @@ -86,7 +86,7 @@ public function testSetFetchData() } - public function testSetFetchClaim() + public function testSetFetchClaim(): void { $jwtEncoded = $this->jwtToken->setAlgorithm('HS256')->compose(); @@ -110,7 +110,7 @@ public function testSetFetchClaim() } - public function testSetClaims() + public function testSetClaims(): void { $jwtToken = new JwtToken($this->key); diff --git a/tests/Unit/Lang/Factories/LangFactoryTest.php b/tests/Unit/Lang/Factories/LangFactoryTest.php index 79b4d56cf..02910fee7 100644 --- a/tests/Unit/Lang/Factories/LangFactoryTest.php +++ b/tests/Unit/Lang/Factories/LangFactoryTest.php @@ -16,7 +16,7 @@ public function setUp(): void $this->setPrivateProperty(LangFactory::class, 'instance', null); } - public function testLangFactoryGetLangInstance() + public function testLangFactoryGetLangInstance(): void { $lang = LangFactory::get(); @@ -27,7 +27,7 @@ public function testLangFactoryGetLangInstance() $this->assertTrue($lang->isEnabled()); } - public function testLangFactoryGetReturnsSameInstance() + public function testLangFactoryGetReturnsSameInstance(): void { $first = LangFactory::get(); @@ -36,7 +36,7 @@ public function testLangFactoryGetReturnsSameInstance() $this->assertSame($first, $second); } - public function testLangFactoryDetectedFromRouteParameter() + public function testLangFactoryDetectedFromRouteParameter(): void { $this->testRequest('http://127.0.0.1/es/api/rest'); @@ -45,7 +45,7 @@ public function testLangFactoryDetectedFromRouteParameter() $this->assertEquals('es', $lang->getLang()); } - public function testLangFactoryDetectedFromQueryParameter() + public function testLangFactoryDetectedFromQueryParameter(): void { $this->testRequest('http://127.0.0.1/api/rest?lang=es'); @@ -54,7 +54,7 @@ public function testLangFactoryDetectedFromQueryParameter() $this->assertEquals('es', $lang->getLang()); } - public function testLangFactoryDetectedFromAcceptedLangParameter() + public function testLangFactoryDetectedFromAcceptedLangParameter(): void { $this->testRequest('http://127.0.0.1/api/rest', 'GET', [], ['Accept-Language' => 'es, en;q=0.8, fr;q=0.6']); @@ -63,7 +63,7 @@ public function testLangFactoryDetectedFromAcceptedLangParameter() $this->assertEquals('es', $lang->getLang()); } - public function testLangFactoryFallsBackToDefaultIfNoLangDetected() + public function testLangFactoryFallsBackToDefaultIfNoLangDetected(): void { $this->testRequest('http://127.0.0.1/api/rest'); @@ -72,7 +72,7 @@ public function testLangFactoryFallsBackToDefaultIfNoLangDetected() $this->assertEquals('en', $lang->getLang()); } - public function testLangFactoryFallsBackToDefaultIfProvidedLangIsNotSupported() + public function testLangFactoryFallsBackToDefaultIfProvidedLangIsNotSupported(): void { config()->set('lang', [ 'enabled' => true, @@ -104,7 +104,7 @@ public function testLangFactoryFallsBackToDefaultIfProvidedLangIsNotSupported() $this->assertEquals('en', $lang->getLang()); } - public function testLangFactoryThrowsErrorIfNoDefaultLangFound() + public function testLangFactoryThrowsErrorIfNoDefaultLangFound(): void { config()->set('lang', [ 'enabled' => true, diff --git a/tests/Unit/Lang/Helpers/LangHelperFunctionsTest.php b/tests/Unit/Lang/Helpers/LangHelperFunctionsTest.php index f7f21527d..46981484f 100644 --- a/tests/Unit/Lang/Helpers/LangHelperFunctionsTest.php +++ b/tests/Unit/Lang/Helpers/LangHelperFunctionsTest.php @@ -3,11 +3,12 @@ namespace Quantum\Tests\Unit\Lang\Helpers; use Quantum\Lang\Factories\LangFactory; +use Quantum\Lang\Lang; use Quantum\Tests\Unit\AppTestCase; class LangHelperFunctionsTest extends AppTestCase { - private $lang; + private Lang $lang; public function setUp(): void { @@ -20,7 +21,7 @@ public function setUp(): void $this->lang->load(); } - public function testLangHelperCurrentLang() + public function testLangHelperCurrentLang(): void { $this->assertEquals('en', current_lang()); @@ -29,14 +30,14 @@ public function testLangHelperCurrentLang() $this->assertEquals('am', current_lang()); } - public function testLangHelperT() + public function testLangHelperT(): void { $this->assertEquals('Testing', t('custom.test')); $this->assertEquals('Information about the new feature', t('custom.info', ['new'])); } - public function testLangHelperUnderscoreT() + public function testLangHelperUnderscoreT(): void { ob_start(); @@ -47,7 +48,7 @@ public function testLangHelperUnderscoreT() $this->assertEquals('Testing', $output); } - public function testLangHelperTFail() + public function testLangHelperTFail(): void { $this->assertEquals('custom.non_existing_key', t('custom.non_existing_key')); } diff --git a/tests/Unit/Lang/LangTest.php b/tests/Unit/Lang/LangTest.php index 1b4c86ca1..35141829e 100644 --- a/tests/Unit/Lang/LangTest.php +++ b/tests/Unit/Lang/LangTest.php @@ -12,7 +12,7 @@ class LangTest extends AppTestCase { - private $lang; + private Lang $lang; public function setUp(): void { @@ -25,8 +25,7 @@ public function setUp(): void ['POST'], '/api-signin', 'SomeController', - 'signin', - null + 'signin' ); $route->module('Test'); @@ -40,7 +39,7 @@ public function setUp(): void } } - public function testLangGetSet() + public function testLangGetSet(): void { $this->assertEquals('en', $this->lang->getLang()); diff --git a/tests/Unit/Loader/LoaderTest.php b/tests/Unit/Loader/LoaderTest.php index 58d399db0..6491db7c8 100644 --- a/tests/Unit/Loader/LoaderTest.php +++ b/tests/Unit/Loader/LoaderTest.php @@ -8,7 +8,7 @@ class LoaderTest extends AppTestCase { - private $loader; + private Loader $loader; public function setUp(): void { @@ -17,7 +17,7 @@ public function setUp(): void $this->loader = new Loader(); } - public function testLoaderFileExists() + public function testLoaderFileExists(): void { $this->loader->setup(new Setup('config', 'app')); @@ -28,7 +28,7 @@ public function testLoaderFileExists() $this->assertFalse($this->loader->fileExists()); } - public function testLoaderSetupAndLoad() + public function testLoaderSetupAndLoad(): void { $this->loader->setup(new Setup('config', 'app')); diff --git a/tests/Unit/Loader/SetupTest.php b/tests/Unit/Loader/SetupTest.php index 6158fc205..3dc94cbc6 100644 --- a/tests/Unit/Loader/SetupTest.php +++ b/tests/Unit/Loader/SetupTest.php @@ -7,7 +7,7 @@ class SetupTest extends AppTestCase { - private $setup; + private Setup $setup; public function setUp(): void { @@ -21,7 +21,7 @@ public function tearDown(): void unset($this->setup); } - public function testSetupConstructor() + public function testSetupConstructor(): void { $setup = new Setup('config', 'database'); @@ -34,35 +34,35 @@ public function testSetupConstructor() $this->assertEquals('File `' . $setup->getPathPrefix() . DS . $setup->getFilename() . '` not found!', $setup->getExceptionMessage()); } - public function testSetGetPathPrefix() + public function testSetGetPathPrefix(): void { $this->setup->setPathPrefix('config'); $this->assertEquals('config', $this->setup->getPathPrefix()); } - public function testSetGetFilename() + public function testSetGetFilename(): void { $this->setup->setFilename('users'); $this->assertEquals('users', $this->setup->getFilename()); } - public function testSetGetHierarchy() + public function testSetGetHierarchy(): void { $this->setup->setHierarchy(true); $this->assertTrue($this->setup->getHierarchy()); } - public function testSetGetModule() + public function testSetGetModule(): void { $this->setup->setModule('admin'); $this->assertEquals('admin', $this->setup->getModule()); } - public function testSetGetExceptionMessage() + public function testSetGetExceptionMessage(): void { $this->setup->setExceptionMessage('Action not allowed'); diff --git a/tests/Unit/Logger/Adapters/DailyAdapterTest.php b/tests/Unit/Logger/Adapters/DailyAdapterTest.php index 4a9bee4f1..daac9bf01 100644 --- a/tests/Unit/Logger/Adapters/DailyAdapterTest.php +++ b/tests/Unit/Logger/Adapters/DailyAdapterTest.php @@ -8,7 +8,7 @@ class DailyAdapterTest extends AppTestCase { - private $adapter; + private DailyAdapter $adapter; public function setUp(): void { @@ -19,12 +19,12 @@ public function setUp(): void ]); } - public function testDailyAdapterInstance() + public function testDailyAdapterInstance(): void { $this->assertInstanceOf(DailyAdapter::class, $this->adapter); } - public function testDailyAdapterConstructorThrowsExceptionForInvalidPath() + public function testDailyAdapterConstructorThrowsExceptionForInvalidPath(): void { $this->expectException(LoggerException::class); @@ -33,7 +33,7 @@ public function testDailyAdapterConstructorThrowsExceptionForInvalidPath() ]); } - public function testDailyAdapterReportWritesToFile() + public function testDailyAdapterReportWritesToFile(): void { $level = 'info'; $message = 'Test log message'; diff --git a/tests/Unit/Logger/Adapters/MessageAdapterTest.php b/tests/Unit/Logger/Adapters/MessageAdapterTest.php index 33fcd11d5..844d8897a 100644 --- a/tests/Unit/Logger/Adapters/MessageAdapterTest.php +++ b/tests/Unit/Logger/Adapters/MessageAdapterTest.php @@ -9,8 +9,8 @@ class MessageAdapterTest extends AppTestCase { - private $adapter; - private $debugger; + private MessageAdapter $adapter; + private Debugger $debugger; public function setUp(): void { @@ -25,7 +25,7 @@ public function setUp(): void $this->adapter = new MessageAdapter(); } - public function testReportAddsMessageToDebuggerStore() + public function testReportAddsMessageToDebuggerStore(): void { $level = 'info'; $message = 'Test message'; diff --git a/tests/Unit/Logger/Adapters/SingleAdapterTest.php b/tests/Unit/Logger/Adapters/SingleAdapterTest.php index 50afb8c5e..98785210f 100644 --- a/tests/Unit/Logger/Adapters/SingleAdapterTest.php +++ b/tests/Unit/Logger/Adapters/SingleAdapterTest.php @@ -8,7 +8,7 @@ class SingleAdapterTest extends AppTestCase { - private $adapter; + private SingleAdapter $adapter; public function setUp(): void { @@ -19,12 +19,12 @@ public function setUp(): void ]); } - public function testSingleAdapterInstance() + public function testSingleAdapterInstance(): void { $this->assertInstanceOf(SingleAdapter::class, $this->adapter); } - public function testSingleAdapterConstructorThrowsExceptionForInvalidPath() + public function testSingleAdapterConstructorThrowsExceptionForInvalidPath(): void { $this->expectException(LoggerException::class); @@ -33,7 +33,7 @@ public function testSingleAdapterConstructorThrowsExceptionForInvalidPath() ]); } - public function testSingleAdapterReportWritesToFile() + public function testSingleAdapterReportWritesToFile(): void { $level = 'info'; $message = 'Test log message'; diff --git a/tests/Unit/Logger/Factories/LoggerFactoryTest.php b/tests/Unit/Logger/Factories/LoggerFactoryTest.php index 7e04c1cc4..92fa0a4c0 100644 --- a/tests/Unit/Logger/Factories/LoggerFactoryTest.php +++ b/tests/Unit/Logger/Factories/LoggerFactoryTest.php @@ -22,14 +22,14 @@ public function setUp(): void $this->setPrivateProperty(LoggerFactory::class, 'instances', []); } - public function testLoggerFactoryInstance() + public function testLoggerFactoryInstance(): void { $logger = LoggerFactory::get(); $this->assertInstanceOf(Logger::class, $logger); } - public function testLoggerFactoryGetDefaultAdapter() + public function testLoggerFactoryGetDefaultAdapter(): void { $logger = LoggerFactory::get(); @@ -38,7 +38,7 @@ public function testLoggerFactoryGetDefaultAdapter() $this->assertInstanceOf(ReportableInterface::class, $logger->getAdapter()); } - public function testLoggerFactoryGetSingleAdapter() + public function testLoggerFactoryGetSingleAdapter(): void { $logger = LoggerFactory::get(Logger::SINGLE); @@ -47,7 +47,7 @@ public function testLoggerFactoryGetSingleAdapter() $this->assertInstanceOf(ReportableInterface::class, $logger->getAdapter()); } - public function testLoggerFactoryGetDailyAdapter() + public function testLoggerFactoryGetDailyAdapter(): void { $logger = LoggerFactory::get(Logger::DAILY); @@ -56,7 +56,7 @@ public function testLoggerFactoryGetDailyAdapter() $this->assertInstanceOf(ReportableInterface::class, $logger->getAdapter()); } - public function testLoggerFactoryGetMessageAdapter() + public function testLoggerFactoryGetMessageAdapter(): void { config()->set('app.debug', true); @@ -67,7 +67,7 @@ public function testLoggerFactoryGetMessageAdapter() $this->assertInstanceOf(ReportableInterface::class, $logger->getAdapter()); } - public function testLoggerFactoryTryingToGetMessageAdapter() + public function testLoggerFactoryTryingToGetMessageAdapter(): void { $this->expectException(LoggerException::class); @@ -76,7 +76,7 @@ public function testLoggerFactoryTryingToGetMessageAdapter() LoggerFactory::get(Logger::MESSAGE); } - public function testLoggerFactoryInvalidTypeAdapter() + public function testLoggerFactoryInvalidTypeAdapter(): void { $this->expectException(LoggerException::class); @@ -85,7 +85,7 @@ public function testLoggerFactoryInvalidTypeAdapter() LoggerFactory::get('invalid_type'); } - public function testLoggerFactoryReturnsSameInstance() + public function testLoggerFactoryReturnsSameInstance(): void { $logger1 = LoggerFactory::get(Logger::SINGLE); $logger2 = LoggerFactory::get(Logger::SINGLE); diff --git a/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php b/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php index 208e93697..8a9ef7c2d 100644 --- a/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php +++ b/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php @@ -13,7 +13,7 @@ class LoggerHelperFunctionsTest extends AppTestCase { - private $debugger; + private Debugger $debugger; public function setUp(): void { @@ -33,7 +33,7 @@ public function tearDown(): void $this->debugger->resetStore(); } - public function testLoggerHelperGetDefaultLoggerAdapter() + public function testLoggerHelperGetDefaultLoggerAdapter(): void { config()->set('app.debug', false); @@ -44,7 +44,7 @@ public function testLoggerHelperGetDefaultLoggerAdapter() $this->assertInstanceOf(SingleAdapter::class, $logger->getAdapter()); } - public function testLoggerHelperGetSingleLoggerAdapter() + public function testLoggerHelperGetSingleLoggerAdapter(): void { config()->set('app.debug', false); @@ -55,7 +55,7 @@ public function testLoggerHelperGetSingleLoggerAdapter() $this->assertInstanceOf(SingleAdapter::class, $logger->getAdapter()); } - public function testLoggerHelperGetDailyLoggerAdapter() + public function testLoggerHelperGetDailyLoggerAdapter(): void { config()->set('app.debug', false); @@ -66,7 +66,7 @@ public function testLoggerHelperGetDailyLoggerAdapter() $this->assertInstanceOf(DailyAdapter::class, $logger->getAdapter()); } - public function testLoggerHelperGetMessageLoggerAdapter() + public function testLoggerHelperGetMessageLoggerAdapter(): void { $logger = logger(); @@ -75,7 +75,7 @@ public function testLoggerHelperGetMessageLoggerAdapter() $this->assertInstanceOf(MessageAdapter::class, $logger->getAdapter()); } - public function testLoggerHelperTryToGetMessageLoggerAdapterInNonDebugMode() + public function testLoggerHelperTryToGetMessageLoggerAdapterInNonDebugMode(): void { config()->set('app.debug', false); @@ -86,7 +86,7 @@ public function testLoggerHelperTryToGetMessageLoggerAdapterInNonDebugMode() logger(Logger::MESSAGE); } - public function testErrorHelper() + public function testErrorHelper(): void { error('Fatal Error'); @@ -97,7 +97,7 @@ public function testErrorHelper() $this->assertEquals('Fatal Error', $storedMessages[0]['error']); } - public function testWarningHelper() + public function testWarningHelper(): void { warning('Warning!!'); @@ -108,7 +108,7 @@ public function testWarningHelper() $this->assertEquals('Warning!!', $storedMessages[0]['warning']); } - public function testNoticeHelper() + public function testNoticeHelper(): void { notice('Simple Notice'); @@ -119,7 +119,7 @@ public function testNoticeHelper() $this->assertEquals('Simple Notice', $storedMessages[0]['notice']); } - public function testInfoHelper() + public function testInfoHelper(): void { info('For your information'); @@ -130,7 +130,7 @@ public function testInfoHelper() $this->assertEquals('For your information', $storedMessages[0]['info']); } - public function testDebugHelper() + public function testDebugHelper(): void { debug('Debugging!!'); diff --git a/tests/Unit/Logger/LoggerConfigTest.php b/tests/Unit/Logger/LoggerConfigTest.php index e459c7141..ae597f586 100644 --- a/tests/Unit/Logger/LoggerConfigTest.php +++ b/tests/Unit/Logger/LoggerConfigTest.php @@ -14,17 +14,17 @@ public function setUp(): void $this->setPrivateProperty(LoggerConfig::class, 'logLevel', 'error'); } - public function testDefaultLogLevel() + public function testDefaultLogLevel(): void { $this->assertEquals('error', LoggerConfig::DEFAULT_LOG_LEVEL); } - public function testGetAppLogLevelWithDefault() + public function testGetAppLogLevelWithDefault(): void { $this->assertEquals(400, LoggerConfig::getAppLogLevel()); } - public function testSetGetAppLogLevel() + public function testSetGetAppLogLevel(): void { LoggerConfig::setAppLogLevel('debug'); @@ -39,7 +39,7 @@ public function testSetGetAppLogLevel() $this->assertEquals(500, LoggerConfig::getAppLogLevel()); } - public function testGetLogLevel() + public function testGetLogLevel(): void { $this->assertEquals(500, LoggerConfig::getLogLevel('critical')); @@ -48,7 +48,7 @@ public function testGetLogLevel() $this->assertEquals(600, LoggerConfig::getLogLevel('emergency')); } - public function testGetLogLevelWithInvalidErrorType() + public function testGetLogLevelWithInvalidErrorType(): void { $this->assertEquals(400, LoggerConfig::getLogLevel('non_existing_error')); } diff --git a/tests/Unit/Logger/LoggerTest.php b/tests/Unit/Logger/LoggerTest.php index dda777d58..422546a5c 100644 --- a/tests/Unit/Logger/LoggerTest.php +++ b/tests/Unit/Logger/LoggerTest.php @@ -11,9 +11,9 @@ class LoggerTest extends AppTestCase { - private $logger; - private $adapter; - private $debugger; + private Logger $logger; + private MessageAdapter $adapter; + private Debugger $debugger; public function setUp(): void { @@ -30,7 +30,7 @@ public function setUp(): void $this->logger = new Logger($this->adapter); } - public function testLoggerGetAdapter() + public function testLoggerGetAdapter(): void { $this->assertEquals($this->adapter, $this->logger->getAdapter()); @@ -39,7 +39,7 @@ public function testLoggerGetAdapter() $this->assertInstanceOf(ReportableInterface::class, $this->logger->getAdapter()); } - public function testLoggerLogAddsMessageToDebuggerStore() + public function testLoggerLogAddsMessageToDebuggerStore(): void { $levelInfo = 'info'; $messageInfo = 'Test message'; diff --git a/tests/Unit/Mailer/Adapters/MailerAdapterTraitTest.php b/tests/Unit/Mailer/Adapters/MailerAdapterTraitTest.php index f69af48d7..e29ab74eb 100644 --- a/tests/Unit/Mailer/Adapters/MailerAdapterTraitTest.php +++ b/tests/Unit/Mailer/Adapters/MailerAdapterTraitTest.php @@ -9,7 +9,7 @@ class MailerAdapterTraitTest extends AppTestCase { - private $adapter; + private SmtpAdapter $adapter; public function setUp(): void { @@ -22,7 +22,7 @@ public function setUp(): void $this->adapter = new SmtpAdapter(config()->get('mailer.smtp')); } - public function testMailerTraitSetGetFrom() + public function testMailerTraitSetGetFrom(): void { $this->adapter->setFrom('johndoe@gmail.com', 'John Doe'); @@ -35,7 +35,7 @@ public function testMailerTraitSetGetFrom() $this->assertEquals('John Doe', $from['name']); } - public function testMailerTraitSetGetAddresses() + public function testMailerTraitSetGetAddresses(): void { $this->adapter->setAddress('johndoe@gmail.com', 'John Doe'); @@ -50,7 +50,7 @@ public function testMailerTraitSetGetAddresses() $this->assertEquals('John Doe', $addresses[0]['name']); } - public function testMailerTraitSetGetSubject() + public function testMailerTraitSetGetSubject(): void { $this->adapter->setSubject('Lorem ipsum'); @@ -59,7 +59,7 @@ public function testMailerTraitSetGetSubject() $this->assertEquals('Lorem ipsum', $this->adapter->getSubject()); } - public function testMailerTraitSetGetTemplate() + public function testMailerTraitSetGetTemplate(): void { $templatePath = base_dir() . DS . 'shared' . DS . 'views' . DS . 'email' . DS . 'template'; @@ -71,7 +71,7 @@ public function testMailerTraitSetGetTemplate() $this->assertEquals($templatePath, $this->adapter->getTemplate()); } - public function testSetGetBody() + public function testSetGetBody(): void { $this->adapter->setBody('Lorem ipsum dolor sit amet'); @@ -86,7 +86,7 @@ public function testSetGetBody() $this->assertEquals('Lorem ipsum', $this->adapter->getBody()[0]); } - public function testMailerTraitGetMessageId() + public function testMailerTraitGetMessageId(): void { $adapter = new SendinblueAdapter(['api_key' => 'xxx11122233']); diff --git a/tests/Unit/Mailer/Adapters/MailgunAdapterTest.php b/tests/Unit/Mailer/Adapters/MailgunAdapterTest.php index 8ebfdbe3d..e2cf78e6f 100644 --- a/tests/Unit/Mailer/Adapters/MailgunAdapterTest.php +++ b/tests/Unit/Mailer/Adapters/MailgunAdapterTest.php @@ -20,14 +20,14 @@ public function setUp(): void $this->adapter = new MailgunAdapter($config); } - public function testMailgunAdapterInstance() + public function testMailgunAdapterInstance(): void { $this->assertInstanceOf(MailgunAdapter::class, $this->adapter); $this->assertInstanceOf(MailerInterface::class, $this->adapter); } - public function testMailgunAdapterSend() + public function testMailgunAdapterSend(): void { $this->adapter->setFrom('john@hotmail.com', 'John Doe'); diff --git a/tests/Unit/Mailer/Adapters/MandrillAdapterTest.php b/tests/Unit/Mailer/Adapters/MandrillAdapterTest.php index 455cc9b18..9a9099e8c 100644 --- a/tests/Unit/Mailer/Adapters/MandrillAdapterTest.php +++ b/tests/Unit/Mailer/Adapters/MandrillAdapterTest.php @@ -15,14 +15,14 @@ public function setUp(): void $this->adapter = new MandrillAdapter(['api_key' => 'xxx111222333']); } - public function testMandrillAdapterInstance() + public function testMandrillAdapterInstance(): void { $this->assertInstanceOf(MandrillAdapter::class, $this->adapter); $this->assertInstanceOf(MailerInterface::class, $this->adapter); } - public function testMandrillAdapterSend() + public function testMandrillAdapterSend(): void { $this->adapter->setFrom('john@hotmail.com', 'John Doe'); diff --git a/tests/Unit/Mailer/Adapters/SendgridAdapterTest.php b/tests/Unit/Mailer/Adapters/SendgridAdapterTest.php index 9f66603d0..635a88432 100644 --- a/tests/Unit/Mailer/Adapters/SendgridAdapterTest.php +++ b/tests/Unit/Mailer/Adapters/SendgridAdapterTest.php @@ -15,14 +15,14 @@ public function setUp(): void $this->adapter = new SendgridAdapter(['api_key' => 'xxx111222333']); } - public function testSendgridAdapterInstance() + public function testSendgridAdapterInstance(): void { $this->assertInstanceOf(SendgridAdapter::class, $this->adapter); $this->assertInstanceOf(MailerInterface::class, $this->adapter); } - public function testSendgridAdapterSend() + public function testSendgridAdapterSend(): void { $this->adapter->setFrom('john@hotmail.com', 'John Doe'); diff --git a/tests/Unit/Mailer/Adapters/SendinblueAdapterTest.php b/tests/Unit/Mailer/Adapters/SendinblueAdapterTest.php index 18519aa90..0a066d5c8 100644 --- a/tests/Unit/Mailer/Adapters/SendinblueAdapterTest.php +++ b/tests/Unit/Mailer/Adapters/SendinblueAdapterTest.php @@ -15,14 +15,14 @@ public function setUp(): void $this->adapter = new SendinblueAdapter(['api_key' => 'xxx111222333']); } - public function testSendinblueAdapterInstance() + public function testSendinblueAdapterInstance(): void { $this->assertInstanceOf(SendinblueAdapter::class, $this->adapter); $this->assertInstanceOf(MailerInterface::class, $this->adapter); } - public function testSendinblueAdapterSend() + public function testSendinblueAdapterSend(): void { $this->adapter->setFrom('john@hotmail.com', 'John Doe'); diff --git a/tests/Unit/Mailer/Adapters/SmtpAdapterTest.php b/tests/Unit/Mailer/Adapters/SmtpAdapterTest.php index 762f2205f..d91dd8d01 100644 --- a/tests/Unit/Mailer/Adapters/SmtpAdapterTest.php +++ b/tests/Unit/Mailer/Adapters/SmtpAdapterTest.php @@ -20,14 +20,14 @@ public function setUp(): void $this->adapter = new SmtpAdapter(config()->get('mailer.smtp')); } - public function testSmtpAdapterInstance() + public function testSmtpAdapterInstance(): void { $this->assertInstanceOf(SmtpAdapter::class, $this->adapter); $this->assertInstanceOf(MailerInterface::class, $this->adapter); } - public function testSmtpAdapterSetGetReplays() + public function testSmtpAdapterSetGetReplays(): void { $this->adapter->setReplay('jonny@hotmail.com', 'Jonny') ->setReplay('jane@gmail.com'); @@ -45,7 +45,7 @@ public function testSmtpAdapterSetGetReplays() $this->assertNull($replays[1]['name']); } - public function testSmtpAdapterSetGetCCs() + public function testSmtpAdapterSetGetCCs(): void { $this->adapter->setCC('jonny@hotmail.com', 'Jonny')->setCC('jane@gmail.com'); @@ -61,7 +61,7 @@ public function testSmtpAdapterSetGetCCs() } - public function testSmtpAdapterSetGetBCCs() + public function testSmtpAdapterSetGetBCCs(): void { $this->adapter->setBCC('jonny@hotmail.com', 'Jonny')->setBCC('jane@gmail.com'); @@ -76,7 +76,7 @@ public function testSmtpAdapterSetGetBCCs() $this->assertEquals('Jonny', $BCCs[0]['name']); } - public function testSmtpAdapterSetGetAttachments() + public function testSmtpAdapterSetGetAttachments(): void { $this->adapter->setAttachment(base_dir() . DS . 'php8fe1.tmp'); @@ -87,7 +87,7 @@ public function testSmtpAdapterSetGetAttachments() $this->assertEquals(base_dir() . DS . 'php8fe1.tmp', current($attachments)); } - public function testSmtpAdapterSetGetStringAttachments() + public function testSmtpAdapterSetGetStringAttachments(): void { $this->adapter->setStringAttachment('content of the document', 'document.txt'); @@ -100,7 +100,7 @@ public function testSmtpAdapterSetGetStringAttachments() $this->assertEquals('document.txt', current($attachments)['filename']); } - public function testSmtpAdapterSend() + public function testSmtpAdapterSend(): void { $this->adapter->setFrom('john@hotmail.com', 'John Doe'); diff --git a/tests/Unit/Mailer/Factories/MailerFactoryTest.php b/tests/Unit/Mailer/Factories/MailerFactoryTest.php index 88cb13606..0fcd81559 100644 --- a/tests/Unit/Mailer/Factories/MailerFactoryTest.php +++ b/tests/Unit/Mailer/Factories/MailerFactoryTest.php @@ -26,56 +26,56 @@ public function setUp(): void } } - public function testMailerFactoryInstance() + public function testMailerFactoryInstance(): void { $mailer = MailerFactory::get(); $this->assertInstanceOf(Mailer::class, $mailer); } - public function testMailerFactoryGetDefaultAdapter() + public function testMailerFactoryGetDefaultAdapter(): void { $mailer = MailerFactory::get(); $this->assertInstanceOf(SmtpAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetSmtpAdapter() + public function testMailerFactoryGetSmtpAdapter(): void { $mailer = MailerFactory::get(Mailer::SMTP); $this->assertInstanceOf(SmtpAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetMailgunAdapter() + public function testMailerFactoryGetMailgunAdapter(): void { $mailer = MailerFactory::get(Mailer::MAILGUN); $this->assertInstanceOf(MailgunAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetMandrillAdapter() + public function testMailerFactoryGetMandrillAdapter(): void { $mailer = MailerFactory::get(Mailer::MANDRILL); $this->assertInstanceOf(MandrillAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetSendgridAdapter() + public function testMailerFactoryGetSendgridAdapter(): void { $mailer = MailerFactory::get(Mailer::SENDGRID); $this->assertInstanceOf(SendgridAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetSendinblueAdapter() + public function testMailerFactoryGetSendinblueAdapter(): void { $mailer = MailerFactory::get(Mailer::SENDINBLUE); $this->assertInstanceOf(SendinblueAdapter::class, $mailer->getAdapter()); } - public function testMailerFactoryGetInvalidTypeAdapter() + public function testMailerFactoryGetInvalidTypeAdapter(): void { $this->expectException(MailerException::class); @@ -84,7 +84,7 @@ public function testMailerFactoryGetInvalidTypeAdapter() MailerFactory::get('invalid_type'); } - public function testMailerFactoryReturnsSameInstance() + public function testMailerFactoryReturnsSameInstance(): void { $mailer1 = MailerFactory::get(Mailer::SMTP); $mailer2 = MailerFactory::get(Mailer::SMTP); diff --git a/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php b/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php index cb32de53d..54eaccacd 100644 --- a/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php +++ b/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php @@ -12,7 +12,7 @@ class MailerHelperFunctionsTest extends AppTestCase { - public function testMailerHelperGetDefaultAdapter() + public function testMailerHelperGetDefaultAdapter(): void { $mailer = mailer(); @@ -21,7 +21,7 @@ public function testMailerHelperGetDefaultAdapter() $this->assertInstanceOf(SmtpAdapter::class, $mailer->getAdapter()); } - public function testMailerHelperGetSmtpAdapter() + public function testMailerHelperGetSmtpAdapter(): void { $mailer = mailer(Mailer::SMTP); @@ -30,7 +30,7 @@ public function testMailerHelperGetSmtpAdapter() $this->assertInstanceOf(SmtpAdapter::class, $mailer->getAdapter()); } - public function testMailerHelperGetMailgunAdapter() + public function testMailerHelperGetMailgunAdapter(): void { $mailer = mailer(Mailer::MAILGUN); @@ -39,7 +39,7 @@ public function testMailerHelperGetMailgunAdapter() $this->assertInstanceOf(MailgunAdapter::class, $mailer->getAdapter()); } - public function testMailerHelperGetMandrillAdapter() + public function testMailerHelperGetMandrillAdapter(): void { $mailer = mailer(Mailer::MANDRILL); @@ -48,7 +48,7 @@ public function testMailerHelperGetMandrillAdapter() $this->assertInstanceOf(MandrillAdapter::class, $mailer->getAdapter()); } - public function testMailerHelperGetSendgridAdapter() + public function testMailerHelperGetSendgridAdapter(): void { $mailer = mailer(Mailer::SENDGRID); @@ -57,7 +57,7 @@ public function testMailerHelperGetSendgridAdapter() $this->assertInstanceOf(SendgridAdapter::class, $mailer->getAdapter()); } - public function testMailerHelperGetSendinblueAdapter() + public function testMailerHelperGetSendinblueAdapter(): void { $mailer = mailer(Mailer::SENDINBLUE); diff --git a/tests/Unit/Mailer/MailTrapTest.php b/tests/Unit/Mailer/MailTrapTest.php index 0c4658893..c62d10861 100644 --- a/tests/Unit/Mailer/MailTrapTest.php +++ b/tests/Unit/Mailer/MailTrapTest.php @@ -7,13 +7,13 @@ class MailTrapTest extends AppTestCase { - private $mailTrap; + private MailTrap $mailTrap; - private $filename; + private string $filename; - private $content; + private string $content; - private $path; + private string $path; public function setUp(): void { @@ -64,12 +64,12 @@ public function tearDown(): void $this->fs->remove($this->path . DS . $this->filename . '.eml'); } - public function testMailTrapInstance() + public function testMailTrapInstance(): void { $this->assertInstanceOf(MailTrap::class, $this->mailTrap); } - public function testMailTrapSaveMessage() + public function testMailTrapSaveMessage(): void { $filename = bin2hex(random_bytes(16)); @@ -82,7 +82,7 @@ public function testMailTrapSaveMessage() $this->fs->remove($this->path . DS . $filename . '.eml'); } - public function testMailTrapGetParsedMessageId() + public function testMailTrapGetParsedMessageId(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -93,7 +93,7 @@ public function testMailTrapGetParsedMessageId() $this->assertStringContainsString($this->filename, $parsedMessagedId); } - public function testMailTrapGetParsedXMailer() + public function testMailTrapGetParsedXMailer(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -104,7 +104,7 @@ public function testMailTrapGetParsedXMailer() $this->assertStringContainsStringIgnoringCase('PHPMailer 6.8.0', $parsedXMailer); } - public function testMailTrapGetParsedMimeVersion() + public function testMailTrapGetParsedMimeVersion(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -115,7 +115,7 @@ public function testMailTrapGetParsedMimeVersion() $this->assertEquals('1.0', $parsedMimeVersion); } - public function testMailTrapGetParsedContentType() + public function testMailTrapGetParsedContentType(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -126,7 +126,7 @@ public function testMailTrapGetParsedContentType() $this->assertEquals('multipart/mixed', $parsedContentType); } - public function testMailTrapGetParsedDate() + public function testMailTrapGetParsedDate(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -137,7 +137,7 @@ public function testMailTrapGetParsedDate() $this->assertEquals('Wed, 5 Apr 2023 19:15:37 +0300', $parsedDate); } - public function testMailTrapGetParsedFromAddress() + public function testMailTrapGetParsedFromAddress(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -148,7 +148,7 @@ public function testMailTrapGetParsedFromAddress() $this->assertEquals('John Doe ', $parsedFromAddress); } - public function testMailTrapGetParsedToAddresses() + public function testMailTrapGetParsedToAddresses(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -159,7 +159,7 @@ public function testMailTrapGetParsedToAddresses() $this->assertEquals('Jane Due ', $parsedToAddresses[0]); } - public function testMailTrapGetParsedCcAddresses() + public function testMailTrapGetParsedCcAddresses(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -172,7 +172,7 @@ public function testMailTrapGetParsedCcAddresses() $this->assertEquals('Bill ', $parsedCcAddress[1]); } - public function testMailTrapGetParsedBccAddresses() + public function testMailTrapGetParsedBccAddresses(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -183,7 +183,7 @@ public function testMailTrapGetParsedBccAddresses() $this->assertEquals('Dan ', $parsedBccAddress[0]); } - public function testMailTrapGetParsedReplyToAddresses() + public function testMailTrapGetParsedReplyToAddresses(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -194,7 +194,7 @@ public function testMailTrapGetParsedReplyToAddresses() $this->assertEquals('Sam ', $parsedReplyToAddress[0]); } - public function testMailTrapGetParsedSubject() + public function testMailTrapGetParsedSubject(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -205,7 +205,7 @@ public function testMailTrapGetParsedSubject() $this->assertEquals('Lorem', $parsedSubject); } - public function testMailTrapGetParsedBody() + public function testMailTrapGetParsedBody(): void { $message = $this->mailTrap->parseMessage($this->filename); @@ -216,7 +216,7 @@ public function testMailTrapGetParsedBody() $this->assertStringContainsString('Lorem ipsum dolor sit amet', $parsedBody); } - public function testMailTrapGetParsedAttachments() + public function testMailTrapGetParsedAttachments(): void { $message = $this->mailTrap->parseMessage($this->filename); diff --git a/tests/Unit/Mailer/MailerTest.php b/tests/Unit/Mailer/MailerTest.php index 9428a17d1..98fa204f4 100644 --- a/tests/Unit/Mailer/MailerTest.php +++ b/tests/Unit/Mailer/MailerTest.php @@ -20,7 +20,7 @@ public function setUp(): void } } - public function testMailerGetAdapter() + public function testMailerGetAdapter(): void { $mailer = new Mailer(new SmtpAdapter(config()->get('mailer.smtp'))); @@ -29,7 +29,7 @@ public function testMailerGetAdapter() $this->assertInstanceOf(MailerInterface::class, $mailer->getAdapter()); } - public function testMailerCallingValidMethod() + public function testMailerCallingValidMethod(): void { $mailer = new Mailer(new SmtpAdapter(config()->get('mailer.smtp'))); @@ -38,7 +38,7 @@ public function testMailerCallingValidMethod() $this->assertEquals('Welcome', $mailer->getSubject()); } - public function testMailerCallingInvalidMethod() + public function testMailerCallingInvalidMethod(): void { $mailer = new Mailer(new SmtpAdapter(config()->get('mailer.smtp'))); diff --git a/tests/Unit/Model/DbModelTest.php b/tests/Unit/Model/DbModelTest.php index 6efbc074c..83e9d6c45 100644 --- a/tests/Unit/Model/DbModelTest.php +++ b/tests/Unit/Model/DbModelTest.php @@ -2,6 +2,7 @@ namespace Quantum\Tests\Unit\Model; +use Quantum\Model\Model; use Quantum\Tests\_root\shared\Models\TestProfileModel; use Quantum\Database\Adapters\Idiorm\IdiormDbal; use Quantum\Model\Exceptions\ModelException; @@ -13,7 +14,7 @@ class DbModelTest extends AppTestCase { - private $model; + private Model $model; public function setUp(): void { @@ -33,12 +34,12 @@ public function tearDown(): void IdiormDbal::execute('DROP TABLE profiles'); } - public function testDbModelInstance() + public function testDbModelInstance(): void { $this->assertInstanceOf(DbModel::class, $this->model); } - public function testDbModelSetAndGetOrmInstance() + public function testDbModelSetAndGetOrmInstance(): void { $ormInstance = new IdiormDbal('profiles'); @@ -47,14 +48,14 @@ public function testDbModelSetAndGetOrmInstance() $this->assertSame($ormInstance, $this->model->getOrmInstance()); } - public function testDbModelRelationsReturnsArray() + public function testDbModelRelationsReturnsArray(): void { $relations = $this->model->relations(); $this->assertIsArray($relations); } - public function testDbModelGetReturnsModelCollection() + public function testDbModelGetReturnsModelCollection(): void { $collection = $this->model->get(); @@ -65,7 +66,7 @@ public function testDbModelGetReturnsModelCollection() $this->assertInstanceOf(TestProfileModel::class, $collection->first()); } - public function testDbModelPaginateReturnsPaginator() + public function testDbModelPaginateReturnsPaginator(): void { $paginator = $this->model->paginate(1); @@ -80,14 +81,14 @@ public function testDbModelPaginateReturnsPaginator() $this->assertInstanceOf(TestProfileModel::class, $collection->first()); } - public function testDbModelIsEmptyReturnsFalse() + public function testDbModelIsEmptyReturnsFalse(): void { $record = $this->model->first(); $this->assertFalse($record->isEmpty()); } - public function testDbModelIsEmptyReturnsTrue() + public function testDbModelIsEmptyReturnsTrue(): void { $this->model->deleteMany(); @@ -96,7 +97,7 @@ public function testDbModelIsEmptyReturnsTrue() $this->assertTrue($record->isEmpty()); } - public function testDbModelFill() + public function testDbModelFill(): void { $this->model->fill([ 'firstname' => 'Jane', @@ -111,7 +112,7 @@ public function testDbModelFill() $this->assertEquals(35, $this->model->age); } - public function testDbModelFillWithUndefinedFillable() + public function testDbModelFillWithUndefinedFillable(): void { $this->expectException(ModelException::class); @@ -120,7 +121,7 @@ public function testDbModelFillWithUndefinedFillable() $this->model->fill(['currency' => 'Ireland']); } - public function testDbModelSetterAndGetter() + public function testDbModelSetterAndGetter(): void { $this->assertNull($this->model->undefinedProperty); @@ -129,7 +130,7 @@ public function testDbModelSetterAndGetter() $this->assertEquals('Something', $this->model->undefinedProperty); } - public function testDbModelCallingUndefinedModelMethod() + public function testDbModelCallingUndefinedModelMethod(): void { $this->expectException(ModelException::class); @@ -138,7 +139,7 @@ public function testDbModelCallingUndefinedModelMethod() $this->model->undefinedMethod(); } - public function testDbModelCreateNewRecordByCallingOrmMethod() + public function testDbModelCreateNewRecordByCallingOrmMethod(): void { $userModel = $this->model->create(); @@ -163,7 +164,7 @@ public function testDbModelCreateNewRecordByCallingOrmMethod() $this->assertEquals('Smith', $userData['lastname']); } - public function testDbModelUpdatingExistingRecordByCallingOrmMethod() + public function testDbModelUpdatingExistingRecordByCallingOrmMethod(): void { $userModel = $this->model->findOne(1); @@ -190,7 +191,7 @@ public function testDbModelUpdatingExistingRecordByCallingOrmMethod() $this->assertEquals(35, $userModel->age); } - public function testDbModelPropUnknownColumnThrowsPdoExceptionOnSave() + public function testDbModelPropUnknownColumnThrowsPdoExceptionOnSave(): void { $userModel = $this->model->create(); @@ -205,7 +206,7 @@ public function testDbModelPropUnknownColumnThrowsPdoExceptionOnSave() $userModel->save(); } - public function testDbModelCallingModelWithCriterias() + public function testDbModelCallingModelWithCriterias(): void { $profileModel = ModelFactory::get(TestProfileModel::class); @@ -224,7 +225,7 @@ public function testDbModelCallingModelWithCriterias() $this->assertEquals('Jane', $userData['firstname']); } - public function tesDbModelGetModelProperties() + public function tesDbModelGetModelProperties(): void { $expected = [ 'id' => '1', @@ -245,7 +246,7 @@ public function tesDbModelGetModelProperties() $this->assertEquals($expected, $actual); } - private function _createProfileTableWithData() + private function _createProfileTableWithData(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS profiles ( id INTEGER PRIMARY KEY, diff --git a/tests/Unit/Model/DbModelTimestampsTest.php b/tests/Unit/Model/DbModelTimestampsTest.php index d96c763d3..e90067db4 100644 --- a/tests/Unit/Model/DbModelTimestampsTest.php +++ b/tests/Unit/Model/DbModelTimestampsTest.php @@ -29,7 +29,7 @@ public function tearDown(): void IdiormDbal::execute('DROP TABLE posts_custom'); } - public function testTimestampsAreNotAppliedWhenTraitIsNotUsed() + public function testTimestampsAreNotAppliedWhenTraitIsNotUsed(): void { /** @var TestPostModel $model */ $model = ModelFactory::get(TestPostModel::class); @@ -56,7 +56,7 @@ public function testTimestampsAreNotAppliedWhenTraitIsNotUsed() $this->assertNull($data['updated_at']); } - public function testTimestampsAreAppliedOnInsertWhenTraitIsUsed() + public function testTimestampsAreAppliedOnInsertWhenTraitIsUsed(): void { /** @var TestPostTimestampModel $model */ $model = ModelFactory::get(TestPostTimestampModel::class); @@ -78,7 +78,7 @@ public function testTimestampsAreAppliedOnInsertWhenTraitIsUsed() $this->assertNotEmpty($saved->updated_at); } - public function testUpdatedAtChangesOnUpdateButCreatedAtStaysSame() + public function testUpdatedAtChangesOnUpdateButCreatedAtStaysSame(): void { /** @var TestPostTimestampModel $model */ $model = ModelFactory::get(TestPostTimestampModel::class); @@ -113,7 +113,7 @@ public function testUpdatedAtChangesOnUpdateButCreatedAtStaysSame() $this->assertNotEquals($updatedAt1, $saved2->updated_at); } - public function testUnixTimestampTypeStoresIntegers() + public function testUnixTimestampTypeStoresIntegers(): void { /** @var TestPostUnixTimestampModel $model */ $model = ModelFactory::get(TestPostUnixTimestampModel::class); @@ -135,7 +135,7 @@ public function testUnixTimestampTypeStoresIntegers() $this->assertIsNumeric($saved->updated_at); } - public function testCustomTimestampColumnsAreApplied() + public function testCustomTimestampColumnsAreApplied(): void { /** @var TestPostCustomTimestampModel $model */ $model = ModelFactory::get(TestPostCustomTimestampModel::class); diff --git a/tests/Unit/Model/Factories/ModelFactoryTest.php b/tests/Unit/Model/Factories/ModelFactoryTest.php index f4c19b6b8..38ae2ecf1 100644 --- a/tests/Unit/Model/Factories/ModelFactoryTest.php +++ b/tests/Unit/Model/Factories/ModelFactoryTest.php @@ -20,7 +20,7 @@ public function setUp(): void parent::setUp(); } - public function testModelFactoryGet() + public function testModelFactoryGet(): void { $userModel = ModelFactory::get(TestUserModel::class); @@ -29,7 +29,7 @@ public function testModelFactoryGet() $this->assertInstanceOf(TestUserModel::class, $userModel); } - public function testModelFactoryGetNonExistingModel() + public function testModelFactoryGetNonExistingModel(): void { $this->expectException(ModelException::class); @@ -38,7 +38,7 @@ public function testModelFactoryGetNonExistingModel() ModelFactory::get(\NonExistentClass::class); } - public function testModelFactoryModelNotInstanceOfDbModel() + public function testModelFactoryModelNotInstanceOfDbModel(): void { $this->expectException(ModelException::class); @@ -47,7 +47,7 @@ public function testModelFactoryModelNotInstanceOfDbModel() ModelFactory::get(\Mockery\Undefined::class); } - public function testModelFactoryCreateDynamicModel() + public function testModelFactoryCreateDynamicModel(): void { $dynamicModel = ModelFactory::createDynamicModel('test_table', TestUserModel::class); diff --git a/tests/Unit/Model/Helpers/ModelHelperFunctionsTest.php b/tests/Unit/Model/Helpers/ModelHelperFunctionsTest.php index ea40dc531..cbfbedc87 100644 --- a/tests/Unit/Model/Helpers/ModelHelperFunctionsTest.php +++ b/tests/Unit/Model/Helpers/ModelHelperFunctionsTest.php @@ -11,7 +11,7 @@ class ModelHelperFunctionsTest extends AppTestCase { - public function testModelReturnsDbModelInstance() + public function testModelReturnsDbModelInstance(): void { $model = model(TestUserModel::class); @@ -20,14 +20,14 @@ public function testModelReturnsDbModelInstance() $this->assertInstanceOf(DbModel::class, $model); } - public function testModelThrowsOnInvalidClass() + public function testModelThrowsOnInvalidClass(): void { $this->expectException(ModelException::class); model('NonExistentModelClass'); } - public function testDynamicModelReturnsAnonymousDbModel() + public function testDynamicModelReturnsAnonymousDbModel(): void { $dynamicModel = dynamicModel('test_table', TestUserModel::class); @@ -38,7 +38,7 @@ public function testDynamicModelReturnsAnonymousDbModel() $this->assertEquals(TestUserModel::class, $dynamicModel->getModelName()); } - public function testWrapToModelReturnsModelInstance() + public function testWrapToModelReturnsModelInstance(): void { $dbal = Mockery::mock(DbalInterface::class); @@ -49,7 +49,7 @@ public function testWrapToModelReturnsModelInstance() $this->assertInstanceOf(DbModel::class, $model); } - public function testWrapToModelThrowsOnInvalidClass() + public function testWrapToModelThrowsOnInvalidClass(): void { $dbal = Mockery::mock(DbalInterface::class); @@ -58,7 +58,7 @@ public function testWrapToModelThrowsOnInvalidClass() wrapToModel($dbal, 'NonExistentModelClass'); } - public function testWrapToModelThrowsIfNotDbModel() + public function testWrapToModelThrowsIfNotDbModel(): void { $dbal = Mockery::mock(DbalInterface::class); diff --git a/tests/Unit/Model/ModelCollectionTest.php b/tests/Unit/Model/ModelCollectionTest.php index 0e5c26b67..00bafc069 100644 --- a/tests/Unit/Model/ModelCollectionTest.php +++ b/tests/Unit/Model/ModelCollectionTest.php @@ -10,9 +10,9 @@ class ModelCollectionTest extends AppTestCase { - private $modelCollection; - private $model1; - private $model2; + private ModelCollection $modelCollection; + private TestUserModel $model1; + private TestUserModel $model2; public function setUp(): void { @@ -23,21 +23,21 @@ public function setUp(): void $this->model2 = new TestUserModel(); } - public function testModelCollectionConstructorWithValidModels() + public function testModelCollectionConstructorWithValidModels(): void { $modelCollection = new ModelCollection([$this->model1, $this->model2]); $this->assertCount(2, $modelCollection); } - public function testModelCollectionConstructorWithInvalidModels() + public function testModelCollectionConstructorWithInvalidModels(): void { $this->expectException(ModelException::class); new ModelCollection([new stdClass(), $this->model1, $this->model2]); } - public function testModelCollectionAddModel() + public function testModelCollectionAddModel(): void { $this->modelCollection->add($this->model1); $this->assertCount(1, $this->modelCollection); @@ -48,7 +48,7 @@ public function testModelCollectionAddModel() $this->assertSame($this->model2, $this->modelCollection->last()); } - public function testModelCollectionRemoveModel() + public function testModelCollectionRemoveModel(): void { $this->modelCollection->add($this->model1); $this->modelCollection->add($this->model2); @@ -59,7 +59,7 @@ public function testModelCollectionRemoveModel() $this->assertSame($this->model2, $this->modelCollection->first()); } - public function testModelCollectionAllModels() + public function testModelCollectionAllModels(): void { $this->modelCollection->add($this->model1); $this->modelCollection->add($this->model2); @@ -71,7 +71,7 @@ public function testModelCollectionAllModels() $this->assertSame($this->model2, $models[1]); } - public function testModelCollectionFirstModel() + public function testModelCollectionFirstModel(): void { $this->modelCollection->add($this->model1); $this->modelCollection->add($this->model2); @@ -79,7 +79,7 @@ public function testModelCollectionFirstModel() $this->assertSame($this->model1, $this->modelCollection->first()); } - public function testModelCollectionLastModel() + public function testModelCollectionLastModel(): void { $this->modelCollection->add($this->model1); $this->modelCollection->add($this->model2); @@ -87,7 +87,7 @@ public function testModelCollectionLastModel() $this->assertSame($this->model2, $this->modelCollection->last()); } - public function testModelCollectionIsEmpty() + public function testModelCollectionIsEmpty(): void { $this->assertTrue($this->modelCollection->isEmpty()); @@ -95,7 +95,7 @@ public function testModelCollectionIsEmpty() $this->assertFalse($this->modelCollection->isEmpty()); } - public function testModelCollectionCount() + public function testModelCollectionCount(): void { $this->assertCount(0, $this->modelCollection); @@ -106,7 +106,7 @@ public function testModelCollectionCount() $this->assertCount(2, $this->modelCollection); } - public function testModelCollectionGetIterator() + public function testModelCollectionGetIterator(): void { $this->modelCollection->add($this->model1); $this->modelCollection->add($this->model2); diff --git a/tests/Unit/Model/ModelSoftDeletesIdiOrmTest.php b/tests/Unit/Model/ModelSoftDeletesIdiOrmTest.php index 12653ebd9..0a8df16ef 100644 --- a/tests/Unit/Model/ModelSoftDeletesIdiOrmTest.php +++ b/tests/Unit/Model/ModelSoftDeletesIdiOrmTest.php @@ -2,6 +2,7 @@ namespace Quantum\Tests\Unit\Model; +use Quantum\Model\Model; use Quantum\Tests\_root\shared\Models\TestProductsModel; use Quantum\Database\Adapters\Idiorm\IdiormDbal; use Quantum\Model\Factories\ModelFactory; @@ -11,7 +12,7 @@ class ModelSoftDeletesIdiOrmTest extends AppTestCase { - private $model; + private Model $model; public function setUp(): void { @@ -31,7 +32,7 @@ public function tearDown(): void IdiormDbal::execute('DROP TABLE products '); } - public function testDeleteSetsDeletedAt() + public function testDeleteSetsDeletedAt(): void { $this->assertEquals(4, $this->model->count()); @@ -46,7 +47,7 @@ public function testDeleteSetsDeletedAt() $this->assertEquals(3, $this->model->count()); } - public function testRestoreSetsDeletedAtToNull() + public function testRestoreSetsDeletedAtToNull(): void { $this->assertEquals(4, $this->model->count()); @@ -65,7 +66,7 @@ public function testRestoreSetsDeletedAtToNull() $this->assertEquals(4, $this->model->count()); } - public function testForceDeleteActuallyDeletes() + public function testForceDeleteActuallyDeletes(): void { $this->assertEquals(6, $this->model->withTrashed()->count()); @@ -80,7 +81,7 @@ public function testForceDeleteActuallyDeletes() $this->assertTrue($product->isEmpty()); } - public function testGetReturnsOnlyNonDeletedRecords() + public function testGetReturnsOnlyNonDeletedRecords(): void { $result = $this->model->get(); @@ -89,7 +90,7 @@ public function testGetReturnsOnlyNonDeletedRecords() $this->assertCount(4, $result); } - public function testGetWithTrashedReturnsAllRecords() + public function testGetWithTrashedReturnsAllRecords(): void { $result = $this->model->withTrashed()->get(); @@ -98,7 +99,7 @@ public function testGetWithTrashedReturnsAllRecords() $this->assertCount(6, $result); } - public function testGetOnlyTrashedReturnsOnlySoftDeletedRecords() + public function testGetOnlyTrashedReturnsOnlySoftDeletedRecords(): void { $result = $this->model->onlyTrashed()->get(); @@ -107,7 +108,7 @@ public function testGetOnlyTrashedReturnsOnlySoftDeletedRecords() $this->assertCount(2, $result); } - public function testPaginateExcludesDeleted() + public function testPaginateExcludesDeleted(): void { $paginator = $this->model->paginate(3); @@ -118,14 +119,14 @@ public function testPaginateExcludesDeleted() } } - public function testCountExcludesDeleted() + public function testCountExcludesDeleted(): void { $this->assertEquals(4, $this->model->count()); $this->assertEquals(6, ModelFactory::get(TestProductsModel::class)->withTrashed()->count()); } - public function testFindOneRespectsSoftDelete() + public function testFindOneRespectsSoftDelete(): void { $product = $this->model->findOne(3); @@ -138,7 +139,7 @@ public function testFindOneRespectsSoftDelete() $this->assertEquals('Product C', $product->prop('title')); } - public function testFindOneByRespectsSoftDelete() + public function testFindOneByRespectsSoftDelete(): void { $product = $this->model->findOneBy('title', 'Product C'); @@ -149,7 +150,7 @@ public function testFindOneByRespectsSoftDelete() $this->assertFalse($product->isEmpty()); } - public function testFirstExcludesDeleted() + public function testFirstExcludesDeleted(): void { $product = $this->model->criteria('title', '=', 'Product C')->first(); @@ -162,7 +163,7 @@ public function testFirstExcludesDeleted() $this->assertFalse($product->isEmpty()); } - private function _createProductsTableWithData() + private function _createProductsTableWithData(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS products ( id INTEGER PRIMARY KEY AUTOINCREMENT, diff --git a/tests/Unit/Model/ModelSoftDeletesSleekTest.php b/tests/Unit/Model/ModelSoftDeletesSleekTest.php index d2cfcf17e..913ffbaeb 100644 --- a/tests/Unit/Model/ModelSoftDeletesSleekTest.php +++ b/tests/Unit/Model/ModelSoftDeletesSleekTest.php @@ -2,6 +2,7 @@ namespace Quantum\Tests\Unit\Model; +use Quantum\Model\Model; use Quantum\Tests\_root\shared\Models\TestProductsModel; use Quantum\Database\Adapters\Sleekdb\SleekDbal; use Quantum\Model\Factories\ModelFactory; @@ -13,7 +14,7 @@ class ModelSoftDeletesSleekTest extends AppTestCase { - private $model; + private Model $model; public function setUp(): void { @@ -39,7 +40,7 @@ public function tearDown(): void ModelFactory::get(TestProductsModel::class)->truncate(); } - public function testSleekDeleteSetsDeletedAt() + public function testSleekDeleteSetsDeletedAt(): void { $this->assertEquals(4, $this->model->count()); @@ -54,7 +55,7 @@ public function testSleekDeleteSetsDeletedAt() $this->assertEquals(3, $this->model->count()); } - public function testSleekRestoreSetsDeletedAtToNull() + public function testSleekRestoreSetsDeletedAtToNull(): void { $this->assertEquals(4, $this->model->count()); @@ -73,7 +74,7 @@ public function testSleekRestoreSetsDeletedAtToNull() $this->assertEquals(4, $this->model->count()); } - public function testSleekForceDeleteActuallyDeletes() + public function testSleekForceDeleteActuallyDeletes(): void { $this->assertEquals(6, $this->model->withTrashed()->count()); @@ -90,7 +91,7 @@ public function testSleekForceDeleteActuallyDeletes() $this->assertTrue($product->isEmpty()); } - public function testSleekGetReturnsOnlyNonDeletedRecords() + public function testSleekGetReturnsOnlyNonDeletedRecords(): void { $result = $this->model->get(); @@ -99,7 +100,7 @@ public function testSleekGetReturnsOnlyNonDeletedRecords() $this->assertCount(4, $result); } - public function testSleekGetWithTrashedReturnsAllRecords() + public function testSleekGetWithTrashedReturnsAllRecords(): void { $result = $this->model->withTrashed()->get(); @@ -108,7 +109,7 @@ public function testSleekGetWithTrashedReturnsAllRecords() $this->assertCount(6, $result); } - public function testSleekGetOnlyTrashedReturnsOnlySoftDeletedRecords() + public function testSleekGetOnlyTrashedReturnsOnlySoftDeletedRecords(): void { $result = $this->model->onlyTrashed()->get(); @@ -117,7 +118,7 @@ public function testSleekGetOnlyTrashedReturnsOnlySoftDeletedRecords() $this->assertCount(2, $result); } - public function testSleekPaginateExcludesDeleted() + public function testSleekPaginateExcludesDeleted(): void { $paginator = $this->model->paginate(3); @@ -129,14 +130,14 @@ public function testSleekPaginateExcludesDeleted() } } - public function testSleekCountExcludesDeleted() + public function testSleekCountExcludesDeleted(): void { $this->assertEquals(4, $this->model->count()); $this->assertEquals(6, ModelFactory::get(TestProductsModel::class)->withTrashed()->count()); } - public function testSleekFindOneRespectsSoftDelete() + public function testSleekFindOneRespectsSoftDelete(): void { $product = $this->model->findOne(2); @@ -149,7 +150,7 @@ public function testSleekFindOneRespectsSoftDelete() $this->assertEquals('Product B', $product->prop('title')); } - public function testSleekFindOneByRespectsSoftDelete() + public function testSleekFindOneByRespectsSoftDelete(): void { $product = $this->model->findOneBy('title', 'Product B'); @@ -160,7 +161,7 @@ public function testSleekFindOneByRespectsSoftDelete() $this->assertFalse($product->isEmpty()); } - public function testSleekFirstRespectsSoftDelete() + public function testSleekFirstRespectsSoftDelete(): void { $product = $this->model->criteria('title', '=', 'Product B')->first(); @@ -173,7 +174,7 @@ public function testSleekFirstRespectsSoftDelete() $this->assertFalse($product->isEmpty()); } - private function _createProductsTableWithData() + private function _createProductsTableWithData(): void { $product = new SleekDbal('products'); @@ -182,7 +183,7 @@ private function _createProductsTableWithData() $product->prop('description', 'High-quality product A'); $product->prop('price', 19.99); $product->prop('created_at', '2025-05-01 10:00:00'); - $product->prop('deleted_at', null); + $product->prop('deleted_at'); $product->save(); $product->create(); @@ -198,7 +199,7 @@ private function _createProductsTableWithData() $product->prop('description', 'Popular product C'); $product->prop('price', 39.99); $product->prop('created_at', '2025-05-01 10:00:00'); - $product->prop('deleted_at', null); + $product->prop('deleted_at'); $product->save(); $product->create(); @@ -206,7 +207,7 @@ private function _createProductsTableWithData() $product->prop('description', 'Limited edition product D'); $product->prop('price', 49.99); $product->prop('created_at', '2025-05-01 10:00:00'); - $product->prop('deleted_at', null); + $product->prop('deleted_at'); $product->save(); $product->create(); @@ -222,7 +223,7 @@ private function _createProductsTableWithData() $product->prop('description', 'Premium product F'); $product->prop('price', 69.99); $product->prop('created_at', '2025-05-01 10:00:00'); - $product->prop('deleted_at', null); + $product->prop('deleted_at'); $product->save(); } } diff --git a/tests/Unit/Model/ModelTest.php b/tests/Unit/Model/ModelTest.php index aefb6a272..59c80f5b7 100644 --- a/tests/Unit/Model/ModelTest.php +++ b/tests/Unit/Model/ModelTest.php @@ -17,12 +17,12 @@ public function setUp(): void $this->model = new TestPlainModel(); } - public function testModelInstance() + public function testModelInstance(): void { $this->assertInstanceOf(Model::class, $this->model); } - public function testModelPropSetterAndGetter() + public function testModelPropSetterAndGetter(): void { $this->assertNull($this->model->prop('firstname')); @@ -31,14 +31,14 @@ public function testModelPropSetterAndGetter() $this->assertEquals('John', $this->model->prop('firstname')); } - public function testModelPropReturnsSelfWhenSettingValue() + public function testModelPropReturnsSelfWhenSettingValue(): void { $result = $this->model->prop('lastname', 'Doe'); $this->assertSame($this->model, $result); } - public function testModelFill() + public function testModelFill(): void { $this->model->fill([ 'firstname' => 'Jane', @@ -51,7 +51,7 @@ public function testModelFill() $this->assertEquals(35, $this->model->age); } - public function testModelFillWithUndefinedFillable() + public function testModelFillWithUndefinedFillable(): void { $this->expectException(ModelException::class); @@ -62,7 +62,7 @@ public function testModelFillWithUndefinedFillable() ]); } - public function testModelAsArrayReturnsAttributes() + public function testModelAsArrayReturnsAttributes(): void { $this->model->prop('firstname', 'John'); $this->model->prop('lastname', 'Doe'); @@ -77,7 +77,7 @@ public function testModelAsArrayReturnsAttributes() $this->assertEquals(45, $data['age']); } - public function testModelAsArrayHidesHiddenFields() + public function testModelAsArrayHidesHiddenFields(): void { $this->model->prop('firstname', 'John'); $this->model->prop('lastname', 'Doe'); @@ -95,19 +95,19 @@ public function testModelAsArrayHidesHiddenFields() $this->assertArrayNotHasKey('password', $data); } - public function testModelIsEmptyReturnsTrue() + public function testModelIsEmptyReturnsTrue(): void { $this->assertTrue($this->model->isEmpty()); } - public function testModelIsEmptyReturnsFalse() + public function testModelIsEmptyReturnsFalse(): void { $this->model->prop('firstname', 'John'); $this->assertFalse($this->model->isEmpty()); } - public function testModelMagicGetterAndSetter() + public function testModelMagicGetterAndSetter(): void { $this->assertNull($this->model->undefinedProperty); @@ -116,7 +116,7 @@ public function testModelMagicGetterAndSetter() $this->assertEquals('Something', $this->model->undefinedProperty); } - public function testModelMagicIsset() + public function testModelMagicIsset(): void { $this->assertFalse(isset($this->model->firstname)); @@ -125,7 +125,7 @@ public function testModelMagicIsset() $this->assertTrue(isset($this->model->firstname)); } - public function testModelMagicUnset() + public function testModelMagicUnset(): void { $this->model->firstname = 'John'; diff --git a/tests/Unit/Module/ModuleLoaderTest.php b/tests/Unit/Module/ModuleLoaderTest.php index 2b4df8d72..ab5161f50 100644 --- a/tests/Unit/Module/ModuleLoaderTest.php +++ b/tests/Unit/Module/ModuleLoaderTest.php @@ -23,12 +23,12 @@ public function tearDown(): void parent::tearDown(); } - public function testGetInstance() + public function testGetInstance(): void { $this->assertInstanceOf(ModuleLoader::class, $this->moduleLoader); } - public function testLoadModulesRoutes() + public function testLoadModulesRoutes(): void { $modulesRoutes = $this->moduleLoader->loadModulesRoutes(); @@ -41,7 +41,7 @@ public function testLoadModulesRoutes() $this->assertInstanceOf(Closure::class, $modulesRoutes['Test']); } - public function testLoadModulesDependencies() + public function testLoadModulesDependencies(): void { $deps = $this->moduleLoader->loadModulesDependencies(); @@ -54,7 +54,7 @@ public function testLoadModulesDependencies() $this->assertSame(\Quantum\Tests\_root\shared\Services\TokenService::class, $deps[\Quantum\Storage\Contracts\TokenServiceInterface::class]); } - public function testGetModuleConfigs() + public function testGetModuleConfigs(): void { $configs = $this->moduleLoader->getModuleConfigs(); diff --git a/tests/Unit/Module/ModuleManagerTest.php b/tests/Unit/Module/ModuleManagerTest.php index 5ebdbf4f4..e01e9e64d 100644 --- a/tests/Unit/Module/ModuleManagerTest.php +++ b/tests/Unit/Module/ModuleManagerTest.php @@ -11,7 +11,7 @@ class ModuleManagerTest extends AppTestCase { - private $modulesConfigPath; + private string $modulesConfigPath; public function setUp(): void { @@ -20,7 +20,7 @@ public function setUp(): void $this->modulesConfigPath = App::getBaseDir() . DS . 'shared' . DS . 'config' . DS . 'modules.php'; } - public function testCreateModule() + public function testCreateModule(): void { $moduleManager = new ModuleManager('Api', 'DefaultApi', 'yes', false); @@ -49,7 +49,7 @@ public function testCreateModule() $this->assertEquals('Api module.', $result->message); } - public function testAddModuleConfigWithoutModule() + public function testAddModuleConfigWithoutModule(): void { $moduleManager = new ModuleManager('Api', 'DefaultApi', 'yes', false); @@ -60,7 +60,7 @@ public function testAddModuleConfigWithoutModule() $moduleManager->addModuleConfig(); } - public function testIncompleteCopyTemplates() + public function testIncompleteCopyTemplates(): void { $moduleManager = Mockery::mock(ModuleManager::class, ['Api', 'DefaultApi', 'yes', false])->makePartial(); @@ -75,7 +75,7 @@ public function testIncompleteCopyTemplates() $moduleManager->writeContents(); } - public function testInvalidTemplate() + public function testInvalidTemplate(): void { $moduleManager = new ModuleManager('NotExists', 'notExists', 'yes', false); diff --git a/tests/Unit/Paginator/Adapters/ArrayPaginatorTest.php b/tests/Unit/Paginator/Adapters/ArrayPaginatorTest.php index f3bfda8d4..991aa1317 100644 --- a/tests/Unit/Paginator/Adapters/ArrayPaginatorTest.php +++ b/tests/Unit/Paginator/Adapters/ArrayPaginatorTest.php @@ -7,9 +7,9 @@ class ArrayPaginatorTest extends AppTestCase { - private $items; + private array $items; - private $paginator; + private ArrayPaginator $paginator; public function setUp(): void { @@ -28,12 +28,12 @@ public function setUp(): void $this->paginator = new ArrayPaginator($this->items, 2, 1); } - public function testArrayPaginatorConstructor() + public function testArrayPaginatorConstructor(): void { $this->assertInstanceOf(ArrayPaginator::class, $this->paginator); } - public function testArrayPaginatorData() + public function testArrayPaginatorData(): void { $data = $this->paginator->data(); @@ -46,7 +46,7 @@ public function testArrayPaginatorData() $this->assertEquals('Item 2', $data[1]['title']); } - public function testArrayPaginatorFirstItem() + public function testArrayPaginatorFirstItem(): void { $firstItem = $this->paginator->firstItem(); @@ -57,7 +57,7 @@ public function testArrayPaginatorFirstItem() $this->assertEquals('Item 1', $firstItem['title']); } - public function testArrayPaginatorLastItem() + public function testArrayPaginatorLastItem(): void { $lastItem = $this->paginator->lastItem(); @@ -68,72 +68,72 @@ public function testArrayPaginatorLastItem() $this->assertEquals('Item 2', $lastItem['title']); } - public function testArrayPaginatorTotal() + public function testArrayPaginatorTotal(): void { $this->assertEquals(5, $this->paginator->total()); } - public function testArrayPaginatorCurrentPageNumber() + public function testArrayPaginatorCurrentPageNumber(): void { $this->assertEquals(1, $this->paginator->currentPageNumber()); } - public function testArrayPaginatorPreviousPageNumber() + public function testArrayPaginatorPreviousPageNumber(): void { $this->assertEquals(1, $this->paginator->previousPageNumber()); } - public function testArrayPaginatorNextPageNumber() + public function testArrayPaginatorNextPageNumber(): void { $this->assertEquals(2, $this->paginator->nextPageNumber()); } - public function testArrayPaginatorLastPageNumber() + public function testArrayPaginatorLastPageNumber(): void { $this->assertEquals(3, $this->paginator->lastPageNumber()); } - public function testArrayPaginatorCurrentPageLink() + public function testArrayPaginatorCurrentPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->currentPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->currentPageLink(true)); } - public function testArrayPaginatorFirstPageLink() + public function testArrayPaginatorFirstPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->firstPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->firstPageLink(true)); } - public function testArrayPaginatorPreviousPageLink() + public function testArrayPaginatorPreviousPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->previousPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->previousPageLink(true)); } - public function testArrayPaginatorNextPageLink() + public function testArrayPaginatorNextPageLink(): void { $this->assertEquals('?per_page=2&page=2', $this->paginator->nextPageLink()); $this->assertEquals('http://localhost?per_page=2&page=2', $this->paginator->nextPageLink(true)); } - public function testArrayPaginatorLastPageLink() + public function testArrayPaginatorLastPageLink(): void { $this->assertEquals('?per_page=2&page=3', $this->paginator->lastPageLink()); $this->assertEquals('http://localhost?per_page=2&page=3', $this->paginator->lastPageLink(true)); } - public function testArrayPaginatorPerPage() + public function testArrayPaginatorPerPage(): void { $this->assertEquals(2, $this->paginator->perPage()); } - public function testArrayPaginatorGetPaginationRendersCurrentAndLastPage() + public function testArrayPaginatorGetPaginationRendersCurrentAndLastPage(): void { $html = $this->paginator->getPagination(); @@ -141,14 +141,14 @@ public function testArrayPaginatorGetPaginationRendersCurrentAndLastPage() $this->assertStringContainsString('>3<', $html); } - public function testArrayPaginatorGetPaginationRendersEllipsisForHiddenPages() + public function testArrayPaginatorGetPaginationRendersEllipsisForHiddenPages(): void { $html = $this->paginator->getPagination(); $this->assertStringContainsString('...', $html); } - public function testArrayPaginatorGetPaginationRendersMiddlePageWhenCurrentPageIsTwo() + public function testArrayPaginatorGetPaginationRendersMiddlePageWhenCurrentPageIsTwo(): void { $paginator = new ArrayPaginator($this->items, 2, 2); diff --git a/tests/Unit/Paginator/Adapters/ModelPaginatorTest.php b/tests/Unit/Paginator/Adapters/ModelPaginatorTest.php index 29dfd1cdb..8906773f4 100644 --- a/tests/Unit/Paginator/Adapters/ModelPaginatorTest.php +++ b/tests/Unit/Paginator/Adapters/ModelPaginatorTest.php @@ -11,7 +11,7 @@ class ModelPaginatorTest extends PaginatorTestCase { - private $paginator; + private ModelPaginator $paginator; public function setUp(): void { @@ -24,12 +24,12 @@ public function setUp(): void $this->paginator = new ModelPaginator($postModel, 2, 1); } - public function testModelPaginatorConstructor() + public function testModelPaginatorConstructor(): void { $this->assertInstanceOf(ModelPaginator::class, $this->paginator); } - public function testModelPaginatorData() + public function testModelPaginatorData(): void { $data = $this->paginator->data(); @@ -52,7 +52,7 @@ public function testModelPaginatorData() $this->assertEquals('First post!', $record->content); } - public function testModelPaginatorDataWithAnonymousModel() + public function testModelPaginatorDataWithAnonymousModel(): void { $dynamicModel = ModelFactory::createDynamicModel('posts'); @@ -77,7 +77,7 @@ public function testModelPaginatorDataWithAnonymousModel() $this->assertEquals('First post!', $record->content); } - public function testModelPaginatorFirstItem() + public function testModelPaginatorFirstItem(): void { $firstItem = $this->paginator->firstItem(); @@ -88,7 +88,7 @@ public function testModelPaginatorFirstItem() $this->assertEquals('First post!', $firstItem->content); } - public function testModelPaginatorLastItem() + public function testModelPaginatorLastItem(): void { $lastItem = $this->paginator->lastItem(); $this->assertInstanceOf(TestPostModel::class, $lastItem); @@ -96,72 +96,72 @@ public function testModelPaginatorLastItem() $this->assertEquals('Hello world', $lastItem->content); } - public function testModelPaginatorTotal() + public function testModelPaginatorTotal(): void { $this->assertEquals(5, $this->paginator->total()); } - public function testModelPaginatorCurrentPageNumber() + public function testModelPaginatorCurrentPageNumber(): void { $this->assertEquals(1, $this->paginator->currentPageNumber()); } - public function testModelPaginatorPreviousPageNumber() + public function testModelPaginatorPreviousPageNumber(): void { $this->assertEquals(1, $this->paginator->previousPageNumber()); } - public function testModelPaginatorNextPageNumber() + public function testModelPaginatorNextPageNumber(): void { $this->assertEquals(2, $this->paginator->nextPageNumber()); } - public function testModelPaginatorLastPageNumber() + public function testModelPaginatorLastPageNumber(): void { $this->assertEquals(3, $this->paginator->lastPageNumber()); } - public function testModelPaginatorCurrentPageLink() + public function testModelPaginatorCurrentPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->currentPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->currentPageLink(true)); } - public function testModelPaginatorFirstPageLink() + public function testModelPaginatorFirstPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->firstPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->firstPageLink(true)); } - public function testModelPaginatorPreviousPageLink() + public function testModelPaginatorPreviousPageLink(): void { $this->assertEquals('?per_page=2&page=1', $this->paginator->previousPageLink()); $this->assertEquals('http://localhost?per_page=2&page=1', $this->paginator->previousPageLink(true)); } - public function testModelPaginatorNextPageLink() + public function testModelPaginatorNextPageLink(): void { $this->assertEquals('?per_page=2&page=2', $this->paginator->nextPageLink()); $this->assertEquals('http://localhost?per_page=2&page=2', $this->paginator->nextPageLink(true)); } - public function testModelPaginatorLastPageLink() + public function testModelPaginatorLastPageLink(): void { $this->assertEquals('?per_page=2&page=3', $this->paginator->lastPageLink()); $this->assertEquals('http://localhost?per_page=2&page=3', $this->paginator->lastPageLink(true)); } - public function testModelPaginatorPerPage() + public function testModelPaginatorPerPage(): void { $this->assertEquals(2, $this->paginator->perPage()); } - public function testModelPaginatorGetPaginationRendersCurrentAndLastPage() + public function testModelPaginatorGetPaginationRendersCurrentAndLastPage(): void { $html = $this->paginator->getPagination(); @@ -169,14 +169,14 @@ public function testModelPaginatorGetPaginationRendersCurrentAndLastPage() $this->assertStringContainsString('>3<', $html); } - public function testModelPaginatorGetPaginationRendersEllipsisForHiddenPages() + public function testModelPaginatorGetPaginationRendersEllipsisForHiddenPages(): void { $html = $this->paginator->getPagination(); $this->assertStringContainsString('...', $html); } - public function testModelPaginatorGetPaginationRendersMiddlePageWhenCurrentPageIsTwo() + public function testModelPaginatorGetPaginationRendersMiddlePageWhenCurrentPageIsTwo(): void { $postModel = ModelFactory::createDynamicModel('posts', TestPostModel::class); diff --git a/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php b/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php index 8e00be1a4..bf8be0daa 100644 --- a/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php +++ b/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php @@ -2,6 +2,7 @@ namespace Quantum\Tests\Unit\Paginator\Factories; +use Quantum\Model\DbModel; use Quantum\Paginator\Exceptions\PaginatorException; use Quantum\Tests\_root\shared\Models\TestPostModel; use Quantum\Paginator\Contracts\PaginatorInterface; @@ -14,7 +15,7 @@ class PaginatorFactoryTest extends PaginatorTestCase { - private $postModel; + private DbModel $postModel; public function setUp(): void { @@ -23,7 +24,7 @@ public function setUp(): void $this->postModel = ModelFactory::createDynamicModel('posts', TestPostModel::class); } - public function testPaginatorFactoryInstance() + public function testPaginatorFactoryInstance(): void { $paginator = PaginatorFactory::create(Paginator::ARRAY, [ 'items' => [], @@ -34,7 +35,7 @@ public function testPaginatorFactoryInstance() $this->assertInstanceOf(Paginator::class, $paginator); } - public function testPaginatorFactoryArrayAdapter() + public function testPaginatorFactoryArrayAdapter(): void { $paginator = PaginatorFactory::create(Paginator::ARRAY, [ 'items' => [], @@ -47,7 +48,7 @@ public function testPaginatorFactoryArrayAdapter() $this->assertInstanceOf(PaginatorInterface::class, $paginator->getAdapter()); } - public function testPaginatorFactoryModelAdapter() + public function testPaginatorFactoryModelAdapter(): void { $paginator = PaginatorFactory::create(Paginator::MODEL, [ 'model' => $this->postModel, @@ -60,7 +61,7 @@ public function testPaginatorFactoryModelAdapter() $this->assertInstanceOf(PaginatorInterface::class, $paginator->getAdapter()); } - public function testPaginatorFactoryInvalidAdapter() + public function testPaginatorFactoryInvalidAdapter(): void { $this->expectException(PaginatorException::class); diff --git a/tests/Unit/Paginator/PaginatorTest.php b/tests/Unit/Paginator/PaginatorTest.php index d24fe666d..ecd2057c0 100644 --- a/tests/Unit/Paginator/PaginatorTest.php +++ b/tests/Unit/Paginator/PaginatorTest.php @@ -9,10 +9,11 @@ use Quantum\Paginator\Adapters\ModelPaginator; use Quantum\Model\Factories\ModelFactory; use Quantum\Paginator\Paginator; +use Quantum\Model\DbModel; class PaginatorTest extends PaginatorTestCase { - private $model; + private DbModel $model; public function setUp(): void { @@ -21,7 +22,7 @@ public function setUp(): void $this->model = ModelFactory::createDynamicModel('posts', TestPostModel::class); } - public function testPaginatorGetAdapter() + public function testPaginatorGetAdapter(): void { $paginator = new Paginator(new ArrayPaginator([], 2, 2)); @@ -36,14 +37,14 @@ public function testPaginatorGetAdapter() $this->assertInstanceOf(PaginatorInterface::class, $paginator->getAdapter()); } - public function testPaginatorCallingValidMethod() + public function testPaginatorCallingValidMethod(): void { $paginator = new Paginator(new ArrayPaginator([], 2, 2)); $this->assertEquals(0, $paginator->total()); } - public function testPaginatorCallingInvalidMethod() + public function testPaginatorCallingInvalidMethod(): void { $paginator = new Paginator(new ArrayPaginator([], 2, 2)); diff --git a/tests/Unit/Paginator/PaginatorTestCase.php b/tests/Unit/Paginator/PaginatorTestCase.php index 09c68211b..8303c835c 100644 --- a/tests/Unit/Paginator/PaginatorTestCase.php +++ b/tests/Unit/Paginator/PaginatorTestCase.php @@ -24,7 +24,7 @@ public function tearDown(): void IdiormDbal::execute('DROP TABLE IF EXISTS posts'); } - private function _createPostTableWithData() + private function _createPostTableWithData(): void { IdiormDbal::execute('CREATE TABLE IF NOT EXISTS posts ( id INTEGER PRIMARY KEY, diff --git a/tests/Unit/Renderer/Adapters/HtmlAdapterTest.php b/tests/Unit/Renderer/Adapters/HtmlAdapterTest.php index 0b00bb2d2..f76bb90b4 100644 --- a/tests/Unit/Renderer/Adapters/HtmlAdapterTest.php +++ b/tests/Unit/Renderer/Adapters/HtmlAdapterTest.php @@ -19,8 +19,7 @@ public function setUp(): void ['GET'], '/test', 'SomeController', - 'test', - null + 'test' ); $route->module('Test'); diff --git a/tests/Unit/Renderer/Adapters/TwigAdapterTest.php b/tests/Unit/Renderer/Adapters/TwigAdapterTest.php index 344792ad2..7d7e401d4 100644 --- a/tests/Unit/Renderer/Adapters/TwigAdapterTest.php +++ b/tests/Unit/Renderer/Adapters/TwigAdapterTest.php @@ -19,8 +19,7 @@ public function setUp(): void ['GET'], '/test', 'SomeController', - 'test', - null + 'test' ); $route->module('Test'); diff --git a/tests/Unit/Renderer/Factories/RendererFactoryTest.php b/tests/Unit/Renderer/Factories/RendererFactoryTest.php index 4dc95c9f8..f97b391b1 100644 --- a/tests/Unit/Renderer/Factories/RendererFactoryTest.php +++ b/tests/Unit/Renderer/Factories/RendererFactoryTest.php @@ -19,14 +19,14 @@ public function setUp(): void $this->setPrivateProperty(RendererFactory::class, 'instances', []); } - public function testRendererFactoryInstance() + public function testRendererFactoryInstance(): void { $renderer = RendererFactory::get(); $this->assertInstanceOf(Renderer::class, $renderer); } - public function testRendererFactoryGetDefaultAdapter() + public function testRendererFactoryGetDefaultAdapter(): void { $renderer = RendererFactory::get(); @@ -35,7 +35,7 @@ public function testRendererFactoryGetDefaultAdapter() $this->assertInstanceOf(HtmlAdapter::class, $renderer->getAdapter()); } - public function testRendererFactoryGetHtmlAdapter() + public function testRendererFactoryGetHtmlAdapter(): void { $renderer = RendererFactory::get(Renderer::HTML); @@ -44,7 +44,7 @@ public function testRendererFactoryGetHtmlAdapter() $this->assertInstanceOf(HtmlAdapter::class, $renderer->getAdapter()); } - public function testRendererFactoryTwigAdapter() + public function testRendererFactoryTwigAdapter(): void { $renderer = RendererFactory::get(Renderer::TWIG); @@ -53,7 +53,7 @@ public function testRendererFactoryTwigAdapter() $this->assertInstanceOf(TwigAdapter::class, $renderer->getAdapter()); } - public function testRendererFactoryInvalidTypeAdapter() + public function testRendererFactoryInvalidTypeAdapter(): void { $this->expectException(RendererException::class); @@ -62,7 +62,7 @@ public function testRendererFactoryInvalidTypeAdapter() RendererFactory::get('invalid_type'); } - public function testRendererFactoryReturnsSameInstance() + public function testRendererFactoryReturnsSameInstance(): void { $renderer1 = RendererFactory::get(Renderer::HTML); $renderer2 = RendererFactory::get(Renderer::HTML); diff --git a/tests/Unit/Renderer/RendererTest.php b/tests/Unit/Renderer/RendererTest.php index 3d5b77bb5..7237a98ca 100644 --- a/tests/Unit/Renderer/RendererTest.php +++ b/tests/Unit/Renderer/RendererTest.php @@ -23,8 +23,7 @@ public function setUp(): void ['GET'], '/test', 'SomeController', - 'test', - null + 'test' ); $route->module('Test'); @@ -38,7 +37,7 @@ public function setUp(): void } } - public function testRendererGetHtmlAdapter() + public function testRendererGetHtmlAdapter(): void { $renderer = new Renderer(new HtmlAdapter()); @@ -47,7 +46,7 @@ public function testRendererGetHtmlAdapter() $this->assertInstanceOf(TemplateRendererInterface::class, $renderer->getAdapter()); } - public function testRendererGetTwigAdapter() + public function testRendererGetTwigAdapter(): void { $renderer = new Renderer(new TwigAdapter()); @@ -56,7 +55,7 @@ public function testRendererGetTwigAdapter() $this->assertInstanceOf(TemplateRendererInterface::class, $renderer->getAdapter()); } - public function testRendererCallingValidMethod() + public function testRendererCallingValidMethod(): void { $renderer = new Renderer(new HtmlAdapter()); @@ -67,7 +66,7 @@ public function testRendererCallingValidMethod() $this->assertSame('

    Hello Tester, this is rendered html view

    ', $output); } - public function testRendererCallingInvalidMethod() + public function testRendererCallingInvalidMethod(): void { $renderer = new Renderer(new HtmlAdapter()); diff --git a/tests/Unit/ResourceCache/ViewCacheTest.php b/tests/Unit/ResourceCache/ViewCacheTest.php index df5de1031..ab9760dd8 100644 --- a/tests/Unit/ResourceCache/ViewCacheTest.php +++ b/tests/Unit/ResourceCache/ViewCacheTest.php @@ -9,7 +9,7 @@ class ViewCacheDouble extends ViewCache { - private $forceMissingHtmlMin = false; + private bool $forceMissingHtmlMin = false; public function simulateMissingHtmlMin(bool $state): void { @@ -29,11 +29,11 @@ protected function htmlMinifierExists(): bool class ViewCacheTest extends AppTestCase { - private $viewCache; + private \Quantum\ResourceCache\ViewCache $viewCache; - private $route = '/current-route'; + private string $route = '/current-route'; - private $content = << Test html contentspan> @@ -53,7 +53,7 @@ public function tearDown(): void $this->viewCache->enableCaching(false); } - public function testServeCachedView() + public function testServeCachedView(): void { $this->viewCache->enableCaching(true); @@ -68,7 +68,7 @@ public function testServeCachedView() $this->assertEquals($this->content, $response->getContent()); } - public function testSetAndGetViewCache() + public function testSetAndGetViewCache(): void { $this->viewCache->set($this->route, $this->content); @@ -77,7 +77,7 @@ public function testSetAndGetViewCache() $this->assertEquals($this->content, $viewCache); } - public function testViewCacheContentMinification() + public function testViewCacheContentMinification(): void { $this->viewCache->enableMinification(true); @@ -90,7 +90,7 @@ public function testViewCacheContentMinification() $this->assertEquals($minifiedContent, $content); } - public function testViewCacheMinificationMissingDependency() + public function testViewCacheMinificationMissingDependency(): void { $viewCache = new ViewCacheDouble(); $viewCache->enableMinification(true); @@ -101,14 +101,14 @@ public function testViewCacheMinificationMissingDependency() $viewCache->set($this->route, '
    test
    '); } - public function testExistsViewCache() + public function testExistsViewCache(): void { $this->viewCache->set($this->route, $this->content); $this->assertTrue($this->viewCache->exists($this->route)); } - public function testDeleteViewCache() + public function testDeleteViewCache(): void { $this->viewCache->set($this->route, $this->content); @@ -119,14 +119,14 @@ public function testDeleteViewCache() $this->assertFalse($this->viewCache->exists($this->route)); } - public function testGetNonExistentViewCache() + public function testGetNonExistentViewCache(): void { $viewCache = $this->viewCache->get('/non-existent-route'); $this->assertNull($viewCache); } - public function testViewCacheIsExpired() + public function testViewCacheIsExpired(): void { $this->viewCache->setTtl(1); @@ -139,7 +139,7 @@ public function testViewCacheIsExpired() $this->assertNull($viewCache); } - public function testEnableDisableViewCache() + public function testEnableDisableViewCache(): void { $this->assertFalse($this->viewCache->isEnabled()); diff --git a/tests/Unit/Router/Helpers/RouteHelpersTest.php b/tests/Unit/Router/Helpers/RouteHelpersTest.php index 6c3f8e1fe..47ca61264 100644 --- a/tests/Unit/Router/Helpers/RouteHelpersTest.php +++ b/tests/Unit/Router/Helpers/RouteHelpersTest.php @@ -25,7 +25,7 @@ public function tearDown(): void parent::tearDown(); } - public function testHelpersReturnDefaultsWhenNoRouteMatched() + public function testHelpersReturnDefaultsWhenNoRouteMatched(): void { $this->assertNull(current_middlewares()); $this->assertNull(current_module()); @@ -41,14 +41,13 @@ public function testHelpersReturnDefaultsWhenNoRouteMatched() $this->assertNull(route_prefix()); } - public function testHelpersReturnValuesForMatchedControllerRoute() + public function testHelpersReturnValuesForMatchedControllerRoute(): void { $route = new Route( ['GET'], '[:alpha:2]?/post/[uuid=:any]', 'PostController', - 'show', - null + 'show' ); $route @@ -80,9 +79,9 @@ public function testHelpersReturnValuesForMatchedControllerRoute() $this->assertSame('api', route_prefix()); } - public function testRouteCallbackReturnsClosureForClosureRoute() + public function testRouteCallbackReturnsClosureForClosureRoute(): void { - $closure = function () { + $closure = function (): void { }; $route = new Route( @@ -102,14 +101,13 @@ public function testRouteCallbackReturnsClosureForClosureRoute() $this->assertNull(current_action()); } - public function testFindRouteByNameReturnsRouteFromCollection() + public function testFindRouteByNameReturnsRouteFromCollection(): void { $route = new Route( ['GET'], 'dashboard', 'DashboardController', - 'index', - null + 'index' ); $route->name('Dashboard')->module('Admin'); @@ -125,14 +123,13 @@ public function testFindRouteByNameReturnsRouteFromCollection() $this->assertSame('DashboardController', $found->getController()); } - public function testRouteGroupExistsDetectsGroupInModule() + public function testRouteGroupExistsDetectsGroupInModule(): void { $route = new Route( ['GET'], 'profile', 'ProfileController', - 'show', - null + 'show' ); $route->group('auth')->module('Web'); @@ -147,7 +144,7 @@ public function testRouteGroupExistsDetectsGroupInModule() $this->assertFalse(route_group_exists('auth', 'api')); } - public function testRouteMethodAndUri() + public function testRouteMethodAndUri(): void { $request = new Request(); $request->create('POST', 'http://example.com/api/test'); @@ -157,7 +154,7 @@ public function testRouteMethodAndUri() $this->assertSame('api/test', route_uri()); } - public function testFindRouteByNameDependsOnCollectionRegistration() + public function testFindRouteByNameDependsOnCollectionRegistration(): void { $this->assertNull( find_route_by_name('dashboard', 'admin'), @@ -176,8 +173,7 @@ public function testFindRouteByNameDependsOnCollectionRegistration() ['GET'], 'dashboard', 'DashboardController', - 'index', - null + 'index' ); $route->name('dashboard')->module('admin'); @@ -190,7 +186,7 @@ public function testFindRouteByNameDependsOnCollectionRegistration() $this->assertSame('DashboardController', $found->getController()); } - public function testRouteGroupExistsDependsOnCollectionRegistration() + public function testRouteGroupExistsDependsOnCollectionRegistration(): void { $this->assertFalse( route_group_exists('auth', 'web'), @@ -209,8 +205,7 @@ public function testRouteGroupExistsDependsOnCollectionRegistration() ['GET'], 'profile', 'ProfileController', - 'show', - null + 'show' ); $route->group('auth')->module('web'); diff --git a/tests/Unit/Router/MatchedRouteTest.php b/tests/Unit/Router/MatchedRouteTest.php index 5b687aa75..983e5b1b6 100644 --- a/tests/Unit/Router/MatchedRouteTest.php +++ b/tests/Unit/Router/MatchedRouteTest.php @@ -8,7 +8,7 @@ class MatchedRouteTest extends AppTestCase { - public function testMatchedRouteStoresRouteAndParams() + public function testMatchedRouteStoresRouteAndParams(): void { $route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act'); $params = ['id' => '42']; @@ -19,7 +19,7 @@ public function testMatchedRouteStoresRouteAndParams() $this->assertSame($params, $matched->getParams()); } - public function testMatchedRouteSupportsEmptyParams() + public function testMatchedRouteSupportsEmptyParams(): void { $route = new Route(['GET'], 'users', 'Ctrl', 'act'); @@ -28,7 +28,7 @@ public function testMatchedRouteSupportsEmptyParams() $this->assertSame([], $matched->getParams()); } - public function testMatchedRouteParamsAreReturnedAsGiven() + public function testMatchedRouteParamsAreReturnedAsGiven(): void { $route = new Route(['GET'], 'x', 'Ctrl', 'act'); @@ -48,7 +48,7 @@ public function testMatchedRouteParamsAreReturnedAsGiven() $this->assertSame('hello', $matched->getParams()['slug']); } - public function testMatchedRouteRouteInstanceIsExactSameObject() + public function testMatchedRouteRouteInstanceIsExactSameObject(): void { $route = new Route(['POST'], 'submit', 'Ctrl', 'act'); diff --git a/tests/Unit/Router/PatternCompilerTest.php b/tests/Unit/Router/PatternCompilerTest.php index 775fedab2..30e0ce40d 100644 --- a/tests/Unit/Router/PatternCompilerTest.php +++ b/tests/Unit/Router/PatternCompilerTest.php @@ -18,7 +18,7 @@ public function setUp(): void $this->compiler = new PatternCompiler(); } - public function testPatternCompilerStaticRouteMatch() + public function testPatternCompilerStaticRouteMatch(): void { $this->route = new Route(['GET'], 'users', 'Ctrl', 'act'); @@ -31,7 +31,7 @@ public function testPatternCompilerStaticRouteMatch() $this->assertFalse($this->compiler->match($this->route, '/users/1')); } - public function testPatternCompilerNumericParamMatch() + public function testPatternCompilerNumericParamMatch(): void { $this->route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act'); @@ -44,7 +44,7 @@ public function testPatternCompilerNumericParamMatch() $this->assertSame([], $this->compiler->getParams()); } - public function testPatternCompilerAlphaParamMatch() + public function testPatternCompilerAlphaParamMatch(): void { $this->route = new Route(['GET'], 'tag/[name=:alpha]', 'Ctrl', 'act'); @@ -55,7 +55,7 @@ public function testPatternCompilerAlphaParamMatch() $this->assertFalse($this->compiler->match($this->route, '/tag/test1')); } - public function testPatternCompilerAnyParamMatch() + public function testPatternCompilerAnyParamMatch(): void { $this->route = new Route(['GET'], 'file/[path=:any]', 'Ctrl', 'act'); @@ -64,7 +64,7 @@ public function testPatternCompilerAnyParamMatch() $this->assertSame(['path' => 'a-b_c'], $this->compiler->getParams()); } - public function testPatternCompilerOptionalParamAtEnd() + public function testPatternCompilerOptionalParamAtEnd(): void { $this->route = new Route(['GET'], 'post/[id=:num]?', 'Ctrl', 'act'); @@ -77,7 +77,7 @@ public function testPatternCompilerOptionalParamAtEnd() $this->assertSame(['id' => '7'], $this->compiler->getParams()); } - public function testPatternCompilerLengthConstraint() + public function testPatternCompilerLengthConstraint(): void { $this->route = new Route(['GET'], 'code/[id=:num:4]', 'Ctrl', 'act'); @@ -88,7 +88,7 @@ public function testPatternCompilerLengthConstraint() $this->assertFalse($this->compiler->match($this->route, '/code/123')); } - public function testPatternCompilerMultipleParams() + public function testPatternCompilerMultipleParams(): void { $this->route = new Route( ['GET'], @@ -102,7 +102,7 @@ public function testPatternCompilerMultipleParams() $this->assertSame(['id' => '5', 'slug' => 'hello'], $this->compiler->getParams()); } - public function testPatternCompilerOptionalLeadingParam() + public function testPatternCompilerOptionalLeadingParam(): void { $this->route = new Route( ['GET'], @@ -116,7 +116,7 @@ public function testPatternCompilerOptionalLeadingParam() $this->assertTrue($this->compiler->match($this->route, '/en/about')); } - public function testPatternCompilerInvalidParamNameThrowsException() + public function testPatternCompilerInvalidParamNameThrowsException(): void { $this->route = new Route(['GET'], '[id1=:num]', 'Ctrl', 'act'); @@ -125,7 +125,7 @@ public function testPatternCompilerInvalidParamNameThrowsException() $this->compiler->compile($this->route); } - public function testPatternCompilerDuplicateParamNameThrowsException() + public function testPatternCompilerDuplicateParamNameThrowsException(): void { $this->route = new Route( ['GET'], @@ -139,7 +139,7 @@ public function testPatternCompilerDuplicateParamNameThrowsException() $this->compiler->compile($this->route); } - public function tesPatternCompilertUrlDecodedInput() + public function tesPatternCompilertUrlDecodedInput(): void { $this->route = new Route(['GET'], 'user/[id=:num]', 'Ctrl', 'act'); @@ -153,14 +153,14 @@ public function tesPatternCompilertUrlDecodedInput() $this->assertSame(['id' => '42'], $this->compiler->getParams()); } - public function testPatternCompilerRootPatternMatches() + public function testPatternCompilerRootPatternMatches(): void { $this->route = new Route(['GET'], '/', 'Ctrl', 'act'); $this->assertTrue($this->compiler->match($this->route, '/')); } - public function testPatternCompilerParamsResetAfterFailedMatch() + public function testPatternCompilerParamsResetAfterFailedMatch(): void { $this->route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act'); diff --git a/tests/Unit/Router/RouteBuilderTest.php b/tests/Unit/Router/RouteBuilderTest.php index f9ae15964..e272e05e0 100644 --- a/tests/Unit/Router/RouteBuilderTest.php +++ b/tests/Unit/Router/RouteBuilderTest.php @@ -10,12 +10,12 @@ class RouteBuilderTest extends AppTestCase { - public function testRouteBuilderBuildReturnsRouteCollection() + public function testRouteBuilderBuildReturnsRouteCollection(): void { $builder = new RouteBuilder(); $routes = $builder->build([ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('users', 'UserController', 'index'); }, ], []); @@ -25,16 +25,16 @@ public function testRouteBuilderBuildReturnsRouteCollection() $this->assertSame(1, $routes->count()); } - public function testRouteBuilderBuildCollectsRoutesFromMultipleModules() + public function testRouteBuilderBuildCollectsRoutesFromMultipleModules(): void { $builder = new RouteBuilder(); $closures = [ - 'Api' => function (RouteBuilder $route) { + 'Api' => function (RouteBuilder $route): void { $route->get('users', 'UsersController', 'index'); $route->post('login', 'AuthController', 'login'); }, - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('', 'HomeController', 'index'); }, ]; @@ -69,13 +69,13 @@ public function testRouteBuilderBuildCollectsRoutesFromMultipleModules() $this->assertTrue($all[2]->allowsMethod('GET')); } - public function testRouteBuilderMissingModuleConfigFallsBackSafely() + public function testRouteBuilderMissingModuleConfigFallsBackSafely(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Test' => function (RouteBuilder $route) { + 'Test' => function (RouteBuilder $route): void { $route->get('ping', 'PingController', 'index'); }, ], @@ -91,13 +91,13 @@ public function testRouteBuilderMissingModuleConfigFallsBackSafely() $this->assertSame('/ping', $route->getPattern()); } - public function testRouteBuilderPrefixIsAppliedToRoutes() + public function testRouteBuilderPrefixIsAppliedToRoutes(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Api' => function (RouteBuilder $route) { + 'Api' => function (RouteBuilder $route): void { $route->get('status', 'StatusController', 'index'); }, ], @@ -113,14 +113,14 @@ public function testRouteBuilderPrefixIsAppliedToRoutes() $this->assertSame('Api', $route->getModule()); } - public function testRouteBuilderGroupAssignsGroupNameToRoutes() + public function testRouteBuilderGroupAssignsGroupNameToRoutes(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('auth', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('auth', function (RouteBuilder $route): void { $route->get('dashboard', 'DashboardController', 'index'); }); }, @@ -133,7 +133,7 @@ public function testRouteBuilderGroupAssignsGroupNameToRoutes() $this->assertSame('auth', $route->getGroup()); } - public function testRouteBuilderNestedGroupsAreNotAllowed() + public function testRouteBuilderNestedGroupsAreNotAllowed(): void { $this->expectException(RouteException::class); @@ -141,9 +141,9 @@ public function testRouteBuilderNestedGroupsAreNotAllowed() $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('one', function (RouteBuilder $route) { - $route->group('two', function () { + 'Web' => function (RouteBuilder $route): void { + $route->group('one', function (RouteBuilder $route): void { + $route->group('two', function (): void { }); }); }, @@ -152,14 +152,14 @@ public function testRouteBuilderNestedGroupsAreNotAllowed() ); } - public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes() + public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('auth', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('auth', function (RouteBuilder $route): void { $route->get('profile', 'ProfileController', 'show'); })->middlewares(['Auth']); }, @@ -172,14 +172,14 @@ public function testRouteBuilderGroupMiddlewaresAreAppliedToRoutes() $this->assertSame(['Auth'], $route->getMiddlewares()); } - public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares() + public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('auth', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('auth', function (RouteBuilder $route): void { $route ->get('profile', 'ProfileController', 'show') ->middlewares(['Editor']); @@ -197,7 +197,7 @@ public function testRouteBuilderRouteMiddlewaresPrependToGroupMiddlewares() ); } - public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup() + public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup(): void { $this->expectException(RouteException::class); @@ -205,7 +205,7 @@ public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup() $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->middlewares(['Invalid']); }, ], @@ -213,14 +213,14 @@ public function testRouteBuilderMiddlewaresMustBeCalledAfterRouteOrInsideGroup() ); } - public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneRoutes() + public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneRoutes(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('auth', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('auth', function (RouteBuilder $route): void { $route->get('profile', 'ProfileController', 'show')->middlewares(['ProfileMw']); $route->get('settings', 'SettingsController', 'show')->middlewares(['SettingsMw']); })->middlewares(['AuthMw']); @@ -228,8 +228,8 @@ public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneR $route->get('home', 'HomeController', 'index')->middlewares(['HomeMw']); }, - 'Api' => function (RouteBuilder $route) { - $route->group('api-auth', function (RouteBuilder $route) { + 'Api' => function (RouteBuilder $route): void { + $route->group('api-auth', function (RouteBuilder $route): void { $route->get('users', 'UsersController', 'index')->middlewares(['UsersMw1', 'UsersMw2']); $route->post('login', 'AuthController', 'login')->middlewares(['LoginMw']); })->middlewares(['ApiAuthMw']); @@ -255,13 +255,13 @@ public function testRouteBuilderMiddlewareOrderAcrossModulesGroupsAndStandaloneR $this->assertSame(['StatusMw'], $all[5]->getMiddlewares()); } - public function testRouteBuilderRouteNameIsAssigned() + public function testRouteBuilderRouteNameIsAssigned(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('home', 'HomeController', 'index') ->name('home'); }, @@ -272,7 +272,7 @@ public function testRouteBuilderRouteNameIsAssigned() $this->assertSame('home', $routes->all()[0]->getName()); } - public function testRouteBuilderRouteNamesMustBeUnique() + public function testRouteBuilderRouteNamesMustBeUnique(): void { $this->expectException(RouteException::class); @@ -280,7 +280,7 @@ public function testRouteBuilderRouteNamesMustBeUnique() $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('a', 'AController', 'a')->name('dup'); $route->get('b', 'BController', 'b')->name('dup'); }, @@ -289,16 +289,16 @@ public function testRouteBuilderRouteNamesMustBeUnique() ); } - public function testRouteBuilderRouteNamesCanRepeatAcrossModules() + public function testRouteBuilderRouteNamesCanRepeatAcrossModules(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Api' => function (RouteBuilder $route) { + 'Api' => function (RouteBuilder $route): void { $route->get('posts', 'ApiPostController', 'index')->name('posts'); }, - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('posts', 'WebPostController', 'index')->name('posts'); }, ], @@ -317,7 +317,7 @@ public function testRouteBuilderRouteNamesCanRepeatAcrossModules() $this->assertSame('Web', $all[1]->getModule()); } - public function testRouteBuilderNameMustBeCalledAfterRouteDefinition() + public function testRouteBuilderNameMustBeCalledAfterRouteDefinition(): void { $this->expectException(RouteException::class); @@ -325,7 +325,7 @@ public function testRouteBuilderNameMustBeCalledAfterRouteDefinition() $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->name('invalid'); }, ], @@ -333,13 +333,13 @@ public function testRouteBuilderNameMustBeCalledAfterRouteDefinition() ); } - public function testRouteBuilderCacheableAppliesToSingleRoute() + public function testRouteBuilderCacheableAppliesToSingleRoute(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('page', 'PageController', 'show') ->cacheable(true, 60); }, @@ -353,14 +353,14 @@ public function testRouteBuilderCacheableAppliesToSingleRoute() $this->assertSame(60, $cache['ttl']); } - public function testRouteBuilderCacheableAppliesToGroupRoutes() + public function testRouteBuilderCacheableAppliesToGroupRoutes(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Web' => function (RouteBuilder $route) { - $route->group('cached', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('cached', function (RouteBuilder $route): void { $route->get('a', 'AController', 'a'); $route->get('b', 'BController', 'b'); })->cacheable(true, 120); @@ -376,7 +376,7 @@ public function testRouteBuilderCacheableAppliesToGroupRoutes() } } - public function testRouteBuilderAddRouteRequiresControllerAndAction() + public function testRouteBuilderAddRouteRequiresControllerAndAction(): void { $this->expectException(RouteException::class); @@ -384,7 +384,7 @@ public function testRouteBuilderAddRouteRequiresControllerAndAction() $builder->build( [ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('broken', 'OnlyController'); }, ], @@ -392,13 +392,13 @@ public function testRouteBuilderAddRouteRequiresControllerAndAction() ); } - public function testRouteBuilderResolvesShortControllerNameToFqcn() + public function testRouteBuilderResolvesShortControllerNameToFqcn(): void { $builder = new RouteBuilder(); $routes = $builder->build( [ - 'Test' => function (RouteBuilder $route) { + 'Test' => function (RouteBuilder $route): void { $route->get('tests', 'TestController', 'tests'); }, ], @@ -407,22 +407,22 @@ public function testRouteBuilderResolvesShortControllerNameToFqcn() $route = $routes->all()[0]; - $expected = 'Quantum\\Tests\\_root\\modules\\Test\\Controllers\\TestController'; + $expected = \Quantum\Tests\_root\modules\Test\Controllers\TestController::class; $this->assertTrue(class_exists($expected), 'Expected test controller class to exist'); $this->assertSame($expected, $route->getController()); } - public function testRouteBuilderDoesNotModifyExplicitFqcnController() + public function testRouteBuilderDoesNotModifyExplicitFqcnController(): void { $builder = new RouteBuilder(); - $fqcn = 'Quantum\\Tests\\_root\\modules\\Test\\Controllers\\TestController'; + $fqcn = \Quantum\Tests\_root\modules\Test\Controllers\TestController::class; $routes = $builder->build( [ - 'Test' => function (RouteBuilder $route) use ($fqcn) { + 'Test' => function (RouteBuilder $route) use ($fqcn): void { $route->get('tests', $fqcn, 'tests'); }, ], @@ -436,19 +436,19 @@ public function testRouteBuilderDoesNotModifyExplicitFqcnController() $this->assertSame($fqcn, $route->getController()); } - public function testRouteBuilderAddRouteRejectsEmptyMethods() + public function testRouteBuilderAddRouteRejectsEmptyMethods(): void { $this->expectException(RouteException::class); $builder = new RouteBuilder(); $builder->build([ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->add('test', '', 'TestController', 'index'); }, ], []); } - public function testRouteBuilderShortControllerWithoutModuleThrows() + public function testRouteBuilderShortControllerWithoutModuleThrows(): void { $this->expectException(RouteException::class); @@ -467,10 +467,10 @@ public function testRouteBuilderShortControllerWithoutModuleThrows() ); } - public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute() + public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute(): void { $routes = (new RouteBuilder())->build([ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->get('a', 'AController', 'a'); $route->middlewares(['Direct']); }, @@ -479,22 +479,22 @@ public function testRouteBuilderMiddlewaresAppliedDirectlyToRoute() $this->assertSame(['Direct'], $routes->all()[0]->getMiddlewares()); } - public function testRouteBuilderCacheableMustFollowRouteOrGroup() + public function testRouteBuilderCacheableMustFollowRouteOrGroup(): void { $this->expectException(RouteException::class); (new RouteBuilder())->build([ - 'Web' => function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { $route->cacheable(true); }, ], []); } - public function testRouteBuilderResolvePathTrimsSlashesCorrectly() + public function testRouteBuilderResolvePathTrimsSlashesCorrectly(): void { $routes = (new RouteBuilder())->build( [ - 'Api' => function (RouteBuilder $route) { + 'Api' => function (RouteBuilder $route): void { $route->get('/users/', 'UserController', 'index'); }, ], @@ -506,13 +506,11 @@ public function testRouteBuilderResolvePathTrimsSlashesCorrectly() $this->assertSame('/v1/users', $routes->all()[0]->getPattern()); } - public function testRouteBuilderClosureBasedRouteIsSupported() + public function testRouteBuilderClosureBasedRouteIsSupported(): void { $routes = (new RouteBuilder())->build([ - 'Web' => function (RouteBuilder $route) { - $route->get('ping', function () { - return 'pong'; - }); + 'Web' => function (RouteBuilder $route): void { + $route->get('ping', fn (): string => 'pong'); }, ], []); @@ -520,11 +518,11 @@ public function testRouteBuilderClosureBasedRouteIsSupported() $this->assertNull($routes->all()[0]->getController()); } - public function testRouteBuilderGroupedRoutesAreRegisteredIndividually() + public function testRouteBuilderGroupedRoutesAreRegisteredIndividually(): void { $routes = (new RouteBuilder())->build([ - 'Web' => function (RouteBuilder $route) { - $route->group('g', function (RouteBuilder $route) { + 'Web' => function (RouteBuilder $route): void { + $route->group('g', function (RouteBuilder $route): void { $route->get('a', 'AController', 'a'); $route->get('b', 'BController', 'b'); }); diff --git a/tests/Unit/Router/RouteCollectionTest.php b/tests/Unit/Router/RouteCollectionTest.php index 8d40f8623..8860a5a0f 100644 --- a/tests/Unit/Router/RouteCollectionTest.php +++ b/tests/Unit/Router/RouteCollectionTest.php @@ -8,7 +8,7 @@ class RouteCollectionTest extends AppTestCase { - public function testRouteCollectionStartsEmpty() + public function testRouteCollectionStartsEmpty(): void { $collection = new RouteCollection(); @@ -17,7 +17,7 @@ public function testRouteCollectionStartsEmpty() $this->assertSame(0, $collection->count()); } - public function testRouteCollectionAddIncreasesCount() + public function testRouteCollectionAddIncreasesCount(): void { $collection = new RouteCollection(); @@ -28,7 +28,7 @@ public function testRouteCollectionAddIncreasesCount() $this->assertSame(2, $collection->count()); } - public function testRouteCollectionAllReturnsAddedRoutes() + public function testRouteCollectionAllReturnsAddedRoutes(): void { $collection = new RouteCollection(); @@ -44,7 +44,7 @@ public function testRouteCollectionAllReturnsAddedRoutes() $this->assertSame([$r1, $r2], $all); } - public function testRouteCollectionInsertionOrderIsPreserved() + public function testRouteCollectionInsertionOrderIsPreserved(): void { $collection = new RouteCollection(); @@ -61,7 +61,7 @@ public function testRouteCollectionInsertionOrderIsPreserved() $this->assertSame($r2, $all[1]); } - public function testRouteCollectionAllReturnsSameInstances() + public function testRouteCollectionAllReturnsSameInstances(): void { $collection = new RouteCollection(); diff --git a/tests/Unit/Router/RouteDispatcherTest.php b/tests/Unit/Router/RouteDispatcherTest.php index 1352c1852..46a5a4a3f 100644 --- a/tests/Unit/Router/RouteDispatcherTest.php +++ b/tests/Unit/Router/RouteDispatcherTest.php @@ -21,12 +21,12 @@ public function tearDown(): void parent::tearDown(); } - public function testDispatchExecutesClosureRoute() + public function testDispatchExecutesClosureRoute(): void { $called = false; $receivedParam = null; - $closure = function (string $id) use (&$called, &$receivedParam) { + $closure = function (string $id) use (&$called, &$receivedParam): void { $called = true; $receivedParam = $id; }; @@ -41,31 +41,31 @@ public function testDispatchExecutesClosureRoute() $dispatcher = new RouteDispatcher(); $request = Mockery::mock(Request::class); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); $this->assertTrue($called); $this->assertSame('123', $receivedParam); } - public function testDispatchThrowsWhenClosureRouteHasNoClosure() + public function testDispatchThrowsWhenClosureRouteHasNoClosure(): void { $this->expectException(RouteException::class); - $route = new Route(['GET'], '/broken', null, null, null); + $route = new Route(['GET'], '/broken', null, null); $matched = new MatchedRoute($route, []); $dispatcher = new RouteDispatcher(); $request = Mockery::mock(Request::class); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); } - public function testDispatchExecutesControllerActionWithParams() + public function testDispatchExecutesControllerActionWithParams(): void { $controllerClass = new class () { public static ?string $received = null; @@ -76,16 +76,16 @@ public function post(string $uuid): void } }; - $route = new Route(['GET'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post', null); + $route = new Route(['GET'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post'); $matched = new MatchedRoute($route, ['uuid' => 'abc-123']); $dispatcher = new RouteDispatcher(); $request = Mockery::mock(Request::class); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); $this->assertSame( 'abc-123', @@ -94,7 +94,7 @@ public function post(string $uuid): void ); } - public function testDispatchCallsControllerHooksInCorrectOrder() + public function testDispatchCallsControllerHooksInCorrectOrder(): void { $controllerClass = new class () { public static array $calls = []; @@ -115,7 +115,7 @@ public function __after(string $uuid): void } }; - $route = new Route(['GET', 'POST'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post', null); + $route = new Route(['GET', 'POST'], '[:alpha:2]?/post/[uuid=:any]', get_class($controllerClass), 'post'); $matched = new MatchedRoute($route, ['uuid' => 'abc']); @@ -124,9 +124,9 @@ public function __after(string $uuid): void $request = Mockery::mock(Request::class); $request->shouldReceive('getMethod')->andReturn('POST'); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); $this->assertSame( [ @@ -139,7 +139,7 @@ public function __after(string $uuid): void ); } - public function testDispatchThrowsWhenControllerActionDoesNotExist() + public function testDispatchThrowsWhenControllerActionDoesNotExist(): void { $this->expectException(RouteException::class); @@ -147,19 +147,19 @@ public function testDispatchThrowsWhenControllerActionDoesNotExist() // Intentionally no action method }; - $route = new Route(['GET'], '[:alpha:2]?/broken', get_class($controllerClass), 'missingAction', null); + $route = new Route(['GET'], '[:alpha:2]?/broken', get_class($controllerClass), 'missingAction'); $matched = new MatchedRoute($route, []); $dispatcher = new RouteDispatcher(); $request = Mockery::mock(Request::class); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); } - public function testDispatchFailsWhenCsrfIsEnabledAndTokenIsMissing() + public function testDispatchFailsWhenCsrfIsEnabledAndTokenIsMissing(): void { $this->expectException(CsrfException::class); @@ -172,7 +172,7 @@ public function submit(): void } }; - $route = new Route(['POST'], '[:alpha:2]?/submit', get_class($controllerClass), 'submit', null); + $route = new Route(['POST'], '[:alpha:2]?/submit', get_class($controllerClass), 'submit'); $matched = new MatchedRoute($route, []); @@ -182,10 +182,10 @@ public function submit(): void ->with(Csrf::TOKEN_KEY) ->andReturn(false); - $response = Mockery::mock(Response::class); + Mockery::mock(Response::class); $dispatcher = new RouteDispatcher(); - $dispatcher->dispatch($matched, $request, $response); + $dispatcher->dispatch($matched, $request); } } diff --git a/tests/Unit/Router/RouteFinderTest.php b/tests/Unit/Router/RouteFinderTest.php index 3a5f37743..f81d474da 100644 --- a/tests/Unit/Router/RouteFinderTest.php +++ b/tests/Unit/Router/RouteFinderTest.php @@ -22,7 +22,7 @@ public function setUp(): void $this->finder = new RouteFinder($this->collection); } - public function testRouteFinderFindReturnsMatchedRouteForStaticMatch() + public function testRouteFinderFindReturnsMatchedRouteForStaticMatch(): void { $route = new Route(['GET'], 'users', 'Ctrl', 'act'); $this->collection->add($route); @@ -37,7 +37,7 @@ public function testRouteFinderFindReturnsMatchedRouteForStaticMatch() $this->assertSame([], $result->getParams()); } - public function testRouteFinderFindReturnsNullWhenNoMatch() + public function testRouteFinderFindReturnsNullWhenNoMatch(): void { $route = new Route(['GET'], 'users', 'Ctrl', 'act'); $this->collection->add($route); @@ -48,7 +48,7 @@ public function testRouteFinderFindReturnsNullWhenNoMatch() $this->assertNull($this->finder->find($req)); } - public function testRouteFinderFindSkipsWrongHttpMethod() + public function testRouteFinderFindSkipsWrongHttpMethod(): void { $route = new Route(['POST'], 'users', 'Ctrl', 'act'); $this->collection->add($route); @@ -59,7 +59,7 @@ public function testRouteFinderFindSkipsWrongHttpMethod() $this->assertNull($this->finder->find($req)); } - public function testRouteFinderFindReturnsFirstMatchingRouteOnly() + public function testRouteFinderFindReturnsFirstMatchingRouteOnly(): void { $r1 = new Route(['GET'], 'users', 'C1', 'a1'); $r2 = new Route(['GET'], 'users', 'C2', 'a2'); @@ -75,7 +75,7 @@ public function testRouteFinderFindReturnsFirstMatchingRouteOnly() $this->assertSame($r1, $result->getRoute()); } - public function testRouteFinderFindPassesExtractedParams() + public function testRouteFinderFindPassesExtractedParams(): void { $route = new Route(['GET'], 'users/[id=:num]', 'Ctrl', 'act'); $this->collection->add($route); @@ -88,7 +88,7 @@ public function testRouteFinderFindPassesExtractedParams() $this->assertSame(['id' => '42'], $result->getParams()); } - public function testRouteFinderFindWithMultipleRoutesOnlyOneMatches() + public function testRouteFinderFindWithMultipleRoutesOnlyOneMatches(): void { $r1 = new Route(['GET'], 'posts', 'Ctrl', 'act'); $this->collection->add($r1); diff --git a/tests/Unit/Router/RouteTest.php b/tests/Unit/Router/RouteTest.php index b78f0b137..811719185 100644 --- a/tests/Unit/Router/RouteTest.php +++ b/tests/Unit/Router/RouteTest.php @@ -8,7 +8,7 @@ class RouteTest extends AppTestCase { - public function testRouteControllerRouteConstruction() + public function testRouteControllerRouteConstruction(): void { $route = new Route( ['get', 'post'], @@ -28,9 +28,9 @@ public function testRouteControllerRouteConstruction() $this->assertFalse($route->isClosure()); } - public function testRouteClosureRouteConstruction() + public function testRouteClosureRouteConstruction(): void { - $handler = function () { + $handler = function (): void { }; $route = new Route( @@ -50,14 +50,14 @@ public function testRouteClosureRouteConstruction() $this->assertNull($route->getAction()); } - public function testRouteConstructorRejectsEmptyMethods() + public function testRouteConstructorRejectsEmptyMethods(): void { $this->expectException(RouteException::class); new Route([], 'users', 'UserController', 'listAction'); } - public function testRouteClosureRouteCannotDefineControllerOrAction() + public function testRouteClosureRouteCannotDefineControllerOrAction(): void { $this->expectException(RouteException::class); @@ -66,19 +66,19 @@ public function testRouteClosureRouteCannotDefineControllerOrAction() 'health', 'HealthController', 'checkAction', - function () { + function (): void { } ); } - public function testRouteControllerRouteRequiresControllerAndAction() + public function testRouteControllerRouteRequiresControllerAndAction(): void { $this->expectException(RouteException::class); new Route(['GET'], 'users', null, null); } - public function testRouteAllowsMethodIsCaseInsensitive() + public function testRouteAllowsMethodIsCaseInsensitive(): void { $route = new Route( ['GET'], @@ -94,7 +94,7 @@ public function testRouteAllowsMethodIsCaseInsensitive() $this->assertFalse($route->allowsMethod('POST')); } - public function testRouteCacheConfigurationIsStored() + public function testRouteCacheConfigurationIsStored(): void { $route = new Route( ['GET'], @@ -111,7 +111,7 @@ public function testRouteCacheConfigurationIsStored() ); } - public function testRouteCompiledPatternCanBeStored() + public function testRouteCompiledPatternCanBeStored(): void { $route = new Route( ['GET'], @@ -125,7 +125,7 @@ public function testRouteCompiledPatternCanBeStored() $this->assertSame('^users$', $route->getCompiledPattern()); } - public function testRouteMiddlewareStackingOrder() + public function testRouteMiddlewareStackingOrder(): void { $route = new Route( ['GET'], @@ -143,7 +143,7 @@ public function testRouteMiddlewareStackingOrder() ); } - public function testRouteToArrayExportsRouteState() + public function testRouteToArrayExportsRouteState(): void { $route = new Route( ['GET'], diff --git a/tests/Unit/Service/Factories/ServiceFactoryTest.php b/tests/Unit/Service/Factories/ServiceFactoryTest.php index 3ef243f6a..a491da556 100644 --- a/tests/Unit/Service/Factories/ServiceFactoryTest.php +++ b/tests/Unit/Service/Factories/ServiceFactoryTest.php @@ -9,6 +9,9 @@ class TestService extends QtService { public static $count = 0; + /** + * @var TestModel + */ public $model; public function __construct(TestModel $model) @@ -18,7 +21,7 @@ public function __construct(TestModel $model) $this->model = $model; } - public function hello() + public function hello(): string { return 'Hello'; } @@ -55,7 +58,7 @@ public function tearDown(): void TestService::$count = 0; } - public function testServiceFactoryGetInstance() + public function testServiceFactoryGetInstance(): void { $service = ServiceFactory::get(TestService::class); @@ -64,7 +67,7 @@ public function testServiceFactoryGetInstance() $this->assertInstanceOf(TestService::class, $service); } - public function testServiceFactoryVerifySingletonInstance() + public function testServiceFactoryVerifySingletonInstance(): void { $testServiceOne = ServiceFactory::get(TestService::class); @@ -77,7 +80,7 @@ public function testServiceFactoryVerifySingletonInstance() $this->assertSame($testServiceOne, $testServiceTwo); } - public function testServiceFactoryCreateInstance() + public function testServiceFactoryCreateInstance(): void { $service = ServiceFactory::create(TestService::class); @@ -86,7 +89,7 @@ public function testServiceFactoryCreateInstance() $this->assertInstanceOf(TestService::class, $service); } - public function testServiceFactoryVerifyFreshInstance() + public function testServiceFactoryVerifyFreshInstance(): void { $testServiceOne = ServiceFactory::create(TestService::class); @@ -99,21 +102,21 @@ public function testServiceFactoryVerifyFreshInstance() $this->assertNotSame($testServiceOne, $testServiceTwo); } - public function testServiceFactoryVerifyConstructorDependencyResolved() + public function testServiceFactoryVerifyConstructorDependencyResolved(): void { $testService = ServiceFactory::get(TestService::class); $this->assertInstanceOf(DbModel::class, $testService->model); } - public function testServiceFactoryServiceMethodCall() + public function testServiceFactoryServiceMethodCall(): void { $this->assertEquals('Hello', ServiceFactory::get(TestService::class)->hello()); $this->assertEquals('Hello', ServiceFactory::create(TestService::class)->hello()); } - public function testServiceFactoryServiceNotFound() + public function testServiceFactoryServiceNotFound(): void { $this->expectException(ServiceException::class); diff --git a/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php b/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php index e940480ff..8473c8f7c 100644 --- a/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php +++ b/tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php @@ -9,7 +9,7 @@ class ServiceHelperFunctionTest extends AppTestCase { - public function testServiceReturnsQtServiceInstance() + public function testServiceReturnsQtServiceInstance(): void { $service = service(TokenService::class); @@ -18,7 +18,7 @@ public function testServiceReturnsQtServiceInstance() $this->assertInstanceOf(QtService::class, $service); } - public function testModelThrowsOnInvalidClass() + public function testModelThrowsOnInvalidClass(): void { $this->expectException(ServiceException::class); diff --git a/tests/Unit/Service/QtServiceTest.php b/tests/Unit/Service/QtServiceTest.php index af9d729b6..49fc275bb 100644 --- a/tests/Unit/Service/QtServiceTest.php +++ b/tests/Unit/Service/QtServiceTest.php @@ -28,7 +28,7 @@ public function setUp(): void parent::setUp(); } - public function testMissingMethods() + public function testMissingMethods(): void { $this->expectException(ServiceException::class); diff --git a/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php b/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php index afe6e8519..157302b8e 100644 --- a/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php +++ b/tests/Unit/Session/Adapters/Database/DatabaseSessionAdapterTest.php @@ -12,7 +12,7 @@ class DatabaseSessionAdapterTest extends AppTestCase { use TestCaseHelper; - private $session; + private DatabaseSessionAdapter $session; public function setUp(): void { @@ -32,12 +32,12 @@ public function tearDown(): void ModelFactory::createDynamicModel('sessions')->deleteMany(); } - public function testDatabaseSessionConstructor() + public function testDatabaseSessionConstructor(): void { $this->assertInstanceOf(DatabaseSessionAdapter::class, $this->session); } - public function testDatabaseSessionAll() + public function testDatabaseSessionAll(): void { $this->assertEmpty($this->session->all()); @@ -54,7 +54,7 @@ public function testDatabaseSessionAll() $this->assertEquals('Test data', $this->session->all()['test']); } - public function testDatabaseSessionGetSetHasDelete() + public function testDatabaseSessionGetSetHasDelete(): void { $this->assertNull($this->session->get('auth')); @@ -73,7 +73,7 @@ public function testDatabaseSessionGetSetHasDelete() $this->assertNull($this->session->get('auth')); } - public function testDatabaseSessionGetSetFlash() + public function testDatabaseSessionGetSetFlash(): void { $this->session->setFlash('message', 'Flash message'); @@ -82,7 +82,7 @@ public function testDatabaseSessionGetSetFlash() $this->assertNull($this->session->getFlash('message')); } - public function testDatabaseSessionFlush() + public function testDatabaseSessionFlush(): void { $this->session->set('test', 'Test data'); @@ -93,12 +93,12 @@ public function testDatabaseSessionFlush() $this->assertEmpty($this->session->all()); } - public function testDatabaseSessionGetSessionId() + public function testDatabaseSessionGetSessionId(): void { $this->assertEquals(session_id(), $this->session->getId()); } - public function testDatabaseSessionRegenerateSessionId() + public function testDatabaseSessionRegenerateSessionId(): void { $sessionId = $this->session->getId(); diff --git a/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php b/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php index cfcd8d6dd..b48f51c9e 100644 --- a/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php +++ b/tests/Unit/Session/Adapters/Native/NativeSessionAdapterTest.php @@ -7,7 +7,7 @@ class NativeSessionAdapterTest extends AppTestCase { - private $session; + private NativeSessionAdapter $session; public function setUp(): void { @@ -18,12 +18,12 @@ public function setUp(): void $this->session->delete('LAST_ACTIVITY'); } - public function testNativeSessionConstructor() + public function testNativeSessionConstructor(): void { $this->assertInstanceOf(NativeSessionAdapter::class, $this->session); } - public function testNativeSessionSessionAll() + public function testNativeSessionSessionAll(): void { $this->assertEmpty($this->session->all()); @@ -40,7 +40,7 @@ public function testNativeSessionSessionAll() $this->assertEquals('Test data', $this->session->all()['test']); } - public function testNativeSessionGetSetHasDelete() + public function testNativeSessionGetSetHasDelete(): void { $this->assertNull($this->session->get('auth')); @@ -59,7 +59,7 @@ public function testNativeSessionGetSetHasDelete() $this->assertNull($this->session->get('auth')); } - public function testNativeSessionGetSetFlash() + public function testNativeSessionGetSetFlash(): void { $this->session->setFlash('message', 'Flash message'); @@ -68,7 +68,7 @@ public function testNativeSessionGetSetFlash() $this->assertNull($this->session->getFlash('message')); } - public function testNativeSessionFlush() + public function testNativeSessionFlush(): void { $this->session->set('test', 'Test data'); @@ -81,12 +81,12 @@ public function testNativeSessionFlush() session_start(); } - public function testNativeSessionGetSessionId() + public function testNativeSessionGetSessionId(): void { $this->assertEquals(session_id(), $this->session->getId()); } - public function testNativeSessionRegenerateSessionId() + public function testNativeSessionRegenerateSessionId(): void { $sessionId = $this->session->getId(); diff --git a/tests/Unit/Session/Factories/SessionFactoryTest.php b/tests/Unit/Session/Factories/SessionFactoryTest.php index 6913dd60b..0db03a381 100644 --- a/tests/Unit/Session/Factories/SessionFactoryTest.php +++ b/tests/Unit/Session/Factories/SessionFactoryTest.php @@ -39,35 +39,35 @@ public function tearDown(): void ModelFactory::createDynamicModel('sessions')->deleteMany(); } - public function testSessionFactoryInstance() + public function testSessionFactoryInstance(): void { $session = SessionFactory::get(); $this->assertInstanceOf(Session::class, $session); } - public function testSessionFactoryGetDefaultSessionAdapter() + public function testSessionFactoryGetDefaultSessionAdapter(): void { $session = SessionFactory::get(); $this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter()); } - public function testSessionFactoryGetNativeSessionAdapter() + public function testSessionFactoryGetNativeSessionAdapter(): void { $session = SessionFactory::get(Session::NATIVE); $this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter()); } - public function testSessionFactoryGetDatabaseAdapter() + public function testSessionFactoryGetDatabaseAdapter(): void { $session = SessionFactory::get(Session::DATABASE); $this->assertInstanceOf(DatabaseSessionAdapter::class, $session->getAdapter()); } - public function testSessionSubsequentRequests() + public function testSessionSubsequentRequests(): void { config()->set('session.default', 'database'); @@ -102,7 +102,7 @@ public function testSessionSubsequentRequests() $this->assertEquals('Data saved in persistent storage', $session->get('data')); } - public function testSessionFactoryInvalidTypeAdapter() + public function testSessionFactoryInvalidTypeAdapter(): void { $this->expectException(SessionException::class); @@ -111,7 +111,7 @@ public function testSessionFactoryInvalidTypeAdapter() SessionFactory::get('invalid_type'); } - public function testMailerFactoryReturnsSameInstance() + public function testMailerFactoryReturnsSameInstance(): void { $session1 = SessionFactory::get(Session::NATIVE); $session2 = SessionFactory::get(Session::NATIVE); diff --git a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php index 28096c073..b1b7ee494 100644 --- a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php +++ b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php @@ -9,7 +9,7 @@ class SessionHelperFunctionsTest extends AppTestCase { - public function testSessionHelperGetDefaultSessionAdapter() + public function testSessionHelperGetDefaultSessionAdapter(): void { config()->delete('session'); @@ -20,7 +20,7 @@ public function testSessionHelperGetDefaultSessionAdapter() $this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter()); } - public function testSessionHelperGetNativeSessionAdapter() + public function testSessionHelperGetNativeSessionAdapter(): void { $session = session(Session::NATIVE); @@ -29,7 +29,7 @@ public function testSessionHelperGetNativeSessionAdapter() $this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter()); } - public function testSessionHelperGetDatabaseSessionAdapter() + public function testSessionHelperGetDatabaseSessionAdapter(): void { $session = session(Session::DATABASE); @@ -38,7 +38,7 @@ public function testSessionHelperGetDatabaseSessionAdapter() $this->assertInstanceOf(DatabaseSessionAdapter::class, $session->getAdapter()); } - public function testSessionMethodsViaHelper() + public function testSessionMethodsViaHelper(): void { $this->assertFalse(session()->has('test')); diff --git a/tests/Unit/Session/SessionTest.php b/tests/Unit/Session/SessionTest.php index e180c088a..56c3b787a 100644 --- a/tests/Unit/Session/SessionTest.php +++ b/tests/Unit/Session/SessionTest.php @@ -21,7 +21,7 @@ public function setUp(): void } } - public function testSessionGetAdapter() + public function testSessionGetAdapter(): void { $session = new Session(new NativeSessionAdapter()); @@ -36,7 +36,7 @@ public function testSessionGetAdapter() $this->assertInstanceOf(SessionStorageInterface::class, $session->getAdapter()); } - public function testSessionCallingValidMethod() + public function testSessionCallingValidMethod(): void { $session = new Session(new NativeSessionAdapter()); @@ -45,7 +45,7 @@ public function testSessionCallingValidMethod() $this->assertEquals('Test data', $session->get('test')); } - public function testSessionCallingInvalidMethod() + public function testSessionCallingInvalidMethod(): void { $mailer = new Session(new NativeSessionAdapter()); diff --git a/tests/Unit/Session/TestCaseHelper.php b/tests/Unit/Session/TestCaseHelper.php index 3ff2a429d..62280d160 100644 --- a/tests/Unit/Session/TestCaseHelper.php +++ b/tests/Unit/Session/TestCaseHelper.php @@ -6,7 +6,7 @@ trait TestCaseHelper { - private function _createSessionsTable() + private function _createSessionsTable(): void { IdiormDbal::execute( 'CREATE TABLE IF NOT EXISTS sessions ( diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php index bfd03f8ae..b12901e17 100644 --- a/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php +++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxAppTest.php @@ -11,35 +11,17 @@ class DropboxAppTest extends AppTestCase use DropboxTokenServiceTestCase; use HttpClientTestCase; - /** - * @var DropboxApp - */ - private $dropboxApp; - - /** - * @var string - */ - private $appKey = 'x0hwm8wy63rrynm'; - - /** - * @var string - */ - private $appSecret = 'xxx123yyy'; - - /** - * @var string - */ - private $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA'; - - /** - * @var string - */ - private $redirectUrl = 'http://localhost/confirm'; - - /** - * @var array - */ - private $tokensGrantResponse = [ + private DropboxApp $dropboxApp; + + private string $appKey = 'x0hwm8wy63rrynm'; + + private string $appSecret = 'xxx123yyy'; + + private string $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA'; + + private string $redirectUrl = 'http://localhost/confirm'; + + private array $tokensGrantResponse = [ 'access_token' => 'sl.BYEQ1_VadTz6nBU36WPBBVwokc3zWVMXGjcOKxV4Tadms8ZlEPM85aHVFa_k1sfjilCWOnl79RUncPZzJ3GhrqhLGIBFFRCH0rKMa_ZtcqkerJn-f5lu10Ki5PSw4fxYM80V4PL_', 'token_type' => 'bearer', 'expires_in' => 14400, @@ -49,10 +31,7 @@ class DropboxAppTest extends AppTestCase 'account_id' => 'dbid:AAC9tDKbzTQlyNms0ZcB_iH3wLv7yNn-iyE', ]; - /** - * @var array - */ - private $profileDataResponse = [ + private array $profileDataResponse = [ 'account_id' => 'dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc', 'disabled' => false, 'email' => 'franz@dropbox.com', @@ -68,20 +47,14 @@ class DropboxAppTest extends AppTestCase 'profile_photo_url' => 'https://dl-web.dropbox.com/account_photo/get/69330102&size=128x128', ]; - /** - * @var array - */ - private $errorResponse = [ + private array $errorResponse = [ 'error' => [ '.tag' => 'no_account', ], 'error_summary' => 'no_account/...', ]; - /** - * @var string - */ - private $fileContentResponse = 'Some plain text!'; + private string $fileContentResponse = 'Some plain text!'; public function setUp(): void { @@ -94,7 +67,7 @@ public function setUp(): void $this->dropboxApp = new DropboxApp($this->appKey, $this->appSecret, $tokenServiceMock, $httpClientMock); } - public function testDropboxGetAuthUrl() + public function testDropboxGetAuthUrl(): void { $authUrl = $this->dropboxApp->getAuthUrl($this->redirectUrl); @@ -105,7 +78,7 @@ public function testDropboxGetAuthUrl() $this->assertStringContainsString('token_access_type', $authUrl); } - public function testDropboxFetchTokens() + public function testDropboxFetchTokens(): void { $this->currentResponse = (object) $this->tokensGrantResponse; @@ -118,7 +91,7 @@ public function testDropboxFetchTokens() $this->assertTrue(property_exists($response, 'refresh_token')); } - public function testDropboxRpcRequest() + public function testDropboxRpcRequest(): void { $this->currentResponse = (object) $this->profileDataResponse; @@ -131,7 +104,7 @@ public function testDropboxRpcRequest() $this->assertTrue(property_exists($response, 'name')); } - public function testDropboxContentRequest() + public function testDropboxContentRequest(): void { $this->currentResponse = $this->fileContentResponse; @@ -142,7 +115,7 @@ public function testDropboxContentRequest() $this->assertEquals('Some plain text!', $response); } - public function testDropboxSendRequest() + public function testDropboxSendRequest(): void { $this->currentResponse = (object) $this->profileDataResponse; @@ -153,7 +126,7 @@ public function testDropboxSendRequest() $this->assertEquals((object) $this->profileDataResponse, $response); } - public function testDropboxRequestWithAccessTokenExpired() + public function testDropboxRequestWithAccessTokenExpired(): void { $this->currentErrors = ['code' => 401]; @@ -166,7 +139,7 @@ public function testDropboxRequestWithAccessTokenExpired() $this->assertEquals((object) $this->profileDataResponse, $response); } - public function testDropboxPathNormalizer() + public function testDropboxPathNormalizer(): void { $this->assertEquals(['path' => '/message.txt'], $this->dropboxApp->path('/message.txt')); diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php index 79aca06bd..07a80a9bd 100644 --- a/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php +++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php @@ -14,25 +14,13 @@ class DropboxFileSystemAdapterTest extends AppTestCase */ protected $fs; - /** - * @var string - */ - private $dirname = 'common'; + private string $dirname = 'common'; - /** - * @var string - */ - private $filename = 'sample.txt'; + private string $filename = 'sample.txt'; - /** - * @var string - */ - private $content = 'This file was created via dropbox api'; + private string $content = 'This file was created via dropbox api'; - /** - * @var array - */ - private static $response = []; + private static array $response = []; public function setUp(): void { @@ -42,7 +30,7 @@ public function setUp(): void $dropboxAppMock ->shouldReceive('rpcRequest') - ->andReturnUsing(function ($endpoint, $params) { + ->andReturnUsing(function ($endpoint, $params): array { self::$response = array_merge(self::$response, $params); return self::$response; }); @@ -59,7 +47,7 @@ public function setUp(): void $dropboxAppMock ->shouldReceive('path') - ->andReturnUsing(fn ($path) => ['path' => '/' . trim($path, '/')]); + ->andReturnUsing(fn ($path): array => ['path' => '/' . trim($path, '/')]); $this->fs = new DropboxFileSystemAdapter($dropboxAppMock); } @@ -69,7 +57,7 @@ public function tearDown(): void self::$response = []; } - public function testDropboxMakeCheckRemoveDirectory() + public function testDropboxMakeCheckRemoveDirectory(): void { $this->assertFalse($this->fs->isDirectory($this->dirname)); @@ -86,7 +74,7 @@ public function testDropboxMakeCheckRemoveDirectory() $this->assertFalse($this->fs->isDirectory($this->dirname)); } - public function testDropboxCreateGetCheckRemoveFile() + public function testDropboxCreateGetCheckRemoveFile(): void { $this->assertFalse($this->fs->isFile($this->filename)); @@ -107,7 +95,7 @@ public function testDropboxCreateGetCheckRemoveFile() $this->assertFalse($this->fs->exists($this->filename)); } - public function testDropboxFileAppend() + public function testDropboxFileAppend(): void { self::$response['.tag'] = 'file'; @@ -122,7 +110,7 @@ public function testDropboxFileAppend() $this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename)); } - public function testDropboxFileRename() + public function testDropboxFileRename(): void { $this->fs->put($this->filename, $this->content); @@ -139,7 +127,7 @@ public function testDropboxFileRename() $this->fs->remove($newFilename); } - public function testDropboxFileCopy() + public function testDropboxFileCopy(): void { $dirName = 'testing'; @@ -160,7 +148,7 @@ public function testDropboxFileCopy() $this->fs->removeDirectory($dirName); } - public function testDropboxFileSize() + public function testDropboxFileSize(): void { $text = 'some bytes'; @@ -171,7 +159,7 @@ public function testDropboxFileSize() $this->assertEquals(10, $this->fs->size($this->filename)); } - public function testDropboxFileLastModified() + public function testDropboxFileLastModified(): void { $modified = '2023-02-12T15:50:38Z'; @@ -184,7 +172,7 @@ public function testDropboxFileLastModified() $this->assertEquals(strtotime($modified), $this->fs->lastModified($this->filename)); } - public function testDropboxListDirectory() + public function testDropboxListDirectory(): void { self::$response['entries'] = [ [ diff --git a/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php b/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php index 365f4b81e..c7e72b907 100644 --- a/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php +++ b/tests/Unit/Storage/Adapters/Dropbox/DropboxTokenServiceTestCase.php @@ -13,7 +13,7 @@ protected function mockTokenService() $tokenServiceMock ->shouldReceive('getRefreshToken') - ->andReturnUsing(function () { + ->andReturnUsing(function (): string { $this->currentResponse = (object) $this->tokensGrantResponse; return 'ref_tok_1234'; }); @@ -24,7 +24,7 @@ protected function mockTokenService() $tokenServiceMock ->shouldReceive('saveTokens') - ->andReturnUsing(function ($tokens) { + ->andReturnUsing(function ($tokens): bool { $this->currentResponse = (object) $this->profileDataResponse; return true; }); diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php index dc2d48d59..58d7f8f43 100644 --- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php +++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveAppTest.php @@ -11,58 +11,34 @@ class GoogleDriveAppTest extends AppTestCase use GoogleDriveTokenServiceTestCase; use HttpClientTestCase; - /** - * @var GoogleDriveApp - */ - private $googleDriveApp; + private GoogleDriveApp $googleDriveApp; - /** - * @var string - */ - private $appKey = 'x0hwm8wy63rrynm'; + private string $appKey = 'x0hwm8wy63rrynm'; - /** - * @var string - */ - private $appSecret = 'xxx123yyy'; + private string $appSecret = 'xxx123yyy'; - /** - * @var string - */ - private $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA'; + private string $authCode = 'd4k29ovC7-UAAAAAAAA3Q45go2mLgjMhJSeJNBOo-EA'; - /** - * @var string - */ - private $redirectUrl = 'http://localhost/confirm'; + private string $redirectUrl = 'http://localhost/confirm'; - /** - * @var array - */ - private $tokensGrantResponse = [ + private array $tokensGrantResponse = [ 'access_token' => 'sl.BYEQ1_VadTz6nBU36WPBBVwokc3zWVMXGjcOKxV4Tadms8ZlEPM85aHVFa_k1sfjilCWOnl79RUncPZzJ3GhrqhLGIBFFRCH0rKMa_ZtcqkerJn-f5lu10Ki5PSw4fxYM80V4PL_', 'refresh_token' => '-3S067m3M5kAAAAAAAAAAcQF8zVqFUuhK-PFkFqiOfFTgiazWj5NyU-1EGWIh0ZS', ]; - /** - * @var array - */ - private $fileMetadataResponse = [ + private array $fileMetadataResponse = [ 'id' => 'file1', 'kind' => GoogleDriveApp::DRIVE_FILE_KIND, 'name' => 'myFile', 'mimeType' => 'text/plain', ]; - /** - * @var string - */ - private $fileContentResponse = 'Some plain text!'; + private string $fileContentResponse = 'Some plain text!'; /** * @var string */ - private $errorResponse = [ + private array $errorResponse = [ 'code' => GoogleDriveApp::INVALID_TOKEN_ERROR_CODE, 'message' => 'Invalid access token', ]; @@ -78,7 +54,7 @@ public function setUp(): void $this->googleDriveApp = new GoogleDriveApp($this->appKey, $this->appSecret, $tokenServiceMock, $httpClientMock); } - public function testGoogleDriveGetAuthUrl() + public function testGoogleDriveGetAuthUrl(): void { $authUrl = $this->googleDriveApp->getAuthUrl($this->redirectUrl); @@ -89,7 +65,7 @@ public function testGoogleDriveGetAuthUrl() $this->assertStringContainsString('access_type', $authUrl); } - public function testGoogleDriveFetchTokens() + public function testGoogleDriveFetchTokens(): void { $this->currentResponse = (object) $this->tokensGrantResponse; @@ -102,7 +78,7 @@ public function testGoogleDriveFetchTokens() $this->assertTrue(property_exists($response, 'refresh_token')); } - public function testGoogleDriveRpcRequest() + public function testGoogleDriveRpcRequest(): void { $this->currentResponse = (object) $this->fileMetadataResponse; @@ -119,7 +95,7 @@ public function testGoogleDriveRpcRequest() $this->assertTrue(property_exists($response, 'mimeType')); } - public function testGoogleDriveGetFileInfo() + public function testGoogleDriveGetFileInfo(): void { $this->currentResponse = $this->fileContentResponse; @@ -130,7 +106,7 @@ public function testGoogleDriveGetFileInfo() $this->assertEquals('Some plain text!', $response); } - public function testGoogleDriveRequestWithAccessTokenExpired() + public function testGoogleDriveRequestWithAccessTokenExpired(): void { $this->currentErrors = ['code' => 401]; diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php index 9b71b7cd8..90b53c116 100644 --- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php +++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapterTest.php @@ -14,30 +14,15 @@ class GoogleDriveFileSystemAdapterTest extends AppTestCase */ protected $fs; - /** - * @var string - */ - private $dirname = 'common'; + private string $dirname = 'common'; - /** - * @var string - */ - private $filename = 'sample.txt'; + private string $filename = 'sample.txt'; - /** - * @var string - */ - private $newFilename = 'new_name.txt'; + private string $newFilename = 'new_name.txt'; - /** - * @var string - */ - private $content = 'This file was created via gdrive api'; + private string $content = 'This file was created via gdrive api'; - /** - * @var array - */ - private static $response = []; + private static array $response = []; public function setUp(): void { @@ -63,7 +48,7 @@ public function tearDown(): void self::$response = []; } - public function testGoogleDriveMakeCheckRemoveDirectory() + public function testGoogleDriveMakeCheckRemoveDirectory(): void { $this->assertFalse($this->fs->isDirectory($this->dirname)); @@ -80,7 +65,7 @@ public function testGoogleDriveMakeCheckRemoveDirectory() $this->assertFalse($this->fs->isDirectory($this->dirname)); } - public function testGoogleDriveCreateGetCheckRemoveFile() + public function testGoogleDriveCreateGetCheckRemoveFile(): void { $this->assertFalse($this->fs->isFile($this->filename)); @@ -102,7 +87,7 @@ public function testGoogleDriveCreateGetCheckRemoveFile() $this->assertFalse($this->fs->exists($this->filename)); } - public function testGoogleDriveFileAppend() + public function testGoogleDriveFileAppend(): void { self::$response['kind'] = GoogleDriveApp::DRIVE_FILE_KIND; self::$response['mimeType'] = 'text/plain'; @@ -118,7 +103,7 @@ public function testGoogleDriveFileAppend() $this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename)); } - public function testGoogleDriveFileRename() + public function testGoogleDriveFileRename(): void { $this->fs->put($this->filename, $this->content); @@ -134,7 +119,7 @@ public function testGoogleDriveFileRename() $this->fs->remove($this->newFilename); } - public function testGoogleDriveFileCopy() + public function testGoogleDriveFileCopy(): void { $this->fs->makeDirectory($this->dirname); @@ -154,7 +139,7 @@ public function testGoogleDriveFileCopy() $this->fs->removeDirectory($this->dirname); } - public function testGoogleDriveFileSize() + public function testGoogleDriveFileSize(): void { $text = 'some bytes'; @@ -165,7 +150,7 @@ public function testGoogleDriveFileSize() $this->assertEquals(strlen($text), $this->fs->size($this->filename)); } - public function testGoogleDriveFileLastModified() + public function testGoogleDriveFileLastModified(): void { $modified = '2023-02-12T15:50:38Z'; @@ -179,7 +164,7 @@ public function testGoogleDriveFileLastModified() $this->assertEquals(strtotime($modified), $result); } - public function testGoogleDriveListDirectory() + public function testGoogleDriveListDirectory(): void { self::$response['files'] = [ [ diff --git a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php index c884b30b2..f27f59388 100644 --- a/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php +++ b/tests/Unit/Storage/Adapters/GoogleDrive/GoogleDriveTokenServiceTestCase.php @@ -11,14 +11,14 @@ protected function mockTokenService() { $tokenServiceMock = Mockery::mock(TokenServiceInterface::class); - $tokenServiceMock->shouldReceive('getRefreshToken')->andReturnUsing(function () { + $tokenServiceMock->shouldReceive('getRefreshToken')->andReturnUsing(function (): string { $this->currentResponse = (object) $this->tokensGrantResponse; return 'ref_tok_1234'; }); $tokenServiceMock->shouldReceive('getAccessToken')->andReturn('acc_tok_1234'); - $tokenServiceMock->shouldReceive('saveTokens')->andReturnUsing(function ($tokens) { + $tokenServiceMock->shouldReceive('saveTokens')->andReturnUsing(function ($tokens): bool { $this->currentResponse = (object) $this->fileMetadataResponse; return true; }); diff --git a/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php b/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php index a9fab2268..330c4bd69 100644 --- a/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php +++ b/tests/Unit/Storage/Adapters/Local/LocalFileSystemAdapterTest.php @@ -12,20 +12,11 @@ class LocalFileSystemAdapterTest extends AppTestCase */ protected $fs; - /** - * @var string - */ - private $dirname; + private string $dirname; - /** - * @var string - */ - private $filename; + private string $filename; - /** - * @var string - */ - private $content = 'Hello world'; + private string $content = 'Hello world'; public function setUp(): void { @@ -47,7 +38,7 @@ public function tearDown(): void } } - public function testLocalMakeRemoveDirectory() + public function testLocalMakeRemoveDirectory(): void { $this->assertDirectoryDoesNotExist($this->dirname); @@ -60,7 +51,7 @@ public function testLocalMakeRemoveDirectory() $this->assertDirectoryDoesNotExist($this->dirname); } - public function testLocalFileGetPut() + public function testLocalFileGetPut(): void { $this->fs->put($this->filename, $this->content); @@ -69,7 +60,7 @@ public function testLocalFileGetPut() $this->assertEquals($this->content, $this->fs->get($this->filename)); } - public function testLocalFileAppend() + public function testLocalFileAppend(): void { $this->fs->put($this->filename, $this->content); @@ -82,7 +73,7 @@ public function testLocalFileAppend() $this->assertEquals($this->content . $moreContent, $this->fs->get($this->filename)); } - public function tesLocalFileRename() + public function tesLocalFileRename(): void { $this->fs->put($this->filename, $this->content); @@ -97,7 +88,7 @@ public function tesLocalFileRename() $this->fs->remove($newFilename); } - public function testLocalFileCopy() + public function testLocalFileCopy(): void { $this->fs->makeDirectory($this->dirname); @@ -114,7 +105,7 @@ public function testLocalFileCopy() $this->fs->removeDirectory($this->dirname); } - public function testLocalFileExists() + public function testLocalFileExists(): void { $newFilename = base_dir() . DS . 'new_name.txt'; @@ -127,21 +118,21 @@ public function testLocalFileExists() $this->fs->remove($newFilename); } - public function testLocalFileSize() + public function testLocalFileSize(): void { $this->fs->put($this->filename, 'some bytes'); $this->assertEquals(10, $this->fs->size($this->filename)); } - public function testLocalFileLastModified() + public function testLocalFileLastModified(): void { $this->fs->put($this->filename, $this->content); $this->assertIsInt($this->fs->lastModified($this->filename)); } - public function testLocalFileRemove() + public function testLocalFileRemove(): void { $this->fs->put($this->filename, $this->content); @@ -152,21 +143,21 @@ public function testLocalFileRemove() $this->assertFileDoesNotExist($this->filename); } - public function testLocalIsFile() + public function testLocalIsFile(): void { $this->assertTrue($this->fs->isFile(__FILE__)); $this->assertFalse($this->fs->isFile(__DIR__)); } - public function testLocalIsDirectory() + public function testLocalIsDirectory(): void { $this->assertTrue($this->fs->isDirectory(__DIR__)); $this->assertFalse($this->fs->isDirectory(__FILE__)); } - public function testLocalListDirectory() + public function testLocalListDirectory(): void { $entries = $this->fs->listDirectory(base_dir()); @@ -177,7 +168,7 @@ public function testLocalListDirectory() $this->assertEmpty($this->fs->listDirectory('nowhere')); } - public function testLocalGlob() + public function testLocalGlob(): void { $entries = $this->fs->glob(base_dir() . DS . '*.log'); @@ -186,7 +177,7 @@ public function testLocalGlob() $this->assertIsString(current($entries)); } - public function testLocalFileIsReadableWritable() + public function testLocalFileIsReadableWritable(): void { $this->fs->put($this->filename, ''); @@ -201,7 +192,7 @@ public function testLocalFileIsReadableWritable() $this->assertFalse($this->fs->isWritable($this->filename)); } - public function testLocalFileGetLines() + public function testLocalFileGetLines(): void { $lineOne = 'It\'s was started then ' . PHP_EOL; $lineTwo = 'something happens' . PHP_EOL; @@ -227,19 +218,19 @@ public function testLocalFileGetLines() $this->assertCount(4, $lines); } - public function testLocalFileNameAndExtension() + public function testLocalFileNameAndExtension(): void { $this->assertEquals('test', $this->fs->fileName($this->filename)); $this->assertEquals('txt', $this->fs->extension($this->filename)); } - public function testLocalFileNameWithExtension() + public function testLocalFileNameWithExtension(): void { $this->assertEquals('test.txt', $this->fs->fileNameWithExtension($this->filename)); } - public function testLocalRequireOutput() + public function testLocalRequireOutput(): void { $this->fs->put($this->filename, $this->content); @@ -252,7 +243,7 @@ public function testLocalRequireOutput() $this->assertSame($this->content, $output); } - public function testLocalRequireReturn() + public function testLocalRequireReturn(): void { $this->fs->put($this->filename, " 'abc'];"); @@ -265,7 +256,7 @@ public function testLocalRequireReturn() $this->assertEquals($result['key'], 'abc'); } - public function testLocalRequireBehavior() + public function testLocalRequireBehavior(): void { $this->fs->put($this->filename, 'assertEquals(3, $GLOBALS['include_count']); } - public function testLocalRequireOnceBehavior() + public function testLocalRequireOnceBehavior(): void { $file = base_dir() . DS . 'track1.txt'; @@ -291,7 +282,7 @@ public function testLocalRequireOnceBehavior() $this->fs->remove($file); } - public function testLocalIncludeOutput() + public function testLocalIncludeOutput(): void { $this->fs->put($this->filename, $this->content); @@ -304,7 +295,7 @@ public function testLocalIncludeOutput() $this->assertSame($this->content, $output); } - public function testLocalIncludeReturn() + public function testLocalIncludeReturn(): void { $this->fs->put($this->filename, " 'abc'];"); @@ -317,7 +308,7 @@ public function testLocalIncludeReturn() $this->assertEquals($result['key'], 'abc'); } - public function testLocalIncludeBehavior() + public function testLocalIncludeBehavior(): void { $this->fs->put($this->filename, 'assertEquals(3, $GLOBALS['include_count']); } - public function testLocalIncludeOnceBehavior() + public function testLocalIncludeOnceBehavior(): void { $file = base_dir() . DS . 'track2.txt'; diff --git a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php index 271531996..92214cff9 100644 --- a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php +++ b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php @@ -17,42 +17,42 @@ public function setUp(): void parent::setUp(); } - public function testFileSystemFactoryInstance() + public function testFileSystemFactoryInstance(): void { $fs = FileSystemFactory::get(); $this->assertInstanceOf(FileSystem::class, $fs); } - public function testFileSystemFactoryDefaultAdapter() + public function testFileSystemFactoryDefaultAdapter(): void { $fs = FileSystemFactory::get(); $this->assertInstanceOf(LocalFileSystemAdapter::class, $fs->getAdapter()); } - public function testFileSystemFactoryLocalAdapter() + public function testFileSystemFactoryLocalAdapter(): void { $fs = FileSystemFactory::get(FileSystem::LOCAL); $this->assertInstanceOf(LocalFileSystemAdapter::class, $fs->getAdapter()); } - public function testFileSystemFactoryDropboxAdapter() + public function testFileSystemFactoryDropboxAdapter(): void { $fs = FileSystemFactory::get(FileSystem::DROPBOX); $this->assertInstanceOf(DropboxFileSystemAdapter::class, $fs->getAdapter()); } - public function testFileSystemFactoryGoogleDriveAdapter() + public function testFileSystemFactoryGoogleDriveAdapter(): void { $fs = FileSystemFactory::get(FileSystem::GDRIVE); $this->assertInstanceOf(GoogleDriveFileSystemAdapter::class, $fs->getAdapter()); } - public function testFileSystemFactoryInvalidTypeAdapter() + public function testFileSystemFactoryInvalidTypeAdapter(): void { $this->expectException(FileSystemException::class); @@ -61,7 +61,7 @@ public function testFileSystemFactoryInvalidTypeAdapter() FileSystemFactory::get('invalid_type'); } - public function testFileSystemFactoryReturnsSameInstance() + public function testFileSystemFactoryReturnsSameInstance(): void { $fs1 = FileSystemFactory::get(FileSystem::LOCAL); $fs2 = FileSystemFactory::get(FileSystem::LOCAL); diff --git a/tests/Unit/Storage/FileSystemTest.php b/tests/Unit/Storage/FileSystemTest.php index a95faa1ec..88a92299f 100644 --- a/tests/Unit/Storage/FileSystemTest.php +++ b/tests/Unit/Storage/FileSystemTest.php @@ -27,7 +27,7 @@ public function setUp(): void $this->googleDriveAppMock = Mockery::mock(GoogleDriveApp::class); } - public function testFileSystemGetAdapter() + public function testFileSystemGetAdapter(): void { $localFs = new FileSystem(new LocalFileSystemAdapter()); @@ -48,14 +48,14 @@ public function testFileSystemGetAdapter() $this->assertInstanceOf(FilesystemAdapterInterface::class, $googleDriveFs->getAdapter()); } - public function testFileSystemCallingValidMethod() + public function testFileSystemCallingValidMethod(): void { $fs = new FileSystem(new LocalFileSystemAdapter()); $this->assertFalse($fs->exists('test.txt')); } - public function testMailerCallingInvalidMethod() + public function testMailerCallingInvalidMethod(): void { $mailer = new FileSystem(new LocalFileSystemAdapter()); diff --git a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php index c4a3ad1c1..0c2f69150 100644 --- a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php +++ b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php @@ -10,28 +10,28 @@ class FileSystemHelperFunctionsTest extends AppTestCase { - public function testFileSystemHelperGetDefaultFileSystem() + public function testFileSystemHelperGetDefaultFileSystem(): void { $this->assertInstanceOf(FileSystem::class, fs()); $this->assertInstanceOf(LocalFileSystemAdapter::class, fs()->getAdapter()); } - public function testFileSystemHelperGetLocalFileSystem() + public function testFileSystemHelperGetLocalFileSystem(): void { $this->assertInstanceOf(FileSystem::class, fs(FileSystem::LOCAL)); $this->assertInstanceOf(LocalFileSystemAdapter::class, fs(FileSystem::LOCAL)->getAdapter()); } - public function testFileSystemHelperGetDropboxFileSystem() + public function testFileSystemHelperGetDropboxFileSystem(): void { $this->assertInstanceOf(FileSystem::class, fs(FileSystem::DROPBOX)); $this->assertInstanceOf(DropboxFileSystemAdapter::class, fs(FileSystem::DROPBOX)->getAdapter()); } - public function testFileSystemHelperGetGoogleDriveFileSystem() + public function testFileSystemHelperGetGoogleDriveFileSystem(): void { $this->assertInstanceOf(FileSystem::class, fs(FileSystem::GDRIVE)); diff --git a/tests/Unit/Storage/HttpClientTestCase.php b/tests/Unit/Storage/HttpClientTestCase.php index 4d2686fa3..ae1cf845f 100644 --- a/tests/Unit/Storage/HttpClientTestCase.php +++ b/tests/Unit/Storage/HttpClientTestCase.php @@ -42,7 +42,7 @@ protected function mockHttpClient() return $httpClientMock; }); - $httpClientMock->shouldReceive('getErrors')->andReturnUsing(fn () => (array) $this->response[$this->url]['errors']); + $httpClientMock->shouldReceive('getErrors')->andReturnUsing(fn (): array => (array) $this->response[$this->url]['errors']); $httpClientMock->shouldReceive('getResponseBody')->andReturnUsing(fn () => $this->response[$this->url]['body']); diff --git a/tests/Unit/Storage/UploadedFileTest.php b/tests/Unit/Storage/UploadedFileTest.php index f3536c7c3..5982253c1 100644 --- a/tests/Unit/Storage/UploadedFileTest.php +++ b/tests/Unit/Storage/UploadedFileTest.php @@ -26,7 +26,7 @@ protected function moveUploadedFile(string $filePath): bool class UploadedFileTest extends AppTestCase { - private $fileMeta; + private array $fileMeta; public function setUp(): void { @@ -52,14 +52,14 @@ public function tearDown(): void } } - public function testUploadedFileConstructor() + public function testUploadedFileConstructor(): void { $uploadedFile = new UploadedFile($this->fileMeta); $this->assertInstanceOf(UploadedFile::class, $uploadedFile); } - public function testUploadedFileGetSetName() + public function testUploadedFileGetSetName(): void { $uploadedFile = new UploadedFile($this->fileMeta); @@ -70,7 +70,7 @@ public function testUploadedFileGetSetName() $this->assertEquals('bar', $uploadedFile->getName()); } - public function testUploadedFileSetGetRemoteFileSystem() + public function testUploadedFileSetGetRemoteFileSystem(): void { $dropboxAppMock = Mockery::mock(DropboxApp::class); @@ -81,35 +81,35 @@ public function testUploadedFileSetGetRemoteFileSystem() } - public function testUploadedFileGetExtension() + public function testUploadedFileGetExtension(): void { $uploadedFile = new UploadedFile($this->fileMeta); $this->assertEquals('jpg', $uploadedFile->getExtension()); } - public function testUploadedFileGetNameWithExtension() + public function testUploadedFileGetNameWithExtension(): void { $uploadedFile = new UploadedFile($this->fileMeta); $this->assertEquals('foo.jpg', $uploadedFile->getNameWithExtension()); } - public function testUploadedFileGetMimeType() + public function testUploadedFileGetMimeType(): void { $uploadedFile = new UploadedFile($this->fileMeta); $this->assertSame('image/jpeg', $uploadedFile->getMimeType()); } - public function testUploadedFileGetMd5() + public function testUploadedFileGetMd5(): void { $uploadedFile = new UploadedFile($this->fileMeta); $this->assertIsString($uploadedFile->getMd5()); } - public function testUploadedFileGetDimensions() + public function testUploadedFileGetDimensions(): void { $uploadedFile = new UploadedFile($this->fileMeta); @@ -118,7 +118,7 @@ public function testUploadedFileGetDimensions() $this->assertEquals(300, $uploadedFile->getDimensions()['height']); } - public function testUploadedFileUploadWithoutFileSent() + public function testUploadedFileUploadWithoutFileSent(): void { $fileMeta = [ 'size' => 500, @@ -137,7 +137,7 @@ public function testUploadedFileUploadWithoutFileSent() $this->assertFalse($uploadedFile->save(base_dir())); } - public function testUploadedFileUploadAndSave() + public function testUploadedFileUploadAndSave(): void { $uploadedFile = new UploadedDouble($this->fileMeta); @@ -148,7 +148,7 @@ public function testUploadedFileUploadAndSave() $this->assertTrue(file_exists(base_dir() . DS . $uploadedFile->getNameWithExtension())); } - public function testUploadedFileUploadNotAllowedExtensionForMimeType() + public function testUploadedFileUploadNotAllowedExtensionForMimeType(): void { $fileMeta = $this->fileMeta; $fileMeta['name'] = 'foo.php'; @@ -161,7 +161,7 @@ public function testUploadedFileUploadNotAllowedExtensionForMimeType() $uploadedFile->save(base_dir()); } - public function testUploadedFileUploadNotAllowedMimeType() + public function testUploadedFileUploadNotAllowedMimeType(): void { $fileMeta = $this->fileMeta; $fileMeta['name'] = 'foo.jpg'; @@ -175,7 +175,7 @@ public function testUploadedFileUploadNotAllowedMimeType() $uploadedFile->save(base_dir()); } - public function testUploadedFileUploadAllowedAfterSetterOverride() + public function testUploadedFileUploadAllowedAfterSetterOverride(): void { $fileMeta = $this->fileMeta; $fileMeta['name'] = 'foo.txt'; @@ -191,7 +191,7 @@ public function testUploadedFileUploadAllowedAfterSetterOverride() $this->assertTrue(file_exists(base_dir() . DS . $uploadedFile->getNameWithExtension())); } - public function testUploadedFileSaveAndTryOverwrite() + public function testUploadedFileSaveAndTryOverwrite(): void { $uploadedFile = new UploadedDouble($this->fileMeta); @@ -208,7 +208,7 @@ public function testUploadedFileSaveAndTryOverwrite() $uploadedFile->save(base_dir()); } - public function testUploadedFileSaveAndOverwrite() + public function testUploadedFileSaveAndOverwrite(): void { $uploadedFile = new UploadedDouble($this->fileMeta); @@ -219,7 +219,7 @@ public function testUploadedFileSaveAndOverwrite() $this->assertTrue($uploadedFile->save(base_dir(), true)); } - public function testUploadedFileModifyAndSave() + public function testUploadedFileModifyAndSave(): void { $uploadedFile = new UploadedDouble($this->fileMeta); @@ -234,7 +234,7 @@ public function testUploadedFileModifyAndSave() $this->assertEquals(100, $img[1]); } - public function testUploadedFileGetErrorCodeAndMessage() + public function testUploadedFileGetErrorCodeAndMessage(): void { $fileMeta = [ 'size' => 500, diff --git a/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php b/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php index ed91828ab..6e30d05aa 100644 --- a/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php +++ b/tests/Unit/Transformer/Helpers/TransformerHelperFunctionsTest.php @@ -51,7 +51,7 @@ class TransformerHelperFunctionsTest extends AppTestCase 'author' => 'Ken Watson', ], ]; - public function testTransformerHelper() + public function testTransformerHelper(): void { $transformed = transform($this->posts, new PostTransformer()); diff --git a/tests/Unit/Transformer/PostTransformer.php b/tests/Unit/Transformer/PostTransformer.php index 5662f6304..b8b2b9aaa 100644 --- a/tests/Unit/Transformer/PostTransformer.php +++ b/tests/Unit/Transformer/PostTransformer.php @@ -6,7 +6,7 @@ class PostTransformer implements TransformerInterface { - public function transform($item) + public function transform($item): array { return [ 'id' => $item['id'], diff --git a/tests/Unit/Transformer/TransformerTest.php b/tests/Unit/Transformer/TransformerTest.php index 5c058087e..e2f7d5a02 100644 --- a/tests/Unit/Transformer/TransformerTest.php +++ b/tests/Unit/Transformer/TransformerTest.php @@ -52,7 +52,7 @@ class TransformerTest extends TestCase ], ]; - public function testDataTransforming() + public function testDataTransforming(): void { $transformed = Transformer::transform($this->posts, new PostTransformer()); diff --git a/tests/Unit/Validation/Traits/FileRuleTest.php b/tests/Unit/Validation/Traits/FileRuleTest.php index 3e3f8d949..4a3d3ccc5 100644 --- a/tests/Unit/Validation/Traits/FileRuleTest.php +++ b/tests/Unit/Validation/Traits/FileRuleTest.php @@ -9,8 +9,8 @@ class FileRuleTest extends AppTestCase { - public $validator; - private $request; + public Validator $validator; + private Request $request; public function setUp(): void { @@ -39,7 +39,7 @@ public function tearDown(): void unlink(base_dir() . DS . 'php8fe2.tmp'); } - public function testRuleFileSize() + public function testRuleFileSize(): void { $file = [ 'image' => [ @@ -72,7 +72,7 @@ public function testRuleFileSize() $this->assertEquals('validation.fileSize', $errors['image'][0]); } - public function testRuleFileMimeType() + public function testRuleFileMimeType(): void { $file = [ 'image' => [ @@ -111,7 +111,7 @@ public function testRuleFileMimeType() $this->assertEquals('validation.fileMimeType', $errors['image'][0]); } - public function testRuleFileExtension() + public function testRuleFileExtension(): void { $file = [ 'image' => [ @@ -150,7 +150,7 @@ public function testRuleFileExtension() $this->assertEquals('validation.fileExtension', $errors['image'][0]); } - public function testRuleImageDimensions() + public function testRuleImageDimensions(): void { $file = [ 'image' => [ diff --git a/tests/Unit/Validation/Traits/GeneralRuleTest.php b/tests/Unit/Validation/Traits/GeneralRuleTest.php index 0f658de8c..27b75633e 100644 --- a/tests/Unit/Validation/Traits/GeneralRuleTest.php +++ b/tests/Unit/Validation/Traits/GeneralRuleTest.php @@ -12,7 +12,7 @@ class GeneralRuleTest extends AppTestCase { - public $validator; + public Validator $validator; public function setUp(): void { parent::setUp(); @@ -33,7 +33,7 @@ public function tearDown(): void Database::execute('DROP TABLE IF EXISTS users'); } - public function testRuleRequired() + public function testRuleRequired(): void { $this->validator->setRule('text', [ Rule::required(), @@ -52,7 +52,7 @@ public function testRuleRequired() $this->assertEquals('validation.required', $errors['text'][0]); } - public function testRuleEmail() + public function testRuleEmail(): void { $this->validator->setRule('text', [ Rule::email(), @@ -69,7 +69,7 @@ public function testRuleEmail() $this->assertEquals('validation.email', $errors['text'][0]); } - public function testRuleCreditCard() + public function testRuleCreditCard(): void { $this->validator->setRule('text', [ Rule::creditCard(), @@ -86,7 +86,7 @@ public function testRuleCreditCard() $this->assertEquals('validation.creditCard', $errors['text'][0]); } - public function testRuleIban() + public function testRuleIban(): void { $this->validator->setRule('text', [ Rule::iban(), @@ -105,7 +105,7 @@ public function testRuleIban() $this->assertEquals('validation.iban', $errors['text'][0]); } - public function testRuleName() + public function testRuleName(): void { $this->validator->setRule('text', [ Rule::name(), @@ -126,7 +126,7 @@ public function testRuleName() $this->assertEquals('validation.name', $errors['text'][0]); } - public function testRuleStreetAddress() + public function testRuleStreetAddress(): void { $this->validator->setRule('text', [ Rule::streetAddress(), @@ -147,7 +147,7 @@ public function testRuleStreetAddress() $this->assertEquals('validation.streetAddress', $errors['text'][0]); } - public function testRulePhoneNumber() + public function testRulePhoneNumber(): void { $this->validator->setRule('text', [ Rule::phoneNumber(), @@ -176,7 +176,7 @@ public function testRulePhoneNumber() $this->assertEquals('validation.phoneNumber', $errors['text'][0]); } - public function testRuleDate() + public function testRuleDate(): void { $this->validator->setRule('text', [ Rule::date(), @@ -207,7 +207,7 @@ public function testRuleDate() $this->assertEquals('validation.date', $errors['text'][0]); } - public function testRuleStarts() + public function testRuleStarts(): void { $this->validator->setRule('text', [ Rule::starts('b'), @@ -230,7 +230,7 @@ public function testRuleStarts() $this->assertEquals('validation.starts', $errors['text'][0]); } - public function testRuleRegex() + public function testRuleRegex(): void { $this->validator->setRule('text', [ Rule::regex('/^[1-9]+$/'), @@ -255,7 +255,7 @@ public function testRuleRegex() $this->assertEquals('validation.regex', $errors['text'][0]); } - public function testRuleJsonString() + public function testRuleJsonString(): void { $this->validator->setRule('text', [ Rule::jsonString(), @@ -272,7 +272,7 @@ public function testRuleJsonString() $this->assertEquals('validation.jsonString', $errors['text'][0]); } - public function testRuleSame() + public function testRuleSame(): void { $this->validator->setRule('password', [ Rule::same('confirm_password'), @@ -289,7 +289,7 @@ public function testRuleSame() $this->assertEquals('validation.same', $errors['password'][0]); } - public function testRuleUnique() + public function testRuleUnique(): void { $this->createUsersTable(); @@ -310,7 +310,7 @@ public function testRuleUnique() $this->assertEquals('validation.unique', $errors['username'][0]); } - public function testRuleExists() + public function testRuleExists(): void { $this->createUsersTable(); diff --git a/tests/Unit/Validation/Traits/LengthRuleTest.php b/tests/Unit/Validation/Traits/LengthRuleTest.php index 9837a441d..2a505454c 100644 --- a/tests/Unit/Validation/Traits/LengthRuleTest.php +++ b/tests/Unit/Validation/Traits/LengthRuleTest.php @@ -8,7 +8,7 @@ class LengthRuleTest extends AppTestCase { - public $validator; + public Validator $validator; public function setUp(): void { @@ -18,7 +18,7 @@ public function setUp(): void } - public function testRuleMinLen() + public function testRuleMinLen(): void { $this->validator->setRule('text', [ Rule::minLen(3), @@ -35,7 +35,7 @@ public function testRuleMinLen() $this->assertEquals('validation.minLen', $errors['text'][0]); } - public function testRuleMaxLen() + public function testRuleMaxLen(): void { $this->validator->setRule('text', [ Rule::maxLen(5), @@ -52,7 +52,7 @@ public function testRuleMaxLen() $this->assertEquals('validation.maxLen', $errors['text'][0]); } - public function testRuleExactLen() + public function testRuleExactLen(): void { $this->validator->setRule('text', [ Rule::exactLen(4), diff --git a/tests/Unit/Validation/Traits/ListRuleTest.php b/tests/Unit/Validation/Traits/ListRuleTest.php index f1dd49512..a47911c51 100644 --- a/tests/Unit/Validation/Traits/ListRuleTest.php +++ b/tests/Unit/Validation/Traits/ListRuleTest.php @@ -8,8 +8,7 @@ class ListRuleTest extends AppTestCase { - public $validator; - private $request; + public Validator $validator; public function setUp(): void { @@ -19,7 +18,7 @@ public function setUp(): void } - public function testRuleContains() + public function testRuleContains(): void { $this->validator->setRule('text', [ Rule::contains('Fisherman goes out'), @@ -40,7 +39,7 @@ public function testRuleContains() $this->assertEquals('validation.contains', $errors['text'][0]); } - public function testRuleContainsList() + public function testRuleContainsList(): void { $this->validator->setRule('text', [ Rule::containsList('male', 'female'), @@ -59,7 +58,7 @@ public function testRuleContainsList() $this->assertEquals('validation.containsList', $errors['text'][0]); } - public function testRuleDoesntContainsList() + public function testRuleDoesntContainsList(): void { $this->validator->setRule('text', [ Rule::doesntContainsList('male', 'famale'), diff --git a/tests/Unit/Validation/Traits/ResourceRuleTest.php b/tests/Unit/Validation/Traits/ResourceRuleTest.php index b5ee157cf..313bf0820 100644 --- a/tests/Unit/Validation/Traits/ResourceRuleTest.php +++ b/tests/Unit/Validation/Traits/ResourceRuleTest.php @@ -8,7 +8,7 @@ class ResourceRuleTest extends AppTestCase { - public $validator; + public Validator $validator; public function setUp(): void { @@ -18,7 +18,7 @@ public function setUp(): void } - public function testRuleUrl() + public function testRuleUrl(): void { $this->validator->setRule('text', [ Rule::url(), @@ -39,7 +39,7 @@ public function testRuleUrl() $this->assertEquals('validation.url', $errors['text'][0]); } - public function testRuleUrlExists() + public function testRuleUrlExists(): void { $this->validator->setRule('text', [ Rule::urlExists(), @@ -56,7 +56,7 @@ public function testRuleUrlExists() $this->assertEquals('validation.urlExists', $errors['text'][0]); } - public function testRuleIp() + public function testRuleIp(): void { $this->validator->setRule('text', [ Rule::ip(), @@ -73,7 +73,7 @@ public function testRuleIp() $this->assertEquals('validation.ip', $errors['text'][0]); } - public function testRuleIpV4() + public function testRuleIpV4(): void { $this->validator->setRule('text', [ Rule::ipv4(), @@ -90,7 +90,7 @@ public function testRuleIpV4() $this->assertEquals('validation.ipv4', $errors['text'][0]); } - public function testRuleIpV6() + public function testRuleIpV6(): void { $this->validator->setRule('text', [ Rule::ipv6(), diff --git a/tests/Unit/Validation/Traits/TypeRuleTest.php b/tests/Unit/Validation/Traits/TypeRuleTest.php index d2a2ce052..75ae1cce1 100644 --- a/tests/Unit/Validation/Traits/TypeRuleTest.php +++ b/tests/Unit/Validation/Traits/TypeRuleTest.php @@ -8,7 +8,7 @@ class TypeRuleTest extends AppTestCase { - public $validator; + public Validator $validator; public function setUp(): void { parent::setUp(); @@ -16,7 +16,7 @@ public function setUp(): void $this->validator = new Validator(); } - public function testRuleAlpha() + public function testRuleAlpha(): void { $this->validator->setRule('text', [ Rule::alpha(), @@ -35,7 +35,7 @@ public function testRuleAlpha() $this->assertEquals('validation.alpha', $errors['text'][0]); } - public function testRuleAlphaNumeric() + public function testRuleAlphaNumeric(): void { $this->validator->setRule('text', [ Rule::alphaNumeric(), @@ -56,7 +56,7 @@ public function testRuleAlphaNumeric() $this->assertEquals('validation.alphaNumeric', $errors['text'][0]); } - public function testRuleAlphaDash() + public function testRuleAlphaDash(): void { $this->validator->setRule('text', [ Rule::alphaDash(), @@ -75,7 +75,7 @@ public function testRuleAlphaDash() $this->assertEquals('validation.alphaDash', $errors['text'][0]); } - public function testRuleAlphaSpace() + public function testRuleAlphaSpace(): void { $this->validator->setRule('text', [ Rule::alphaSpace(), @@ -96,7 +96,7 @@ public function testRuleAlphaSpace() $this->assertEquals('validation.alphaSpace', $errors['text'][0]); } - public function testRuleNumeric() + public function testRuleNumeric(): void { $this->validator->setRule('text', [ Rule::numeric(), @@ -115,7 +115,7 @@ public function testRuleNumeric() $this->assertEquals('validation.numeric', $errors['text'][0]); } - public function testRuleInteger() + public function testRuleInteger(): void { $this->validator->setRule('text', [ Rule::integer(), @@ -134,7 +134,7 @@ public function testRuleInteger() $this->assertEquals('validation.integer', $errors['text'][0]); } - public function testRuleFloat() + public function testRuleFloat(): void { $this->validator->setRule('text', [ Rule::float(), @@ -155,7 +155,7 @@ public function testRuleFloat() $this->assertEquals('validation.float', $errors['text'][0]); } - public function testRuleBoolean() + public function testRuleBoolean(): void { $this->validator->setRule('text', [ Rule::boolean(), @@ -182,7 +182,7 @@ public function testRuleBoolean() $this->assertEquals('validation.boolean', $errors['text'][0]); } - public function testRuleMinNumeric() + public function testRuleMinNumeric(): void { $this->validator->setRule('text', [ Rule::minNumeric(20), @@ -199,7 +199,7 @@ public function testRuleMinNumeric() $this->assertEquals('validation.minNumeric', $errors['text'][0]); } - public function testRuleMaxNumeric() + public function testRuleMaxNumeric(): void { $this->validator->setRule('text', [ Rule::maxNumeric(20), diff --git a/tests/Unit/Validation/ValidatorTest.php b/tests/Unit/Validation/ValidatorTest.php index 82659c243..503647b0d 100644 --- a/tests/Unit/Validation/ValidatorTest.php +++ b/tests/Unit/Validation/ValidatorTest.php @@ -8,7 +8,7 @@ class ValidatorTest extends AppTestCase { - private $validator; + private Validator $validator; public function setUp(): void { @@ -17,12 +17,12 @@ public function setUp(): void $this->validator = new Validator(); } - public function testValidatorConstructor() + public function testValidatorConstructor(): void { $this->assertInstanceOf(Validator::class, $this->validator); } - public function testAddUpdateDeleteRule() + public function testAddUpdateDeleteRule(): void { $this->validator->setRule('text', [ Rule::minLen(5), @@ -46,7 +46,7 @@ public function testAddUpdateDeleteRule() $this->assertTrue($this->validator->isValid(['text' => 'some long text goes'])); } - public function testMultipleRules() + public function testMultipleRules(): void { $this->validator->setRule('text', [ Rule::minLen(7), @@ -75,7 +75,7 @@ public function testMultipleRules() $this->assertEquals('validation.maxLen', $errors['text'][0]); } - public function testMultipleFields() + public function testMultipleFields(): void { $this->validator->setRules([ 'name' => [ @@ -134,7 +134,7 @@ public function testMultipleFields() $this->assertFalse($this->validator->isValid($data)); } - public function testDifferentMultipleFields() + public function testDifferentMultipleFields(): void { $this->validator->setRules([ 'name' => [ @@ -166,9 +166,9 @@ public function testDifferentMultipleFields() $this->assertTrue($this->validator->isValid($data)); } - public function testCustomValidator() + public function testCustomValidator(): void { - $this->validator->addRule('checkName', fn ($value, $param = null) => $value == $param); + $this->validator->addRule('checkName', fn ($value, $param = null): bool => $value == $param); $this->validator->setRules([ 'name' => [ diff --git a/tests/Unit/View/Factories/ViewFactoryTest.php b/tests/Unit/View/Factories/ViewFactoryTest.php index 92b033230..e87edf72b 100644 --- a/tests/Unit/View/Factories/ViewFactoryTest.php +++ b/tests/Unit/View/Factories/ViewFactoryTest.php @@ -8,7 +8,7 @@ class ViewFactoryTest extends AppTestCase { - private $viewFactory; + private ViewFactory $viewFactory; public function setUp(): void { @@ -17,12 +17,12 @@ public function setUp(): void $this->viewFactory = new ViewFactory(); } - public function testGetInstance() + public function testGetInstance(): void { $this->assertInstanceOf(QtView::class, $this->viewFactory->get()); } - public function testProxyCalls() + public function testProxyCalls(): void { $view = $this->viewFactory->get(); diff --git a/tests/Unit/View/Helpers/ViewHelperTest.php b/tests/Unit/View/Helpers/ViewHelperTest.php index 7b0b29d0c..ca3e0790d 100644 --- a/tests/Unit/View/Helpers/ViewHelperTest.php +++ b/tests/Unit/View/Helpers/ViewHelperTest.php @@ -8,10 +8,11 @@ use Quantum\Http\Request; use Quantum\Di\Di; use Quantum\Tests\Unit\AppTestCase; +use Quantum\View\QtView; class ViewHelperTest extends AppTestCase { - private $view; + private QtView $view; public function setUp(): void { @@ -21,8 +22,7 @@ public function setUp(): void ['GET', 'POST'], '/test', 'TestController', - 'testAction', - null + 'testAction' ); $route->module('Test'); @@ -40,7 +40,7 @@ public function tearDown(): void $this->view->setLayout(null); } - public function testView() + public function testView(): void { $this->view->setLayout('layout'); @@ -49,7 +49,7 @@ public function testView() $this->assertEquals('

    Hello World, this is rendered html view

    ', view()); } - public function testPartial() + public function testPartial(): void { $this->assertEquals('

    Hello World, this is rendered partial html view

    ', partial('partial')); diff --git a/tests/Unit/View/QtViewTest.php b/tests/Unit/View/QtViewTest.php index 766270b69..d1d181f5b 100644 --- a/tests/Unit/View/QtViewTest.php +++ b/tests/Unit/View/QtViewTest.php @@ -6,6 +6,7 @@ use Quantum\View\Factories\ViewFactory; use Quantum\Tests\Unit\AppTestCase; use Quantum\Router\MatchedRoute; +use Quantum\View\QtView; use Quantum\View\RawParam; use Quantum\Router\Route; use Quantum\Http\Request; @@ -13,7 +14,7 @@ class QtViewTest extends AppTestCase { - private $view; + private QtView $view; public function setUp(): void { @@ -23,8 +24,7 @@ public function setUp(): void ['GET'], '/test', 'SomeController', - 'test', - null + 'test' ); $route->module('Test'); @@ -45,7 +45,7 @@ public function tearDown(): void $this->view->flushParams(); } - public function testSetGetLayout() + public function testSetGetLayout(): void { $this->assertNull($this->view->getLayout()); @@ -56,7 +56,7 @@ public function testSetGetLayout() $this->assertIsString($this->view->getLayout()); } - public function testSetGetParams() + public function testSetGetParams(): void { $this->assertEmpty($this->view->getParams()); @@ -75,7 +75,7 @@ public function testSetGetParams() $this->assertNotEmpty($this->view->getParams()); } - public function testSetGetRawParams() + public function testSetGetRawParams(): void { $this->assertEmpty($this->view->getParams()); @@ -103,7 +103,7 @@ public function testSetGetRawParams() $this->assertEquals('

    Monkey people

    ', $this->view->getParam('chapter_two')); } - public function testRenderWithoutLayout() + public function testRenderWithoutLayout(): void { $this->expectException(ViewException::class); @@ -112,7 +112,7 @@ public function testRenderWithoutLayout() $this->view->render('index'); } - public function testRenderWithLayout() + public function testRenderWithLayout(): void { $this->view->setLayout('layout'); @@ -123,7 +123,7 @@ public function testRenderWithLayout() $this->assertEquals('' . PHP_EOL . '' . PHP_EOL . '' . PHP_EOL . '

    Hello World, this is rendered html view

    ' . PHP_EOL . '' . PHP_EOL, $renderedView); } - public function testRenderWithData() + public function testRenderWithData(): void { $this->view->setLayout('layout'); @@ -138,7 +138,7 @@ public function testRenderWithData() $this->assertEquals('

    Hello dolor sit amet, this is rendered html view

    ', $this->view->getView()); } - public function testRenderWithEscapedHtmlData() + public function testRenderWithEscapedHtmlData(): void { $this->view->setLayout('layout'); @@ -149,7 +149,7 @@ public function testRenderWithEscapedHtmlData() $this->assertEquals('<h1>Hello</h1>', $this->view->getView()); } - public function testRenderWithUnEscapedHtmlData() + public function testRenderWithUnEscapedHtmlData(): void { $this->view->setLayout('layout'); @@ -160,7 +160,7 @@ public function testRenderWithUnEscapedHtmlData() $this->assertEquals('

    Hello

    ', $this->view->getView()); } - public function testRenderPartial() + public function testRenderPartial(): void { $this->assertIsString($this->view->renderPartial('partial')); diff --git a/tests/Unit/View/RawParamTest.php b/tests/Unit/View/RawParamTest.php index df5523b6b..f10e8f4e6 100644 --- a/tests/Unit/View/RawParamTest.php +++ b/tests/Unit/View/RawParamTest.php @@ -7,39 +7,39 @@ class RawParamTest extends AppTestCase { - public function testStoresAndReturnsString() + public function testStoresAndReturnsString(): void { $raw = new RawParam('test'); $this->assertSame('test', $raw->getValue()); } - public function testStoresAndReturnsInteger() + public function testStoresAndReturnsInteger(): void { $raw = new RawParam(123); $this->assertSame(123, $raw->getValue()); } - public function testStoresAndReturnsArray() + public function testStoresAndReturnsArray(): void { $value = ['key' => 'value']; $raw = new RawParam($value); $this->assertSame($value, $raw->getValue()); } - public function testStoresAndReturnsObject() + public function testStoresAndReturnsObject(): void { $value = (object) ['foo' => 'bar']; $raw = new RawParam($value); $this->assertSame($value, $raw->getValue()); } - public function testStoresAndReturnsNull() + public function testStoresAndReturnsNull(): void { $raw = new RawParam(null); $this->assertNull($raw->getValue()); } - public function testStoresAndReturnsBoolean() + public function testStoresAndReturnsBoolean(): void { $rawTrue = new RawParam(true); $rawFalse = new RawParam(false); diff --git a/tests/_root/modules/Test/Controllers/TestController.php b/tests/_root/modules/Test/Controllers/TestController.php index 17e48e18a..bf5079b6a 100644 --- a/tests/_root/modules/Test/Controllers/TestController.php +++ b/tests/_root/modules/Test/Controllers/TestController.php @@ -4,7 +4,7 @@ class TestController { - public function tests() + public function tests(): void { // } diff --git a/tests/_root/modules/Test/routes/routes.php b/tests/_root/modules/Test/routes/routes.php index a5cd9152d..cf056a4e0 100644 --- a/tests/_root/modules/Test/routes/routes.php +++ b/tests/_root/modules/Test/routes/routes.php @@ -1,6 +1,6 @@ get('[:alpha:2]?/tests', 'TestController', 'tests'); $route->get('[:alpha:2]?/Test/[id=:any]', 'TestController', 'test'); }; diff --git a/tests/_root/shared/Commands/TestCommand.php b/tests/_root/shared/Commands/TestCommand.php index 267a00ad9..d7f72e645 100644 --- a/tests/_root/shared/Commands/TestCommand.php +++ b/tests/_root/shared/Commands/TestCommand.php @@ -6,19 +6,19 @@ class TestCommand extends QtCommand { - protected $name = 'test:dummy'; - protected $description = 'Dummy test command'; - protected $help = 'Used only for core command discovery tests'; + protected ?string $name = 'test:dummy'; + protected ?string $description = 'Dummy test command'; + protected ?string $help = 'Used only for core command discovery tests'; - protected $args = [ + protected array $args = [ ['uuid', 'optional', 'User uuid'], ]; - protected $options = [ + protected array $options = [ ['force', 'f', 'none', 'Force execution'], ]; - public function exec() + public function exec(): void { // intentionally empty } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4fa5639eb..8f8fefceb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -16,6 +16,6 @@ createEnvFile(); -register_shutdown_function(function () { +register_shutdown_function(function (): void { removeEnvFile(); });