From 3c0b1b945a0aaca3c0bdaf365b2199f2861dd3a0 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 7 Jan 2026 14:15:17 +0400 Subject: [PATCH 01/12] =?UTF-8?q?Update=20Composer=20dependencies=20within?= =?UTF-8?q?=20PHP=207.4=E2=80=938.0=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index e69ac3b58..718ccbf12 100644 --- a/composer.json +++ b/composer.json @@ -30,15 +30,15 @@ "j4mie/paris": "^1.5", "firebase/php-jwt": "^6.0", "gumlet/php-image-resize": "^2.0", - "symfony/var-dumper": "^4.2", + "symfony/var-dumper": "^5.4", "symfony/var-exporter": "^5.2", - "symfony/console": "^4.3", - "vlucas/phpdotenv": "^4.2", + "symfony/console": "^5.4", + "vlucas/phpdotenv": "^5.0", "dflydev/dot-access-data": "^3.0", - "php-debugbar/php-debugbar": "^1.23", + "php-debugbar/php-debugbar": "^2.0", "phpmailer/phpmailer": "^6.0", - "twig/twig": "^2.7", - "php-curl-class/php-curl-class": "^9.0", + "twig/twig": "^3.0", + "php-curl-class/php-curl-class": "^11.0", "psr/log": "^1.1", "rakibtg/sleekdb": "^2.13", "swagger-api/swagger-ui": "^4.14", @@ -47,7 +47,7 @@ "vaibhavpandeyvpz/phemail": "^1.1", "doctrine/annotations": "^2.0", "voku/html-min": "^4.5", - "league/commonmark": "^1.6", + "league/commonmark": "^2.0", "ezyang/htmlpurifier": "^4.18", "povils/figlet": "^0.1.0", "ramsey/uuid": "^4.2" @@ -56,7 +56,8 @@ "phpunit/phpunit": "^9.0", "mockery/mockery": "^1.4", "mikey179/vfsstream": "^1.6", - "rector/rector": "^2.3" + "rector/rector": "^2.3", + "phpstan/phpstan": "^2.1" }, "suggest": { "ext-dom": "Required for XML/HTML processing", @@ -77,6 +78,6 @@ "scripts": { "test": "vendor/bin/phpunit --stderr --testdox --coverage-clover coverage.xml" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} From 845bcdca99e73dea9d3f51ee16111af3a572dc79 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 7 Jan 2026 14:24:54 +0400 Subject: [PATCH 02/12] Resolve PHPStan level 0 static analysis issues --- phpstan.neon.dist | 8 +++ src/App/Exceptions/AppException.php | 9 ++- src/App/Exceptions/BaseException.php | 20 +++--- src/App/Exceptions/StopExecutionException.php | 9 ++- src/App/Helpers/app.php | 4 +- src/Config/Exceptions/ConfigException.php | 9 ++- src/Console/QtCommand.php | 5 +- src/Environment/Exceptions/EnvException.php | 16 +++-- src/Hook/Exceptions/HookException.php | 16 +++-- .../Archive/Exceptions/ArchiveException.php | 16 +++-- .../Auth/Exceptions/AuthException.php | 37 +++++++--- .../Csrf/Exceptions/CsrfException.php | 16 +++-- .../Database/Exceptions/DatabaseException.php | 30 +++++--- .../Exceptions/CryptorException.php | 23 ++++-- .../Hasher/Exceptions/HasherException.php | 12 +++- .../Exceptions/HttpClientException.php | 7 +- src/Libraries/Jwt/Exceptions/JwtException.php | 9 ++- .../Lang/Exceptions/LangException.php | 16 +++-- .../Logger/Exceptions/LoggerException.php | 16 +++-- .../Mailer/Adapters/MailgunAdapter.php | 4 +- .../Mailer/Adapters/MandrillAdapter.php | 4 +- .../Mailer/Adapters/SendgridAdapter.php | 4 +- .../Mailer/Adapters/SendinblueAdapter.php | 4 +- src/Libraries/Mailer/Adapters/SmtpAdapter.php | 14 ++-- src/Libraries/Mailer/Traits/MailerTrait.php | 44 +++++++++++- .../Session/Exceptions/SessionException.php | 16 +++-- .../Exceptions/FileSystemException.php | 23 ++++-- .../Exceptions/FileUploadException.php | 17 +++-- .../Exceptions/MiddlewareException.php | 9 ++- .../Exceptions/MigrationException.php | 23 ++++-- src/Model/Exceptions/ModelException.php | 26 +++---- src/Module/Exceptions/ModuleException.php | 44 ++++++++---- .../Exceptions/PaginatorException.php | 9 ++- .../Exceptions/RouteControllerException.php | 16 +++-- src/Router/Exceptions/RouteException.php | 72 +++++++++++++------ src/View/Exceptions/ViewException.php | 16 +++-- 36 files changed, 433 insertions(+), 190 deletions(-) create mode 100644 phpstan.neon.dist diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 000000000..2017bafb2 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,8 @@ +parameters: + phpVersion: 70400 + + + level: 0 + + paths: + - src \ No newline at end of file diff --git a/src/App/Exceptions/AppException.php b/src/App/Exceptions/AppException.php index d37a5046e..1a90ba954 100644 --- a/src/App/Exceptions/AppException.php +++ b/src/App/Exceptions/AppException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\App\Exceptions; @@ -28,8 +28,11 @@ class AppException extends BaseException /** * @return AppException */ - public static function missingAppKey(): AppException + public static function missingAppKey(): self { - return new static(ExceptionMessages::APP_KEY_MISSING, E_ERROR); + return new self( + ExceptionMessages::APP_KEY_MISSING, + E_ERROR + ); } } diff --git a/src/App/Exceptions/BaseException.php b/src/App/Exceptions/BaseException.php index 8c002f686..6d161aeb0 100644 --- a/src/App/Exceptions/BaseException.php +++ b/src/App/Exceptions/BaseException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\App\Exceptions; @@ -33,7 +33,7 @@ class BaseException extends Exception */ public static function methodNotSupported(string $methodName, string $className): self { - return new static( + return new self( _message(ExceptionMessages::METHOD_NOT_SUPPORTED, [$methodName, $className]), E_WARNING ); @@ -45,7 +45,7 @@ public static function methodNotSupported(string $methodName, string $className) */ public static function adapterNotSupported(string $name): self { - return new static( + return new self( _message(ExceptionMessages::ADAPTER_NOT_SUPPORTED, [$name]), E_ERROR ); @@ -57,7 +57,7 @@ public static function adapterNotSupported(string $name): self */ public static function driverNotSupported(string $name): self { - return new static( + return new self( _message(ExceptionMessages::DRIVER_NOT_SUPPORTED, [$name]), E_ERROR ); @@ -69,7 +69,7 @@ public static function driverNotSupported(string $name): self */ public static function fileNotFound(string $name): self { - return new static( + return new self( _message(ExceptionMessages::FILE_NOT_FOUND, [$name]), E_ERROR ); @@ -82,7 +82,7 @@ public static function fileNotFound(string $name): self */ public static function notFound(string $subject, string $name): self { - return new static( + return new self( _message(ExceptionMessages::NOT_FOUND, [$subject, $name]), E_ERROR ); @@ -95,7 +95,7 @@ public static function notFound(string $subject, string $name): self */ public static function notInstanceOf(string $instance, string $name): self { - return new static( + return new self( _message(ExceptionMessages::NOT_INSTANCE_OF, [$instance, $name]), E_ERROR ); @@ -107,7 +107,7 @@ public static function notInstanceOf(string $instance, string $name): self */ public static function cantConnect(string $name): self { - return new static( + return new self( _message(ExceptionMessages::CANT_CONNECT, [$name]), E_ERROR ); @@ -120,7 +120,7 @@ public static function cantConnect(string $name): self public static function missingConfig(string $name): self { - return new static( + return new self( _message(ExceptionMessages::MISSING_CONFIG, $name), E_ERROR ); @@ -132,7 +132,7 @@ public static function missingConfig(string $name): self */ public static function requestMethodNotAvailable(string $name): self { - return new static( + return new self( _message(ExceptionMessages::UNAVAILABLE_REQUEST_METHOD, [$name]), E_WARNING ); diff --git a/src/App/Exceptions/StopExecutionException.php b/src/App/Exceptions/StopExecutionException.php index a677a0d4c..dad7ec66c 100644 --- a/src/App/Exceptions/StopExecutionException.php +++ b/src/App/Exceptions/StopExecutionException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\App\Exceptions; @@ -29,8 +29,11 @@ class StopExecutionException extends BaseException * @param int|null $code * @return StopExecutionException */ - public static function executionTerminated(?int $code): StopExecutionException + public static function executionTerminated(?int $code): self { - return new static(ExceptionMessages::EXECUTION_TERMINATED, $code); + return new self( + ExceptionMessages::EXECUTION_TERMINATED, + $code + ); } } \ No newline at end of file diff --git a/src/App/Helpers/app.php b/src/App/Helpers/app.php index 23712fc5f..8ec9e2e0d 100644 --- a/src/App/Helpers/app.php +++ b/src/App/Helpers/app.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ use Quantum\App\Exceptions\StopExecutionException; @@ -18,7 +18,7 @@ * Stops the app execution * @param Closure|null $closure * @param int|null $code - * @return mixed + * @return never * @throws StopExecutionException */ function stop(?Closure $closure = null, ?int $code = 0) diff --git a/src/Config/Exceptions/ConfigException.php b/src/Config/Exceptions/ConfigException.php index 5154e4b00..c92eb087d 100644 --- a/src/Config/Exceptions/ConfigException.php +++ b/src/Config/Exceptions/ConfigException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Config\Exceptions; @@ -30,8 +30,11 @@ class ConfigException extends BaseException * @param string $name * @return ConfigException */ - public static function configCollision(string $name): ConfigException + public static function configCollision(string $name): self { - return new static(_message(ExceptionMessages::CONFIG_COLLISION, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::CONFIG_COLLISION, [$name]), + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Console/QtCommand.php b/src/Console/QtCommand.php index e3277fb1d..a6995b4af 100644 --- a/src/Console/QtCommand.php +++ b/src/Console/QtCommand.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Console; @@ -175,12 +175,15 @@ protected function configure() * Executes the current command. * @param InputInterface $input * @param OutputInterface $output + * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; $this->output = $output; $this->exec(); + + return Command::SUCCESS; } /** diff --git a/src/Environment/Exceptions/EnvException.php b/src/Environment/Exceptions/EnvException.php index 3b2b4e9f8..3eb882bfa 100644 --- a/src/Environment/Exceptions/EnvException.php +++ b/src/Environment/Exceptions/EnvException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Environment\Exceptions; @@ -29,16 +29,22 @@ class EnvException extends BaseException /** * @return EnvException */ - public static function environmentImmutable(): EnvException + public static function environmentImmutable(): self { - return new static(ExceptionMessages::IMMUTABLE_ENVIRONMENT, E_ERROR); + return new self( + ExceptionMessages::IMMUTABLE_ENVIRONMENT, + E_ERROR + ); } /** * @return EnvException */ - public static function environmentNotLoaded(): EnvException + public static function environmentNotLoaded(): self { - return new static(ExceptionMessages::ENVIRONMENT_NOT_LOADED, E_ERROR); + return new self( + ExceptionMessages::ENVIRONMENT_NOT_LOADED, + E_ERROR + ); } } diff --git a/src/Hook/Exceptions/HookException.php b/src/Hook/Exceptions/HookException.php index 8d90e3a99..ccbe7df54 100644 --- a/src/Hook/Exceptions/HookException.php +++ b/src/Hook/Exceptions/HookException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Hook\Exceptions; @@ -29,17 +29,23 @@ class HookException extends BaseException * @param string $name * @return HookException */ - public static function hookDuplicateName(string $name): HookException + public static function hookDuplicateName(string $name): self { - return new static(_message(ExceptionMessages::DUPLICATE_HOOK_NAME, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::DUPLICATE_HOOK_NAME, [$name]), + E_ERROR + ); } /** * @param string $name * @return HookException */ - public static function unregisteredHookName(string $name): HookException + public static function unregisteredHookName(string $name): self { - return new static(_message(ExceptionMessages::UNREGISTERED_HOOK_NAME, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::UNREGISTERED_HOOK_NAME, [$name]), + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Archive/Exceptions/ArchiveException.php b/src/Libraries/Archive/Exceptions/ArchiveException.php index 1f87d90f5..b2edc4f0a 100644 --- a/src/Libraries/Archive/Exceptions/ArchiveException.php +++ b/src/Libraries/Archive/Exceptions/ArchiveException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Archive\Exceptions; @@ -29,16 +29,22 @@ class ArchiveException extends BaseException * @param string $name * @return ArchiveException */ - public static function cantOpen(string $name): ArchiveException + public static function cantOpen(string $name): self { - return new static(_message(ExceptionMessages::CANT_OPEN, $name), E_WARNING); + return new self( + _message(ExceptionMessages::CANT_OPEN, $name), + E_WARNING + ); } /** * @return ArchiveException */ - public static function missingArchiveName(): ArchiveException + public static function missingArchiveName(): self { - return new static(ExceptionMessages::NAME_NOT_SET, E_WARNING); + return new self( + ExceptionMessages::NAME_NOT_SET, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Auth/Exceptions/AuthException.php b/src/Libraries/Auth/Exceptions/AuthException.php index 1022aa483..32d26a46d 100644 --- a/src/Libraries/Auth/Exceptions/AuthException.php +++ b/src/Libraries/Auth/Exceptions/AuthException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Auth\Exceptions; @@ -28,40 +28,55 @@ class AuthException extends BaseException /** * @return AuthException */ - public static function incorrectCredentials(): AuthException + public static function incorrectCredentials(): self { - return new static(ExceptionMessages::INCORRECT_CREDENTIALS, E_ERROR); + return new self( + ExceptionMessages::INCORRECT_CREDENTIALS, + E_ERROR + ); } /** * @return AuthException */ - public static function inactiveAccount(): AuthException + public static function inactiveAccount(): self { - return new static(ExceptionMessages::INACTIVE_ACCOUNT); + return new self( + ExceptionMessages::INACTIVE_ACCOUNT, + E_ERROR + ); } /** * @return AuthException */ - public static function incorrectVerificationCode(): AuthException + public static function incorrectVerificationCode(): self { - return new static(ExceptionMessages::INCORRECT_VERIFICATION_CODE, E_ERROR); + return new self( + ExceptionMessages::INCORRECT_VERIFICATION_CODE, + E_ERROR + ); } /** * @return AuthException */ - public static function verificationCodeExpired(): AuthException + public static function verificationCodeExpired(): self { - return new static(ExceptionMessages::VERIFICATION_CODE_EXPIRED, E_ERROR); + return new self( + ExceptionMessages::VERIFICATION_CODE_EXPIRED, + E_ERROR + ); } /** * @return AuthException */ - public static function incorrectUserSchema(): AuthException + public static function incorrectUserSchema(): self { - return new static(ExceptionMessages::INCORRECT_USER_SCHEMA, E_ERROR); + return new self( + ExceptionMessages::INCORRECT_USER_SCHEMA, + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Libraries/Csrf/Exceptions/CsrfException.php b/src/Libraries/Csrf/Exceptions/CsrfException.php index b5478a92d..7aa69fbd4 100644 --- a/src/Libraries/Csrf/Exceptions/CsrfException.php +++ b/src/Libraries/Csrf/Exceptions/CsrfException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Csrf\Exceptions; @@ -28,16 +28,22 @@ class CsrfException extends BaseException /** * @return CsrfException */ - public static function tokenNotFound(): CsrfException + public static function tokenNotFound(): self { - return new static(ExceptionMessages::CSRF_TOKEN_MISSING, E_WARNING); + return new self( + ExceptionMessages::CSRF_TOKEN_MISSING, + E_WARNING + ); } /** * @return CsrfException */ - public static function tokenNotMatched(): CsrfException + public static function tokenNotMatched(): self { - return new static(ExceptionMessages::CSRF_TOKEN_MISMATCH, E_WARNING); + return new self( + ExceptionMessages::CSRF_TOKEN_MISMATCH, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Database/Exceptions/DatabaseException.php b/src/Libraries/Database/Exceptions/DatabaseException.php index 031e024bf..7b8f1fab4 100644 --- a/src/Libraries/Database/Exceptions/DatabaseException.php +++ b/src/Libraries/Database/Exceptions/DatabaseException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Exceptions; @@ -29,35 +29,47 @@ class DatabaseException extends BaseException /** * @return DatabaseException */ - public static function incorrectConfig(): DatabaseException + public static function incorrectConfig(): self { - return new static(ExceptionMessages::INCORRECT_CONFIG, E_ERROR); + return new self( + ExceptionMessages::INCORRECT_CONFIG, + E_ERROR + ); } /** * @param string $operator * @return DatabaseException */ - public static function operatorNotSupported(string $operator): DatabaseException + public static function operatorNotSupported(string $operator): self { - return new static(_message(ExceptionMessages::NOT_SUPPORTED_OPERATOR, [$operator]), E_WARNING); + return new self( + _message(ExceptionMessages::NOT_SUPPORTED_OPERATOR, [$operator]), + E_WARNING + ); } /** * @param string $name * @return DatabaseException */ - public static function tableAlreadyExists(string $name): DatabaseException + public static function tableAlreadyExists(string $name): self { - return new static(_message(ExceptionMessages::TABLE_ALREADY_EXISTS, $name), E_ERROR); + return new self( + _message(ExceptionMessages::TABLE_ALREADY_EXISTS, $name), + E_ERROR + ); } /** * @param string $name * @return DatabaseException */ - public static function tableDoesNotExists(string $name): DatabaseException + public static function tableDoesNotExists(string $name): self { - return new static(_message(ExceptionMessages::TABLE_NOT_EXISTS, $name), E_ERROR); + return new self( + _message(ExceptionMessages::TABLE_NOT_EXISTS, $name), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Libraries/Encryption/Exceptions/CryptorException.php b/src/Libraries/Encryption/Exceptions/CryptorException.php index b5697d762..8cbb56a49 100644 --- a/src/Libraries/Encryption/Exceptions/CryptorException.php +++ b/src/Libraries/Encryption/Exceptions/CryptorException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Encryption\Exceptions; @@ -29,24 +29,33 @@ class CryptorException extends BaseException /** * @return CryptorException */ - public static function publicKeyNotProvided(): CryptorException + public static function publicKeyNotProvided(): self { - return new static(ExceptionMessages::PUBLIC_KEY_MISSING, E_WARNING); + return new self( + ExceptionMessages::PUBLIC_KEY_MISSING, + E_WARNING + ); } /** * @return CryptorException */ - public static function privateKeyNotProvided(): CryptorException + public static function privateKeyNotProvided(): self { - return new static(ExceptionMessages::PRIVATE_KEY_MISSING, E_WARNING); + return new self( + ExceptionMessages::PRIVATE_KEY_MISSING, + E_WARNING + ); } /** * @return CryptorException */ - public static function invalidCipher(): CryptorException + public static function invalidCipher(): self { - return new static(ExceptionMessages::INVALID_CIPHER, E_WARNING); + return new self( + ExceptionMessages::INVALID_CIPHER, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Hasher/Exceptions/HasherException.php b/src/Libraries/Hasher/Exceptions/HasherException.php index 486c7f1dc..6ea4c280f 100644 --- a/src/Libraries/Hasher/Exceptions/HasherException.php +++ b/src/Libraries/Hasher/Exceptions/HasherException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Hasher\Exceptions; @@ -33,7 +33,10 @@ class HasherException extends BaseException */ public static function algorithmNotSupported(string $algorithm): self { - return new static(_message(ExceptionMessages::ALGORITHM_NOT_SUPPORTED, $algorithm), E_WARNING); + return new self( + _message(ExceptionMessages::ALGORITHM_NOT_SUPPORTED, $algorithm), + E_WARNING + ); } /** @@ -42,6 +45,9 @@ public static function algorithmNotSupported(string $algorithm): self */ public static function invalidBcryptCost(): self { - return new static(ExceptionMessages::INVALID_BCRYPT_COST, E_WARNING); + return new self( + ExceptionMessages::INVALID_BCRYPT_COST, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/HttpClient/Exceptions/HttpClientException.php b/src/Libraries/HttpClient/Exceptions/HttpClientException.php index b7c61ec92..cfaf8326c 100644 --- a/src/Libraries/HttpClient/Exceptions/HttpClientException.php +++ b/src/Libraries/HttpClient/Exceptions/HttpClientException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\HttpClient\Exceptions; @@ -32,6 +32,9 @@ class HttpClientException extends BaseException public static function requestNotCreated(): self { - return new static(ExceptionMessages::REQUEST_NOT_CREATED, E_WARNING); + return new self( + ExceptionMessages::REQUEST_NOT_CREATED, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Jwt/Exceptions/JwtException.php b/src/Libraries/Jwt/Exceptions/JwtException.php index 30ed5445a..0792fb1f4 100644 --- a/src/Libraries/Jwt/Exceptions/JwtException.php +++ b/src/Libraries/Jwt/Exceptions/JwtException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Jwt\Exceptions; @@ -29,8 +29,11 @@ class JwtException extends BaseException /** * @return JwtException */ - public static function payloadNotFound(): JwtException + public static function payloadNotFound(): self { - return new static(ExceptionMessages::MISSING_PAYLOAD, E_WARNING); + return new self( + ExceptionMessages::MISSING_PAYLOAD, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Lang/Exceptions/LangException.php b/src/Libraries/Lang/Exceptions/LangException.php index 632179c53..3bc696259 100644 --- a/src/Libraries/Lang/Exceptions/LangException.php +++ b/src/Libraries/Lang/Exceptions/LangException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Lang\Exceptions; @@ -29,16 +29,22 @@ class LangException extends BaseException /** * @return LangException */ - public static function translationsNotFound(): LangException + public static function translationsNotFound(): self { - return new static(ExceptionMessages::TRANSLATION_FILES_NOT_FOUND, E_WARNING); + return new self( + ExceptionMessages::TRANSLATION_FILES_NOT_FOUND, + E_WARNING + ); } /** * @return LangException */ - public static function misconfiguredDefaultConfig(): LangException + public static function misconfiguredDefaultConfig(): self { - return new static(ExceptionMessages::MISCONFIGURED_DEFAULT_LANG, E_WARNING); + return new self( + ExceptionMessages::MISCONFIGURED_DEFAULT_LANG, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Logger/Exceptions/LoggerException.php b/src/Libraries/Logger/Exceptions/LoggerException.php index 34fc70502..b229dd195 100644 --- a/src/Libraries/Logger/Exceptions/LoggerException.php +++ b/src/Libraries/Logger/Exceptions/LoggerException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Logger\Exceptions; @@ -30,17 +30,23 @@ class LoggerException extends BaseException * @param string $name * @return LoggerException */ - public static function logPathIsNotDirectory(string $name): LoggerException + public static function logPathIsNotDirectory(string $name): self { - return new static(_message(ExceptionMessages::LOG_PATH_NOT_DIRECTORY, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::LOG_PATH_NOT_DIRECTORY, [$name]), + E_ERROR + ); } /** * @param string $name * @return LoggerException */ - public static function logPathIsNotFile(string $name): LoggerException + public static function logPathIsNotFile(string $name): self { - return new static(_message(ExceptionMessages::LOG_PATH_NOT_FILE, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::LOG_PATH_NOT_FILE, [$name]), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Libraries/Mailer/Adapters/MailgunAdapter.php b/src/Libraries/Mailer/Adapters/MailgunAdapter.php index 8d0cf13c3..6f9da612a 100644 --- a/src/Libraries/Mailer/Adapters/MailgunAdapter.php +++ b/src/Libraries/Mailer/Adapters/MailgunAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Adapters; @@ -36,7 +36,7 @@ class MailgunAdapter implements MailerInterface /** * @var HttpClient */ - private $httpClient; + protected $httpClient; /** * @var string diff --git a/src/Libraries/Mailer/Adapters/MandrillAdapter.php b/src/Libraries/Mailer/Adapters/MandrillAdapter.php index b37076b5f..cd54d1243 100644 --- a/src/Libraries/Mailer/Adapters/MandrillAdapter.php +++ b/src/Libraries/Mailer/Adapters/MandrillAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Adapters; @@ -36,7 +36,7 @@ class MandrillAdapter implements MailerInterface /** * @var HttpClient */ - private $httpClient; + protected $httpClient; /** * @var string diff --git a/src/Libraries/Mailer/Adapters/SendgridAdapter.php b/src/Libraries/Mailer/Adapters/SendgridAdapter.php index 542aa4d72..34946fc56 100644 --- a/src/Libraries/Mailer/Adapters/SendgridAdapter.php +++ b/src/Libraries/Mailer/Adapters/SendgridAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Adapters; @@ -36,7 +36,7 @@ class SendgridAdapter implements MailerInterface /** * @var HttpClient */ - private $httpClient; + protected $httpClient; /** * @var string diff --git a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php index 77fdb33ef..3942eff88 100644 --- a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php +++ b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Adapters; @@ -36,7 +36,7 @@ class SendinblueAdapter implements MailerInterface /** * @var HttpClient */ - private $httpClient; + protected $httpClient; /** * @var string diff --git a/src/Libraries/Mailer/Adapters/SmtpAdapter.php b/src/Libraries/Mailer/Adapters/SmtpAdapter.php index 3ef3c7f02..6698c1d41 100644 --- a/src/Libraries/Mailer/Adapters/SmtpAdapter.php +++ b/src/Libraries/Mailer/Adapters/SmtpAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Adapters; @@ -38,37 +38,37 @@ class SmtpAdapter implements MailerInterface /** * @var PHPMailer */ - private $mailer; + protected $mailer; /** * Reply To addresses * @var array */ - private $replyToAddresses = []; + protected $replyToAddresses = []; /** * CC addresses * @var array */ - private $ccAddresses = []; + protected $ccAddresses = []; /** * BCC addresses * @var array */ - private $bccAddresses = []; + protected $bccAddresses = []; /** * Email attachments * @var array */ - private $attachments = []; + protected $attachments = []; /** * Email attachments created from string * @var array */ - private $stringAttachments = []; + protected $stringAttachments = []; /** * @var SmtpAdapter|null diff --git a/src/Libraries/Mailer/Traits/MailerTrait.php b/src/Libraries/Mailer/Traits/MailerTrait.php index 5e0072bfc..1bdb466ca 100644 --- a/src/Libraries/Mailer/Traits/MailerTrait.php +++ b/src/Libraries/Mailer/Traits/MailerTrait.php @@ -9,14 +9,16 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Traits; use Quantum\Libraries\Mailer\Contracts\MailerInterface; +use Quantum\Libraries\HttpClient\HttpClient; use Quantum\Di\Exceptions\DiException; use Quantum\Libraries\Mailer\MailTrap; +use PHPMailer\PHPMailer\PHPMailer; use Quantum\Debugger\Debugger; use ReflectionException; use Exception; @@ -63,6 +65,46 @@ trait MailerTrait */ private $templatePath = null; + /** + * @var HttpClient + */ + protected $httpClient; + + /** + * @var PHPMailer + */ + protected $mailer; + + /** + * Reply To addresses + * @var array + */ + protected $replyToAddresses = []; + + /** + * CC addresses + * @var array + */ + protected $ccAddresses = []; + + /** + * BCC addresses + * @var array + */ + protected $bccAddresses = []; + + /** + * Email attachments + * @var array + */ + protected $attachments = []; + + /** + * Email attachments created from string + * @var array + */ + protected $stringAttachments = []; + /** * Sets the 'From' email and the name * @param string $email diff --git a/src/Libraries/Session/Exceptions/SessionException.php b/src/Libraries/Session/Exceptions/SessionException.php index 46d894fe9..9486eb3ff 100644 --- a/src/Libraries/Session/Exceptions/SessionException.php +++ b/src/Libraries/Session/Exceptions/SessionException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Session\Exceptions; @@ -28,16 +28,22 @@ class SessionException extends BaseException /** * @return SessionException */ - public static function sessionNotStarted(): SessionException + public static function sessionNotStarted(): self { - return new static(ExceptionMessages::SESSION_NOT_STARTED, E_WARNING); + return new self( + ExceptionMessages::SESSION_NOT_STARTED, + E_WARNING + ); } /** * @return SessionException */ - public static function sessionNotDestroyed(): SessionException + public static function sessionNotDestroyed(): self { - return new static(ExceptionMessages::SESSION_NOT_DESTROYED, E_WARNING); + return new self( + ExceptionMessages::SESSION_NOT_DESTROYED, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Storage/Exceptions/FileSystemException.php b/src/Libraries/Storage/Exceptions/FileSystemException.php index b3b801b16..abd170e9d 100644 --- a/src/Libraries/Storage/Exceptions/FileSystemException.php +++ b/src/Libraries/Storage/Exceptions/FileSystemException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage\Exceptions; @@ -30,26 +30,35 @@ class FileSystemException extends BaseException * @param string $name * @return FileSystemException */ - public static function directoryNotExists(string $name): FileSystemException + public static function directoryNotExists(string $name): self { - return new static(_message(ExceptionMessages::DIRECTORY_NOT_EXISTS, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::DIRECTORY_NOT_EXISTS, [$name]), + E_WARNING + ); } /** * @param string $name * @return FileSystemException */ - public static function directoryNotWritable(string $name): FileSystemException + public static function directoryNotWritable(string $name): self { - return new static(_message(ExceptionMessages::DIRECTORY_NOT_WRITABLE, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::DIRECTORY_NOT_WRITABLE, [$name]), + E_WARNING + ); } /** * @param string $path * @return FileSystemException */ - public static function fileAlreadyExists(string $path): FileSystemException + public static function fileAlreadyExists(string $path): self { - return new static(_message(ExceptionMessages::FILE_ALREADY_EXISTS, [$path]), E_WARNING); + return new self( + _message(ExceptionMessages::FILE_ALREADY_EXISTS, [$path]), + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Libraries/Storage/Exceptions/FileUploadException.php b/src/Libraries/Storage/Exceptions/FileUploadException.php index 37b294237..96c1ddef7 100644 --- a/src/Libraries/Storage/Exceptions/FileUploadException.php +++ b/src/Libraries/Storage/Exceptions/FileUploadException.php @@ -11,11 +11,12 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage\Exceptions; +use Quantum\App\Enums\ExceptionMessages as ExceptionMessagesAlias; use Quantum\Libraries\Storage\Enums\ExceptionMessages; use Quantum\App\Exceptions\BaseException; @@ -30,17 +31,23 @@ class FileUploadException extends BaseException * @param string $name * @return FileUploadException */ - public static function fileTypeNotAllowed(string $name): FileUploadException + public static function fileTypeNotAllowed(string $name): self { - return new static(_message(ExceptionMessages::FILE_TYPE_NOT_ALLOWED, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::FILE_TYPE_NOT_ALLOWED, [$name]), + E_WARNING + ); } /** * @param string $name * @return FileUploadException */ - public static function incorrectMimeTypesConfig(string $name): FileUploadException + public static function incorrectMimeTypesConfig(string $name): self { - return new static(_message(ExceptionMessages::MISSING_CONFIG, $name), E_ERROR); + return new self( + _message(ExceptionMessagesAlias::MISSING_CONFIG, $name), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Middleware/Exceptions/MiddlewareException.php b/src/Middleware/Exceptions/MiddlewareException.php index 0f1358988..4f7fa74f0 100644 --- a/src/Middleware/Exceptions/MiddlewareException.php +++ b/src/Middleware/Exceptions/MiddlewareException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Middleware\Exceptions; @@ -30,8 +30,11 @@ class MiddlewareException extends BaseException * @param string $name * @return MiddlewareException */ - public static function middlewareNotFound(string $name): MiddlewareException + public static function middlewareNotFound(string $name): self { - return new static(_message(ExceptionMessages::MIDDLEWARE_NOT_FOUND, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::MIDDLEWARE_NOT_FOUND, [$name]), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Migration/Exceptions/MigrationException.php b/src/Migration/Exceptions/MigrationException.php index 71fe7cdae..b9b1accd7 100644 --- a/src/Migration/Exceptions/MigrationException.php +++ b/src/Migration/Exceptions/MigrationException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Migration\Exceptions; @@ -31,25 +31,34 @@ class MigrationException extends BaseException /** * @return MigrationException */ - public static function wrongDirection(): MigrationException + public static function wrongDirection(): self { - return new static(ExceptionMessages::WRONG_MIGRATION_DIRECTION, E_ERROR); + return new self( + ExceptionMessages::WRONG_MIGRATION_DIRECTION, + E_ERROR + ); } /** * @param string $action * @return MigrationException */ - public static function unsupportedAction(string $action): MigrationException + public static function unsupportedAction(string $action): self { - return new static(_message(ExceptionMessages::NOT_SUPPORTED_ACTION, [$action]), E_ERROR); + return new self( + _message(ExceptionMessages::NOT_SUPPORTED_ACTION, [$action]), + E_ERROR + ); } /** * @return MigrationException */ - public static function nothingToMigrate(): MigrationException + public static function nothingToMigrate(): self { - return new static(ExceptionMessages::NOTHING_TO_MIGRATE, E_NOTICE); + return new self( + ExceptionMessages::NOTHING_TO_MIGRATE, + E_NOTICE + ); } } \ No newline at end of file diff --git a/src/Model/Exceptions/ModelException.php b/src/Model/Exceptions/ModelException.php index a2e82f776..7d40482be 100644 --- a/src/Model/Exceptions/ModelException.php +++ b/src/Model/Exceptions/ModelException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Model\Exceptions; @@ -30,9 +30,9 @@ class ModelException extends BaseException * @param string $name * @return ModelException */ - public static function inappropriateProperty(string $name): ModelException + public static function inappropriateProperty(string $name): self { - return new static( + return new self( _message(ExceptionMessages::INAPPROPRIATE_MODEL_PROPERTY, $name), E_WARNING ); @@ -43,9 +43,9 @@ public static function inappropriateProperty(string $name): ModelException * @param string $tableName * @return ModelException */ - public static function wrongRelation(string $modelName, string $tableName): ModelException + public static function wrongRelation(string $modelName, string $tableName): self { - return new static( + return new self( _message(ExceptionMessages::WRONG_RELATION, [$modelName, $tableName]), E_ERROR ); @@ -56,9 +56,9 @@ public static function wrongRelation(string $modelName, string $tableName): Mode * @param string $relatedModelName * @return ModelException */ - public static function relationTypeMissing(string $modelName, string $relatedModelName): ModelException + public static function relationTypeMissing(string $modelName, string $relatedModelName): self { - return new static( + return new self( _message(ExceptionMessages::RELATION_TYPE_MISSING, [$modelName, $relatedModelName]), E_ERROR ); @@ -69,9 +69,9 @@ public static function relationTypeMissing(string $modelName, string $relatedMod * @param string $relatedModelName * @return ModelException */ - public static function missingRelationKeys(string $modelName, string $relatedModelName): ModelException + public static function missingRelationKeys(string $modelName, string $relatedModelName): self { - return new static( + return new self( _message(ExceptionMessages::MISSING_RELATION_KEYS, [$modelName, $relatedModelName]), E_ERROR ); @@ -82,9 +82,9 @@ public static function missingRelationKeys(string $modelName, string $relatedMod * @param string $foreignKey * @return ModelException */ - public static function missingForeignKeyValue(string $modelName, string $foreignKey): ModelException + public static function missingForeignKeyValue(string $modelName, string $foreignKey): self { - return new static( + return new self( _message(ExceptionMessages::MISSING_FOREIGN_KEY, [$foreignKey, $modelName]), E_ERROR ); @@ -94,9 +94,9 @@ public static function missingForeignKeyValue(string $modelName, string $foreign * @param string $relationType * @return ModelException */ - public static function unsupportedRelationType(string $relationType): ModelException + public static function unsupportedRelationType(string $relationType): self { - return new static( + return new self( _message(ExceptionMessages::UNSUPPORTED_RELATION, [$relationType]), E_ERROR ); diff --git a/src/Module/Exceptions/ModuleException.php b/src/Module/Exceptions/ModuleException.php index d1230d1cc..6cc09ba1f 100644 --- a/src/Module/Exceptions/ModuleException.php +++ b/src/Module/Exceptions/ModuleException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Module\Exceptions; @@ -29,50 +29,68 @@ class ModuleException extends \Exception * @param string $name * @return ModuleException */ - public static function moduleRoutesNotFound(string $name): ModuleException + public static function moduleRoutesNotFound(string $name): self { - return new static(_message(ExceptionMessages::MODULE_ROUTES_NOT_FOUND, $name), E_ERROR); + return new self( + _message(ExceptionMessages::MODULE_ROUTES_NOT_FOUND, $name), + E_ERROR + ); } /** * @return ModuleException */ - public static function moduleConfigNotFound(): ModuleException + public static function moduleConfigNotFound(): self { - return new static(ExceptionMessages::MODULE_CONFIG_NOT_FOUND, E_ERROR); + return new self( + ExceptionMessages::MODULE_CONFIG_NOT_FOUND, + E_ERROR + ); } /** * @return ModuleException */ - public static function moduleCreationIncomplete(): ModuleException + public static function moduleCreationIncomplete(): self { - return new static(ExceptionMessages::MODULE_CREATION_INCOMPLETE, E_ERROR); + return new self( + ExceptionMessages::MODULE_CREATION_INCOMPLETE, + E_ERROR + ); } /** * @param string $name * @return ModuleException */ - public static function missingModuleTemplate(string $name): ModuleException + public static function missingModuleTemplate(string $name): self { - return new static(_message(ExceptionMessages::MISSING_MODULE_TEMPLATE, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::MISSING_MODULE_TEMPLATE, [$name]), + E_ERROR + ); } /** * @return ModuleException */ - public static function missingModuleDirectory(): ModuleException + public static function missingModuleDirectory(): self { - return new static(ExceptionMessages::MISSING_MODULE_DIRECTORY, E_ERROR); + return new self( + ExceptionMessages::MISSING_MODULE_DIRECTORY, + E_ERROR + ); } /** * @param string $name * @return ModuleException */ - public static function moduleAlreadyExists(string $name): ModuleException + public static function moduleAlreadyExists(string $name): self { - return new static(_message(ExceptionMessages::MODULE_ALREADY_EXISTS, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::MODULE_ALREADY_EXISTS, [$name]), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Paginator/Exceptions/PaginatorException.php b/src/Paginator/Exceptions/PaginatorException.php index faab9486c..616eeb056 100644 --- a/src/Paginator/Exceptions/PaginatorException.php +++ b/src/Paginator/Exceptions/PaginatorException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Paginator\Exceptions; @@ -31,8 +31,11 @@ class PaginatorException extends BaseException * @param $missingParam * @return PaginatorException */ - public static function missingRequiredParams(string $type, $missingParam): PaginatorException + public static function missingRequiredParams(string $type, $missingParam): self { - return new static(_message(ExceptionMessages::MISSING_REQUIRED_PARAMS, [$missingParam, ucfirst($type)]), E_WARNING); + return new self( + _message(ExceptionMessages::MISSING_REQUIRED_PARAMS, [$missingParam, ucfirst($type)]), + E_WARNING + ); } } \ No newline at end of file diff --git a/src/Router/Exceptions/RouteControllerException.php b/src/Router/Exceptions/RouteControllerException.php index d5bb3d845..c8114fae4 100644 --- a/src/Router/Exceptions/RouteControllerException.php +++ b/src/Router/Exceptions/RouteControllerException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Router\Exceptions; @@ -30,17 +30,23 @@ class RouteControllerException extends BaseException * @param string|null $name * @return RouteControllerException */ - public static function controllerNotDefined(?string $name): RouteControllerException + public static function controllerNotDefined(?string $name): self { - return new static(_message(ExceptionMessages::CONTROLLER_NOT_FOUND, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::CONTROLLER_NOT_FOUND, [$name]), + E_ERROR + ); } /** * @param string $name * @return RouteControllerException */ - public static function actionNotDefined(string $name): RouteControllerException + public static function actionNotDefined(string $name): self { - return new static(_message(ExceptionMessages::ACTION_NOT_DEFINED, [$name]), E_ERROR); + return new self( + _message(ExceptionMessages::ACTION_NOT_DEFINED, [$name]), + E_ERROR + ); } } \ No newline at end of file diff --git a/src/Router/Exceptions/RouteException.php b/src/Router/Exceptions/RouteException.php index 0dee8fe1d..77afeb5b4 100644 --- a/src/Router/Exceptions/RouteException.php +++ b/src/Router/Exceptions/RouteException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Router\Exceptions; @@ -28,83 +28,113 @@ class RouteException extends BaseException /** * @return RouteException */ - public static function routeNotFound(): RouteException + public static function routeNotFound(): self { - return new static(ExceptionMessages::ROUTE_NOT_FOUND, E_ERROR); + return new self( + ExceptionMessages::ROUTE_NOT_FOUND, + E_ERROR + ); } /** * @return RouteException */ - public static function notClosure(): RouteException + public static function notClosure(): self { - return new static(ExceptionMessages::ROUTE_NOT_CLOSURE, E_WARNING); + return new self( + ExceptionMessages::ROUTE_NOT_CLOSURE, + E_WARNING + ); } /** * @param string $name * @return RouteException */ - public static function repetitiveRouteSameMethod(string $name): RouteException + public static function repetitiveRouteSameMethod(string $name): self { - return new static(_message(ExceptionMessages::REPETITIVE_ROUTE_WITH_SAME_NAME, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::REPETITIVE_ROUTE_WITH_SAME_NAME, [$name]), + E_WARNING + ); } /** * @return RouteException */ - public static function repetitiveRouteDifferentModules(): RouteException + public static function repetitiveRouteDifferentModules(): self { - return new static(ExceptionMessages::REPETITIVE_ROUTE_IN_DIFFERENT_MODULES, E_WARNING); + return new self( + ExceptionMessages::REPETITIVE_ROUTE_IN_DIFFERENT_MODULES, + E_WARNING + ); } /** * @param string|null $name * @return RouteException */ - public static function incorrectMethod(?string $name): RouteException + public static function incorrectMethod(?string $name): self { - return new static(_message(ExceptionMessages::INCORRECT_METHOD, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::INCORRECT_METHOD, [$name]), + E_WARNING + ); } /** * @return RouteException */ - public static function nameBeforeDefinition(): RouteException + public static function nameBeforeDefinition(): self { - return new static(ExceptionMessages::NAME_BEFORE_ROUTE_DEFINITION, E_WARNING); + return new self( + ExceptionMessages::NAME_BEFORE_ROUTE_DEFINITION, + E_WARNING + ); } /** * @return RouteException */ - public static function nameOnGroup(): RouteException + public static function nameOnGroup(): self { - return new static(ExceptionMessages::NAME_ON_ROUTE_GROUP, E_WARNING); + return new self( + ExceptionMessages::NAME_ON_ROUTE_GROUP, + E_WARNING + ); } /** * @return RouteException */ - public static function nonUniqueName(): RouteException + public static function nonUniqueName(): self { - return new static(ExceptionMessages::NAME_NOT_UNIQUE, E_WARNING); + return new self( + ExceptionMessages::NAME_NOT_UNIQUE, + E_WARNING + ); } /** * @param string $name * @return RouteException */ - public static function paramNameNotAvailable(string $name): RouteException + public static function paramNameNotAvailable(string $name): self { - return new static(_message(ExceptionMessages::ROUTE_PARAM_NAME_IN_USE, [$name]), E_WARNING); + return new self( + _message(ExceptionMessages::ROUTE_PARAM_NAME_IN_USE, [$name]), + E_WARNING + ); } /** * @return RouteException */ - public static function paramNameNotValid(): RouteException + public static function paramNameNotValid(): self { - return new static(ExceptionMessages::INVALID_ROUTE_PARAM_NAME, E_WARNING); + return new self( + ExceptionMessages::INVALID_ROUTE_PARAM_NAME, + E_WARNING + ); } } \ No newline at end of file diff --git a/src/View/Exceptions/ViewException.php b/src/View/Exceptions/ViewException.php index f70c3e5fe..cfde8ff34 100644 --- a/src/View/Exceptions/ViewException.php +++ b/src/View/Exceptions/ViewException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\View\Exceptions; @@ -29,16 +29,22 @@ class ViewException extends BaseException /** * @return ViewException */ - public static function noLayoutSet(): ViewException + public static function noLayoutSet(): self { - return new static(ExceptionMessages::LAYOUT_NOT_SET, E_ERROR); + return new self( + ExceptionMessages::LAYOUT_NOT_SET, + E_ERROR + ); } /** * @return ViewException */ - public static function viewNotRendered(): ViewException + public static function viewNotRendered(): self { - return new static(ExceptionMessages::VIEW_NOT_RENDERED_YET, E_ERROR); + return new self( + ExceptionMessages::VIEW_NOT_RENDERED_YET, + E_ERROR + ); } } From fa5e6c4324b72829009f957337d3b9ea9a59208d Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 7 Jan 2026 14:30:01 +0400 Subject: [PATCH 03/12] Resolve PHPStan level 1 static analysis issues --- src/Environment/Server.php | 4 ++-- .../Encryption/Adapters/SymmetricEncryptionAdapter.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Environment/Server.php b/src/Environment/Server.php index 9fd8d3fe7..b7bfa56d7 100644 --- a/src/Environment/Server.php +++ b/src/Environment/Server.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Environment; @@ -34,7 +34,7 @@ class Server */ private function __construct() { - $this->server = $_SERVER ?? []; + $this->server = $_SERVER; } /** diff --git a/src/Libraries/Encryption/Adapters/SymmetricEncryptionAdapter.php b/src/Libraries/Encryption/Adapters/SymmetricEncryptionAdapter.php index 557a69481..78075172d 100644 --- a/src/Libraries/Encryption/Adapters/SymmetricEncryptionAdapter.php +++ b/src/Libraries/Encryption/Adapters/SymmetricEncryptionAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Encryption\Adapters; @@ -78,7 +78,7 @@ public function decrypt(string $encrypted): string $data = explode('::', base64_decode($encrypted), 2); - if (empty($data) || count($data) < 2) { + if (count($data) < 2) { throw CryptorException::invalidCipher(); } From 47b9e26782c8c40ba1ba8fe11e8bbe85f9e5578e Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 7 Jan 2026 16:32:20 +0400 Subject: [PATCH 04/12] Resolve PHPStan level 2 static analysis issues --- src/Console/Commands/ServeCommand.php | 4 +- src/Console/QtCommand.php | 2 +- src/Debugger/Debugger.php | 4 +- src/Di/Di.php | 8 +++- src/Http/Traits/Response/Header.php | 4 +- src/Libraries/Cache/Adapters/RedisAdapter.php | 9 +--- src/Libraries/Jwt/JwtToken.php | 6 ++- .../Adapters/Local/LocalFileSystemAdapter.php | 47 +++++-------------- .../Contracts/FilesystemAdapterInterface.php | 4 +- src/Libraries/Storage/UploadedFile.php | 17 +++++-- src/Libraries/Validation/Traits/File.php | 4 +- src/Libraries/Validation/Traits/General.php | 4 +- src/Model/Factories/ModelFactory.php | 8 ++-- src/Router/Router.php | 4 +- src/Tracer/ErrorHandler.php | 16 ++++--- 15 files changed, 66 insertions(+), 75 deletions(-) diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index 71963616d..37465ba25 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Console\Commands; @@ -71,7 +71,7 @@ class ServeCommand extends QtCommand /** * Command arguments - * @var \string[][] + * @var string[][] */ protected $options = [ ['host', null, 'optional', 'Host', '127.0.0.1'], diff --git a/src/Console/QtCommand.php b/src/Console/QtCommand.php index a6995b4af..4ae697a68 100644 --- a/src/Console/QtCommand.php +++ b/src/Console/QtCommand.php @@ -67,7 +67,7 @@ abstract class QtCommand extends Command implements CommandInterface protected $input; /** - * @var OutputInterface; + * @var OutputInterface */ protected $output; diff --git a/src/Debugger/Debugger.php b/src/Debugger/Debugger.php index b58640d18..fbe344b9e 100644 --- a/src/Debugger/Debugger.php +++ b/src/Debugger/Debugger.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Debugger; @@ -58,7 +58,7 @@ class Debugger /** * Store - * @var array + * @var DebuggerStore */ private $store; diff --git a/src/Di/Di.php b/src/Di/Di.php index 8b2964451..421c1247c 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Di; @@ -230,7 +230,11 @@ private static function resolveParameters(array $parameters, array &$args = []): */ private static function resolveParameter(ReflectionParameter $param, ?array &$args = []) { - $type = $param->getType() instanceof \ReflectionType ? $param->getType()->getName() : null; + $type = null; + + if ($param->getType() instanceof \ReflectionNamedType) { + $type = $param->getType()->getName(); + } $concrete = self::$dependencies[$type] ?? $type; diff --git a/src/Http/Traits/Response/Header.php b/src/Http/Traits/Response/Header.php index da4408975..b3890e38b 100644 --- a/src/Http/Traits/Response/Header.php +++ b/src/Http/Traits/Response/Header.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Http\Traits\Response; @@ -91,7 +91,7 @@ public static function setContentType(string $contentType) /** * Gets the content type - * @return string|null + * @return string */ public static function getContentType(): string { diff --git a/src/Libraries/Cache/Adapters/RedisAdapter.php b/src/Libraries/Cache/Adapters/RedisAdapter.php index b261c44b8..7a1318838 100644 --- a/src/Libraries/Cache/Adapters/RedisAdapter.php +++ b/src/Libraries/Cache/Adapters/RedisAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Cache\Adapters; @@ -112,15 +112,10 @@ public function set($key, $value, $ttl = null) return $this->redis->set($this->keyHash($key), serialize($value), $this->ttl); } - /** - * - * @throws InvalidArgumentException - */ - /** * @inheritDoc * @throws RedisException - * @throws \Psr\SimpleCache\InvalidArgumentException + * @throws InvalidArgumentException */ public function setMultiple($values, $ttl = null): bool { diff --git a/src/Libraries/Jwt/JwtToken.php b/src/Libraries/Jwt/JwtToken.php index c8d9e2788..ea37a493d 100644 --- a/src/Libraries/Jwt/JwtToken.php +++ b/src/Libraries/Jwt/JwtToken.php @@ -9,12 +9,13 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Jwt; use Quantum\Libraries\Jwt\Exceptions\JwtException; +use Quantum\Environment\Exceptions\EnvException; use Firebase\JWT\JWT; use Firebase\JWT\Key; @@ -51,7 +52,8 @@ class JwtToken extends JWT /** * JwtToken constructor. - * @param mixed $key + * @param string|null $key + * @throws EnvException */ public function __construct(string $key = null) { diff --git a/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php b/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php index af9e8c556..68a5a66f9 100644 --- a/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php +++ b/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php @@ -9,19 +9,19 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage\Adapters\Local; -use Quantum\Libraries\Storage\Contracts\FilesystemAdapterInterface; +use Quantum\Libraries\Storage\Contracts\LocalFilesystemAdapterInterface; use Throwable; /** * Class LocalFileSystemAdapter * @package Quantum\Libraries\Storage */ -class LocalFileSystemAdapter implements FilesystemAdapterInterface +class LocalFileSystemAdapter implements LocalFilesystemAdapterInterface { /** @@ -177,10 +177,7 @@ public function listDirectory(string $dirname) } /** - * Find path names matching a pattern - * @param string $pattern - * @param int $flags - * @return array|false + * @inheritDoc */ public function glob(string $pattern, int $flags = 0) { @@ -188,9 +185,7 @@ public function glob(string $pattern, int $flags = 0) } /** - * Is Readable - * @param string $filename - * @return bool + * @inheritDoc */ public function isReadable(string $filename): bool { @@ -198,9 +193,7 @@ public function isReadable(string $filename): bool } /** - * Is Writable - * @param string $filename - * @return bool + * @inheritDoc */ public function isWritable(string $filename): bool { @@ -208,11 +201,7 @@ public function isWritable(string $filename): bool } /** - * Gets the content between given lines - * @param string $filename - * @param int $offset - * @param int|null $length - * @return array + * @inheritDoc */ public function getLines(string $filename, int $offset = 0, ?int $length = null): array { @@ -230,9 +219,7 @@ public function getLines(string $filename, int $offset = 0, ?int $length = null) } /** - * Gets the filename with extension - * @param string $path - * @return string + * @inheritDoc */ public function fileNameWithExtension(string $path): string { @@ -240,9 +227,7 @@ public function fileNameWithExtension(string $path): string } /** - * Gets the file name - * @param string $path - * @return string + * @inheritDoc */ public function fileName(string $path): string { @@ -250,9 +235,7 @@ public function fileName(string $path): string } /** - * Gets the file extension - * @param string $path - * @return string + * @inheritDoc */ public function extension(string $path): string { @@ -260,10 +243,7 @@ public function extension(string $path): string } /** - * Includes the required file - * @param string $file - * @param bool $once - * @return mixed + * @inheritDoc */ public function require(string $file, bool $once = false) { @@ -275,10 +255,7 @@ public function require(string $file, bool $once = false) } /** - * Includes a file - * @param string $file - * @param bool $once - * @return mixed + * @inheritDoc */ public function include(string $file, bool $once = false) { diff --git a/src/Libraries/Storage/Contracts/FilesystemAdapterInterface.php b/src/Libraries/Storage/Contracts/FilesystemAdapterInterface.php index 8e6f986b7..0047e280a 100644 --- a/src/Libraries/Storage/Contracts/FilesystemAdapterInterface.php +++ b/src/Libraries/Storage/Contracts/FilesystemAdapterInterface.php @@ -9,13 +9,13 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage\Contracts; /** - * Interface StorageInterface + * Interface FilesystemAdapterInterface * @package Quantum\Libraries\Storage */ interface FilesystemAdapterInterface diff --git a/src/Libraries/Storage/UploadedFile.php b/src/Libraries/Storage/UploadedFile.php index e160aba4b..d0300d33a 100644 --- a/src/Libraries/Storage/UploadedFile.php +++ b/src/Libraries/Storage/UploadedFile.php @@ -9,15 +9,15 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage; +use Quantum\Libraries\Storage\Contracts\LocalFilesystemAdapterInterface; use Quantum\Libraries\Storage\Contracts\FilesystemAdapterInterface; use Quantum\Libraries\Storage\Exceptions\FileSystemException; use Quantum\Libraries\Storage\Exceptions\FileUploadException; -use Quantum\Libraries\Storage\Factories\FileSystemFactory; use Quantum\Libraries\Lang\Exceptions\LangException; use Quantum\Environment\Exceptions\EnvException; use Quantum\Config\Exceptions\ConfigException; @@ -41,7 +41,7 @@ class UploadedFile extends SplFileInfo /** * Local File System - * @var FilesystemAdapterInterface + * @var LocalFilesystemAdapterInterface */ protected $localFileSystem; @@ -126,7 +126,16 @@ class UploadedFile extends SplFileInfo */ public function __construct(array $meta) { - $this->localFileSystem = FileSystemFactory::get(); + $adapter = fs()->getAdapter(); + + if (!$adapter instanceof LocalFilesystemAdapterInterface) { + throw FileSystemException::methodNotSupported( + 'local filesystem operations', + get_class($adapter) + ); + } + + $this->localFileSystem = $adapter; $this->originalName = $meta['name']; $this->errorCode = $meta['error']; diff --git a/src/Libraries/Validation/Traits/File.php b/src/Libraries/Validation/Traits/File.php index 2122d412c..e2c5d7ca8 100644 --- a/src/Libraries/Validation/Traits/File.php +++ b/src/Libraries/Validation/Traits/File.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Libraries\Validation\Traits; @@ -27,7 +27,7 @@ trait File /** * Validates file size * @param UploadedFile $file - * @param int|null $maxSize + * @param int $maxSize * @param int|null $minSize * @return bool */ diff --git a/src/Libraries/Validation/Traits/General.php b/src/Libraries/Validation/Traits/General.php index bd1d9e9f6..5f1ac11b0 100644 --- a/src/Libraries/Validation/Traits/General.php +++ b/src/Libraries/Validation/Traits/General.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Libraries\Validation\Traits; @@ -68,7 +68,7 @@ protected function creditCard(string $value): bool $total = 0; for ($i = 0; $i < $length; ++$i) { - $digit = $number[$i]; + $digit = (int) $number[$i]; if ($i % 2 === $parity) { $digit *= 2; diff --git a/src/Model/Factories/ModelFactory.php b/src/Model/Factories/ModelFactory.php index 5c06f2e39..5b8ae8d9d 100644 --- a/src/Model/Factories/ModelFactory.php +++ b/src/Model/Factories/ModelFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Model\Factories; @@ -63,7 +63,7 @@ public static function get(string $modelClass): QtModel * Creates anonymous dynamic model * @param string $table * @param string $modelName - * @param string|null $idColumn + * @param string $idColumn * @param array $foreignKeys * @param array $hidden * @return QtModel @@ -87,11 +87,11 @@ public static function createDynamicModel( /** * @param string $table - * @param string|null $modelName + * @param string $modelName * @param string $idColumn * @param array $foreignKeys * @param array $hidden - * @return mixed + * @return DbalInterface */ protected static function createOrmInstance( string $table, diff --git a/src/Router/Router.php b/src/Router/Router.php index 8ec103f38..93845f020 100644 --- a/src/Router/Router.php +++ b/src/Router/Router.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Router; @@ -45,7 +45,7 @@ class Router extends RouteController /** * Request instance - * @var Request; + * @var Request */ private $request; diff --git a/src/Tracer/ErrorHandler.php b/src/Tracer/ErrorHandler.php index e8a5c9822..7eac61799 100644 --- a/src/Tracer/ErrorHandler.php +++ b/src/Tracer/ErrorHandler.php @@ -9,12 +9,12 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Tracer; -use Quantum\Libraries\Storage\Factories\FileSystemFactory; +use Quantum\Libraries\Storage\Contracts\LocalFilesystemAdapterInterface; use Symfony\Component\Console\Output\ConsoleOutput; use Quantum\Renderer\Exceptions\RendererException; use Quantum\Config\Exceptions\ConfigException; @@ -42,7 +42,7 @@ class ErrorHandler const NUM_LINES = 10; /** - * @var string[][] + * @var array */ const ERROR_TYPES = [ E_ERROR => 'error', @@ -235,13 +235,17 @@ private function composeStackTrace(Throwable $e): array */ private function getSourceCode(string $filename, int $lineNumber, string $className): string { - $fs = FileSystemFactory::get(); - $lineNumber--; $start = max($lineNumber - floor(self::NUM_LINES / 2), 1); - $lines = $fs->getLines($filename, $start, self::NUM_LINES); + $adapter = fs()->getAdapter(); + + if (!$adapter instanceof LocalFilesystemAdapterInterface) { + return ''; + } + + $lines = $adapter->getLines($filename, $start, self::NUM_LINES); $code = '
    '; From f4214b77deba11d5af693e9673fd23d68f93bf10 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 11:56:26 +0400 Subject: [PATCH 05/12] Resolve PHPStan level 3 static analysis issues --- phpstan.neon.dist | 10 ++- src/App/Exceptions/BaseException.php | 65 ++++++++------ src/Console/Commands/RouteListCommand.php | 4 +- src/Console/Commands/ServeCommand.php | 2 +- src/Di/Di.php | 4 +- src/Http/Traits/Request/File.php | 4 +- src/Http/Traits/Request/Query.php | 4 +- src/Http/Traits/Request/RawInput.php | 6 +- src/Http/Traits/Request/Url.php | 10 +-- .../Archive/Adapters/PharAdapter.php | 4 +- src/Libraries/Auth/Factories/AuthFactory.php | 4 +- src/Libraries/Auth/Traits/AuthTrait.php | 6 +- .../Cache/Factories/CacheFactory.php | 4 +- .../Captcha/Factories/CaptchaFactory.php | 4 +- .../Database/Adapters/Idiorm/IdiormDbal.php | 6 +- .../Database/Adapters/Idiorm/IdiormPatch.php | 4 +- .../Adapters/Idiorm/Statements/Join.php | 12 ++- .../Database/Adapters/Sleekdb/SleekDbal.php | 6 +- .../Logger/Factories/LoggerFactory.php | 4 +- .../Mailer/Factories/MailerFactory.php | 4 +- src/Libraries/Mailer/Traits/MailerTrait.php | 6 +- .../Adapters/Database/DatabaseHandler.php | 14 ++- .../Session/Factories/SessionFactory.php | 4 +- .../LocalFilesystemAdapterInterface.php | 90 +++++++++++++++++++ src/Renderer/Factories/RendererFactory.php | 4 +- src/Router/Route.php | 4 +- src/Router/RouteController.php | 4 +- src/Router/Router.php | 2 +- 28 files changed, 205 insertions(+), 90 deletions(-) create mode 100644 src/Libraries/Storage/Contracts/LocalFilesystemAdapterInterface.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 2017bafb2..11c1374fa 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,8 +1,12 @@ parameters: phpVersion: 70400 + level: 3 + paths: + - src - level: 0 + checkNullables: true + checkUninitializedProperties: true - paths: - - src \ No newline at end of file + checkDynamicProperties: false + treatPhpDocTypesAsCertain: false \ No newline at end of file diff --git a/src/App/Exceptions/BaseException.php b/src/App/Exceptions/BaseException.php index 6d161aeb0..94cf36cff 100644 --- a/src/App/Exceptions/BaseException.php +++ b/src/App/Exceptions/BaseException.php @@ -23,17 +23,26 @@ * Class BaseException * @package Quantum\App */ -class BaseException extends Exception +abstract class BaseException extends Exception { + /** + * @param string $message + * @param int $code + */ + final public function __construct(string $message = "", int $code = 0) + { + parent::__construct($message, $code); + } + /** * @param string $methodName * @param string $className - * @return self + * @return static */ - public static function methodNotSupported(string $methodName, string $className): self + public static function methodNotSupported(string $methodName, string $className) { - return new self( + return new static( _message(ExceptionMessages::METHOD_NOT_SUPPORTED, [$methodName, $className]), E_WARNING ); @@ -41,11 +50,11 @@ public static function methodNotSupported(string $methodName, string $className) /** * @param string $name - * @return self + * @return static */ - public static function adapterNotSupported(string $name): self + public static function adapterNotSupported(string $name) { - return new self( + return new static( _message(ExceptionMessages::ADAPTER_NOT_SUPPORTED, [$name]), E_ERROR ); @@ -53,11 +62,11 @@ public static function adapterNotSupported(string $name): self /** * @param string $name - * @return self + * @return static */ - public static function driverNotSupported(string $name): self + public static function driverNotSupported(string $name) { - return new self( + return new static( _message(ExceptionMessages::DRIVER_NOT_SUPPORTED, [$name]), E_ERROR ); @@ -65,11 +74,11 @@ public static function driverNotSupported(string $name): self /** * @param string $name - * @return self + * @return static */ - public static function fileNotFound(string $name): self + public static function fileNotFound(string $name) { - return new self( + return new static( _message(ExceptionMessages::FILE_NOT_FOUND, [$name]), E_ERROR ); @@ -78,11 +87,11 @@ public static function fileNotFound(string $name): self /** * @param string $subject * @param string $name - * @return self + * @return static */ - public static function notFound(string $subject, string $name): self + public static function notFound(string $subject, string $name) { - return new self( + return new static( _message(ExceptionMessages::NOT_FOUND, [$subject, $name]), E_ERROR ); @@ -91,11 +100,11 @@ public static function notFound(string $subject, string $name): self /** * @param string $instance * @param string $name - * @return self + * @return static */ - public static function notInstanceOf(string $instance, string $name): self + public static function notInstanceOf(string $instance, string $name) { - return new self( + return new static( _message(ExceptionMessages::NOT_INSTANCE_OF, [$instance, $name]), E_ERROR ); @@ -103,11 +112,11 @@ public static function notInstanceOf(string $instance, string $name): self /** * @param string $name - * @return self + * @return static */ - public static function cantConnect(string $name): self + public static function cantConnect(string $name) { - return new self( + return new static( _message(ExceptionMessages::CANT_CONNECT, [$name]), E_ERROR ); @@ -115,12 +124,12 @@ public static function cantConnect(string $name): self /** * @param string $name - * @return self + * @return static */ - public static function missingConfig(string $name): self + public static function missingConfig(string $name) { - return new self( + return new static( _message(ExceptionMessages::MISSING_CONFIG, $name), E_ERROR ); @@ -128,11 +137,11 @@ public static function missingConfig(string $name): self /** * @param string $name - * @return self + * @return static */ - public static function requestMethodNotAvailable(string $name): self + public static function requestMethodNotAvailable(string $name) { - return new self( + return new static( _message(ExceptionMessages::UNAVAILABLE_REQUEST_METHOD, [$name]), E_WARNING ); diff --git a/src/Console/Commands/RouteListCommand.php b/src/Console/Commands/RouteListCommand.php index f48fe9d25..f1f015f13 100644 --- a/src/Console/Commands/RouteListCommand.php +++ b/src/Console/Commands/RouteListCommand.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Console\Commands; @@ -41,7 +41,7 @@ class RouteListCommand extends QtCommand /** * Command options - * @var string + * @var array> */ protected $options = [ ['module', 'm', 'optional', 'Filter by module name'], diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index 37465ba25..cd3ac950b 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -71,7 +71,7 @@ class ServeCommand extends QtCommand /** * Command arguments - * @var string[][] + * @var array> */ protected $options = [ ['host', null, 'optional', 'Host', '127.0.0.1'], diff --git a/src/Di/Di.php b/src/Di/Di.php index 421c1247c..9efa89d9a 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -223,12 +223,12 @@ private static function resolveParameters(array $parameters, array &$args = []): /** * Resolves the parameter * @param ReflectionParameter $param - * @param array|null $args + * @param array $args * @return array|mixed|null * @throws DiException * @throws ReflectionException */ - private static function resolveParameter(ReflectionParameter $param, ?array &$args = []) + private static function resolveParameter(ReflectionParameter $param, array &$args = []) { $type = null; diff --git a/src/Http/Traits/Request/File.php b/src/Http/Traits/Request/File.php index b9f95183b..4ecb02193 100644 --- a/src/Http/Traits/Request/File.php +++ b/src/Http/Traits/Request/File.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Http\Traits\Request; @@ -77,7 +77,7 @@ public static function getFile(string $key) /** * Handle files * @param array $files - * @return array|UploadedFile[] + * @return array> * @throws BaseException * @throws ReflectionException */ diff --git a/src/Http/Traits/Request/Query.php b/src/Http/Traits/Request/Query.php index 4c49317a9..17245fc7a 100644 --- a/src/Http/Traits/Request/Query.php +++ b/src/Http/Traits/Request/Query.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Http\Traits\Request; @@ -23,7 +23,7 @@ trait Query /** * Query string - * @var string + * @var string|null */ private static $__query = null; diff --git a/src/Http/Traits/Request/RawInput.php b/src/Http/Traits/Request/RawInput.php index 91d398ee7..5a79b4a8e 100644 --- a/src/Http/Traits/Request/RawInput.php +++ b/src/Http/Traits/Request/RawInput.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Http\Traits\Request; @@ -223,7 +223,7 @@ private static function getParsedFile(string $block): ?array /** * Parses a file block into metadata and binary content * @param string $block - * @return array{name: string, filename: string, contentType: string, content: string} + * @return array{string, string, string, string} */ private static function parseFileData(string $block): array { @@ -274,7 +274,7 @@ private static function getParsedParameter(string $block): array /** * Extracts name, filename, and content type from header lines * @param string $rawHeaders - * @return array{name: string, filename: string, contentType: string} + * @return array{string, string, string} */ private static function parseHeaders(string $rawHeaders): array { diff --git a/src/Http/Traits/Request/Url.php b/src/Http/Traits/Request/Url.php index 494b5ad54..6090c7a4a 100644 --- a/src/Http/Traits/Request/Url.php +++ b/src/Http/Traits/Request/Url.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Http\Traits\Request; @@ -23,25 +23,25 @@ trait Url /** * Scheme - * @var string + * @var string|null */ private static $__protocol = null; /** * Host name - * @var string + * @var string|null */ private static $__host = null; /** * Server port - * @var string + * @var string|null */ private static $__port = null; /** * Request URI - * @var string + * @var string|null */ private static $__uri = null; diff --git a/src/Libraries/Archive/Adapters/PharAdapter.php b/src/Libraries/Archive/Adapters/PharAdapter.php index ddba1548c..0e66db2bb 100644 --- a/src/Libraries/Archive/Adapters/PharAdapter.php +++ b/src/Libraries/Archive/Adapters/PharAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Archive\Adapters; @@ -40,7 +40,7 @@ class PharAdapter implements ArchiveInterface private $archiveName; /** - * @var Phar + * @var Phar|null */ private $archive = null; diff --git a/src/Libraries/Auth/Factories/AuthFactory.php b/src/Libraries/Auth/Factories/AuthFactory.php index 6ef3e7112..64f8d20d6 100644 --- a/src/Libraries/Auth/Factories/AuthFactory.php +++ b/src/Libraries/Auth/Factories/AuthFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Auth\Factories; @@ -45,7 +45,7 @@ class AuthFactory ]; /** - * @var Auth|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Auth/Traits/AuthTrait.php b/src/Libraries/Auth/Traits/AuthTrait.php index 1885edfc9..2abcc3ca4 100644 --- a/src/Libraries/Auth/Traits/AuthTrait.php +++ b/src/Libraries/Auth/Traits/AuthTrait.php @@ -9,19 +9,19 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Auth\Traits; use Quantum\Libraries\Auth\Contracts\AuthServiceInterface; -use Quantum\Libraries\Mailer\Contracts\MailerInterface; use Quantum\Libraries\Auth\Exceptions\AuthException; use Quantum\Libraries\Jwt\Exceptions\JwtException; use Quantum\Config\Exceptions\ConfigException; use Quantum\Libraries\Auth\Enums\AuthKeys; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Libraries\Mailer\Mailer; use Quantum\Libraries\Hasher\Hasher; use Quantum\Libraries\Jwt\JwtToken; use Quantum\Libraries\Auth\User; @@ -39,7 +39,7 @@ trait AuthTrait { /** - * @var MailerInterface + * @var Mailer */ protected $mailer; diff --git a/src/Libraries/Cache/Factories/CacheFactory.php b/src/Libraries/Cache/Factories/CacheFactory.php index 6ada22e94..0752d8185 100644 --- a/src/Libraries/Cache/Factories/CacheFactory.php +++ b/src/Libraries/Cache/Factories/CacheFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Cache\Factories; @@ -44,7 +44,7 @@ class CacheFactory ]; /** - * @var Cache|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Captcha/Factories/CaptchaFactory.php b/src/Libraries/Captcha/Factories/CaptchaFactory.php index 1512cff61..a363222f2 100644 --- a/src/Libraries/Captcha/Factories/CaptchaFactory.php +++ b/src/Libraries/Captcha/Factories/CaptchaFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Captcha\Factories; @@ -41,7 +41,7 @@ class CaptchaFactory ]; /** - * @var Captcha|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Database/Adapters/Idiorm/IdiormDbal.php b/src/Libraries/Database/Adapters/Idiorm/IdiormDbal.php index 390bfcc43..bfc377206 100644 --- a/src/Libraries/Database/Adapters/Idiorm/IdiormDbal.php +++ b/src/Libraries/Database/Adapters/Idiorm/IdiormDbal.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Adapters\Idiorm; @@ -102,7 +102,7 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * ORM Model - * @var object + * @var ORM|null */ private $ormModel; @@ -114,7 +114,7 @@ class IdiormDbal implements DbalInterface, RelationalInterface /** * Operators map - * @var string[] + * @var array */ private $operators = [ '=' => 'where_equal', diff --git a/src/Libraries/Database/Adapters/Idiorm/IdiormPatch.php b/src/Libraries/Database/Adapters/Idiorm/IdiormPatch.php index d6af1f95b..329b7282b 100644 --- a/src/Libraries/Database/Adapters/Idiorm/IdiormPatch.php +++ b/src/Libraries/Database/Adapters/Idiorm/IdiormPatch.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.8.0 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Adapters\Idiorm; @@ -35,7 +35,7 @@ class IdiormPatch extends ORM /** * Get Instance - * @return IdiormPatch|object|null + * @return IdiormPatch|object */ public static function getInstance() { diff --git a/src/Libraries/Database/Adapters/Idiorm/Statements/Join.php b/src/Libraries/Database/Adapters/Idiorm/Statements/Join.php index 0835c5ed1..c94df2d65 100644 --- a/src/Libraries/Database/Adapters/Idiorm/Statements/Join.php +++ b/src/Libraries/Database/Adapters/Idiorm/Statements/Join.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Adapters\Idiorm\Statements; @@ -54,7 +54,10 @@ public function innerJoin(string $table, array $constraint, ?string $tableAlias */ public function leftJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface { - IdiormPatch::getInstance()->use($this->getOrmModel())->leftJoin($table, $constraint, $tableAlias); + IdiormPatch::getInstance() + ->use($this->getOrmModel()) + ->leftJoin($table, $constraint, $tableAlias); + return $this; } @@ -64,7 +67,10 @@ public function leftJoin(string $table, array $constraint, ?string $tableAlias = */ public function rightJoin(string $table, array $constraint, ?string $tableAlias = null): DbalInterface { - IdiormPatch::getInstance()->use($this->getOrmModel())->rightJoin($table, $constraint, $tableAlias); + IdiormPatch::getInstance() + ->use($this->getOrmModel()) + ->rightJoin($table, $constraint, $tableAlias); + return $this; } diff --git a/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php b/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php index 65191a5f8..bdfc81417 100644 --- a/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php +++ b/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Adapters\Sleekdb; @@ -83,12 +83,12 @@ class SleekDbal implements DbalInterface protected $ordered = []; /** - * @var int + * @var int|null */ protected $offset; /** - * @var int + * @var int|null */ protected $limit; diff --git a/src/Libraries/Logger/Factories/LoggerFactory.php b/src/Libraries/Logger/Factories/LoggerFactory.php index 9c7cc1b45..634716879 100644 --- a/src/Libraries/Logger/Factories/LoggerFactory.php +++ b/src/Libraries/Logger/Factories/LoggerFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Logger\Factories; @@ -43,7 +43,7 @@ class LoggerFactory ]; /** - * @var Logger|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Mailer/Factories/MailerFactory.php b/src/Libraries/Mailer/Factories/MailerFactory.php index dc78f505c..f57850cbd 100644 --- a/src/Libraries/Mailer/Factories/MailerFactory.php +++ b/src/Libraries/Mailer/Factories/MailerFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Mailer\Factories; @@ -46,7 +46,7 @@ class MailerFactory ]; /** - * @var Mailer|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Mailer/Traits/MailerTrait.php b/src/Libraries/Mailer/Traits/MailerTrait.php index 1bdb466ca..44f186955 100644 --- a/src/Libraries/Mailer/Traits/MailerTrait.php +++ b/src/Libraries/Mailer/Traits/MailerTrait.php @@ -44,13 +44,13 @@ trait MailerTrait /** * Email subject - * @var string + * @var string|null */ private $subject = null; /** * Email body - * @var string|array + * @var string|array|null */ private $message = null; @@ -61,7 +61,7 @@ trait MailerTrait /** * Template path - * @var string + * @var string|null */ private $templatePath = null; diff --git a/src/Libraries/Session/Adapters/Database/DatabaseHandler.php b/src/Libraries/Session/Adapters/Database/DatabaseHandler.php index e206da6f6..ba52d0b1e 100644 --- a/src/Libraries/Session/Adapters/Database/DatabaseHandler.php +++ b/src/Libraries/Session/Adapters/Database/DatabaseHandler.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Session\Adapters\Database; @@ -96,10 +96,16 @@ public function destroy($id): bool /** * @inheritDoc */ - #[\ReturnTypeWillChange] - public function gc($max_lifetime): bool + public function gc($max_lifetime) { $old = time() - $max_lifetime; - return $this->sessionModel->criteria('ttl', '<', $old)->deleteMany(); + + $result = $this->sessionModel->criteria('ttl', '<', $old)->deleteMany(); + + if ($result === false) { + return false; + } + + return 0; } } \ No newline at end of file diff --git a/src/Libraries/Session/Factories/SessionFactory.php b/src/Libraries/Session/Factories/SessionFactory.php index 14424ac3a..569226fef 100644 --- a/src/Libraries/Session/Factories/SessionFactory.php +++ b/src/Libraries/Session/Factories/SessionFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Libraries\Session\Factories; @@ -40,7 +40,7 @@ class SessionFactory ]; /** - * @var Session|null + * @var array */ private static $instances = []; diff --git a/src/Libraries/Storage/Contracts/LocalFilesystemAdapterInterface.php b/src/Libraries/Storage/Contracts/LocalFilesystemAdapterInterface.php new file mode 100644 index 000000000..f19839c42 --- /dev/null +++ b/src/Libraries/Storage/Contracts/LocalFilesystemAdapterInterface.php @@ -0,0 +1,90 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Libraries\Storage\Contracts; + +/** + * Interface LocalFilesystemAdapterInterface + * @package Quantum\Libraries\Storage + */ +interface LocalFilesystemAdapterInterface extends FilesystemAdapterInterface +{ + /** + * Find path names matching a pattern + * @param string $pattern + * @param int $flags + * @return array|false + */ + public function glob(string $pattern, int $flags = 0); + + /** + * Is Readable + * @param string $filename + * @return bool + */ + public function isReadable(string $filename): bool; + + /** + * Is Writable + * @param string $filename + * @return bool + */ + public function isWritable(string $filename): bool; + + /** + * Gets the content between given lines + * @param string $filename + * @param int $offset + * @param int|null $length + * @return array + */ + public function getLines(string $filename, int $offset = 0, ?int $length = null): array; + + /** + * Gets the filename with extension + * @param string $path + * @return string + */ + public function fileNameWithExtension(string $path): string; + + /** + * Gets the file name + * @param string $path + * @return string + */ + public function fileName(string $path): string; + + /** + * Gets the file extension + * @param string $path + * @return string + */ + public function extension(string $path): string; + + /** + * Includes the required file + * @param string $file + * @param bool $once + * @return mixed + */ + public function require(string $file, bool $once = false); + + /** + * Includes a file + * @param string $file + * @param bool $once + * @return mixed + */ + public function include(string $file, bool $once = false); +} \ No newline at end of file diff --git a/src/Renderer/Factories/RendererFactory.php b/src/Renderer/Factories/RendererFactory.php index e118eae1e..b9b9a1a97 100644 --- a/src/Renderer/Factories/RendererFactory.php +++ b/src/Renderer/Factories/RendererFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Renderer\Factories; @@ -40,7 +40,7 @@ class RendererFactory ]; /** - * @var Renderer|null + * @var array */ private static $instances = []; diff --git a/src/Router/Route.php b/src/Router/Route.php index d069e4abd..d4b92ff2e 100644 --- a/src/Router/Route.php +++ b/src/Router/Route.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.7 + * @since 3.0.0 */ namespace Quantum\Router; @@ -54,7 +54,7 @@ class Route /** * Current group name - * @var string + * @var string|null */ private $currentGroupName = null; diff --git a/src/Router/RouteController.php b/src/Router/RouteController.php index bb966234c..ad7a0f665 100644 --- a/src/Router/RouteController.php +++ b/src/Router/RouteController.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Router; @@ -33,7 +33,7 @@ abstract class RouteController * Contains current route information * @var array */ - protected static $currentRoute = null; + protected static $currentRoute = []; /** * @var bool diff --git a/src/Router/Router.php b/src/Router/Router.php index 93845f020..b83e5f94b 100644 --- a/src/Router/Router.php +++ b/src/Router/Router.php @@ -112,7 +112,7 @@ public function findRoute() */ public function resetRoutes() { - parent::$currentRoute = null; + parent::$currentRoute = []; $this->matchedRoutes = []; } From c70982518e0593484d1059243b36fe62cdaabf85 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 13:14:14 +0400 Subject: [PATCH 06/12] Fix environment loading on Windows and ensure envContent is initialized --- src/Environment/Environment.php | 4 ++++ tests/Unit/AppTestCase.php | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Environment/Environment.php b/src/Environment/Environment.php index d52449c9e..30e99b1b3 100644 --- a/src/Environment/Environment.php +++ b/src/Environment/Environment.php @@ -137,6 +137,10 @@ public function getValue(string $key, $default = null) throw EnvException::environmentNotLoaded(); } + if (array_key_exists($key, $this->envContent)) { + return $this->envContent[$key]; + } + $val = getenv($key); return $val !== false ? $val : $default; diff --git a/tests/Unit/AppTestCase.php b/tests/Unit/AppTestCase.php index e9d28ecb1..54e1e8dd1 100644 --- a/tests/Unit/AppTestCase.php +++ b/tests/Unit/AppTestCase.php @@ -20,10 +20,6 @@ abstract class AppTestCase extends TestCase public function setUp(): void { - if (!file_exists(PROJECT_ROOT . DS . '.env.testing')) { - createEnvFile(); - } - AppFactory::create(App::WEB, PROJECT_ROOT); Environment::getInstance() From 50fcf4068493a6e5cee6549948e62926c648eccf Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 14:26:31 +0400 Subject: [PATCH 07/12] Resolve PHPStan level 4 static analysis issues --- phpstan.neon.dist | 6 +++- src/App/Helpers/misc.php | 11 +++--- src/Di/Di.php | 2 +- src/Libraries/Asset/Helpers/asset.php | 6 ++-- .../Captcha/Adapters/RecaptchaAdapter.php | 7 +--- .../Adapters/Idiorm/Statements/Query.php | 36 +++++++++++++------ .../Database/Factories/TableFactory.php | 6 ++-- .../Mailer/Adapters/MailgunAdapter.php | 5 --- .../Mailer/Adapters/MandrillAdapter.php | 10 ------ .../Mailer/Adapters/SendgridAdapter.php | 5 --- .../Mailer/Adapters/SendinblueAdapter.php | 5 --- src/Libraries/Mailer/Adapters/SmtpAdapter.php | 5 --- src/Libraries/Session/Traits/SessionTrait.php | 6 ++-- src/Libraries/Validation/Validator.php | 12 +++++-- src/Model/Factories/ModelFactory.php | 2 +- src/Router/RouteDispatcher.php | 6 ++-- src/View/Helpers/view.php | 6 ++-- 17 files changed, 64 insertions(+), 72 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 11c1374fa..51cefdb51 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,10 +1,14 @@ parameters: phpVersion: 70400 - level: 3 + level: 4 paths: - src + ignoreErrors: + - identifier: trait.unused + path: src/Model/Traits + checkNullables: true checkUninitializedProperties: true diff --git a/src/App/Helpers/misc.php b/src/App/Helpers/misc.php index d61dd331b..5dcddba9b 100644 --- a/src/App/Helpers/misc.php +++ b/src/App/Helpers/misc.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ use Symfony\Component\VarExporter\Exception\ExceptionInterface; @@ -111,10 +111,13 @@ function get_caller_class(int $index = 2): ?string */ function get_caller_function(int $index = 2): ?string { - $caller = debug_backtrace(); - $caller = $caller[$index]; + $trace = debug_backtrace(); + + if (!isset($trace[$index])) { + return null; + } - return $caller['function'] ?? null; + return $trace[$index]['function']; } /** diff --git a/src/Di/Di.php b/src/Di/Di.php index 9efa89d9a..d8b976703 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -246,7 +246,7 @@ private static function resolveParameter(ReflectionParameter $param, array &$arg return $args; } - if ($args !== null && $args !== []) { + if ($args !== []) { return array_shift($args); } diff --git a/src/Libraries/Asset/Helpers/asset.php b/src/Libraries/Asset/Helpers/asset.php index 8d361b650..095187253 100644 --- a/src/Libraries/Asset/Helpers/asset.php +++ b/src/Libraries/Asset/Helpers/asset.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ use Quantum\Libraries\Asset\Exceptions\AssetException; @@ -18,9 +18,9 @@ /** * Gets the AssetFactory instance - * @return AssetManager|null + * @return AssetManager */ -function asset(): ?AssetManager +function asset(): AssetManager { return AssetManager::getInstance(); } diff --git a/src/Libraries/Captcha/Adapters/RecaptchaAdapter.php b/src/Libraries/Captcha/Adapters/RecaptchaAdapter.php index b2c419c70..9f0aac7de 100644 --- a/src/Libraries/Captcha/Adapters/RecaptchaAdapter.php +++ b/src/Libraries/Captcha/Adapters/RecaptchaAdapter.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Captcha\Adapters; @@ -41,11 +41,6 @@ class RecaptchaAdapter implements CaptchaInterface */ protected $elementClasses = ['g-recaptcha']; - /** - * @var RecaptchaAdapter - */ - private static $instance = null; - /** * RecaptchaAdapter constructor * @param array $params diff --git a/src/Libraries/Database/Adapters/Idiorm/Statements/Query.php b/src/Libraries/Database/Adapters/Idiorm/Statements/Query.php index 8664557aa..9e48f9dcd 100644 --- a/src/Libraries/Database/Adapters/Idiorm/Statements/Query.php +++ b/src/Libraries/Database/Adapters/Idiorm/Statements/Query.php @@ -9,13 +9,13 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Adapters\Idiorm\Statements; use Quantum\Libraries\Database\Exceptions\DatabaseException; -use Quantum\App\Exceptions\BaseException; +use PDOException; /** * Trait Query @@ -26,7 +26,7 @@ trait Query /** * @inheritDoc - * @throws BaseException + * @throws DatabaseException */ public static function execute(string $query, array $parameters = []): bool { @@ -34,12 +34,19 @@ public static function execute(string $query, array $parameters = []): bool throw DatabaseException::missingConfig('database'); } - return (self::$ormClass)::raw_execute($query, $parameters); + try { + return (self::$ormClass)::raw_execute($query, $parameters); + } catch (PDOException $e) { + throw new DatabaseException( + $e->getMessage(), + (int) $e->getCode(), + ); + } } /** * @inheritDoc - * @throws BaseException + * @throws DatabaseException */ public static function query(string $query, array $parameters = []): array { @@ -47,12 +54,21 @@ public static function query(string $query, array $parameters = []): array throw DatabaseException::missingConfig('database'); } - return (self::$ormClass)::for_table('dummy')->raw_query($query, $parameters)->find_array(); + try { + return (self::$ormClass)::for_table('dummy') + ->raw_query($query, $parameters) + ->find_array(); + } catch (PDOException $e) { + throw new DatabaseException( + $e->getMessage(), + (int) $e->getCode(), + ); + } } /** * @inheritDoc - * @throws BaseException + * @throws DatabaseException */ public static function lastQuery(): ?string { @@ -65,7 +81,7 @@ public static function lastQuery(): ?string /** * @inheritDoc - * @throws BaseException + * @throws DatabaseException */ public static function lastStatement(): object { @@ -78,7 +94,7 @@ public static function lastStatement(): object /** * @inheritDoc - * @throws BaseException + * @throws DatabaseException */ public static function queryLog(): array { @@ -93,7 +109,7 @@ public static function queryLog(): array * Fetches columns of the table * @param string $table * @return array - * @throws BaseException + * @throws DatabaseException */ public static function fetchColumns(string $table): array { diff --git a/src/Libraries/Database/Factories/TableFactory.php b/src/Libraries/Database/Factories/TableFactory.php index 0a2b7495f..3ff30f206 100644 --- a/src/Libraries/Database/Factories/TableFactory.php +++ b/src/Libraries/Database/Factories/TableFactory.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Database\Factories; @@ -17,7 +17,6 @@ use Quantum\Libraries\Database\Exceptions\DatabaseException; use Quantum\Libraries\Database\Schemas\Table; use Quantum\Libraries\Database\Database; -use PDOException; /** * Class TableFactory @@ -93,13 +92,12 @@ public function drop(string $name): bool * Checks if the DB table exists * @param string $name * @return bool - * @throws DatabaseException */ public function checkTableExists(string $name): bool { try { Database::query('SELECT 1 FROM ' . $name); - } catch (PDOException $e) { + } catch (DatabaseException $e) { return false; } diff --git a/src/Libraries/Mailer/Adapters/MailgunAdapter.php b/src/Libraries/Mailer/Adapters/MailgunAdapter.php index 6f9da612a..028f8c96e 100644 --- a/src/Libraries/Mailer/Adapters/MailgunAdapter.php +++ b/src/Libraries/Mailer/Adapters/MailgunAdapter.php @@ -53,11 +53,6 @@ class MailgunAdapter implements MailerInterface */ private $data = []; - /** - * @var MailgunAdapter|null - */ - private static $instance = null; - /** * MailgunAdapter constructor * @param array $params diff --git a/src/Libraries/Mailer/Adapters/MandrillAdapter.php b/src/Libraries/Mailer/Adapters/MandrillAdapter.php index cd54d1243..2b9ae326b 100644 --- a/src/Libraries/Mailer/Adapters/MandrillAdapter.php +++ b/src/Libraries/Mailer/Adapters/MandrillAdapter.php @@ -38,11 +38,6 @@ class MandrillAdapter implements MailerInterface */ protected $httpClient; - /** - * @var string - */ - private $apiKey; - /** * @var string */ @@ -53,11 +48,6 @@ class MandrillAdapter implements MailerInterface */ private $data = []; - /** - * @var MandrillAdapter|null - */ - private static $instance = null; - /** * MandrillAdapter constructor * @param array $params diff --git a/src/Libraries/Mailer/Adapters/SendgridAdapter.php b/src/Libraries/Mailer/Adapters/SendgridAdapter.php index 34946fc56..e2fc13163 100644 --- a/src/Libraries/Mailer/Adapters/SendgridAdapter.php +++ b/src/Libraries/Mailer/Adapters/SendgridAdapter.php @@ -53,11 +53,6 @@ class SendgridAdapter implements MailerInterface */ private $data = []; - /** - * @var SendgridAdapter|null - */ - private static $instance = null; - /** * SendgridAdapter constructor * @param array $params diff --git a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php index 3942eff88..7abf44940 100644 --- a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php +++ b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php @@ -53,11 +53,6 @@ class SendinblueAdapter implements MailerInterface */ private $data = []; - /** - * @var SendinblueAdapter|null - */ - private static $instance = null; - /** * SendinblueAdapter constructor * @param array $params diff --git a/src/Libraries/Mailer/Adapters/SmtpAdapter.php b/src/Libraries/Mailer/Adapters/SmtpAdapter.php index 6698c1d41..b3de08fb9 100644 --- a/src/Libraries/Mailer/Adapters/SmtpAdapter.php +++ b/src/Libraries/Mailer/Adapters/SmtpAdapter.php @@ -70,11 +70,6 @@ class SmtpAdapter implements MailerInterface */ protected $stringAttachments = []; - /** - * @var SmtpAdapter|null - */ - private static $instance = null; - /** * SmtpAdapter constructor * @param array $params diff --git a/src/Libraries/Session/Traits/SessionTrait.php b/src/Libraries/Session/Traits/SessionTrait.php index a915d580e..b7fd64064 100644 --- a/src/Libraries/Session/Traits/SessionTrait.php +++ b/src/Libraries/Session/Traits/SessionTrait.php @@ -9,12 +9,11 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Session\Traits; -use Quantum\Libraries\Database\Exceptions\DatabaseException; use Quantum\Libraries\Session\Exceptions\SessionException; /** @@ -110,12 +109,11 @@ public function flush() */ public function getId(): ?string { - return session_id() ?? null; + return session_id(); } /** * @inheritDoc - * @throws DatabaseException * @throws SessionException */ public function regenerateId(): bool diff --git a/src/Libraries/Validation/Validator.php b/src/Libraries/Validation/Validator.php index 77bcdeb9f..e86177851 100644 --- a/src/Libraries/Validation/Validator.php +++ b/src/Libraries/Validation/Validator.php @@ -9,18 +9,22 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ namespace Quantum\Libraries\Validation; +use Quantum\Libraries\Lang\Exceptions\LangException; use Quantum\Libraries\Validation\Traits\Resource; use Quantum\Libraries\Validation\Traits\General; use Quantum\Libraries\Validation\Traits\Length; use Quantum\Libraries\Validation\Traits\Lists; +use Quantum\Config\Exceptions\ConfigException; use Quantum\Libraries\Validation\Traits\Type; use Quantum\Libraries\Validation\Traits\File; +use Quantum\Di\Exceptions\DiException; use BadMethodCallException; +use ReflectionException; use RuntimeException; use Closure; @@ -185,7 +189,7 @@ public function isValid(array $data): bool */ public function addRule(string $rule, Closure $function): void { - if ($rule === '' || $rule === '0' || !is_callable($function)) { + if ($rule === '' || $rule === '0') { return; } @@ -195,6 +199,10 @@ public function addRule(string $rule, Closure $function): void /** * Gets validation errors with translations * @return array + * @throws ConfigException + * @throws DiException + * @throws LangException + * @throws ReflectionException */ public function getErrors(): array { diff --git a/src/Model/Factories/ModelFactory.php b/src/Model/Factories/ModelFactory.php index 5b8ae8d9d..02e5feaed 100644 --- a/src/Model/Factories/ModelFactory.php +++ b/src/Model/Factories/ModelFactory.php @@ -51,7 +51,7 @@ public static function get(string $modelClass): QtModel $modelClass, $model->idColumn, $model->relations(), - $model->hidden ?? [] + $model->hidden ); $model->setOrmInstance($ormInstance); diff --git a/src/Router/RouteDispatcher.php b/src/Router/RouteDispatcher.php index f9204d9f9..573119a53 100644 --- a/src/Router/RouteDispatcher.php +++ b/src/Router/RouteDispatcher.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Router; @@ -72,10 +72,10 @@ private static function resolveController(): RouteController /** * Retrieves the current route's action for the controller. * @param RouteController $controller - * @return string|null + * @return string * @throws RouteControllerException */ - private static function resolveAction(RouteController $controller): ?string + private static function resolveAction(RouteController $controller): string { $action = current_action(); diff --git a/src/View/Helpers/view.php b/src/View/Helpers/view.php index 6096d5528..910e13f6c 100644 --- a/src/View/Helpers/view.php +++ b/src/View/Helpers/view.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.8 + * @since 3.0.0 */ use Quantum\Config\Exceptions\ConfigException; @@ -41,14 +41,14 @@ function view(): ?string * Rendered partial * @param string $partial * @param array $args - * @return string|null + * @return string * @throws BaseException * @throws ConfigException * @throws DebugBarException * @throws DiException * @throws ReflectionException */ -function partial(string $partial, array $args = []): ?string +function partial(string $partial, array $args = []): string { return ViewFactory::get()->renderPartial($partial, $args); } From 6fbdaaa5cddfd73ec7e2227793b28351b3b1446f Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:03:56 +0400 Subject: [PATCH 08/12] Resolve PHPStan level 5 static analysis issues --- phpstan.neon.dist | 2 +- src/App/Helpers/misc.php | 10 ---------- src/Di/Di.php | 12 +++++++++--- src/Di/Enums/ExceptionMessages.php | 4 +++- src/Di/Exceptions/DiException.php | 11 ++++++++++- src/Libraries/Asset/Exceptions/AssetException.php | 6 +++--- .../Storage/Contracts/CloudAppInterface.php | 6 +++--- src/Libraries/Validation/Traits/General.php | 2 +- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 51cefdb51..ecb4ac859 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,6 @@ parameters: phpVersion: 70400 - level: 4 + level: 5 paths: - src diff --git a/src/App/Helpers/misc.php b/src/App/Helpers/misc.php index 5dcddba9b..9046d91f4 100644 --- a/src/App/Helpers/misc.php +++ b/src/App/Helpers/misc.php @@ -120,16 +120,6 @@ function get_caller_function(int $index = 2): ?string return $trace[$index]['function']; } -/** - * Checks if the entity is closure - * @param mixed $entity - * @return bool - */ -function is_closure($entity): bool -{ - return $entity instanceof Closure; -} - /** * Exports the variable * @param $var diff --git a/src/Di/Di.php b/src/Di/Di.php index d8b976703..cf89c1ac6 100644 --- a/src/Di/Di.php +++ b/src/Di/Di.php @@ -20,6 +20,7 @@ use ReflectionFunction; use ReflectionMethod; use ReflectionClass; +use Closure; /** * Di Class @@ -134,9 +135,14 @@ public static function create(string $dependency, array $args = []) */ public static function autowire(callable $entry, array $args = []): array { - $reflection = is_closure($entry) - ? new ReflectionFunction($entry) - : new ReflectionMethod(...$entry); + if ($entry instanceof Closure) { + $reflection = new ReflectionFunction($entry); + } elseif(is_array($entry)) { + [$target, $method] = $entry; + $reflection = new ReflectionMethod($target, $method); + } else { + throw DiException::invalidCallable(); + } return self::resolveParameters($reflection->getParameters(), $args); } diff --git a/src/Di/Enums/ExceptionMessages.php b/src/Di/Enums/ExceptionMessages.php index 22bb5361d..fe8ad2e95 100644 --- a/src/Di/Enums/ExceptionMessages.php +++ b/src/Di/Enums/ExceptionMessages.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Di\Enums; @@ -32,4 +32,6 @@ final class ExceptionMessages extends BaseExceptionMessages const INVALID_ABSTRACT_DEPENDENCY = 'The dependency `{%1}` is not valid abstract class.'; const CIRCULAR_DEPENDENCY = 'Circular dependency detected: `{%1}`'; + + const INVALID_CALLABLE = 'Invalid callable provided: expected Closure or array-style callable `{%1}`'; } \ No newline at end of file diff --git a/src/Di/Exceptions/DiException.php b/src/Di/Exceptions/DiException.php index 9a6ee14bc..d189cfcb3 100644 --- a/src/Di/Exceptions/DiException.php +++ b/src/Di/Exceptions/DiException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Di\Exceptions; @@ -69,4 +69,13 @@ public static function circularDependency(string $chain): DiException { return new self(_message(ExceptionMessages::CIRCULAR_DEPENDENCY, [$chain]), 0); } + + /** + * @param string $entry + * @return DiException + */ + public static function invalidCallable(string $entry): DiException + { + return new self(_message(ExceptionMessages::INVALID_CALLABLE, [$entry]), E_ERROR); + } } diff --git a/src/Libraries/Asset/Exceptions/AssetException.php b/src/Libraries/Asset/Exceptions/AssetException.php index 4745f46bb..4a32bfcb7 100644 --- a/src/Libraries/Asset/Exceptions/AssetException.php +++ b/src/Libraries/Asset/Exceptions/AssetException.php @@ -11,7 +11,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.9 + * @since 3.0.0 */ namespace Quantum\Libraries\Asset\Exceptions; @@ -25,11 +25,11 @@ class AssetException extends \Exception { /** - * @param string $position + * @param int $position * @param string $name * @return AssetException */ - public static function positionInUse(string $position, string $name): AssetException + public static function positionInUse(int $position, string $name): AssetException { return new self(_message(ExceptionMessages::POSITION_IN_USE, [$position, $name]), E_WARNING); } diff --git a/src/Libraries/Storage/Contracts/CloudAppInterface.php b/src/Libraries/Storage/Contracts/CloudAppInterface.php index 0770f70e7..684009c94 100644 --- a/src/Libraries/Storage/Contracts/CloudAppInterface.php +++ b/src/Libraries/Storage/Contracts/CloudAppInterface.php @@ -9,7 +9,7 @@ * @author Arman Ag. * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) * @link http://quantum.softberg.org/ - * @since 2.9.5 + * @since 3.0.0 */ namespace Quantum\Libraries\Storage\Contracts; @@ -39,14 +39,14 @@ public function __construct( /** * Send request * @param string $url - * @param array $data + * @param array|string|null $data * @param array $headers * @param string $method * @return mixed */ public function sendRequest( string $url, - array $data = [], + $data = null, array $headers = [], string $method = 'POST' ); diff --git a/src/Libraries/Validation/Traits/General.php b/src/Libraries/Validation/Traits/General.php index 5f1ac11b0..2b3aadd33 100644 --- a/src/Libraries/Validation/Traits/General.php +++ b/src/Libraries/Validation/Traits/General.php @@ -107,7 +107,7 @@ protected function iban(string $value): bool $iban = substr($iban, 4) . substr($iban, 0, 4); $iban = strtr($iban, $character); - return bcmod($iban, 97) == 1; + return bcmod($iban, '97') == 1; } /** From 64e916fb5ead136165a8bf115ee2b7359af3edc2 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:18:52 +0400 Subject: [PATCH 09/12] Adding PHPStan check to GitHub Actions --- .github/workflows/php.yml | 3 +++ composer.json | 1 + src/Di/Exceptions/DiException.php | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 6c7b5f52f..5890ea0f1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -54,6 +54,9 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress + - name: Run PHPStan + run: composer phpstan + - name: Run tests run: composer test -- --fail-on-warning --fail-on-risky diff --git a/composer.json b/composer.json index 718ccbf12..5d34eb80a 100644 --- a/composer.json +++ b/composer.json @@ -76,6 +76,7 @@ } }, "scripts": { + "phpstan": "phpstan analyse --memory-limit=512M --no-progress --error-format=github", "test": "vendor/bin/phpunit --stderr --testdox --coverage-clover coverage.xml" }, "minimum-stability": "stable", diff --git a/src/Di/Exceptions/DiException.php b/src/Di/Exceptions/DiException.php index d189cfcb3..22bc74b78 100644 --- a/src/Di/Exceptions/DiException.php +++ b/src/Di/Exceptions/DiException.php @@ -71,10 +71,10 @@ public static function circularDependency(string $chain): DiException } /** - * @param string $entry + * @param string|null $entry * @return DiException */ - public static function invalidCallable(string $entry): DiException + public static function invalidCallable(?string $entry = null): DiException { return new self(_message(ExceptionMessages::INVALID_CALLABLE, [$entry]), E_ERROR); } From 542763872f1f91a35616c7d9b17513182e8790db Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:25:29 +0400 Subject: [PATCH 10/12] Correcting yaml indentation --- .github/workflows/php.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 5890ea0f1..31e642eff 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -37,7 +37,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} extensions: redis, memcached - ini-values: phar.readonly=0, error_reporting=E_ALL + ini-values: phar.readonly=0, error_reporting=E_ALL - name: Validate composer.json and composer.lock run: composer validate --strict @@ -55,7 +55,7 @@ jobs: run: composer install --prefer-dist --no-progress - name: Run PHPStan - run: composer phpstan + run: composer phpstan - name: Run tests run: composer test -- --fail-on-warning --fail-on-risky From 1ebe1972a58f48ce357627fbc98ae5bf96a35eca Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:35:06 +0400 Subject: [PATCH 11/12] Downgrading debugbar to 1.8 for php 7.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d34eb80a..84c6ac50b 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "symfony/console": "^5.4", "vlucas/phpdotenv": "^5.0", "dflydev/dot-access-data": "^3.0", - "php-debugbar/php-debugbar": "^2.0", + "php-debugbar/php-debugbar": "^1.8", "phpmailer/phpmailer": "^6.0", "twig/twig": "^3.0", "php-curl-class/php-curl-class": "^11.0", From dc0083d5b9a99e403c9770889af41756bd74c7a5 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Thu, 8 Jan 2026 20:20:12 +0400 Subject: [PATCH 12/12] Updating to correct exception method to be thrown --- src/Libraries/Storage/UploadedFile.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Libraries/Storage/UploadedFile.php b/src/Libraries/Storage/UploadedFile.php index d0300d33a..94bacd962 100644 --- a/src/Libraries/Storage/UploadedFile.php +++ b/src/Libraries/Storage/UploadedFile.php @@ -129,9 +129,9 @@ public function __construct(array $meta) $adapter = fs()->getAdapter(); if (!$adapter instanceof LocalFilesystemAdapterInterface) { - throw FileSystemException::methodNotSupported( - 'local filesystem operations', - get_class($adapter) + throw FileSystemException::notInstanceOf( + get_class($adapter), + LocalFilesystemAdapterInterface::class ); }