diff --git a/phpstan.neon.dist b/phpstan.neon.dist index ecb4ac859..159c9b14f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,6 @@ parameters: phpVersion: 70400 - level: 5 + level: 6 paths: - src diff --git a/src/App/Adapters/WebAppAdapter.php b/src/App/Adapters/WebAppAdapter.php index edb570a53..39681c5df 100644 --- a/src/App/Adapters/WebAppAdapter.php +++ b/src/App/Adapters/WebAppAdapter.php @@ -132,7 +132,10 @@ public function start(): ?int $this->loadLanguage(); - info(HookManager::getInstance()->getRegistered(), ['tab' => Debugger::HOOKS]); + $debugger = Debugger::getInstance(); + if ($debugger->isEnabled()) { + $debugger->addToStoreCell(Debugger::HOOKS, 'info', HookManager::getInstance()->getRegistered()); + } $middlewareManager = new MiddlewareManager($matchedRoute); diff --git a/src/App/App.php b/src/App/App.php index 552a06d05..99612cb45 100644 --- a/src/App/App.php +++ b/src/App/App.php @@ -61,6 +61,7 @@ public function getAdapter(): AppInterface } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/App/Factories/AppFactory.php b/src/App/Factories/AppFactory.php index f8a788ee7..00671c246 100644 --- a/src/App/Factories/AppFactory.php +++ b/src/App/Factories/AppFactory.php @@ -36,6 +36,9 @@ class AppFactory App::CONSOLE => ConsoleAppAdapter::class, ]; + /** + * @var array + */ private static array $instances = []; /** diff --git a/src/App/Helpers/dir.php b/src/App/Helpers/dir.php index 7051ab379..f40c169ed 100644 --- a/src/App/Helpers/dir.php +++ b/src/App/Helpers/dir.php @@ -99,6 +99,7 @@ function deleteDirectoryWithFiles(string $dir): bool /** * Gets directory classes + * @return array */ function get_directory_classes(string $path): array { diff --git a/src/App/Helpers/misc.php b/src/App/Helpers/misc.php index 7e59f9e42..f51371ee3 100644 --- a/src/App/Helpers/misc.php +++ b/src/App/Helpers/misc.php @@ -17,7 +17,7 @@ /** * Compose a message - * @param string|array $params + * @param string|array $params */ function _message(string $subject, $params): string { @@ -109,7 +109,7 @@ function get_caller_function(int $index = 2): ?string /** * Exports the variable - * @param $var + * @param mixed $var * @throws ExceptionInterface */ function export($var): string diff --git a/src/App/Traits/AppTrait.php b/src/App/Traits/AppTrait.php index 3455625a7..262ce94fb 100644 --- a/src/App/Traits/AppTrait.php +++ b/src/App/Traits/AppTrait.php @@ -56,7 +56,7 @@ public static function getBaseDir(): string /** * @throws DiException */ - protected function loadCoreDependencies() + protected function loadCoreDependencies(): void { $file = dirname(__DIR__) . DS . 'Config' . DS . 'dependencies.php'; diff --git a/src/App/Traits/ConsoleAppTrait.php b/src/App/Traits/ConsoleAppTrait.php index 550257706..04f600526 100644 --- a/src/App/Traits/ConsoleAppTrait.php +++ b/src/App/Traits/ConsoleAppTrait.php @@ -38,7 +38,7 @@ trait ConsoleAppTrait * @throws EnvException * @throws BaseException */ - protected function loadEnvironment() + protected function loadEnvironment(): void { Environment::getInstance() ->setMutable(true) diff --git a/src/App/Traits/WebAppTrait.php b/src/App/Traits/WebAppTrait.php index 677726691..f41922b86 100644 --- a/src/App/Traits/WebAppTrait.php +++ b/src/App/Traits/WebAppTrait.php @@ -44,7 +44,7 @@ trait WebAppTrait * @throws EnvException * @throws BaseException */ - protected function loadEnvironment() + protected function loadEnvironment(): void { Environment::getInstance()->load(new Setup('config', 'env')); } diff --git a/src/Archive/Adapters/ZipAdapter.php b/src/Archive/Adapters/ZipAdapter.php index fa6ed38b6..c7b4b19a1 100644 --- a/src/Archive/Adapters/ZipAdapter.php +++ b/src/Archive/Adapters/ZipAdapter.php @@ -116,6 +116,7 @@ public function addFromString(string $entryName, string $content): bool /** * @inheritDoc + * @param array $fileNames * @throws ArchiveException */ public function addMultipleFiles(array $fileNames): bool @@ -146,6 +147,7 @@ public function count(): int /** * @inheritDoc + * @param array|null $files * @throws ArchiveException */ public function extractTo(string $pathToExtract, $files = null): bool @@ -175,6 +177,7 @@ public function deleteFile(string $filename): bool /** * @inheritDoc + * @param array $fileNames * @throws ArchiveException */ public function deleteMultipleFiles(array $fileNames): bool diff --git a/src/Archive/Archive.php b/src/Archive/Archive.php index 050d1ba10..1299eeb88 100644 --- a/src/Archive/Archive.php +++ b/src/Archive/Archive.php @@ -28,11 +28,11 @@ * @method bool addEmptyDir(string $directory) * @method bool addFile(string $filePath, string $entryName) * @method bool addFromString(string $entryName, string $content) - * @method bool addMultipleFiles(array $fileNames) + * @method bool addMultipleFiles(array $fileNames) * @method int count() * @method bool extractTo(string $pathToExtract, $files = null) * @method bool deleteFile(string $filename) - * @method bool deleteMultipleFiles(array $fileNames) + * @method bool deleteMultipleFiles(array $fileNames) */ class Archive { @@ -59,6 +59,7 @@ public function getAdapter(): ArchiveInterface } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Archive/Contracts/ArchiveInterface.php b/src/Archive/Contracts/ArchiveInterface.php index 779605ea4..1686dd5fd 100644 --- a/src/Archive/Contracts/ArchiveInterface.php +++ b/src/Archive/Contracts/ArchiveInterface.php @@ -44,6 +44,7 @@ public function addFromString(string $entryName, string $content): bool; /** * Adds multiple files to the archive + * @param array $fileNames */ public function addMultipleFiles(array $fileNames): bool; @@ -54,7 +55,7 @@ public function count(): int; /** * Extracts the archive - * @param string|array $files + * @param string|array|null $files */ public function extractTo(string $pathToExtract, $files = null): bool; @@ -65,6 +66,7 @@ public function deleteFile(string $filename): bool; /** * Delete a multiple files + * @param array $fileNames */ public function deleteMultipleFiles(array $fileNames): bool; } diff --git a/src/Archive/Factories/ArchiveFactory.php b/src/Archive/Factories/ArchiveFactory.php index 3e80bd7e0..1272b1a23 100644 --- a/src/Archive/Factories/ArchiveFactory.php +++ b/src/Archive/Factories/ArchiveFactory.php @@ -36,6 +36,9 @@ class ArchiveFactory Archive::ZIP => ZipAdapter::class, ]; + /** + * @var array + */ private static array $instances = []; /** diff --git a/src/Asset/Asset.php b/src/Asset/Asset.php index 802a5212a..6ed96e9f7 100644 --- a/src/Asset/Asset.php +++ b/src/Asset/Asset.php @@ -38,6 +38,9 @@ class Asset private ?string $name; + /** + * @var array|null + */ private ?array $attributes; private ?int $position; @@ -53,6 +56,7 @@ class Asset /** * Asset constructor + * @param array|null $attributes */ public function __construct(int $type, string $path, ?string $name = null, ?int $position = -1, ?array $attributes = []) { @@ -97,8 +101,9 @@ public function getPosition(): ?int /** * Gets asset attributes + * @return array|null */ - public function getAttributes(): array + public function getAttributes(): ?array { return $this->attributes; } diff --git a/src/Asset/AssetManager.php b/src/Asset/AssetManager.php index 2069b532c..03f318115 100644 --- a/src/Asset/AssetManager.php +++ b/src/Asset/AssetManager.php @@ -41,7 +41,7 @@ class AssetManager /** * Published assets - * @var array[] + * @var array> */ private array $published = []; diff --git a/src/Asset/Exceptions/AssetException.php b/src/Asset/Exceptions/AssetException.php index 6321078b0..ced34ecaf 100644 --- a/src/Asset/Exceptions/AssetException.php +++ b/src/Asset/Exceptions/AssetException.php @@ -17,17 +17,18 @@ namespace Quantum\Asset\Exceptions; use Quantum\Asset\Enums\ExceptionMessages; +use Exception; /** * Class AssetException * @package Quantum\Asset */ -class AssetException extends \Exception +class AssetException extends Exception { public static function positionInUse(int $position, string $name): AssetException { return new self( - _message(ExceptionMessages::POSITION_IN_USE, [$position, $name]), + _message(ExceptionMessages::POSITION_IN_USE, [(string) $position, $name]), E_WARNING ); } @@ -35,7 +36,7 @@ public static function positionInUse(int $position, string $name): AssetExceptio public static function nameInUse(?string $name): AssetException { return new self( - _message(ExceptionMessages::NAME_IN_USE, [$name]), + _message(ExceptionMessages::NAME_IN_USE, [(string) $name]), E_WARNING ); } diff --git a/src/Auth/Adapters/JwtAuthAdapter.php b/src/Auth/Adapters/JwtAuthAdapter.php index 1593ee929..853b9dc56 100644 --- a/src/Auth/Adapters/JwtAuthAdapter.php +++ b/src/Auth/Adapters/JwtAuthAdapter.php @@ -128,6 +128,7 @@ public function refreshUser(string $uuid): bool * Verify OTP * @throws AuthException * @throws JwtException + * @return array */ public function verifyOtp(int $otp, string $otpToken): array { @@ -138,6 +139,7 @@ public function verifyOtp(int $otp, string $otpToken): array /** * Get Updated Tokens * @throws JwtException + * @return array */ protected function getUpdatedTokens(User $user): array { @@ -150,6 +152,7 @@ protected function getUpdatedTokens(User $user): array /** * Set Updated Tokens * @throws JwtException + * @return array */ protected function setUpdatedTokens(User $user): array { diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php index 641db71b3..3abb7905e 100644 --- a/src/Auth/Auth.php +++ b/src/Auth/Auth.php @@ -53,6 +53,7 @@ public function getAdapter(): AuthenticatableInterface } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Auth/Contracts/AuthServiceInterface.php b/src/Auth/Contracts/AuthServiceInterface.php index 9b004f410..4c4be74cd 100644 --- a/src/Auth/Contracts/AuthServiceInterface.php +++ b/src/Auth/Contracts/AuthServiceInterface.php @@ -31,16 +31,19 @@ public function get(string $field, ?string $value): ?User; /** * Add + * @param array $data */ public function add(array $data): User; /** * Update + * @param array $data */ public function update(string $field, ?string $value, array $data): ?User; /** * User Schema + * @return array */ public function userSchema(): array; } diff --git a/src/Auth/Factories/AuthFactory.php b/src/Auth/Factories/AuthFactory.php index 379cce31d..503d38113 100644 --- a/src/Auth/Factories/AuthFactory.php +++ b/src/Auth/Factories/AuthFactory.php @@ -25,6 +25,7 @@ use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Service\QtService; use Quantum\Hasher\Hasher; use Quantum\Jwt\JwtToken; use Quantum\Loader\Setup; @@ -115,6 +116,7 @@ private static function createAuthService(string $adapter): AuthServiceInterface { $authServiceClass = config()->get('auth.' . $adapter . '.service'); + /** @var class-string $authServiceClass */ $authService = ServiceFactory::create($authServiceClass); if (!$authService instanceof AuthServiceInterface) { diff --git a/src/Auth/Traits/AuthTrait.php b/src/Auth/Traits/AuthTrait.php index e401ece4e..ccec97daf 100644 --- a/src/Auth/Traits/AuthTrait.php +++ b/src/Auth/Traits/AuthTrait.php @@ -65,12 +65,12 @@ trait AuthTrait protected $otpLength = 6; /** - * @var array + * @var array */ protected $keyFields = []; /** - * @var array + * @var array */ protected $visibleFields = []; @@ -89,6 +89,8 @@ public function check(): bool /** * Sign Up + * @param array $userData + * @param array|null $customData */ public function signup(array $userData, ?array $customData = null): User { @@ -291,7 +293,8 @@ protected function verifyAndUpdateOtp(int $otp, string $otpToken): User } /** - * Filters and gets the visible fields + * Filters and gets visible fields + * @return array */ protected function getVisibleFields(User $user): array { @@ -326,8 +329,9 @@ protected function generateToken(?string $val = null): string /** * Send email + * @param array $body */ - protected function sendMail(User $user, array $body) + protected function sendMail(User $user, array $body): void { $fullName = ($user->hasField('firstname') && $user->hasField('lastname')) ? $user->getFieldValue('firstname') . ' ' . $user->getFieldValue('lastname') : ''; @@ -342,9 +346,10 @@ protected function sendMail(User $user, array $body) /** * Verify user schema + * @param array $schema * @throws AuthException */ - protected function verifySchema(array $schema) + protected function verifySchema(array $schema): void { $constants = (new ReflectionClass(AuthKeys::class))->getConstants(); diff --git a/src/Auth/User.php b/src/Auth/User.php index 24cd3bf91..1bbac695e 100644 --- a/src/Auth/User.php +++ b/src/Auth/User.php @@ -22,10 +22,14 @@ */ class User { + /** + * @var array + */ private array $data = []; /** * Set Data + * @param array $data * @return $this */ public function setData(array $data): self @@ -36,6 +40,7 @@ public function setData(array $data): self /** * Get Data + * @return array */ public function getData(): array { @@ -44,6 +49,7 @@ public function getData(): array /** * Get Fields + * @return array */ public function getFields(): array { @@ -52,6 +58,7 @@ public function getFields(): array /** * Set Fields + * @param array $schema * @return $this */ public function setFields(array $schema): self diff --git a/src/Cache/Adapters/DatabaseAdapter.php b/src/Cache/Adapters/DatabaseAdapter.php index fb14dfdb5..2fc248303 100644 --- a/src/Cache/Adapters/DatabaseAdapter.php +++ b/src/Cache/Adapters/DatabaseAdapter.php @@ -41,6 +41,9 @@ class DatabaseAdapter implements CacheInterface private DbModel $cacheModel; + /** + * @param array $params + */ public function __construct(array $params) { $this->ttl = $params['ttl']; @@ -70,6 +73,8 @@ public function get($key, $default = null) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -126,6 +131,7 @@ public function set($key, $value, $ttl = null): bool /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $values */ public function setMultiple($values, $ttl = null): bool { @@ -159,6 +165,7 @@ public function delete($key): bool /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys */ public function deleteMultiple($keys): bool { diff --git a/src/Cache/Adapters/FileAdapter.php b/src/Cache/Adapters/FileAdapter.php index d26e56cfe..3a43d6d17 100644 --- a/src/Cache/Adapters/FileAdapter.php +++ b/src/Cache/Adapters/FileAdapter.php @@ -54,6 +54,7 @@ class FileAdapter implements CacheInterface * @throws ConfigException * @throws DiException * @throws ReflectionException + * @param array $params */ public function __construct(array $params) { @@ -89,6 +90,8 @@ public function get($key, $default = null) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -135,6 +138,7 @@ public function set($key, $value, $ttl = null) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $values */ public function setMultiple($values, $ttl = null): bool { @@ -168,6 +172,7 @@ public function delete($key) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys */ public function deleteMultiple($keys): bool { diff --git a/src/Cache/Adapters/MemcachedAdapter.php b/src/Cache/Adapters/MemcachedAdapter.php index 43cb65107..f682cded6 100644 --- a/src/Cache/Adapters/MemcachedAdapter.php +++ b/src/Cache/Adapters/MemcachedAdapter.php @@ -44,6 +44,7 @@ class MemcachedAdapter implements CacheInterface /** * @throws BaseException + * @param array $params */ public function __construct(array $params) { @@ -80,6 +81,8 @@ public function get($key, $default = null) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -116,6 +119,7 @@ public function set($key, $value, $ttl = null): bool /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $values */ public function setMultiple($values, $ttl = null): bool { @@ -143,6 +147,7 @@ public function delete($key): bool /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys */ public function deleteMultiple($keys): bool { diff --git a/src/Cache/Adapters/RedisAdapter.php b/src/Cache/Adapters/RedisAdapter.php index 40e7e7f30..c384a1209 100644 --- a/src/Cache/Adapters/RedisAdapter.php +++ b/src/Cache/Adapters/RedisAdapter.php @@ -43,6 +43,7 @@ class RedisAdapter implements CacheInterface /** * @throws RedisException + * @param array $params */ public function __construct(array $params) { @@ -75,6 +76,8 @@ public function get($key, $default = null) /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys + * @return iterable */ public function getMultiple($keys, $default = null) { @@ -113,6 +116,7 @@ public function set($key, $value, $ttl = null) * @inheritDoc * @throws RedisException * @throws InvalidArgumentException + * @param iterable $values */ public function setMultiple($values, $ttl = null): bool { @@ -140,6 +144,7 @@ public function delete($key): bool /** * @inheritDoc * @throws InvalidArgumentException + * @param iterable $keys */ public function deleteMultiple($keys): bool { diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index 1b7df14d9..f907c3533 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -24,7 +24,7 @@ * Class Cache * @package Quantum\Cache * @method mixed get($key, $default = null) - * @method array getMultiple($keys, $default = null) + * @method iterable getMultiple($keys, $default = null) * @method has($key): bool * @method bool set($key, $value, $ttl = null) * @method bool setMultiple($values, $ttl = null) @@ -73,6 +73,7 @@ public function getAdapter(): CacheInterface } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Captcha/Adapters/HcaptchaAdapter.php b/src/Captcha/Adapters/HcaptchaAdapter.php index d730f8b59..a918fd44c 100644 --- a/src/Captcha/Adapters/HcaptchaAdapter.php +++ b/src/Captcha/Adapters/HcaptchaAdapter.php @@ -44,6 +44,7 @@ class HcaptchaAdapter implements CaptchaInterface /** * Hcaptcha constructor + * @param array $params */ public function __construct(array $params, HttpClient $httpClient) { diff --git a/src/Captcha/Adapters/RecaptchaAdapter.php b/src/Captcha/Adapters/RecaptchaAdapter.php index 1c471a989..cb4b9a7ed 100644 --- a/src/Captcha/Adapters/RecaptchaAdapter.php +++ b/src/Captcha/Adapters/RecaptchaAdapter.php @@ -44,6 +44,7 @@ class RecaptchaAdapter implements CaptchaInterface /** * RecaptchaAdapter constructor + * @param array $params */ public function __construct(array $params, HttpClient $httpClient) { diff --git a/src/Captcha/Captcha.php b/src/Captcha/Captcha.php index c94f27896..ac96ce99a 100644 --- a/src/Captcha/Captcha.php +++ b/src/Captcha/Captcha.php @@ -55,6 +55,7 @@ public function getAdapter(): CaptchaInterface } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Captcha/Traits/CaptchaTrait.php b/src/Captcha/Traits/CaptchaTrait.php index 4cc934b22..4e2ac7de1 100644 --- a/src/Captcha/Traits/CaptchaTrait.php +++ b/src/Captcha/Traits/CaptchaTrait.php @@ -44,8 +44,14 @@ trait CaptchaTrait */ protected $type; + /** + * @var array + */ protected array $errorCodes = []; + /** + * @var array + */ protected array $elementAttributes = []; public function getType(): ?string @@ -75,6 +81,7 @@ public function getName(): string * Generates an HTML code block for the captcha * @throws AssetException * @throws Exception + * @param array $attributes */ public function addToForm(string $formIdentifier = '', array $attributes = []): string { @@ -153,6 +160,9 @@ public function getErrorMessage(): ?string return null; } + /** + * @param array $attributes + */ protected function getVisibleElement(array $attributes = []): string { $this->extractAttributes($attributes); @@ -184,9 +194,9 @@ function onSubmit (){ } /** - * @param $type + * @param string $type */ - protected function isValidCaptchaType($type): bool + protected function isValidCaptchaType(string $type): bool { $captchaTypes = [ self::CAPTCHA_VISIBLE, @@ -197,9 +207,10 @@ protected function isValidCaptchaType($type): bool } /** + * @param array $attributes * @return void */ - protected function extractAttributes(array $attributes) + protected function extractAttributes(array $attributes): void { foreach ($attributes as $key => $value) { if ($key == 'class') { diff --git a/src/Console/CommandDiscovery.php b/src/Console/CommandDiscovery.php index cd58a994f..16bb17fa6 100644 --- a/src/Console/CommandDiscovery.php +++ b/src/Console/CommandDiscovery.php @@ -27,6 +27,7 @@ class CommandDiscovery { /** * @throws ReflectionException + * @return array> */ public static function discover(string $directory, string $namespace): array { diff --git a/src/Console/Commands/InstallToolkitCommand.php b/src/Console/Commands/InstallToolkitCommand.php index 0cf0e4258..790ed7fe0 100644 --- a/src/Console/Commands/InstallToolkitCommand.php +++ b/src/Console/Commands/InstallToolkitCommand.php @@ -89,8 +89,10 @@ public function exec(): void /** * Runs an external command * @throws ExceptionInterface + * @param array $arguments + * @return void */ - protected function runExternalCommand(string $commandName, array $arguments) + protected function runExternalCommand(string $commandName, array $arguments): void { $command = $this->getApplication()->find($commandName); $command->run(new ArrayInput($arguments), new NullOutput()); diff --git a/src/Console/Commands/MigrationGenerateCommand.php b/src/Console/Commands/MigrationGenerateCommand.php index 7424e7878..4740d9de6 100644 --- a/src/Console/Commands/MigrationGenerateCommand.php +++ b/src/Console/Commands/MigrationGenerateCommand.php @@ -39,7 +39,7 @@ class MigrationGenerateCommand extends QtCommand /** * Command arguments - * @var string[][] + * @var array> */ 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'], diff --git a/src/Console/Commands/MigrationMigrateCommand.php b/src/Console/Commands/MigrationMigrateCommand.php index fffbd278a..c001edbf8 100644 --- a/src/Console/Commands/MigrationMigrateCommand.php +++ b/src/Console/Commands/MigrationMigrateCommand.php @@ -43,7 +43,7 @@ class MigrationMigrateCommand extends QtCommand /** * Command arguments - * @var string[][] + * @var array> */ protected array $args = [ ['direction', 'optional', '[up] for upgrade, [down] for downgrade'], @@ -51,7 +51,7 @@ class MigrationMigrateCommand extends QtCommand /** * Command options - * @var string[][] + * @var array> */ protected array $options = [ ['step', 's', 'optional', 'Number of migrations to apply'], diff --git a/src/Console/Commands/ModuleGenerateCommand.php b/src/Console/Commands/ModuleGenerateCommand.php index b646edc4e..3310b3495 100644 --- a/src/Console/Commands/ModuleGenerateCommand.php +++ b/src/Console/Commands/ModuleGenerateCommand.php @@ -39,7 +39,7 @@ class ModuleGenerateCommand extends QtCommand /** * Command arguments - * @var string[][] + * @var array> */ protected array $args = [ ['module', 'required', 'The module name'], diff --git a/src/Console/Commands/OpenApiCommand.php b/src/Console/Commands/OpenApiCommand.php index f89e40d65..a9fbbff8d 100644 --- a/src/Console/Commands/OpenApiCommand.php +++ b/src/Console/Commands/OpenApiCommand.php @@ -60,7 +60,7 @@ public function __construct() /** * Command arguments - * @var string[][] + * @var array> */ protected array $args = [ ['module', 'required', 'The module name'], @@ -83,6 +83,7 @@ public function __construct() /** * Exclude File Names + * @var array */ private array $excludeFileNames = ['index.html', 'swagger-initializer.js', 'favicon-16x16.png', 'favicon-32x32.png']; diff --git a/src/Console/Commands/ResourceCacheClearCommand.php b/src/Console/Commands/ResourceCacheClearCommand.php index 93fe056f3..3705fe9b5 100644 --- a/src/Console/Commands/ResourceCacheClearCommand.php +++ b/src/Console/Commands/ResourceCacheClearCommand.php @@ -49,6 +49,7 @@ class ResourceCacheClearCommand extends QtCommand /** * Command options + * @var array> */ protected array $options = [ ['all', 'all', 'none', ''], @@ -56,8 +57,14 @@ class ResourceCacheClearCommand extends QtCommand ['module', 'm', 'required', ''], ]; + /** + * @var array + */ protected array $types = ['views', 'asserts']; + /** + * @var array + */ protected array $modules = []; protected ?string $type = null; diff --git a/src/Console/Commands/RouteListCommand.php b/src/Console/Commands/RouteListCommand.php index 8b78c098c..2f841c521 100644 --- a/src/Console/Commands/RouteListCommand.php +++ b/src/Console/Commands/RouteListCommand.php @@ -106,6 +106,7 @@ static function (Route $route) use ($module): bool { /** * Composes a table row + * @return array */ private function composeTableRow(Route $route, int $maxContentLength = 25): array { @@ -123,7 +124,7 @@ private function composeTableRow(Route $route, int $maxContentLength = 25): arra } $middlewares = $route->getMiddlewares(); - $middlewaresString = $middlewares !== [] + $middlewaresString = !empty($middlewares) ? implode(',', $middlewares) : '-'; diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index e459f7375..f30d11e37 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -41,6 +41,11 @@ class ServeCommand extends QtCommand */ public const PLATFORM_MAC = 'Darwin'; + /** + * Maximum valid TCP/UDP port number + */ + private const MAX_PORT = 65535; + /** * The console command name. */ @@ -68,7 +73,7 @@ class ServeCommand extends QtCommand /** * Command arguments - * @var array> + * @var array> */ protected array $options = [ ['host', null, 'optional', 'Host', '127.0.0.1'], @@ -92,6 +97,7 @@ public function exec(): void /** * Start the server on the first available port. * @throws RuntimeException + * @return array */ protected function startServerOnAvailablePort(string $host, int $startPort): array { @@ -125,6 +131,7 @@ 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 { @@ -253,7 +260,7 @@ protected function openBrowser(string $url): void 2 => STDERR, ]; - $proc = proc_open($cmd, $descriptors, $pipes); + $proc = proc_open($cmd[0] . ' ' . $cmd[1], $descriptors, $pipes); if (is_resource($proc)) { proc_close($proc); } @@ -261,6 +268,7 @@ protected function openBrowser(string $url): void /** * Resolve platform-specific browser command. + * @return array|null */ protected function browserCommand(string $url): ?array { @@ -291,8 +299,8 @@ protected function port(): int { $port = (int) ($this->getOption('port') ?: $this->defaultPort); - if ($port < 1 || $port > 65535) { - throw new RuntimeException("Port must be between 1 and 65535, got: {$port}"); + if ($port < 1 || $port > self::MAX_PORT) { + throw new RuntimeException('Port must be between 1 and ' . self::MAX_PORT . ", got: {$port}"); } return $port; diff --git a/src/Console/Contracts/CommandInterface.php b/src/Console/Contracts/CommandInterface.php index dbae0c70c..e6248f291 100644 --- a/src/Console/Contracts/CommandInterface.php +++ b/src/Console/Contracts/CommandInterface.php @@ -25,6 +25,6 @@ interface CommandInterface /** * Executes the current command. */ - public function exec(); + public function exec(): void; } diff --git a/src/Console/QtCommand.php b/src/Console/QtCommand.php index 7cb08833b..d78cd21b8 100644 --- a/src/Console/QtCommand.php +++ b/src/Console/QtCommand.php @@ -48,12 +48,14 @@ abstract class QtCommand extends Command implements CommandInterface /** * Console command input arguments * @example ['name', 'type', 'description'] + * @var array> */ protected array $args = []; /** * Console command options * @example ['name', 'shortcut', 'type', 'description', 'default'] + * @var array> */ protected array $options = []; @@ -149,8 +151,9 @@ public function error(string $message): void /** * Configures the current command. + * @return void */ - protected function configure() + protected function configure(): void { $this->setArguments(); $this->setOptions(); diff --git a/src/Contracts/StorageInterface.php b/src/Contracts/StorageInterface.php index 29a8f04f8..4156c894c 100644 --- a/src/Contracts/StorageInterface.php +++ b/src/Contracts/StorageInterface.php @@ -24,6 +24,7 @@ interface StorageInterface { /** * Gets whole storage data + * @return mixed */ public function all(); @@ -41,16 +42,19 @@ public function get(string $key); /** * Sets storage value with the given key * @param mixed $value + * @return void */ public function set(string $key, $value); /** * Deletes the data from the storage by given key + * @return void */ public function delete(string $key); /** * Deletes whole storage data + * @return void */ public function flush(); } diff --git a/src/Cookie/Contracts/CookieStorageInterface.php b/src/Cookie/Contracts/CookieStorageInterface.php index baf14ac88..81d89f4d4 100644 --- a/src/Cookie/Contracts/CookieStorageInterface.php +++ b/src/Cookie/Contracts/CookieStorageInterface.php @@ -27,11 +27,13 @@ interface CookieStorageInterface extends StorageInterface /** * Sets data by given key * @param mixed $value + * @return void */ - 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; /** * Deletes data by given key + * @return void */ - public function delete(string $key, string $path = '/'); + public function delete(string $key, string $path = '/'): void; } diff --git a/src/Cookie/Cookie.php b/src/Cookie/Cookie.php index bf0a34cf1..174d1e219 100644 --- a/src/Cookie/Cookie.php +++ b/src/Cookie/Cookie.php @@ -27,6 +27,7 @@ class Cookie implements CookieStorageInterface { /** * Cookie storage + * @var array */ private static array $storage = []; @@ -44,7 +45,8 @@ private function __construct() } /** - * Gets the cookie instance + * Gets the cookie instance + * @param array $storage */ public static function getInstance(array &$storage): Cookie { @@ -60,6 +62,7 @@ public static function getInstance(array &$storage): Cookie /** * @inheritDoc * @throws BaseException + * @return array */ public function all(): array { diff --git a/src/Cron/CronLock.php b/src/Cron/CronLock.php index e704de0eb..99e98daad 100644 --- a/src/Cron/CronLock.php +++ b/src/Cron/CronLock.php @@ -267,7 +267,7 @@ private function cleanupStaleLocks(): void } /** - * @param $handle + * @param resource $handle */ private function writeTimestampToHandle($handle): bool { @@ -293,7 +293,7 @@ private function writeTimestampToHandle($handle): bool } /** - * @param $handle + * @param resource $handle */ private function readTimestampFromHandle($handle): ?int { diff --git a/src/Cron/CronManager.php b/src/Cron/CronManager.php index 37ae1e8c7..f4bb5cdb5 100644 --- a/src/Cron/CronManager.php +++ b/src/Cron/CronManager.php @@ -45,6 +45,7 @@ class CronManager /** * Execution statistics + * @var array */ private array $stats = [ 'total' => 0, @@ -109,6 +110,7 @@ private function loadTaskFromFile(string $file): void /** * Create a task from array definition + * @param array $definition * @throws CronException */ private function createTaskFromArray(array $definition): CronTask @@ -210,6 +212,7 @@ public function getTasks(): array /** * Get execution statistics + * @return array */ public function getStats(): array { @@ -226,6 +229,7 @@ private function getDefaultCronDirectory(): string /** * Log a message + * @param array $context */ private function log(string $level, string $message, array $context = []): void { diff --git a/src/Cron/Schedule.php b/src/Cron/Schedule.php index 35f88ab16..f8bd068da 100644 --- a/src/Cron/Schedule.php +++ b/src/Cron/Schedule.php @@ -329,8 +329,8 @@ public function sundays(): self } /** - * Run the task on specific days - * @param int|array $days + * Run task on specific days + * @param int|array $days */ public function days($days): self { diff --git a/src/Database/Adapters/Idiorm/IdiormDbal.php b/src/Database/Adapters/Idiorm/IdiormDbal.php index ca0727825..7a0f384f8 100644 --- a/src/Database/Adapters/Idiorm/IdiormDbal.php +++ b/src/Database/Adapters/Idiorm/IdiormDbal.php @@ -85,12 +85,13 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * Foreign keys - * @var array + * @var array> */ private $foreignKeys; /** * Hidden fields + * @var array */ private array $hidden; @@ -106,6 +107,7 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * Active connection + * @var array|null */ private static ?array $connection = null; @@ -134,6 +136,10 @@ class IdiormDbal implements DbalInterface, RelationalInterface */ private static string $ormClass = ORM::class; + /** + * @param array> $foreignKeys + * @param array $hidden + */ public function __construct( string $table, ?string $modelName = null, @@ -150,6 +156,7 @@ public function __construct( /** * @inheritDoc + * @param array $config */ public static function connect(array $config): void { @@ -165,6 +172,7 @@ public static function connect(array $config): void /** * @inheritDoc + * @return array|null */ public static function getConnection(): ?array { @@ -207,6 +215,7 @@ public function getOrmModel(): ORM /** * Gets foreign keys + * @return array> */ public function getForeignKeys(): array { @@ -234,11 +243,18 @@ public function truncate(): bool } } + /** + * @return void + */ protected function updateOrmModel(ORM $ormModel) { $this->ormModel = $ormModel; } + /** + * @param array $config + * @return array + */ protected static function getBaseConfig(string $driver, array $config): array { return [ @@ -248,6 +264,10 @@ protected static function getBaseConfig(string $driver, array $config): array ]; } + /** + * @param array $config + * @return array + */ protected static function getDriverConfig(string $driver, array $config, string $charset): array { if ($driver === self::DRIVER_MYSQL || $driver === self::DRIVER_PGSQL) { @@ -267,6 +287,7 @@ protected static function getDriverConfig(string $driver, array $config, string /** * Builds connection string + * @param array $config */ 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 4e4ba8f2b..fec4ca406 100644 --- a/src/Database/Adapters/Idiorm/IdiormPatch.php +++ b/src/Database/Adapters/Idiorm/IdiormPatch.php @@ -52,6 +52,7 @@ public function use(object $ormModel): IdiormPatch /** * Add an LEFT JOIN source to the query + * @param array $constraint */ public function leftJoin(string $table, array $constraint, ?string $table_alias = null): object { @@ -60,6 +61,7 @@ public function leftJoin(string $table, array $constraint, ?string $table_alias /** * Add an RIGHT JOIN source to the query + * @param array $constraint */ public function rightJoin(string $table, array $constraint, ?string $table_alias = null): object { @@ -68,6 +70,7 @@ public function rightJoin(string $table, array $constraint, ?string $table_alias /** * Add Join + * @param array $constraint */ public function addJoin(string $operator, string $table, array $constraint, ?string $table_alias = null): object { diff --git a/src/Database/Adapters/Idiorm/Statements/Criteria.php b/src/Database/Adapters/Idiorm/Statements/Criteria.php index 1975c8461..8f09c4cae 100644 --- a/src/Database/Adapters/Idiorm/Statements/Criteria.php +++ b/src/Database/Adapters/Idiorm/Statements/Criteria.php @@ -95,6 +95,7 @@ public function isNotNull(string $column): DbalInterface * Adds Criteria * @param mixed $value * @throws DatabaseException + * @return void */ protected function addCriteria(string $column, string $operator, $value, ?string $func = null) { @@ -109,7 +110,9 @@ protected function addCriteria(string $column, string $operator, $value, ?string /** * Adds one or more OR criteria in brackets + * @param array $orCriterias * @throws DatabaseException + * @return void */ protected function orCriteria(array $orCriterias) { diff --git a/src/Database/Adapters/Idiorm/Statements/Join.php b/src/Database/Adapters/Idiorm/Statements/Join.php index 9c00cf8d6..ddb1dd446 100644 --- a/src/Database/Adapters/Idiorm/Statements/Join.php +++ b/src/Database/Adapters/Idiorm/Statements/Join.php @@ -109,6 +109,7 @@ public function joinTo(DbModel $relatedModel, bool $switch = true): DbalInterfac } /** + * @param array $relation * @throws BaseException */ protected function applyHasRelation(DbModel $relatedModel, array $relation): void @@ -124,6 +125,7 @@ protected function applyHasRelation(DbModel $relatedModel, array $relation): voi } /** + * @param array $relation * @throws BaseException */ protected function applyBelongsTo(DbModel $relatedModel, array $relation): void @@ -140,6 +142,7 @@ protected function applyBelongsTo(DbModel $relatedModel, array $relation): void /** * @throws ModelException + * @return array */ 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 bddb410fe..68ce30bf4 100644 --- a/src/Database/Adapters/Idiorm/Statements/Query.php +++ b/src/Database/Adapters/Idiorm/Statements/Query.php @@ -109,6 +109,7 @@ public static function queryLog(): array /** * Fetches columns of the table * @throws DatabaseException + * @return array */ public static function fetchColumns(string $table): array { diff --git a/src/Database/Adapters/Idiorm/Statements/Result.php b/src/Database/Adapters/Idiorm/Statements/Result.php index d4488c971..61187cc13 100644 --- a/src/Database/Adapters/Idiorm/Statements/Result.php +++ b/src/Database/Adapters/Idiorm/Statements/Result.php @@ -107,7 +107,8 @@ public function asArray(): array } /** - * @param $result + * @param array $result + * @return array */ public function setHidden($result): array { diff --git a/src/Database/Adapters/Sleekdb/SleekDbal.php b/src/Database/Adapters/Sleekdb/SleekDbal.php index 9d372d5c8..7127b7caa 100644 --- a/src/Database/Adapters/Sleekdb/SleekDbal.php +++ b/src/Database/Adapters/Sleekdb/SleekDbal.php @@ -45,29 +45,38 @@ class SleekDbal implements DbalInterface protected bool $isNew = false; + /** + * @var array + */ protected array $data = []; /** - * @var array + * @var array */ protected $modifiedFields = []; + /** + * @var array> + */ protected array $criterias = []; + /** + * @var array> + */ protected array $havings = []; /** - * @var array + * @var array */ protected $selected = []; /** - * @var array + * @var array */ protected $grouped = []; /** - * @var array + * @var array */ protected $ordered = []; @@ -82,7 +91,7 @@ class SleekDbal implements DbalInterface protected $limit; /** - * @var array + * @var array> */ protected $joins = []; @@ -102,13 +111,14 @@ class SleekDbal implements DbalInterface private string $idColumn; /** - * Foreign keys + * Foreign keys (related class name => relation definition) + * @var array> */ private array $foreignKeys; /** * Hidden fields - * @var array + * @var array */ public $hidden = []; @@ -121,6 +131,7 @@ class SleekDbal implements DbalInterface /** * Active connection + * @var array|null */ private static ?array $connection = null; @@ -137,6 +148,10 @@ class SleekDbal implements DbalInterface 'BETWEEN', 'NOT BETWEEN', ]; + /** + * @param array> $foreignKeys + * @param array $hidden + */ public function __construct( string $table, ?string $modelName = null, @@ -151,6 +166,9 @@ public function __construct( $this->hidden = $hidden; } + /** + * @return mixed + */ public function __get(string $key) { return $this->data[$key] ?? null; @@ -158,19 +176,23 @@ public function __get(string $key) /** * @inheritDoc + * @param array $config */ public static function connect(array $config): void { self::$connection = $config; } + /** + * @param array $data + */ public function setData(array $data): void { $this->data = $data; } /** - * @param $modifiedFields + * @param mixed $modifiedFields */ public function setModifiedFields($modifiedFields): void { @@ -184,6 +206,7 @@ public function setIsNew(bool $isNew): void /** * @inheritDoc + * @return array|null */ public static function getConnection(): ?array { @@ -235,6 +258,9 @@ public function getOrmModel(): Store return $this->ormModel; } + /** + * @param array|null $modelData + */ public function updateOrmModel(?array $modelData): void { $this->data = $modelData; @@ -307,6 +333,7 @@ public function getBuilder(): QueryBuilder /** * Gets foreign keys + * @return array> */ public function getForeignKeys(): array { diff --git a/src/Database/Adapters/Sleekdb/Statements/Criteria.php b/src/Database/Adapters/Sleekdb/Statements/Criteria.php index 5e89c801d..628dc7c92 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Criteria.php +++ b/src/Database/Adapters/Sleekdb/Statements/Criteria.php @@ -92,6 +92,8 @@ public function isNotNull(string $column): DbalInterface /** * Adds one or more OR criteria in brackets + * @param array> $orCriterias + * @return void * @throws DatabaseException */ protected function orCriteria(array $orCriterias) @@ -106,7 +108,7 @@ protected function orCriteria(array $orCriterias) } /** - * @param $value + * @param mixed $value * @return mixed|string|null */ protected function sanitizeValue($value) diff --git a/src/Database/Adapters/Sleekdb/Statements/Join.php b/src/Database/Adapters/Sleekdb/Statements/Join.php index acde0727f..34563cf70 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Join.php +++ b/src/Database/Adapters/Sleekdb/Statements/Join.php @@ -56,6 +56,7 @@ private function applyJoins(): void /** * Apply the join to query builder + * @param array $nextItem * @throws ModelException */ private function applyJoin(QueryBuilder $queryBuilder, SleekDbal $currentItem, array $nextItem, int $level = 1): QueryBuilder @@ -93,6 +94,7 @@ private function applyJoin(QueryBuilder $queryBuilder, SleekDbal $currentItem, a /** * Apply join condition for JOINTO type + * @param array $currentItem * @throws InvalidArgumentException * @throws ModelException */ @@ -116,6 +118,8 @@ private function applyJoinTo(QueryBuilder $queryBuilder, DbModel $relatedModel, } /** + * @param array $currentItem + * @param array $relation * @throws InvalidArgumentException */ private function applyHasRelation(QueryBuilder $queryBuilder, array $currentItem, array $relation): void @@ -128,6 +132,8 @@ private function applyHasRelation(QueryBuilder $queryBuilder, array $currentItem } /** + * @param array $currentItem + * @param array $relation * @throws InvalidArgumentException * @throws ModelException */ @@ -145,6 +151,7 @@ private function applyBelongsTo(QueryBuilder $queryBuilder, array $currentItem, } /** + * @return array * @throws ModelException */ private function getValidatedRelation(SleekDbal $currentModel, DbModel $relatedModel): array diff --git a/src/Database/Adapters/Sleekdb/Statements/Reducer.php b/src/Database/Adapters/Sleekdb/Statements/Reducer.php index 28d2322bc..6c4384a2c 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Reducer.php +++ b/src/Database/Adapters/Sleekdb/Statements/Reducer.php @@ -81,6 +81,10 @@ 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 97cc22df4..cf34687d7 100644 --- a/src/Database/Adapters/Sleekdb/Statements/Result.php +++ b/src/Database/Adapters/Sleekdb/Statements/Result.php @@ -140,7 +140,8 @@ public function asArray(): array } /** - * @param $result + * @param array $result + * @return array */ public function setHidden($result): array { diff --git a/src/Database/Contracts/DbalInterface.php b/src/Database/Contracts/DbalInterface.php index 42bab930a..e6709cf7e 100644 --- a/src/Database/Contracts/DbalInterface.php +++ b/src/Database/Contracts/DbalInterface.php @@ -26,16 +26,20 @@ interface DbalInterface { /** * Connects to database + * @param array $config + * @return void */ public static function connect(array $config); /** * Gets the active connection + * @return array|null */ public static function getConnection(): ?array; /** * Close the database connection + * @return void */ public static function disconnect(); @@ -74,7 +78,7 @@ public function criteria(string $column, string $operator, $value = null): DbalI /** * Adds criteria to query - * @param array ...$criterias + * @param array ...$criterias */ public function criterias(...$criterias): DbalInterface; @@ -105,6 +109,7 @@ public function limit(int $limit): DbalInterface; /** * Gets the result set + * @return array */ public function get(): array; @@ -115,6 +120,7 @@ public function count(): int; /** * Returns the data as array + * @return array */ public function asArray(): array; diff --git a/src/Database/Contracts/RelationalInterface.php b/src/Database/Contracts/RelationalInterface.php index fd91436c4..9bab58cae 100644 --- a/src/Database/Contracts/RelationalInterface.php +++ b/src/Database/Contracts/RelationalInterface.php @@ -24,11 +24,14 @@ interface RelationalInterface { /** * Raw execute + * @param array $parameters */ public static function execute(string $query, array $parameters = []): bool; /** * Raw query + * @param array $parameters + * @return array */ public static function query(string $query, array $parameters = []): array; @@ -45,26 +48,31 @@ 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 array $constraint */ public function join(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an INNER JOIN source to the query + * @param array $constraint */ public function innerJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an LEFT JOIN source to the query + * @param array $constraint */ public function leftJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; /** * Adds an RIGHT JOIN source to the query + * @param array $constraint */ public function rightJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface; diff --git a/src/Database/Database.php b/src/Database/Database.php index 8267323f8..3331be7fc 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -45,7 +45,7 @@ class Database /** * Database configurations - * @var array + * @var array */ private $configs; @@ -100,7 +100,8 @@ public function getOrmClass(): string } /** - * Gets the DB configurations + * Gets DB configurations + * @return array|null */ public function getConfigs(): ?array { diff --git a/src/Database/Schemas/Table.php b/src/Database/Schemas/Table.php index 3f796bc9b..9b5a8f6cd 100644 --- a/src/Database/Schemas/Table.php +++ b/src/Database/Schemas/Table.php @@ -68,15 +68,18 @@ class Table private ?int $action = null; + /** + * @var array + */ private array $columns = []; /** - * @var array + * @var array */ private $indexKeys = []; /** - * @var array + * @var array */ private $droppedIndexKeys = []; @@ -109,6 +112,7 @@ public function renameTo(string $newName): Table /** * Sets an action on a table to be performed + * @param array $data */ public function setAction(int $action, ?array $data = null): Table { @@ -242,6 +246,7 @@ public function getSql(): string /** * Allows to call methods of Column class + * @param array|null $arguments * @return $this * @throws BaseException */ diff --git a/src/Database/Traits/RelationalTrait.php b/src/Database/Traits/RelationalTrait.php index 9e67f08f7..2b2f05371 100644 --- a/src/Database/Traits/RelationalTrait.php +++ b/src/Database/Traits/RelationalTrait.php @@ -26,6 +26,7 @@ trait RelationalTrait { /** * Raw execute + * @param array $parameters * @throws DatabaseException */ public static function execute(string $query, array $parameters = []): bool @@ -35,6 +36,8 @@ public static function execute(string $query, array $parameters = []): bool /** * Raw query + * @param array $parameters + * @return array * @throws DatabaseException */ public static function query(string $query, array $parameters = []): array @@ -44,6 +47,8 @@ public static function query(string $query, array $parameters = []): array /** * Fetches table columns + * @param array $parameters + * @return array * @throws DatabaseException */ public static function fetchColumns(string $query, array $parameters = []): array @@ -63,6 +68,7 @@ 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 @@ -72,6 +78,7 @@ public static function queryLog(): array /** * Resolves the requested query + * @param array $parameters * @return mixed * @throws DatabaseException */ diff --git a/src/Debugger/Debugger.php b/src/Debugger/Debugger.php index 68db9bfc4..8f2419e64 100644 --- a/src/Debugger/Debugger.php +++ b/src/Debugger/Debugger.php @@ -81,6 +81,7 @@ class Debugger /** * Debugger constructor. + * @param array $collectors * @throws DebugBarException */ public function __construct(DebuggerStore $store, DebugBar $debugBar, array $collectors = []) @@ -94,6 +95,7 @@ public function __construct(DebuggerStore $store, DebugBar $debugBar, array $col } /** + * @param array $collectors * @throws DebugBarException */ public static function getInstance(?DebuggerStore $store = null, ?DebugBar $debugBar = null, ?array $collectors = []): Debugger @@ -139,6 +141,9 @@ public function addToStoreCell(string $cell, string $level, $data): void } } + /** + * @return array + */ public function getStoreCell(string $cell): array { return $this->store->get($cell); @@ -174,9 +179,10 @@ public function render(): string /** * Creates a tab + * @return void * @throws DebugBarException */ - protected function createTab(string $type) + protected function createTab(string $type): void { if (!$this->debugBar->hasCollector($type)) { $this->debugBar->addCollector(new MessagesCollector($type)); @@ -201,6 +207,9 @@ 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 63ce3847e..d9bfc0207 100644 --- a/src/Debugger/DebuggerStore.php +++ b/src/Debugger/DebuggerStore.php @@ -24,8 +24,14 @@ */ class DebuggerStore implements StorageInterface { + /** + * @var array + */ private static array $store = []; + /** + * @param array $keys + */ public function init(array $keys): void { foreach ($keys as $key) { @@ -36,7 +42,7 @@ public function init(array $keys): void } /** - * @return array[] + * @return array */ public function all(): array { @@ -48,6 +54,9 @@ public function has(string $key): bool return isset(self::$store[$key]); } + /** + * @return array + */ public function get(string $key): array { return self::$store[$key] ?? []; diff --git a/src/Di/Di.php b/src/Di/Di.php index f0cea1004..f1c77d9cd 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -47,6 +47,7 @@ class Di /** * Register dependencies + * @param array $dependencies * @throws DiException */ public static function registerDependencies(array $dependencies): void @@ -125,6 +126,7 @@ public static function set(string $abstract, object $instance, bool $override = * Retrieves a shared instance of the given dependency. * @template T of object * @param class-string $dependency + * @param array $args * @return T * @throws DiException|ReflectionException */ @@ -141,6 +143,7 @@ public static function get(string $dependency, array $args = []) * Creates new instance of the given dependency. * @template T of object * @param class-string $dependency + * @param array $args * @return T * @throws DiException|ReflectionException */ @@ -155,7 +158,8 @@ public static function create(string $dependency, array $args = []) /** * Autowire callable parameters - * @return list + * @param array $args + * @return array * @throws DiException * @throws ReflectionException */ @@ -187,6 +191,7 @@ public static function resetContainer(): void /** * Resolves the dependency + * @param array $args * @return mixed|object * @throws DiException|ReflectionException */ @@ -214,6 +219,7 @@ private static function resolve(string $abstract, array $args = [], bool $single /** * Instantiates the dependency + * @param array $args * @return mixed * @throws ReflectionException|DiException */ @@ -231,6 +237,9 @@ 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 @@ -246,6 +255,7 @@ private static function resolveParameters(array $parameters, array &$args = []): /** * Resolve single parameter + * @param array $args * @return array|mixed|object|null * @throws DiException|ReflectionException */ @@ -259,11 +269,13 @@ private static function resolveParameter(ReflectionParameter $param, array &$arg // prefer registered dependency if ($type !== null && isset(self::$dependencies[$type])) { + /** @var class-string $type */ return self::get($type); } // fallback instantiable class if ($type !== null && self::instantiable($type)) { + /** @var class-string $type */ return self::create($type); } diff --git a/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php b/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php index 6793eea5b..f05b26c46 100644 --- a/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php +++ b/src/Encryption/Adapters/AsymmetricEncryptionAdapter.php @@ -87,6 +87,7 @@ public function decrypt(string $encrypted): string /** * Generate key pairs + * @return array * @throws BaseException */ private function generateKeyPair(): array diff --git a/src/Encryption/Cryptor.php b/src/Encryption/Cryptor.php index c2bf112c4..70ea9ed56 100644 --- a/src/Encryption/Cryptor.php +++ b/src/Encryption/Cryptor.php @@ -57,6 +57,7 @@ public function isAsymmetric(): bool } /** + * @param array|null $arguments * @return mixed * @throws BaseException */ diff --git a/src/Encryption/Factories/CryptorFactory.php b/src/Encryption/Factories/CryptorFactory.php index 0ac4930b8..8cbfee370 100644 --- a/src/Encryption/Factories/CryptorFactory.php +++ b/src/Encryption/Factories/CryptorFactory.php @@ -36,6 +36,9 @@ class CryptorFactory Cryptor::ASYMMETRIC => AsymmetricEncryptionAdapter::class, ]; + /** + * @var array + */ private static array $instances = []; /** diff --git a/src/Encryption/Helpers/encryption.php b/src/Encryption/Helpers/encryption.php index b1303372d..ceda2b6f2 100644 --- a/src/Encryption/Helpers/encryption.php +++ b/src/Encryption/Helpers/encryption.php @@ -18,7 +18,7 @@ /** * Encodes the data cryptographically - * @param $data + * @param mixed $data * @throws BaseException */ function crypto_encode($data, string $type = Cryptor::SYMMETRIC): string diff --git a/src/Environment/Environment.php b/src/Environment/Environment.php index df1ffb517..e8ef37a2a 100644 --- a/src/Environment/Environment.php +++ b/src/Environment/Environment.php @@ -44,6 +44,7 @@ class Environment /** * Loaded env content + * @var array */ private array $envContent = []; @@ -193,6 +194,9 @@ private function findKeyRow(string $key): ?string return null; } + /** + * @return array + */ private function loadDotenvFile(bool $forceMutableReload = false): array { $baseDir = App::getBaseDir(); diff --git a/src/Environment/Helpers/env.php b/src/Environment/Helpers/env.php index a798720b9..6b8c259af 100644 --- a/src/Environment/Helpers/env.php +++ b/src/Environment/Helpers/env.php @@ -16,8 +16,9 @@ use Quantum\Environment\Environment; /** - * Gets environment variable - * @param $default + * Gets the value of an environment variable + * @param string $var + * @param mixed|null $default * @return mixed * @throws EnvException */ diff --git a/src/Environment/Helpers/server.php b/src/Environment/Helpers/server.php index 58e046f49..652fce035 100644 --- a/src/Environment/Helpers/server.php +++ b/src/Environment/Helpers/server.php @@ -36,6 +36,7 @@ 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 9dd0c6c7b..8c270b4db 100644 --- a/src/Environment/Server.php +++ b/src/Environment/Server.php @@ -22,6 +22,9 @@ */ class Server { + /** + * @var array + */ private array $server; private static ?Server $instance = null; @@ -54,13 +57,16 @@ public function flush(): void $this->server = []; } + /** + * @return array + */ public function all(): array { return $this->server; } /** - * @param $key + * @param string $key * @return mixed|null */ public function get($key) @@ -69,7 +75,7 @@ public function get($key) } /** - * @param $key + * @param string $key */ public function has($key): bool { @@ -77,8 +83,8 @@ public function has($key): bool } /** - * @param $key - * @param $value + * @param string $key + * @param mixed $value */ public function set($key, $value): void { @@ -152,6 +158,9 @@ public function ip(): ?string ?? $this->get('REMOTE_ADDR'); } + /** + * @return array + */ public function getAllHeaders(): array { $data = $this->all(); diff --git a/src/Hasher/Hasher.php b/src/Hasher/Hasher.php index bdb31936b..883c40f17 100644 --- a/src/Hasher/Hasher.php +++ b/src/Hasher/Hasher.php @@ -109,6 +109,7 @@ public function check(string $password, string $hash): bool /** * Gets an info of given hash + * @return array|null */ public function info(string $hash): ?array { diff --git a/src/Hook/HookManager.php b/src/Hook/HookManager.php index 7f2446e69..0a159c1ea 100644 --- a/src/Hook/HookManager.php +++ b/src/Hook/HookManager.php @@ -36,6 +36,7 @@ class HookManager /** * Registered hooks store + * @var array> */ private static array $store = []; @@ -87,6 +88,7 @@ public function on(string $name, callable $function): void /** * Fires the hook + * @param array|null $args * @throws HookException */ public function fire(string $name, ?array $args = null): void @@ -103,6 +105,7 @@ public function fire(string $name, ?array $args = null): void /** * Gets all registered hooks + * @return array> */ public static function getRegistered(): array { @@ -111,9 +114,10 @@ public static function getRegistered(): array /** * Registers new hook + * @return void * @throws HookException */ - protected function register(string $name) + protected function register(string $name): void { if ($this->exists($name)) { throw HookException::hookDuplicateName($name); diff --git a/src/Http/Helpers/http.php b/src/Http/Helpers/http.php index e0a93d4b1..cb6bf96b5 100644 --- a/src/Http/Helpers/http.php +++ b/src/Http/Helpers/http.php @@ -50,6 +50,7 @@ function redirect(string $url, int $code = StatusCode::FOUND): void /** * Redirect with data + * @param array $data * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Http/Request.php b/src/Http/Request.php index 309798b4a..cd10eb0ce 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -21,7 +21,7 @@ /** * Class Request * @package Quantum\Http - * @method static void create(string $method, string $url, array $params = [], array $headers = [], array $file = null) + * @method static void create(string $method, string $url, array $params = [], array $headers = [], array $file = null) * @method static void flush() * @method static string|null getMethod() * @method static void setMethod(string $method) @@ -41,20 +41,20 @@ * @method static bool has(string $key) * @method static mixed get(string $key, string $default = null, bool $raw = false) * @method static void set(string $key, $value) - * @method static array all() + * @method static array all() * @method static void delete(string $key) * @method static bool hasFile(string $key) * @method static mixed getFile(string $key) * @method static bool hasHeader(string $key) * @method static string|null getHeader(string $key) * @method static void setHeader(string $key, $value) - * @method static array allHeaders() + * @method static array allHeaders() * @method static void deleteHeader(string $key) * @method static string|null getSegment(int $number) - * @method static array getAllSegments() + * @method static array getAllSegments() * @method static string|null getCsrfToken() * @method static string|null getAuthorizationBearer() - * @method static array|null getBasicAuthCredentials() + * @method static array|null getBasicAuthCredentials() * @method static bool isAjax() * @method static string|null getReferrer() * @mixin HttpRequest @@ -63,6 +63,7 @@ class Request { /** * @param string $function The function name + * @param array $arguments * @return mixed */ public function __call(string $function, array $arguments) @@ -72,6 +73,7 @@ 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 b70005929..00eb292db 100644 --- a/src/Http/Request/HttpRequest.php +++ b/src/Http/Request/HttpRequest.php @@ -121,6 +121,7 @@ public static function flush(): void /** * Sets the merged request parameters + * @param array $params */ public static function setRequestParams(array $params): void { @@ -135,6 +136,7 @@ public static function setRequestParams(array $params): void /** * Sets the uploaded files array merging handled $_FILES and parsed files + * @param array $files * @throws BaseException * @throws ReflectionException */ diff --git a/src/Http/Response.php b/src/Http/Response.php index 9ef9ef2a6..38bea3c96 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -29,18 +29,18 @@ * @method static int getStatusCode() * @method static string getStatusText() * @method static void redirect(string $url, int $code = null) - * @method static void json(array $data = null, int $code = null) - * @method static void xml(array $data = null, $root = '', int $code = null) + * @method static void json(array $data = null, int $code = null) + * @method static void xml(array $data = null, $root = '', int $code = null) * @method static void html(string $html, int $code = null) * @method static bool has(string $key) * @method static mixed get(string $key, string $default = null) * @method static void set(string $key, $value) - * @method static array all() + * @method static array all() * @method static void delete(string $key) * @method static bool hasHeader(string $key)) * @method static string|null getHeader(string $key) * @method static void setHeader(string $key, string $value) - * @method static array allHeaders() + * @method static array allHeaders() * @method static void deleteHeader(string $key) * @method static void setContentType(string $contentType) * @method static string|null getContentType() @@ -50,6 +50,7 @@ class Response { /** * @param string $function The function name + * @param array $arguments * @return mixed */ public function __call(string $function, array $arguments) @@ -59,6 +60,7 @@ 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/Traits/Request/Body.php b/src/Http/Traits/Request/Body.php index 854f9a1b4..62ae24539 100644 --- a/src/Http/Traits/Request/Body.php +++ b/src/Http/Traits/Request/Body.php @@ -27,6 +27,7 @@ trait Body { /** * Request body + * @var array */ private static array $__request = []; @@ -74,6 +75,7 @@ public static function set(string $key, $value): void /** * Gets all request parameters + * @return array */ public static function all(): array { diff --git a/src/Http/Traits/Request/File.php b/src/Http/Traits/Request/File.php index 8f2df2bc2..f91727eee 100644 --- a/src/Http/Traits/Request/File.php +++ b/src/Http/Traits/Request/File.php @@ -29,6 +29,7 @@ trait File { /** * Files + * @var array */ private static array $__files = []; @@ -73,6 +74,7 @@ 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 76a0b379f..fbf86f953 100644 --- a/src/Http/Traits/Request/Header.php +++ b/src/Http/Traits/Request/Header.php @@ -24,6 +24,7 @@ trait Header { /** * Request headers + * @var array */ private static array $__headers = []; @@ -61,6 +62,7 @@ public static function setHeader(string $key, $value): void /** * Gets all request headers + * @return array */ public static function allHeaders(): array { @@ -95,6 +97,7 @@ public static function getAuthorizationBearer(): ?string /** * Gets Basic Auth Credentials + * @return array|null */ public static function getBasicAuthCredentials(): ?array { @@ -139,6 +142,9 @@ public static function getReferrer(): ?string return self::$server->referrer(); } + /** + * @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 dbed606e5..92c2e35a2 100644 --- a/src/Http/Traits/Request/Internal.php +++ b/src/Http/Traits/Request/Internal.php @@ -31,6 +31,11 @@ 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 @@ -98,7 +103,9 @@ public static function create( /** * Detects the content type - * @param $server + * @param Server $server + * @param array|null $data + * @param array|null $files */ 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 09240b8db..c1adb1d51 100644 --- a/src/Http/Traits/Request/Params.php +++ b/src/Http/Traits/Request/Params.php @@ -36,6 +36,7 @@ trait Params /** * Gets the GET params. + * @return array */ private static function getParams(): array { @@ -48,6 +49,7 @@ private static function getParams(): array /** * Gets the POST params. + * @return array */ private static function postParams(): array { @@ -60,6 +62,7 @@ private static function postParams(): array /** * Parses and returns JSON payload parameters. + * @return array */ private static function jsonPayloadParams(): array { @@ -75,6 +78,7 @@ private static function jsonPayloadParams(): array /** * Parses and returns URL-encoded parameters. + * @return array */ private static function urlEncodedParams(): array { @@ -92,7 +96,7 @@ private static function urlEncodedParams(): array /** * Parses and returns multipart form data parameters. - * @return array[] + * @return array * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Http/Traits/Request/RawInput.php b/src/Http/Traits/Request/RawInput.php index 6f58de097..69be8b120 100644 --- a/src/Http/Traits/Request/RawInput.php +++ b/src/Http/Traits/Request/RawInput.php @@ -33,7 +33,7 @@ trait RawInput { /** * Parses raw input data and returns parsed parameters and files - * @return array|array[] + * @return array * @throws BaseException * @throws ConfigException * @throws DiException @@ -70,6 +70,7 @@ private static function getBoundary(): ?string /** * Splits raw input into multipart blocks + * @return array */ private static function getBlocks(string $boundary, string $rawInput): array { @@ -81,6 +82,8 @@ 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 @@ -127,6 +130,7 @@ private static function processBlocks(array $blocks): array /** * Adds a parsed file to the files collection + * @param array $files */ private static function addFileToCollection(array &$files, string $nameParam, UploadedFile $file): void { @@ -164,6 +168,7 @@ private static function detectBlockType(string $block): string /** * Gets the parsed param + * @return array */ private static function getParsedStream(string $block): array { @@ -174,6 +179,7 @@ private static function getParsedStream(string $block): array /** * Gets the parsed file + * @return array|null * @throws BaseException * @throws ConfigException * @throws DiException @@ -236,6 +242,7 @@ private static function parseFileData(string $block): array /** * Parses a block and extracts normal form parameters + * @return array */ private static function getParsedParameter(string $block): array { @@ -288,7 +295,7 @@ private static function parseHeaders(string $rawHeaders): array /** * Parses array-like parameter names - * @return array|string + * @return array|string */ private static function arrayParam(string $parameter) { diff --git a/src/Http/Traits/Request/Url.php b/src/Http/Traits/Request/Url.php index b5e851a2a..62c962da2 100644 --- a/src/Http/Traits/Request/Url.php +++ b/src/Http/Traits/Request/Url.php @@ -121,6 +121,7 @@ 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 6e723f4f1..b34fe07ac 100644 --- a/src/Http/Traits/Response/Body.php +++ b/src/Http/Traits/Response/Body.php @@ -31,6 +31,7 @@ trait Body { /** * Response + * @var array */ private static array $__response = []; @@ -72,6 +73,7 @@ public static function set(string $key, $value): void /** * Gets all response parameters + * @return array */ public static function all(): array { @@ -90,6 +92,7 @@ public static function delete(string $key): void /** * Prepares the JSON response + * @param array|null $data */ public static function json(?array $data = null, ?int $code = null): void { @@ -106,6 +109,8 @@ public static function json(?array $data = null, ?int $code = null): void /** * Prepares the JSONP response + * @param string $callback + * @param array|null $data */ public static function jsonp(string $callback, ?array $data = null, ?int $code = null): void { @@ -124,6 +129,7 @@ public static function jsonp(string $callback, ?array $data = null, ?int $code = /** * Returns response with function + * @param array $data */ public static function getJsonPData(array $data): string { @@ -132,6 +138,8 @@ public static function getJsonPData(array $data): string /** * Prepares the XML response + * @param array|null $data + * @param string $root */ public static function xml(?array $data = null, $root = '', ?int $code = null): void { @@ -181,6 +189,7 @@ public static function getContent(): string /** * Transforms array to XML + * @param array $arr * @throws Exception */ private static function arrayToXML(array $arr): string @@ -196,6 +205,7 @@ private static function arrayToXML(array $arr): string /** * Compose XML + * @param array $arr */ private static function composeXML(array $arr, SimpleXMLElement &$simpleXML): void { diff --git a/src/Http/Traits/Response/Header.php b/src/Http/Traits/Response/Header.php index ea5f74e03..7f7abd789 100644 --- a/src/Http/Traits/Response/Header.php +++ b/src/Http/Traits/Response/Header.php @@ -27,6 +27,7 @@ trait Header { /** * Response headers + * @var array */ private static array $__headers = []; @@ -56,6 +57,7 @@ public static function setHeader(string $key, string $value): void /** * Get all response headers + * @return array */ public static function allHeaders(): array { diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index c9ab7a808..59e257b64 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -27,7 +27,7 @@ * HttpClient Class * @package Quantum\HttpClient * @uses php-curl-class/php-curl-class - * @method object addGet(string $url, array $data = []) + * @method object addGet(string $url, array $data = []) * @method object addPost(string $url, string $data = '', bool $follow_303_with_post = false) * @method setHeader($key, $value) * @method setHeaders($headers) @@ -67,10 +67,20 @@ class HttpClient */ private $data; + /** + * Request headers section + * @var array + */ private array $requestHeaders = []; + /** + * @var array + */ private array $response = []; + /** + * @var array + */ private array $errors = []; /** @@ -245,6 +255,7 @@ public function getResponseBody() /** * Gets the entire response + * @return array */ public function getResponse(): array { @@ -253,6 +264,7 @@ public function getResponse(): array /** * Returns the errors + * @return array */ public function getErrors(): array { @@ -283,6 +295,7 @@ public function url(): ?string } /** + * @param array $arguments * @throws BaseException * @throws HttpClientException */ @@ -337,6 +350,9 @@ private function handleResponse(Curl $instance): void ]; } + /** + * @return array + */ private function formatHeaders(CaseInsensitiveArray $headers): array { $formatted = []; @@ -358,6 +374,9 @@ private function ensureSingleRequest(): void } } + /** + * @param array $arguments + */ private function interceptCall(string $method, array $arguments): void { switch ($method) { diff --git a/src/Jwt/JwtToken.php b/src/Jwt/JwtToken.php index 5cdaf6b26..608059625 100644 --- a/src/Jwt/JwtToken.php +++ b/src/Jwt/JwtToken.php @@ -40,6 +40,7 @@ class JwtToken extends JWT /** * Payload data + * @var array */ private array $payload = []; @@ -56,6 +57,7 @@ public function __construct(?string $key = null) /** * Sets extra leeway time + * @param int $leeway */ public function setLeeway($leeway): JwtToken { @@ -84,6 +86,7 @@ public function setClaim(string $key, $value): JwtToken /** * Set claims + * @param array $claims */ public function setClaims(array $claims): JwtToken { @@ -96,6 +99,7 @@ public function setClaims(array $claims): JwtToken /** * Sets user data + * @param array $data */ public function setData(array $data): JwtToken { @@ -105,6 +109,7 @@ public function setData(array $data): JwtToken /** * Composes and signs the JWT + * @param array|null $head * @throws JwtException */ public function compose(?string $keyId = null, ?array $head = null): string @@ -136,6 +141,7 @@ public function fetchPayload(): ?object /** * Fetches the user data + * @return array|null */ public function fetchData(): ?array { diff --git a/src/Lang/Factories/LangFactory.php b/src/Lang/Factories/LangFactory.php index 6717319e2..f176b5c67 100644 --- a/src/Lang/Factories/LangFactory.php +++ b/src/Lang/Factories/LangFactory.php @@ -59,6 +59,7 @@ public static function get(): Lang } /** + * @return array{0: bool, 1: array, 2: string} * @throws ConfigException * @throws DiException * @throws ReflectionException @@ -77,6 +78,7 @@ private static function loadLangConfig(): array } /** + * @param array $supported * @throws LangException */ private static function detectLanguage(array $supported, ?string $default): string @@ -102,6 +104,9 @@ private static function detectLanguage(array $supported, ?string $default): stri return $lang; } + /** + * @param array $supported + */ private static function getLangFromQuery(array $supported): ?string { $queryLang = Request::getQueryParam('lang'); @@ -109,6 +114,9 @@ private static function getLangFromQuery(array $supported): ?string return $queryLang && in_array($queryLang, $supported) ? $queryLang : null; } + /** + * @param array $supported + */ private static function getLangFromUrlSegment(array $supported): ?string { $segmentIndex = (int) config()->get('lang.url_segment'); @@ -122,6 +130,9 @@ private static function getLangFromUrlSegment(array $supported): ?string return $segmentLang && in_array($segmentLang, $supported) ? $segmentLang : null; } + /** + * @param array $supported + */ 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 5c5c4ccb3..d61675bd1 100644 --- a/src/Lang/Helpers/lang.php +++ b/src/Lang/Helpers/lang.php @@ -31,7 +31,8 @@ function current_lang(): ?string /** * Gets translation - * @param $params + * @param string $key + * @param array|string|null $params * @throws ConfigException * @throws ReflectionException * @throws DiException @@ -44,7 +45,7 @@ function t(string $key, $params = null): ?string /** * Outputs the translation - * @param $params + * @param array|string|null $params * @throws ConfigException * @throws DiException * @throws LangException diff --git a/src/Lang/Lang.php b/src/Lang/Lang.php index 4f9d3e3f4..bb817e0b6 100644 --- a/src/Lang/Lang.php +++ b/src/Lang/Lang.php @@ -81,7 +81,7 @@ public function load(): void /** * Get translation by key - * @param $params + * @param array|null $params */ public function getTranslation(string $key, $params = null): ?string { diff --git a/src/Lang/Translator.php b/src/Lang/Translator.php index b974653ed..659b85f3f 100644 --- a/src/Lang/Translator.php +++ b/src/Lang/Translator.php @@ -78,6 +78,7 @@ public function loadTranslations(): void /** * Load translations + * @param array $files * @throws BaseException * @throws ConfigException * @throws DiException @@ -96,7 +97,7 @@ private function loadFiles(array $files): void /** * Get translation by key - * @param array|string|null $params + * @param array|string|null $params */ public function get(string $key, $params = null): string { diff --git a/src/Logger/Adapters/DailyAdapter.php b/src/Logger/Adapters/DailyAdapter.php index 654255604..4bb390973 100644 --- a/src/Logger/Adapters/DailyAdapter.php +++ b/src/Logger/Adapters/DailyAdapter.php @@ -34,6 +34,8 @@ class DailyAdapter implements ReportableInterface use LoggerTrait; /** + * DailyAdapter constructor + * @param array $params * @throws BaseException * @throws LoggerException * @throws DiException @@ -48,6 +50,7 @@ public function __construct(array $params) /** * Initialize the adapter for Daily logs + * @param array $params * @throws LoggerException */ protected function initialize(array $params): void diff --git a/src/Logger/Adapters/MessageAdapter.php b/src/Logger/Adapters/MessageAdapter.php index 9060bbf70..15ac4a3f5 100644 --- a/src/Logger/Adapters/MessageAdapter.php +++ b/src/Logger/Adapters/MessageAdapter.php @@ -27,10 +27,10 @@ class MessageAdapter implements ReportableInterface { /** - * @param $message + * @param array|null $context * @throws DebugBarException */ - public function report(string $level, $message, ?array $context = []): void + public function report(string $level, string $message, ?array $context = []): void { $tab = $context['tab'] ?? Debugger::MESSAGES; diff --git a/src/Logger/Adapters/SingleAdapter.php b/src/Logger/Adapters/SingleAdapter.php index 19b2e341e..2c9d669d0 100644 --- a/src/Logger/Adapters/SingleAdapter.php +++ b/src/Logger/Adapters/SingleAdapter.php @@ -40,6 +40,10 @@ class SingleAdapter implements ReportableInterface * @throws ConfigException * @throws ReflectionException */ + /** + * SingleAdapter constructor + * @param array $params + */ public function __construct(array $params) { $this->fs = FileSystemFactory::get(); @@ -47,7 +51,8 @@ public function __construct(array $params) } /** - * Initialize the adapter for Single log file + * Initialize the adapter for Single logs + * @param array $params * @throws LoggerException */ protected function initialize(array $params): void diff --git a/src/Logger/Contracts/ReportableInterface.php b/src/Logger/Contracts/ReportableInterface.php index 6628dc073..699a2f7ce 100644 --- a/src/Logger/Contracts/ReportableInterface.php +++ b/src/Logger/Contracts/ReportableInterface.php @@ -23,9 +23,11 @@ interface ReportableInterface { /** - * Reports the message - * @param mixed $message + * Reports a message + * @param string $message + * @param array|null $context + * @return void */ - public function report(string $level, $message, ?array $context = []); + public function report(string $level, string $message, ?array $context = []): void; } diff --git a/src/Logger/Helpers/logger.php b/src/Logger/Helpers/logger.php index 6bff8a876..5a7d01d45 100644 --- a/src/Logger/Helpers/logger.php +++ b/src/Logger/Helpers/logger.php @@ -31,65 +31,70 @@ function logger(?string $adapter = null): Logger /** * Reports error - * @param $var + * @param string $var + * @param array $context + * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException - * @throws BaseException */ -function error($var, array $context = []): void +function error(string $var, array $context = []): void { LoggerFactory::get()->error($var, $context); } /** * Reports warning - * @param $var + * @param string $var + * @param array $context * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function warning($var, array $context = []): void +function warning(string $var, array $context = []): void { LoggerFactory::get()->warning($var, $context); } /** * Reports notice - * @param $var + * @param string $var + * @param array $context * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function notice($var, array $context = []): void +function notice(string $var, array $context = []): void { LoggerFactory::get()->notice($var, $context); } /** * Reports info - * @param $var + * @param string $var + * @param array $context * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function info($var, array $context = []): void +function info(string $var, array $context = []): void { LoggerFactory::get()->info($var, $context); } /** * Reports debug - * @param $var + * @param string $var + * @param array $context * @throws BaseException * @throws ConfigException * @throws DiException * @throws ReflectionException */ -function debug($var, array $context = []): void +function debug(string $var, array $context = []): void { LoggerFactory::get()->debug($var, $context); } diff --git a/src/Logger/Traits/LoggerTrait.php b/src/Logger/Traits/LoggerTrait.php index a8c683b35..19159edd6 100644 --- a/src/Logger/Traits/LoggerTrait.php +++ b/src/Logger/Traits/LoggerTrait.php @@ -43,16 +43,18 @@ abstract protected function initialize(array $params): void; /** * Reports a log message - * @param $message + * @param string $message + * @param array|null $context */ - public function report(string $level, $message, ?array $context = []): void + public function report(string $level, string $message, ?array $context = []): void { $this->fs->append($this->logFile, $this->formatMessage($level, $message, $context)); } /** * Formats the log message - * @param $message + * @param string|array $message + * @param array|null $context */ protected function formatMessage(string $level, $message, ?array $context = []): string { diff --git a/src/Mailer/Adapters/MailgunAdapter.php b/src/Mailer/Adapters/MailgunAdapter.php index 27b58aa0a..e6c56fdac 100644 --- a/src/Mailer/Adapters/MailgunAdapter.php +++ b/src/Mailer/Adapters/MailgunAdapter.php @@ -38,10 +38,14 @@ class MailgunAdapter implements MailerInterface private string $apiUrl = 'https://api.mailgun.net/v3/'; + /** + * @var array + */ private array $data = []; /** * MailgunAdapter constructor + * @param array $params */ public function __construct(array $params) { diff --git a/src/Mailer/Adapters/MandrillAdapter.php b/src/Mailer/Adapters/MandrillAdapter.php index b608eaad2..c75368c40 100644 --- a/src/Mailer/Adapters/MandrillAdapter.php +++ b/src/Mailer/Adapters/MandrillAdapter.php @@ -36,10 +36,14 @@ class MandrillAdapter implements MailerInterface private string $apiUrl = 'https://mandrillapp.com/api/1.0/messages/send.json'; + /** + * @var array + */ private array $data = []; /** * MandrillAdapter constructor + * @param array $params */ public function __construct(array $params) { diff --git a/src/Mailer/Adapters/SendgridAdapter.php b/src/Mailer/Adapters/SendgridAdapter.php index a2eef4b7b..073d18505 100644 --- a/src/Mailer/Adapters/SendgridAdapter.php +++ b/src/Mailer/Adapters/SendgridAdapter.php @@ -38,10 +38,14 @@ class SendgridAdapter implements MailerInterface private string $apiUrl = 'https://api.sendgrid.com/v3/mail/send'; + /** + * @var array + */ private array $data = []; /** * SendgridAdapter constructor + * @param array $params */ public function __construct(array $params) { diff --git a/src/Mailer/Adapters/SendinblueAdapter.php b/src/Mailer/Adapters/SendinblueAdapter.php index 2a7b24c85..7e7c1da92 100644 --- a/src/Mailer/Adapters/SendinblueAdapter.php +++ b/src/Mailer/Adapters/SendinblueAdapter.php @@ -38,10 +38,14 @@ class SendinblueAdapter implements MailerInterface private string $apiUrl = 'https://api.sendinblue.com/v3/smtp/email'; + /** + * @var array + */ private array $data = []; /** * SendinblueAdapter constructor + * @param array $params */ public function __construct(array $params) { diff --git a/src/Mailer/Adapters/SmtpAdapter.php b/src/Mailer/Adapters/SmtpAdapter.php index 75e2ea182..98648670b 100644 --- a/src/Mailer/Adapters/SmtpAdapter.php +++ b/src/Mailer/Adapters/SmtpAdapter.php @@ -35,6 +35,7 @@ class SmtpAdapter implements MailerInterface /** * SmtpAdapter constructor + * @param array $params */ public function __construct(array $params) { @@ -68,6 +69,7 @@ public function setReplay(string $email, ?string $name = null): SmtpAdapter /** * Gets "Reply-To" addresses + * @return array */ public function getReplays(): array { @@ -76,6 +78,9 @@ public function getReplays(): array /** * Sets "CC" address + * @param string $email + * @param string|null $name + * @return SmtpAdapter */ public function setCC(string $email, ?string $name = null): SmtpAdapter { @@ -89,6 +94,7 @@ public function setCC(string $email, ?string $name = null): SmtpAdapter /** * Gets "CC" addresses + * @return array */ public function getCCs(): array { @@ -97,6 +103,9 @@ public function getCCs(): array /** * Sets "BCC" address + * @param string $email + * @param string|null $name + * @return SmtpAdapter */ public function setBCC(string $email, ?string $name = null): SmtpAdapter { @@ -110,6 +119,7 @@ public function setBCC(string $email, ?string $name = null): SmtpAdapter /** * Get "BCC" addresses + * @return array */ public function getBCCs(): array { @@ -118,6 +128,8 @@ public function getBCCs(): array /** * Sets attachments from the path on the filesystem + * @param string $attachment + * @return SmtpAdapter */ public function setAttachment(string $attachment): SmtpAdapter { @@ -128,6 +140,7 @@ public function setAttachment(string $attachment): SmtpAdapter /** * Gets the attachments + * @return array */ public function getAttachments(): array { @@ -136,6 +149,9 @@ public function getAttachments(): array /** * Sets attachment from the string + * @param string $content + * @param string $filename + * @return SmtpAdapter */ public function setStringAttachment(string $content, string $filename): SmtpAdapter { @@ -149,6 +165,7 @@ public function setStringAttachment(string $content, string $filename): SmtpAdap /** * Gets the string attachments + * @return array */ public function getStringAttachments(): array { @@ -157,6 +174,7 @@ public function getStringAttachments(): array /** * Setups the SMTP + * @param array $params */ private function setupSmtp(array $params): void { @@ -201,6 +219,7 @@ private function prepare(): void /** * Fills the php mailer properties + * @param array $fields */ private function fillProperties(string $method, array $fields = []): void { diff --git a/src/Mailer/Contracts/MailerInterface.php b/src/Mailer/Contracts/MailerInterface.php index 2a8eff63c..b25c0c35e 100644 --- a/src/Mailer/Contracts/MailerInterface.php +++ b/src/Mailer/Contracts/MailerInterface.php @@ -29,6 +29,7 @@ public function setFrom(string $email, ?string $name = null): MailerInterface; /** * Gets the 'From' email and the name + * @return array */ public function getFrom(): array; @@ -39,6 +40,7 @@ public function setAddress(string $email, ?string $name = null): MailerInterface /** * Gets 'To' addresses + * @return array */ public function getAddresses(): array; @@ -64,13 +66,13 @@ public function getTemplate(): ?string; /** * Sets the body - * @param string|array $message + * @param array|string|null $message */ public function setBody($message): MailerInterface; /** * Gets the body - * @return string|array + * @return array|string|null */ public function getBody(); diff --git a/src/Mailer/MailTrap.php b/src/Mailer/MailTrap.php index af49541db..dd275c560 100644 --- a/src/Mailer/MailTrap.php +++ b/src/Mailer/MailTrap.php @@ -141,6 +141,7 @@ public function getParsedDate(): ?string /** * Gets the parsed 'To' addresses + * @return array */ public function getParsedToAddresses(): array { @@ -158,6 +159,7 @@ public function getParsedFromAddress(): ?string /** * Gets the parsed 'CC' addresses + * @return array */ public function getParsedCcAddresses(): array { @@ -167,6 +169,7 @@ public function getParsedCcAddresses(): array /** * Gets the parsed 'BCC' addresses + * @return array */ public function getParsedBccAddresses(): array { @@ -176,6 +179,7 @@ public function getParsedBccAddresses(): array /** * Gets the 'Reply To' addresses + * @return array */ public function getParsedReplyToAddresses(): array { @@ -213,6 +217,7 @@ 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 4bbfcee5a..4cf7ddfe0 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -24,15 +24,15 @@ * Class Mailer * @package Quantum\Mailer * @method MailerInterface setFrom(string $email, ?string $name = null) - * @method array getFrom() + * @method array getFrom() * @method MailerInterface setAddress(string $email, ?string $name = null) - * @method array getAddresses() + * @method array getAddresses() * @method MailerInterface setSubject(?string $subject) * @method string|null getSubject() * @method MailerInterface setTemplate(string $templatePath) * @method string|null getTemplate() * @method MailerInterface setBody($message) - * @method string|array getBody() + * @method array|string getBody() * @method bool send() */ class Mailer @@ -75,6 +75,7 @@ public function getAdapter(): MailerInterface } /** + * @param array $arguments * @return mixed * @throws BaseException */ diff --git a/src/Mailer/Traits/MailerTrait.php b/src/Mailer/Traits/MailerTrait.php index f37641d62..0f1683e5d 100644 --- a/src/Mailer/Traits/MailerTrait.php +++ b/src/Mailer/Traits/MailerTrait.php @@ -33,11 +33,13 @@ trait MailerTrait { /** * From address and name + * @var array */ private array $from = []; /** * To addresses + * @var array */ private array $addresses = []; @@ -48,7 +50,7 @@ trait MailerTrait /** * Email body - * @var string|array|null + * @var array|string|null */ private $message; @@ -65,26 +67,31 @@ trait MailerTrait /** * Reply To addresses + * @var array */ protected array $replyToAddresses = []; /** * CC addresses + * @var array */ protected array $ccAddresses = []; /** * BCC addresses + * @var array */ protected array $bccAddresses = []; /** * Email attachments + * @var array */ protected array $attachments = []; /** * Email attachments created from string + * @var array */ protected array $stringAttachments = []; @@ -100,6 +107,7 @@ public function setFrom(string $email, ?string $name = null): MailerInterface /** * Gets 'From' email and the "name" + * @return array */ public function getFrom(): array { @@ -121,6 +129,7 @@ public function setAddress(string $email, ?string $name = null): MailerInterface /** * Gets 'To' addresses + * @return array */ public function getAddresses(): array { @@ -164,7 +173,7 @@ public function getTemplate(): ?string /** * Sets the body - * @param string|array $message + * @param array|string|null $message */ public function setBody($message): MailerInterface { @@ -174,7 +183,7 @@ public function setBody($message): MailerInterface /** * Gets the body - * @return array|string|null + * @return array|string|null */ public function getBody() { @@ -196,7 +205,7 @@ public function send(): bool $this->resetFields(); if ($this->name !== 'SMTP' && !$sent) { - warning($this->httpClient->getErrors(), ['tab' => Debugger::MAILS]); + warning(implode(', ', $this->httpClient->getErrors()), ['tab' => Debugger::MAILS]); } return $sent; diff --git a/src/Middleware/MiddlewareManager.php b/src/Middleware/MiddlewareManager.php index e6e4251ab..201306794 100644 --- a/src/Middleware/MiddlewareManager.php +++ b/src/Middleware/MiddlewareManager.php @@ -29,6 +29,7 @@ class MiddlewareManager { /** * Middlewares queue + * @var array */ private array $middlewares = []; @@ -41,12 +42,13 @@ public function __construct(MatchedRoute $matchedRoute) { $route = $matchedRoute->getRoute(); - $this->middlewares = array_values($route->getMiddlewares()); + $this->middlewares = array_values($route->getMiddlewares() ?? []); $this->module = $route->getModule(); } /** * Apply Middlewares + * @return array{0: Request, 1: Response} * @throws MiddlewareException */ public function applyMiddlewares(Request $request, Response $response): array diff --git a/src/Migration/MigrationManager.php b/src/Migration/MigrationManager.php index ed4939660..e316dc015 100644 --- a/src/Migration/MigrationManager.php +++ b/src/Migration/MigrationManager.php @@ -56,6 +56,10 @@ class MigrationManager */ public const DRIVERS = ['mysql', 'pgsql', 'sqlite']; + /** + * Migrations + * @var array + */ private array $migrations = []; private TableFactory $tableFactory; @@ -260,6 +264,7 @@ private function prepareDownMigrations(?int $step = null): void /** * Gets migration files + * @return array */ private function getMigrationFiles(): array { @@ -279,6 +284,7 @@ private function getMigrationFiles(): array /** * Gets migrated entries from migrations table + * @return array * @throws DatabaseException */ private function getMigratedEntries(): array @@ -288,6 +294,7 @@ private function getMigratedEntries(): array /** * Adds migrated entries to migrations table + * @param array $entries * @throws DatabaseException */ private function addMigratedEntries(array $entries): void @@ -299,6 +306,7 @@ private function addMigratedEntries(array $entries): void /** * Removes migrated entries from migrations table + * @param array $entries * @throws DatabaseException */ private function removeMigratedEntries(array $entries): void diff --git a/src/Migration/QtMigration.php b/src/Migration/QtMigration.php index 5cc6f1c56..5f1e75640 100644 --- a/src/Migration/QtMigration.php +++ b/src/Migration/QtMigration.php @@ -26,11 +26,13 @@ abstract class QtMigration { /** * Upgrades with the specified migration class + * @return void */ - abstract public function up(?TableFactory $tableFactory); + abstract public function up(?TableFactory $tableFactory): void; /** * Downgrades with the specified migration class + * @return void */ - abstract public function down(?TableFactory $tableFactory); + abstract public function down(?TableFactory $tableFactory): void; } diff --git a/src/Model/DbModel.php b/src/Model/DbModel.php index 69dd65ccf..41df4db71 100644 --- a/src/Model/DbModel.php +++ b/src/Model/DbModel.php @@ -80,6 +80,9 @@ public function getOrmInstance(): DbalInterface return $this->ormInstance; } + /** + * @return array + */ public function relations(): array { return []; @@ -121,6 +124,7 @@ public function first(): ?DbModel /** * Fetch multiple results + * @return ModelCollection * @throws BaseException */ public function get(): ModelCollection @@ -130,7 +134,9 @@ public function get(): ModelCollection $this->getOrmInstance()->get() ); - return new ModelCollection($models); + /** @var ModelCollection $collection */ + $collection = new ModelCollection($models); + return $collection; } /** @@ -188,6 +194,7 @@ public function delete(): bool } /** + * @param array $data * @return $this */ public function hydrateFromOrm(array $data): self @@ -197,6 +204,7 @@ public function hydrateFromOrm(array $data): self } /** + * @param array $args * @return mixed * @throws ModelException */ diff --git a/src/Model/Factories/ModelFactory.php b/src/Model/Factories/ModelFactory.php index 8e259c595..1924fab5b 100644 --- a/src/Model/Factories/ModelFactory.php +++ b/src/Model/Factories/ModelFactory.php @@ -61,6 +61,8 @@ public static function get(string $modelClass): Model /** * Creates anonymous dynamic model + * @param array $foreignKeys + * @param array $hidden */ public static function createDynamicModel( string $table, @@ -84,6 +86,10 @@ public static function createDynamicModel( return $model; } + /** + * @param array $foreignKeys + * @param array $hidden + */ protected static function createOrmInstance( string $table, string $modelName, diff --git a/src/Model/Helpers/model.php b/src/Model/Helpers/model.php index 3af5a4498..9341f90cb 100644 --- a/src/Model/Helpers/model.php +++ b/src/Model/Helpers/model.php @@ -32,6 +32,8 @@ function model(string $modelClass): Model /** * Creates anonymous dynamic model + * @param array $foreignKeys + * @param array $hidden */ function dynamicModel( string $table, diff --git a/src/Model/Model.php b/src/Model/Model.php index 24f6df02a..59dd93177 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -26,22 +26,25 @@ 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 $value + * @param mixed $value * @return $this|mixed|null */ public function prop(string $key, $value = null) @@ -56,6 +59,7 @@ public function prop(string $key, $value = null) /** * Fill object properties + * @param array $props * @return $this * @throws ModelException */ @@ -74,6 +78,7 @@ public function fill(array $props): self /** * Converts to array + * @return array */ public function asArray(): array { @@ -96,7 +101,8 @@ public function isEmpty(): bool } /** - * @return $this|mixed|null + * @param string $key + * @return mixed */ public function __get(string $key) { @@ -104,13 +110,18 @@ public function __get(string $key) } /** - * @param $value + * @param string $key + * @param mixed $value */ 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]); diff --git a/src/Model/ModelCollection.php b/src/Model/ModelCollection.php index 2bdb38b5f..de755e9fd 100644 --- a/src/Model/ModelCollection.php +++ b/src/Model/ModelCollection.php @@ -25,19 +25,26 @@ /** * Class ModelCollection * @package Quantum\Model + * @template TKey of array-key + * @template TValue of Model + * @implements IteratorAggregate */ class ModelCollection implements Countable, IteratorAggregate { /** - * @var Model[] + * @var array */ private array $models = []; + /** + * @var iterable + */ private iterable $originalModels; private bool $modelsProcessed = false; /** + * @param iterable $models * @throws BaseException */ public function __construct(iterable $models = []) @@ -51,7 +58,8 @@ public function __construct(iterable $models = []) /** * Add a model to the collection - * @param Model $model + * @param TValue $model + * @return $this * @throws BaseException */ public function add(Model $model): self @@ -71,7 +79,8 @@ public function add(Model $model): self /** * Remove a model from the collection - * @param Model $model + * @param TValue $model + * @return $this * @throws BaseException */ public function remove(Model $model): self @@ -180,7 +189,7 @@ private function processModels(): void /** * Validate that an item is a Model instance - * @param $model + * @param mixed $model * @throws BaseException */ private function validateModel($model): void diff --git a/src/Model/Traits/HasTimestamps.php b/src/Model/Traits/HasTimestamps.php index f178ed74f..4dc9e176c 100644 --- a/src/Model/Traits/HasTimestamps.php +++ b/src/Model/Traits/HasTimestamps.php @@ -19,7 +19,7 @@ /** * Trait HasTimestamps * - * @property array $attributes + * @property array $attributes * @property string $idColumn */ trait HasTimestamps diff --git a/src/Module/ModuleLoader.php b/src/Module/ModuleLoader.php index 397cba4b6..72be6b718 100644 --- a/src/Module/ModuleLoader.php +++ b/src/Module/ModuleLoader.php @@ -34,8 +34,14 @@ */ class ModuleLoader { + /** + * @var array> + */ private static array $moduleDependencies = []; + /** + * @var array> + */ private static array $moduleConfigs = []; /** @var array */ @@ -67,6 +73,7 @@ public static function getInstance(): ModuleLoader } /** + * @return array * @throws ModuleException * @throws RouteException */ @@ -115,6 +122,7 @@ private function getModuleRouteDefinitions(string $module): Closure } /** + * @return array * @throws ModuleException */ public function loadModulesDependencies(): array @@ -132,6 +140,9 @@ public function loadModulesDependencies(): array return $modulesDependencies; } + /** + * @return array + */ public function getModuleDependencies(string $module): array { if (!isset(self::$moduleDependencies[$module])) { @@ -164,6 +175,7 @@ private function loadModuleConfig(): void } /** + * @return array> * @throws ModuleException */ public function getModuleConfigs(): array @@ -175,6 +187,9 @@ public function getModuleConfigs(): array return self::$moduleConfigs; } + /** + * @param array $options + */ private function isModuleEnabled(array $options): bool { return (bool) ($options['enabled'] ?? false); diff --git a/src/Module/ModuleManager.php b/src/Module/ModuleManager.php index 8e5092c4f..2c002a8b8 100644 --- a/src/Module/ModuleManager.php +++ b/src/Module/ModuleManager.php @@ -124,6 +124,7 @@ public function writeContents(): void } /** + * @return array * @throws Exception */ private function copyDirectoryWithTemplates(string $src, string $dst): array @@ -132,6 +133,7 @@ private function copyDirectoryWithTemplates(string $src, string $dst): array } /** + * @return array * @throws Exception */ private function copyAssets(string $src, string $dst): array @@ -140,6 +142,8 @@ private function copyAssets(string $src, string $dst): array } /** + * @param array $copiedFiles + * @return array * @throws Exception */ private function copyDirectory(string $src, string $dst, bool $processTemplates, array $copiedFiles = []): array @@ -191,6 +195,9 @@ private function replacePlaceholders(string $content): string return str_replace(array_keys($placeholders), array_values($placeholders), $content); } + /** + * @return array + */ private function getModuleOptions(string $module): array { return [ @@ -200,6 +207,7 @@ private function getModuleOptions(string $module): array } /** + * @param array> $moduleConfigs * @throws ExceptionInterface */ private function updateModuleConfigFile(array $moduleConfigs): void @@ -210,6 +218,9 @@ private function updateModuleConfigFile(array $moduleConfigs): void ); } + /** + * @param array $copiedFiles + */ 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 100816e48..38f5b411e 100644 --- a/src/Paginator/Adapters/ArrayPaginator.php +++ b/src/Paginator/Adapters/ArrayPaginator.php @@ -27,8 +27,14 @@ class ArrayPaginator implements PaginatorInterface { use PaginatorTrait; + /** + * @var array + */ private array $items; + /** + * @param array $items + */ public function __construct(array $items, int $perPage, int $page = 1) { $this->initialize($perPage, $page); @@ -39,6 +45,7 @@ public function __construct(array $items, int $perPage, int $page = 1) /** * @inheritDoc + * @return array */ public function data(): array { diff --git a/src/Paginator/Adapters/ModelPaginator.php b/src/Paginator/Adapters/ModelPaginator.php index 0491d4c3b..59bf30e88 100644 --- a/src/Paginator/Adapters/ModelPaginator.php +++ b/src/Paginator/Adapters/ModelPaginator.php @@ -46,6 +46,7 @@ public function __construct(DbModel $model, int $perPage, int $page = 1) /** * @inheritDoc + * @return ModelCollection * @throws BaseException */ public function data(): ModelCollection @@ -59,7 +60,9 @@ public function data(): ModelCollection $result = array_map(fn ($item): ?DbModel => wrapToModel($item->getOrmInstance(), $this->modelClass), iterator_to_array($result)); } - return new ModelCollection($result); + /** @var ModelCollection $collection */ + $collection = new ModelCollection($result); + return $collection; } /** diff --git a/src/Paginator/Contracts/PaginatorInterface.php b/src/Paginator/Contracts/PaginatorInterface.php index b2a92af69..7a7fd696f 100644 --- a/src/Paginator/Contracts/PaginatorInterface.php +++ b/src/Paginator/Contracts/PaginatorInterface.php @@ -97,6 +97,7 @@ public function total(): int; /** * Get all page links + * @return array */ public function links(bool $withBaseUrl = false): array; diff --git a/src/Paginator/Exceptions/PaginatorException.php b/src/Paginator/Exceptions/PaginatorException.php index 272506f4e..1c071baea 100644 --- a/src/Paginator/Exceptions/PaginatorException.php +++ b/src/Paginator/Exceptions/PaginatorException.php @@ -26,7 +26,7 @@ class PaginatorException extends BaseException { /** - * @param $missingParam + * @param string $missingParam */ public static function missingRequiredParams(string $type, $missingParam): self { diff --git a/src/Paginator/Factories/PaginatorFactory.php b/src/Paginator/Factories/PaginatorFactory.php index a50ce823d..cc8005c54 100644 --- a/src/Paginator/Factories/PaginatorFactory.php +++ b/src/Paginator/Factories/PaginatorFactory.php @@ -54,6 +54,7 @@ class PaginatorFactory /** * Creates a new paginator instance using the selected adapter type. + * @param array $params * @throws BaseException * @throws PaginatorException */ @@ -76,6 +77,8 @@ public static function create(string $type, array $params): Paginator /** * Validates that all required parameters are present. + * @param string $type + * @param array $params * @throws PaginatorException */ private static function validateRequiredParams(string $type, array $params): void @@ -89,6 +92,8 @@ private static function validateRequiredParams(string $type, array $params): voi /** * Builds the list of arguments in the correct order for adapter instantiation. + * @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 8fe8f521f..ceb3b172e 100644 --- a/src/Paginator/Paginator.php +++ b/src/Paginator/Paginator.php @@ -37,7 +37,7 @@ * @method string|null lastPageLink(bool $withBaseUrl = false) * @method int perPage() * @method int total() - * @method array links(bool $withBaseUrl = false) + * @method list links(bool $withBaseUrl = false) * @method string|null getPagination(bool $withBaseUrl = false, ?int $pageItemsCount = null) */ class Paginator @@ -68,6 +68,7 @@ public function getAdapter(): PaginatorInterface } /** + * @param array $arguments * @return mixed * @throws BaseException */ diff --git a/src/Paginator/Traits/PaginatorTrait.php b/src/Paginator/Traits/PaginatorTrait.php index 9337ca310..f3264f745 100644 --- a/src/Paginator/Traits/PaginatorTrait.php +++ b/src/Paginator/Traits/PaginatorTrait.php @@ -153,6 +153,7 @@ public function perPage(): int /** * Get all page links + * @return array */ public function links(bool $withBaseUrl = false): array { @@ -274,6 +275,7 @@ protected function getPreviousPageItem(?string $previousPageLink): string /** * Get items links HTML + * @param array $links */ protected function getItemsLinks(int $startPage, int $endPage, int $currentPage, array $links): string { @@ -289,6 +291,7 @@ protected function getItemsLinks(int $startPage, int $endPage, int $currentPage, /** * Calculate start and end pages + * @return array{0: int, 1: int} */ protected function calculateStartEndPages(int $currentPage, int $totalPages, int $pageItemsCount): array { @@ -317,6 +320,7 @@ protected function addFirstPageLink(int $startPage): string /** * Add last page link HTML + * @param array $links */ protected function addLastPageLink(int $endPage, int $totalPages, array $links): string { diff --git a/src/Renderer/Adapters/HtmlAdapter.php b/src/Renderer/Adapters/HtmlAdapter.php index 2d3ec00e8..eede5c468 100644 --- a/src/Renderer/Adapters/HtmlAdapter.php +++ b/src/Renderer/Adapters/HtmlAdapter.php @@ -33,9 +33,13 @@ class HtmlAdapter implements TemplateRendererInterface { protected FileSystem $fs; + /** + * @var array|null + */ protected ?array $configs; /** + * @param array|null $configs * @throws BaseException * @throws DiException * @throws ReflectionException @@ -50,6 +54,7 @@ public function __construct(?array $configs = []) /** * Renders the view + * @param array $params * @throws BaseException|ReflectionException */ public function render(string $view, array $params = []): string diff --git a/src/Renderer/Adapters/TwigAdapter.php b/src/Renderer/Adapters/TwigAdapter.php index 305641ace..a792c4d46 100644 --- a/src/Renderer/Adapters/TwigAdapter.php +++ b/src/Renderer/Adapters/TwigAdapter.php @@ -39,9 +39,13 @@ class TwigAdapter implements TemplateRendererInterface { protected FileSystem $fs; + /** + * @var array|null + */ protected ?array $configs; /** + * @param array|null $configs * @throws BaseException * @throws DiException * @throws ReflectionException @@ -56,6 +60,7 @@ public function __construct(?array $configs = []) /** * Renders the view + * @param array $params * @throws DiException|LoaderError|ReflectionException|RendererException|RuntimeError|SyntaxError */ public function render(string $view, array $params = []): string diff --git a/src/Renderer/Contracts/TemplateRendererInterface.php b/src/Renderer/Contracts/TemplateRendererInterface.php index d65208dc6..7ba97fe7e 100644 --- a/src/Renderer/Contracts/TemplateRendererInterface.php +++ b/src/Renderer/Contracts/TemplateRendererInterface.php @@ -24,6 +24,7 @@ interface TemplateRendererInterface { /** * Renders the template + * @param array $params */ public function render(string $view, array $params = []): string; } diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 46f65672b..09f49fef2 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -23,7 +23,7 @@ /** * Class Renderer * @package Quantum\Renderer - * @method string render(string $view, array $params = []) + * @method string render(string $view, array $params = []) */ class Renderer { @@ -50,6 +50,7 @@ public function getAdapter(): TemplateRendererInterface } /** + * @param array $arguments * @return mixed * @throws BaseException */ diff --git a/src/Router/Helpers/router.php b/src/Router/Helpers/router.php index 698374d6a..1cfebb4b0 100644 --- a/src/Router/Helpers/router.php +++ b/src/Router/Helpers/router.php @@ -21,6 +21,7 @@ /** * Gets current route middlewares + * @return array|null * @throws DiException|ReflectionException */ function current_middlewares(): ?array @@ -33,6 +34,7 @@ function current_middlewares(): ?array /** * Gets current route module + * @return string|null * @throws DiException|ReflectionException */ function current_module(): ?string @@ -45,6 +47,7 @@ function current_module(): ?string /** * Gets current route controller + * @return string|null * @throws DiException|ReflectionException */ function current_controller(): ?string @@ -57,6 +60,7 @@ function current_controller(): ?string /** * Gets current route action + * @return string|null * @throws DiException|ReflectionException */ function current_action(): ?string @@ -69,6 +73,7 @@ function current_action(): ?string /** * Gets current route callback + * @return Closure|null * @throws DiException|ReflectionException */ function route_callback(): ?Closure @@ -81,6 +86,7 @@ function route_callback(): ?Closure /** * Gets current route DSL pattern + * @return string|null * @throws DiException|ReflectionException */ function current_route(): ?string @@ -93,6 +99,7 @@ function current_route(): ?string /** * Gets current route complied pattern + * @return string * @throws DiException|ReflectionException */ function route_pattern(): string @@ -104,7 +111,8 @@ function route_pattern(): string } /** - * Gets current route parameters + * Gets current route params + * @return array * @throws DiException|ReflectionException */ function route_params(): array @@ -117,6 +125,7 @@ function route_params(): array /** * Gets route parameter by name + * @param string $name * @return mixed|null * @throws DiException|ReflectionException */ @@ -128,6 +137,7 @@ function route_param(string $name) /** * Gets current route method + * @return string * @throws DiException|ReflectionException */ function route_method(): string @@ -138,6 +148,7 @@ function route_method(): string /** * Gets the current route uri + * @return string|null * @throws DiException|ReflectionException */ function route_uri(): ?string @@ -148,6 +159,7 @@ function route_uri(): ?string /** * Gets the current route cache settings + * @return array|null * @throws DiException|ReflectionException */ function route_cache_settings(): ?array diff --git a/src/Router/MatchedRoute.php b/src/Router/MatchedRoute.php index e6754278d..35c1a47c2 100644 --- a/src/Router/MatchedRoute.php +++ b/src/Router/MatchedRoute.php @@ -25,8 +25,14 @@ final class MatchedRoute { private Route $route; + /** + * @var array + */ private array $params; + /** + * @param array $params + */ public function __construct(Route $route, array $params) { $this->route = $route; @@ -42,7 +48,8 @@ public function getRoute(): Route } /** - * Return parameters extracted from the URI at match time. + * Return the route's extracted parameters. + * @return array */ public function getParams(): array { diff --git a/src/Router/PatternCompiler.php b/src/Router/PatternCompiler.php index 364cd1bca..5404429da 100644 --- a/src/Router/PatternCompiler.php +++ b/src/Router/PatternCompiler.php @@ -33,10 +33,16 @@ 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 @@ -50,13 +56,15 @@ public function match(Route $route, string $uri): bool return false; } - $this->params = $this->extractParams($segmentParams, $matches); + $this->params = $this->extractParams($matches, $segmentParams); return true; } /** * Compile route pattern into regex and param metadata. + * @param Route $route + * @return array{0: string, 1: list>} * @throws RouteException */ public function compile(Route $route): array @@ -95,7 +103,8 @@ public function compile(Route $route): array } /** - * Return parameters extracted from the last successful match. + * Return the extracted parameters from the last match operation. + * @return array */ public function getParams(): array { @@ -104,15 +113,21 @@ public function getParams(): array /** * Build the final named parameter map from regex matches and param metadata. + * + * @param array $matches PCRE match array from preg_match (named captures) + * @param array $segmentParams + * @return array */ - protected function extractParams(array $params, array $matches): array + protected function extractParams(array $matches, array $segmentParams): array { - $values = array_diff($matches, ['', '/']); $result = []; - foreach ($params as $param) { - if ($param['name'] !== null) { - $result[$param['name']] = $values[$param['name']] ?? null; + foreach ($segmentParams as $param) { + $name = $param['name']; + if (!isset($matches[$name]) || $matches[$name] === '') { + $result[$name] = null; + } else { + $result[$name] = $matches[$name]; } } @@ -121,6 +136,10 @@ 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 @@ -136,6 +155,8 @@ protected function getSegmentParam(string $segment, int $index, int $lastIndex): /** * Generate the regex pattern and name for a matched parameter segment. + * @param array $match + * @return array * @throws RouteException */ protected function getParamPattern(array $match, string $expr, int $index, int $lastIndex): array @@ -168,6 +189,7 @@ protected function getParamPattern(array $match, string $expr, int $index, int $ /** * Resolve and validate the parameter name from a segment match. + * @param array $match * @throws RouteException */ protected function getParamName(array $match, int $index): string @@ -187,9 +209,10 @@ protected function getParamName(array $match, int $index): string /** * Ensure the parameter name is unique within the route pattern. + * @param array|list> $params * @throws RouteException */ - protected function checkParamName(array $params, string $name): void + protected function checkParamName($params, string $name): void { foreach ($params as $param) { if ($param['name'] === $name) { @@ -200,6 +223,7 @@ protected function checkParamName(array $params, string $name): void /** * Adjust the accumulated route regex before appending the last segment pattern. + * @param array $segmentParam */ protected function normalizePattern( string $routePattern, diff --git a/src/Router/Route.php b/src/Router/Route.php index 8910ea180..7be833f12 100644 --- a/src/Router/Route.php +++ b/src/Router/Route.php @@ -26,6 +26,9 @@ */ final class Route { + /** + * @var array + */ protected array $methods; protected string $pattern; @@ -36,21 +39,47 @@ final class Route protected ?Closure $closure; + /** + * @var string|null + */ protected ?string $name = null; + /** + * @var string|null + */ protected ?string $module = null; - protected array $middlewares = []; + /** + * @var array|null + */ + protected ?array $middlewares = null; + /** + * @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( @@ -107,6 +136,7 @@ public function cache(bool $enabled, ?int $ttl = null): self /** * Return caching configuration for this route. + * @return array|null */ public function getCache(): ?array { @@ -125,6 +155,7 @@ public function setCompiledPattern(string $pattern): self /** * Return compiled regex pattern if set. + * @return string|null */ public function getCompiledPattern(): ?string { @@ -143,6 +174,7 @@ public function group(?string $group): self /** * Return group name. + * @return string|null */ public function getGroup(): ?string { @@ -159,6 +191,10 @@ public function prefix(?string $prefix): self return $this; } + /** + * Return URL prefix. + * @return string|null + */ public function getPrefix(): ?string { return $this->prefix; @@ -176,6 +212,7 @@ 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 @@ -213,6 +250,7 @@ public function allowsMethod(string $method): bool /** * Return allowed HTTP methods. + * @return array */ public function getMethods(): array { @@ -253,6 +291,7 @@ public function getAction(): ?string /** * Return route name. + * @return string|null */ public function getName(): ?string { @@ -261,8 +300,9 @@ public function getName(): ?string /** * Return middleware list. + * @return array|null */ - public function getMiddlewares(): array + public function getMiddlewares(): ?array { return $this->middlewares; } @@ -277,6 +317,7 @@ 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 3cddaeea4..5f6189127 100644 --- a/src/Router/RouteBuilder.php +++ b/src/Router/RouteBuilder.php @@ -40,8 +40,14 @@ final class RouteBuilder private ?string $currentGroupName = null; + /** + * @var array + */ private array $groupRoutes = []; + /** + * @var array + */ private array $groupMiddlewares = []; /** @@ -58,6 +64,8 @@ public function __construct() /** * Execute DSL and return final RouteCollection + * @param array $moduleRouteClosures + * @param array> $moduleConfigs * @throws RouteException */ public function build(array $moduleRouteClosures, array $moduleConfigs): RouteCollection @@ -84,7 +92,7 @@ public function build(array $moduleRouteClosures, array $moduleConfigs): RouteCo /** * Define a route with multiple HTTP methods. - * @param $handler + * @param callable|string $handler * @param string|null $action * @throws RouteException */ @@ -100,7 +108,7 @@ public function add(string $path, string $methods, $handler, string $action = nu /** * Define a GET route. - * @param $handler + * @param callable|string $handler * @param string|null $action * @throws RouteException */ @@ -111,7 +119,7 @@ public function get(string $path, $handler, string $action = null): self /** * Define a POST route. - * @param $handler + * @param callable|string $handler * @param string|null $action * @throws RouteException */ @@ -122,7 +130,7 @@ public function post(string $path, $handler, string $action = null): self /** * Define a PUT route. - * @param $handler + * @param callable|string $handler * @param string|null $action * @throws RouteException */ @@ -133,7 +141,7 @@ public function put(string $path, $handler, string $action = null): self /** * Define a DELETE route. - * @param $handler + * @param callable|string $handler * @param string|null $action * @throws RouteException */ @@ -178,6 +186,7 @@ public function group(string $name, callable $callback): self /** * Apply middlewares to the current route or group. + * @param array $middlewares * @return $this * @throws RouteException */ @@ -269,7 +278,8 @@ public function cacheable(bool $enabled, ?int $ttl = null): self /** * Create and register a Route instance. - * @param $handler + * @param array $methods + * @param callable|string $handler * @throws RouteException */ private function addRoute( diff --git a/src/Router/RouteDispatcher.php b/src/Router/RouteDispatcher.php index 41715fc6a..0146a7f5a 100644 --- a/src/Router/RouteDispatcher.php +++ b/src/Router/RouteDispatcher.php @@ -64,6 +64,7 @@ public function dispatch(MatchedRoute $matched, Request $request): void /** * Resolve controller callable from the route definition. + * @return array{0: object, 1: string} * @throws RouteException */ private function resolveControllerCallable(Route $route): array @@ -86,6 +87,7 @@ private function resolveControllerCallable(Route $route): array /** * Invoke a callable with parameters resolved via DI autowiring. + * @param array $params * @throws DiException|ReflectionException */ private function invoke(callable $callable, array $params): void @@ -98,6 +100,7 @@ private function invoke(callable $callable, array $params): void /** * Invoke a controller lifecycle hook if it exists. + * @param array $params * @throws DiException|ReflectionException */ private function callHook(object $controller, string $hook, array $params): void diff --git a/src/Service/Factories/ServiceFactory.php b/src/Service/Factories/ServiceFactory.php index 1fd499589..8e78578da 100644 --- a/src/Service/Factories/ServiceFactory.php +++ b/src/Service/Factories/ServiceFactory.php @@ -31,6 +31,7 @@ class ServiceFactory * Creates and initiates the service once * @template T of QtService * @param class-string $serviceClass + * @param array $args * @return T * @throws BaseException * @throws DiException @@ -52,6 +53,7 @@ public static function get(string $serviceClass, array $args = []): QtService * Creates new service instance * @template T of QtService * @param class-string $serviceClass + * @param array $args * @return T * @throws BaseException * @throws DiException diff --git a/src/Service/QtService.php b/src/Service/QtService.php index f588a25b9..81f7a4f2f 100644 --- a/src/Service/QtService.php +++ b/src/Service/QtService.php @@ -27,6 +27,8 @@ class QtService { /** * Handles the missing methods of the service + * @param array $arguments + * @return never * @throws BaseException */ public function __call(string $method, array $arguments) diff --git a/src/Session/Adapters/Database/DatabaseSessionAdapter.php b/src/Session/Adapters/Database/DatabaseSessionAdapter.php index 6b434268e..cc268df08 100644 --- a/src/Session/Adapters/Database/DatabaseSessionAdapter.php +++ b/src/Session/Adapters/Database/DatabaseSessionAdapter.php @@ -37,15 +37,18 @@ class DatabaseSessionAdapter implements SessionStorageInterface /** * Session params + * @var array|null */ private static ?array $params = []; /** * Session storage + * @var array */ private static array $storage = []; /** + * @param array|null $params * @throws SessionException|ModelException */ public function __construct(?array $params = null) @@ -54,6 +57,7 @@ public function __construct(?array $params = null) } /** + * @param array|null $params * @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 d948c294d..acb8e3ecd 100644 --- a/src/Session/Adapters/Native/NativeSessionAdapter.php +++ b/src/Session/Adapters/Native/NativeSessionAdapter.php @@ -35,15 +35,18 @@ class NativeSessionAdapter implements SessionStorageInterface /** * Session params + * @var array|null */ private static ?array $params = []; /** * Session storage + * @var array */ private static array $storage = []; /** + * @param array|null $params * @throws SessionException */ public function __construct(?array $params = null) @@ -52,6 +55,7 @@ public function __construct(?array $params = null) } /** + * @param array|null $params * @throws SessionException */ protected function initializeSession(?array $params = null): void diff --git a/src/Session/Contracts/SessionStorageInterface.php b/src/Session/Contracts/SessionStorageInterface.php index 79e156716..29dfea85b 100644 --- a/src/Session/Contracts/SessionStorageInterface.php +++ b/src/Session/Contracts/SessionStorageInterface.php @@ -31,8 +31,9 @@ interface SessionStorageInterface extends StorageInterface public function getFlash(string $key); /** - * Sets flash value by given key + * Sets the flash message * @param mixed $value + * @return void */ public function setFlash(string $key, $value); diff --git a/src/Session/Session.php b/src/Session/Session.php index 6c407b339..ee4727d91 100644 --- a/src/Session/Session.php +++ b/src/Session/Session.php @@ -23,7 +23,7 @@ /** * Class Session * @package Quantum\Session - * @method array all() + * @method array all() * @method bool has(string $key) * @method mixed|null get(string $key) * @method void set(string $key, $value) @@ -59,6 +59,7 @@ public function getAdapter(): SessionStorageInterface } /** + * @param array $arguments * @return mixed * @throws BaseException */ diff --git a/src/Session/Traits/SessionTrait.php b/src/Session/Traits/SessionTrait.php index 3fc5e125c..3fa3894c4 100644 --- a/src/Session/Traits/SessionTrait.php +++ b/src/Session/Traits/SessionTrait.php @@ -27,6 +27,7 @@ trait SessionTrait { /** * @inheritDoc + * @return array */ public function all(): array { @@ -80,6 +81,7 @@ public function getFlash(string $key) /** * @inheritDoc + * @return $this */ public function setFlash(string $key, $value) { diff --git a/src/Storage/Adapters/Dropbox/DropboxApp.php b/src/Storage/Adapters/Dropbox/DropboxApp.php index 07938ed3b..baecdea2c 100644 --- a/src/Storage/Adapters/Dropbox/DropboxApp.php +++ b/src/Storage/Adapters/Dropbox/DropboxApp.php @@ -97,6 +97,7 @@ class DropboxApp implements CloudAppInterface /** * Access token status indicating it needs refresh + * @var array */ public const ACCESS_TOKEN_STATUS = ['invalid_access_token', 'expired_access_token']; @@ -194,7 +195,8 @@ private function fetchAccessTokenByRefreshToken(string $refreshToken): string /** * Sends rpc request - * @return mixed|null + * @param array|null $params + * @return mixed * @throws Exception */ public function rpcRequest(string $endpoint, ?array $params = []) @@ -209,6 +211,7 @@ public function rpcRequest(string $endpoint, ?array $params = []) /** * Sends content request + * @param array $params * @return mixed|null * @throws Exception */ @@ -225,6 +228,7 @@ public function contentRequest(string $endpoint, array $params, string $content /** * Gets the normalized path + * @return array{path: string} */ public function path(string $name): array { diff --git a/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php b/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php index e91de5b8a..c5562d9ee 100644 --- a/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php +++ b/src/Storage/Adapters/GoogleDrive/GoogleDriveApp.php @@ -40,6 +40,7 @@ class GoogleDriveApp implements CloudAppInterface /** * Authorization scope + * @var string */ public const AUTH_SCOPE = 'https://www.googleapis.com/auth/drive'; @@ -174,6 +175,7 @@ public function rpcRequest(string $url, $params = [], string $method = 'POST', s /** * Gets file information + * @param array $params * @return mixed|null * @throws Exception */ diff --git a/src/Storage/Adapters/Local/LocalFileSystemAdapter.php b/src/Storage/Adapters/Local/LocalFileSystemAdapter.php index 7d36837e4..b0ed88f1d 100644 --- a/src/Storage/Adapters/Local/LocalFileSystemAdapter.php +++ b/src/Storage/Adapters/Local/LocalFileSystemAdapter.php @@ -173,6 +173,7 @@ public function listDirectory(string $dirname) /** * @inheritDoc + * @return array|false */ public function glob(string $pattern, int $flags = 0) { @@ -197,6 +198,7 @@ public function isWritable(string $filename): bool /** * @inheritDoc + * @return array */ public function getLines(string $filename, int $offset = 0, ?int $length = null): array { diff --git a/src/Storage/Contracts/CloudAppInterface.php b/src/Storage/Contracts/CloudAppInterface.php index c83bf9910..54fe555c2 100644 --- a/src/Storage/Contracts/CloudAppInterface.php +++ b/src/Storage/Contracts/CloudAppInterface.php @@ -33,7 +33,8 @@ public function __construct( /** * Send request - * @param array|string|null $data + * @param array|string|null $data + * @param array $headers * @return mixed */ public function sendRequest( diff --git a/src/Storage/Contracts/FilesystemAdapterInterface.php b/src/Storage/Contracts/FilesystemAdapterInterface.php index 418acd11d..4bc11d9a6 100644 --- a/src/Storage/Contracts/FilesystemAdapterInterface.php +++ b/src/Storage/Contracts/FilesystemAdapterInterface.php @@ -40,12 +40,14 @@ public function get(string $filename); /** * Puts the content into the file + * @param mixed $content * @return int|false */ public function put(string $filename, $content, ?string $parentId = null); /** * Appends the content at the end of the file + * @param mixed $content * @return int|false */ public function append(string $filename, $content); @@ -94,7 +96,7 @@ public function isDirectory(string $dirname): bool; /** * Lists the files inside the directory - * @return array|bool + * @return array|bool */ public function listDirectory(string $dirname); diff --git a/src/Storage/Contracts/LocalFilesystemAdapterInterface.php b/src/Storage/Contracts/LocalFilesystemAdapterInterface.php index 20b7e1827..c42dd7dac 100644 --- a/src/Storage/Contracts/LocalFilesystemAdapterInterface.php +++ b/src/Storage/Contracts/LocalFilesystemAdapterInterface.php @@ -24,7 +24,7 @@ interface LocalFilesystemAdapterInterface extends FilesystemAdapterInterface { /** * Find path names matching a pattern - * @return array|false + * @return array|false */ public function glob(string $pattern, int $flags = 0); @@ -40,6 +40,7 @@ public function isWritable(string $filename): bool; /** * Gets the content between given lines + * @return array */ public function getLines(string $filename, int $offset = 0, ?int $length = null): array; diff --git a/src/Storage/Factories/FileSystemFactory.php b/src/Storage/Factories/FileSystemFactory.php index 17643034c..5e0e27900 100644 --- a/src/Storage/Factories/FileSystemFactory.php +++ b/src/Storage/Factories/FileSystemFactory.php @@ -57,6 +57,9 @@ class FileSystemFactory FileSystem::GDRIVE => GoogleDriveApp::class, ]; + /** + * @var array + */ private static array $instances = []; /** @@ -130,6 +133,9 @@ private static function createCloudApp(string $adapter): ?CloudAppInterface } /** + * Creates token service instance + * @param string $adapter + * @return TokenServiceInterface * @throws BaseException * @throws DiException * @throws ReflectionException @@ -137,8 +143,9 @@ private static function createCloudApp(string $adapter): ?CloudAppInterface */ private static function createTokenService(string $adapter): TokenServiceInterface { - $serviceClass = config()->get('fs.' . $adapter . '.service'); + $serviceClass = (string) config()->get('fs.' . $adapter . '.service'); + /** @var class-string<\Quantum\Service\QtService> $serviceClass */ $tokenService = ServiceFactory::create($serviceClass); if (!$tokenService instanceof TokenServiceInterface) { diff --git a/src/Storage/FileSystem.php b/src/Storage/FileSystem.php index dfe73c0c4..3c0b1f5d7 100644 --- a/src/Storage/FileSystem.php +++ b/src/Storage/FileSystem.php @@ -41,7 +41,7 @@ * @method string extension(string $path) * @method bool isReadable(string $filename) * @method bool isWritable(string $filename) - * @method array|false listDirectory(string $dirname) + * @method array|false listDirectory(string $dirname) * @method glob(string $pattern, int $flags = 0) * @method mixed require (string $file, bool $once = false) * @method mixed include (string $file, bool $once = false) @@ -76,6 +76,7 @@ public function getAdapter(): FilesystemAdapterInterface } /** + * @param array $arguments * @return mixed * @throws BaseException */ diff --git a/src/Storage/Traits/CloudAppTrait.php b/src/Storage/Traits/CloudAppTrait.php index 6ca17924d..6eb778909 100644 --- a/src/Storage/Traits/CloudAppTrait.php +++ b/src/Storage/Traits/CloudAppTrait.php @@ -28,6 +28,8 @@ trait CloudAppTrait { /** * @inheritDoc + * @param array|string|null $data + * @param array $headers * @throws BaseException * @throws HttpException * @throws Exception diff --git a/src/Storage/UploadedFile.php b/src/Storage/UploadedFile.php index 9a52fe44f..86e8402b7 100644 --- a/src/Storage/UploadedFile.php +++ b/src/Storage/UploadedFile.php @@ -78,10 +78,14 @@ class UploadedFile extends SplFileInfo /** * 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', @@ -95,6 +99,7 @@ class UploadedFile extends SplFileInfo /** * Allowed mime types => allowed extensions map + * @var array> */ protected array $allowedMimeTypes = [ 'image/jpeg' => ['jpg', 'jpeg'], @@ -108,6 +113,7 @@ class UploadedFile extends SplFileInfo protected int $errorCode; /** + * @param array $meta * @throws BaseException * @throws ConfigException * @throws DiException @@ -136,6 +142,7 @@ public function __construct(array $meta) /** * Sets the allowed mime types => extensions map + * @param array $allowedMimeTypes */ public function setAllowedMimeTypes(array $allowedMimeTypes, bool $merge = true): UploadedFile { @@ -227,6 +234,7 @@ public function getMd5(): string /** * Get image dimensions + * @return array{width: int<0, max>, height: int<0, max>} * @throws FileUploadException */ public function getDimensions(): array @@ -294,6 +302,7 @@ public function save(string $dest, bool $overwrite = false): bool /** * Sets modification function on image + * @param array $params * @throws BaseException * @throws FileUploadException * @throws LangException @@ -340,7 +349,7 @@ public function isUploaded(): bool /** * Checks if the given file is image - * @param $filePath + * @param string $filePath */ public function isImage($filePath): bool { @@ -370,7 +379,7 @@ protected function allowed(string $extension, string $mimeType): bool $mimeType = strtolower($mimeType); return isset($this->allowedMimeTypes[$mimeType]) && - in_array($extension, $this->allowedMimeTypes[$mimeType], true); + in_array($extension, (array) $this->allowedMimeTypes[$mimeType], true); } /** @@ -407,6 +416,7 @@ protected function loadAllowedMimeTypesFromConfig(): void /** * Sets the allowed mime types => extensions map + * @param array $allowedMimeTypes */ protected function setAllowedMimeTypesMap(array $allowedMimeTypes, bool $merge = true): void { @@ -415,13 +425,14 @@ protected function setAllowedMimeTypesMap(array $allowedMimeTypes, bool $merge = /** * Applies modifications on image - * @param $filePath + * @param string $filePath + * @return void * @throws ImageResizeException */ - protected function applyModifications($filePath) + protected function applyModifications(string $filePath) { $image = new ImageResize($filePath); - call_user_func_array([$image, $this->imageModifierFuncName], $this->params); + call_user_func_array([$image, $this->imageModifierFuncName], array_values($this->params)); $image->save($filePath); } diff --git a/src/Tracer/ErrorHandler.php b/src/Tracer/ErrorHandler.php index 37d0f8303..a5e9b5063 100644 --- a/src/Tracer/ErrorHandler.php +++ b/src/Tracer/ErrorHandler.php @@ -164,6 +164,7 @@ private function logError(Throwable $e, string $errorType): void /** * Composes the stack trace + * @return array * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Transformer/Contracts/TransformerInterface.php b/src/Transformer/Contracts/TransformerInterface.php index 823672be4..46311ac37 100644 --- a/src/Transformer/Contracts/TransformerInterface.php +++ b/src/Transformer/Contracts/TransformerInterface.php @@ -25,6 +25,7 @@ interface TransformerInterface /** * Defines the transformer signature * @param mixed $item + * @return mixed */ public function transform($item); } diff --git a/src/Transformer/Helpers/transformer.php b/src/Transformer/Helpers/transformer.php index 6a956d0ce..cf9be6e21 100644 --- a/src/Transformer/Helpers/transformer.php +++ b/src/Transformer/Helpers/transformer.php @@ -19,6 +19,8 @@ /** * Transforms the data by given transformer signature + * @param array $data + * @return array */ function transform(array $data, TransformerInterface $transformer): array { diff --git a/src/Transformer/Transformer.php b/src/Transformer/Transformer.php index 32a7ebab2..f0c81cc33 100644 --- a/src/Transformer/Transformer.php +++ b/src/Transformer/Transformer.php @@ -26,6 +26,8 @@ class Transformer { /** * Applies the transformer on each item of the array + * @param array $data + * @return array */ public static function transform(array $data, TransformerInterface $transformer): array { diff --git a/src/Validation/Rule.php b/src/Validation/Rule.php index b11da48ed..4a1368a6e 100644 --- a/src/Validation/Rule.php +++ b/src/Validation/Rule.php @@ -64,7 +64,8 @@ class Rule { /** - * @return array[] + * @param array $params + * @return array> */ public static function __callStatic(string $name, array $params): array { diff --git a/src/Validation/Traits/General.php b/src/Validation/Traits/General.php index 9aa20b402..d7eec2dd0 100644 --- a/src/Validation/Traits/General.php +++ b/src/Validation/Traits/General.php @@ -34,6 +34,7 @@ trait General { /** * Checks Field Required + * @param mixed $value */ protected function required($value): bool { @@ -42,6 +43,7 @@ protected function required($value): bool /** * Checks Email + * @param mixed $value */ protected function email($value): bool { @@ -50,6 +52,7 @@ protected function email($value): bool /** * Checks for a valid credit card number + * @param mixed $value */ protected function creditCard($value): bool { @@ -83,6 +86,7 @@ protected function creditCard($value): bool /** * Checks for a valid IBAN + * @param mixed $value */ protected function iban($value): bool { @@ -108,6 +112,7 @@ protected function iban($value): bool /** * Checks for a valid format human name + * @param mixed $value */ protected function name($value): bool { @@ -116,6 +121,7 @@ protected function name($value): bool /** * Checks that the provided string is a likely street address. + * @param mixed $value */ protected function streetAddress($value): bool { @@ -129,6 +135,7 @@ protected function streetAddress($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 mixed $value */ protected function phoneNumber($value): bool { @@ -140,6 +147,7 @@ protected function phoneNumber($value): bool /** * Determines if the provided input is a valid date + * @param mixed $value */ protected function date($value, ?string $format = null): bool { @@ -158,6 +166,7 @@ protected function date($value, ?string $format = null): bool /** * Ensures the value starts with a certain character / set of character + * @param mixed $value */ protected function starts($value, ?string $text = null): bool { @@ -166,6 +175,7 @@ protected function starts($value, ?string $text = null): bool /** * Custom regex validator + * @param mixed $value */ protected function regex($value, string $pattern): bool { @@ -174,6 +184,7 @@ protected function regex($value, string $pattern): bool /** * Validates JSON string + * @param mixed $value */ protected function jsonString($value): bool { @@ -184,6 +195,7 @@ protected function jsonString($value): bool /** * Validates same value for both fields + * @param mixed $value */ protected function same($value, string $otherField): bool { @@ -192,7 +204,7 @@ protected function same($value, string $otherField): bool /** * Validates uniqueness - * @param $value + * @param mixed $value * @throws BaseException * @throws ModelException */ @@ -208,7 +220,7 @@ protected function unique($value, string $className, string $columnName): bool /** * Validates record existence - * @param $value + * @param mixed $value * @throws BaseException * @throws ModelException */ @@ -224,6 +236,7 @@ protected function exists($value, string $className, string $columnName): bool /** * Check Captcha + * @param mixed $value * @throws BaseException * @throws ConfigException * @throws DiException diff --git a/src/Validation/Traits/Type.php b/src/Validation/Traits/Type.php index a77955bcf..3e0eb78c7 100644 --- a/src/Validation/Traits/Type.php +++ b/src/Validation/Traits/Type.php @@ -24,6 +24,7 @@ trait Type { /** * Checks the alpha characters + * @param mixed $value */ protected function alpha($value): bool { @@ -32,6 +33,7 @@ protected function alpha($value): bool /** * Checks the alpha and numeric characters + * @param mixed $value */ protected function alphaNumeric($value): bool { @@ -40,6 +42,7 @@ protected function alphaNumeric($value): bool /** * Checks the alpha and dash characters + * @param mixed $value */ protected function alphaDash($value): bool { @@ -48,6 +51,7 @@ protected function alphaDash($value): bool /** * Checks the alphanumeric and space characters + * @param mixed $value */ protected function alphaSpace($value): bool { @@ -56,6 +60,7 @@ protected function alphaSpace($value): bool /** * Checks the numeric value + * @param mixed $value */ protected function numeric($value): bool { @@ -64,6 +69,7 @@ protected function numeric($value): bool /** * Checks the integer value + * @param mixed $value */ protected function integer($value): bool { @@ -72,6 +78,7 @@ protected function integer($value): bool /** * Checks the float value + * @param mixed $value */ protected function float($value): bool { @@ -80,7 +87,7 @@ protected function float($value): bool /** * Checks the boolean value - * @param $value + * @param mixed $value */ protected function boolean($value): bool { @@ -91,7 +98,8 @@ protected function boolean($value): bool /** * Determines if the provided numeric value is lower to a specific value - * @param $minValue + * @param mixed $value + * @param mixed $minValue */ protected function minNumeric($value, $minValue): bool { @@ -100,7 +108,8 @@ protected function minNumeric($value, $minValue): bool /** * Determines if the provided numeric value is higher to a specific value - * @param $maxValue + * @param mixed $value + * @param mixed $maxValue */ protected function maxNumeric($value, $maxValue): bool { diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index cea8642fc..a458405e6 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -45,16 +45,19 @@ class Validator /** * Rules + * @var array> */ private array $rules = []; /** * Validation Errors + * @var array> */ private array $errors = []; /** * Request data + * @var array */ private array $data = []; @@ -66,7 +69,7 @@ class Validator /** * Add rules for a single field - * @param array $rules Format: [['ruleName' => param], ...] + * @param array> $rules Format: [['ruleName' => param], ...] */ public function setRule(string $field, array $rules): void { @@ -79,7 +82,7 @@ public function setRule(string $field, array $rules): void /** * Add multiple rules for multiple fields - * @param array $rules Format: ['field' => [ ['rule' => param], ... ], ...] + * @param array>> $rules Format: ['field' => [ ['rule' => param], ... ], ...] */ public function setRules(array $rules): void { @@ -90,7 +93,7 @@ public function setRules(array $rules): void /** * Update a single rule for a field if exists - * @param array $rule Format: ['ruleName' => param] + * @param array $rule Format: ['ruleName' => param] */ public function updateRule(string $field, array $rule): void { @@ -131,6 +134,7 @@ 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 @@ -189,6 +193,7 @@ public function addRule(string $rule, Closure $function): void /** * Gets validation errors with translations + * @return array> * @throws ConfigException * @throws DiException * @throws LangException @@ -239,7 +244,7 @@ public function flushErrors(): void /** * Executes user defined rule - * @param $value + * @param mixed $value * @param mixed ...$params */ protected function executeCustomRule(string $rule, $value, ...$params): bool @@ -254,7 +259,7 @@ protected function executeCustomRule(string $rule, $value, ...$params): bool } /** - * @param $ruleParam + * @param mixed $ruleParam */ private function setOrUpdateRule(string $field, string $ruleName, $ruleParam): void { diff --git a/src/View/Helpers/view.php b/src/View/Helpers/view.php index 9af5cc488..a0721730c 100644 --- a/src/View/Helpers/view.php +++ b/src/View/Helpers/view.php @@ -41,6 +41,7 @@ function view(): ?string /** * Rendered partial + * @param array $args * @throws BaseException * @throws ConfigException * @throws DebugBarException @@ -68,7 +69,7 @@ function view_param(string $key) /** * Creates a raw param - * @param $value + * @param mixed $value */ function raw_param($value): RawParam { diff --git a/src/View/QtView.php b/src/View/QtView.php index 9fb08f3bc..c787cb13a 100644 --- a/src/View/QtView.php +++ b/src/View/QtView.php @@ -56,11 +56,13 @@ class QtView /** * Assets to be included + * @var array */ private array $assets = []; /** * View params + * @var array */ private array $params = []; @@ -78,6 +80,7 @@ public function __construct( /** * Sets a layout + * @param array $assets */ public function setLayout(?string $layoutFile, array $assets = []): void { @@ -106,7 +109,7 @@ public function setParam(string $key, $value): void } /** - * @param $value + * @param mixed $value */ public function setRawParam(string $key, $value): void { @@ -130,6 +133,7 @@ public function getParam(string $key) /** * Sets multiple view parameters + * @param array $params */ public function setParams(array $params): void { @@ -140,6 +144,7 @@ public function setParams(array $params): void /** * Gets all view parameters + * @return array */ public function getParams(): array { @@ -156,6 +161,7 @@ public function flushParams(): void /** * Renders the view. + * @param array $params * @throws AssetException * @throws BaseException * @throws ConfigException @@ -198,6 +204,7 @@ public function render(string $viewFile, array $params = []): ?string /** * Renders partial view. + * @param array $params */ public function renderPartial(string $viewFile, array $params = []): string {