diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 3031ebba9..6c7b5f52f 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest ]
- php-versions: [ '7.3', '7.4' ]
+ php-versions: [ '7.4', '8.0', '8.1' ]
redis-version: [ 6 ]
runs-on: ${{ matrix.operating-system }}
@@ -37,7 +37,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: redis, memcached
- ini-values: phar.readonly=0
+ 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 tests
- run: composer test
+ run: composer test -- --fail-on-warning --fail-on-risky
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 50af70346..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-language: php
-php:
- - 7.3
- - 7.4
-
-services:
- - redis-server
- - memcached
-
-before_install:
- - sudo apt-get update -qq
- - sudo apt-get install -y -qq postfix
-
-before_script:
- - sudo service postfix stop
- - smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
- - echo -e '#!/usr/bin/env bash\nexit 0' | sudo tee /usr/sbin/sendmail
- - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' | sudo tee "/home/travis/.phpenv/versions/`php -i | grep "PHP Version" | head -n 1 | grep -o -P '\d+\.\d+\.\d+.*'`/etc/conf.d/sendmail.ini"
-
- - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-
- - composer self-update
- - composer install --prefer-dist --no-progress --no-suggest
-
-script:
- - XDEBUG_MODE=coverage vendor/bin/phpunit --stderr --coverage-clover coverage.xml
-
-after_success:
- - bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 000000000..8dfc6956e
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,44 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+## [3.0.0] - TBD
+
+### Changed
+- **BREAKING:** Minimum PHP version requirement raised from 7.3 to 7.4
+- Modernized codebase with PHP 7.4+ syntax using Rector:
+ - Array destructuring: `list()` → `[]`
+ - Arrow functions for simple closures
+ - Null coalescing assignment operator (`??=`)
+ - Class constant references using `::class`
+ - Secure random number generation with `random_int()`
+ - Modern `setcookie()` array syntax
+- Updated CI pipeline to test against PHP 7.4, 8.0, and 8.1
+- CI now fails on PHP warnings and deprecations for stricter quality control
+- Added `declare(strict_types=1)` to all Exception classes for improved type safety
+
+### Fixed
+- PHP 8.1 compatibility: Fixed null parameter deprecations in `explode()`, `parse_url()`, and `str_replace()`
+- PHP 8.4 forward compatibility: Fixed implicitly nullable parameters in database and auth adapters
+- PHP 8.4 forward compatibility: Added missing type hint to `SleekDbal::__get()` magic method
+- Fixed deprecated `E_STRICT` constant usage in test bootstrap
+- Fixed cURL error message assertions for cross-version compatibility
+
+### Added
+- Rector as dev dependency for automated code refactoring
+- Additional PHP extensions required in CI: `bcmath`, `gd`, `zip`
+- PHPUnit strict testing flags: `--fail-on-warning`, `--fail-on-risky`
+
+### Removed
+- Support for PHP 7.3 and earlier versions
+
+---
+
+## [2.x.x] - Previous versions
+
+See Git history for changes in earlier versions.
\ No newline at end of file
diff --git a/composer.json b/composer.json
index b17b2ec98..e69ac3b58 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,11 @@
{
"name": "quantum/framework",
"description": "The Quantum PHP Framework",
- "keywords": ["framework", "php", "quantum"],
+ "keywords": [
+ "framework",
+ "php",
+ "quantum"
+ ],
"license": "MIT",
"homepage": "https://quantumphp.io",
"support": {
@@ -15,7 +19,7 @@
}
],
"require": {
- "php": ">=7.3",
+ "php": "^7.4 || ^8.0",
"ext-pdo": "*",
"ext-curl": "*",
"ext-json": "*",
@@ -51,7 +55,8 @@
"require-dev": {
"phpunit/phpunit": "^9.0",
"mockery/mockery": "^1.4",
- "mikey179/vfsstream": "^1.6"
+ "mikey179/vfsstream": "^1.6",
+ "rector/rector": "^2.3"
},
"suggest": {
"ext-dom": "Required for XML/HTML processing",
@@ -74,4 +79,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
-}
+}
\ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 260ba78cd..3b2122c21 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -7,7 +7,12 @@
verbose="true"
stderr="true"
stopOnFailure="false"
+ convertDeprecationsToExceptions="false"
>
+
+
+
+
./tests/Unit
diff --git a/rector.php b/rector.php
new file mode 100644
index 000000000..758052b3d
--- /dev/null
+++ b/rector.php
@@ -0,0 +1,15 @@
+withPaths([
+ __DIR__ . '/src',
+ __DIR__ . '/tests',
+ ])
+ ->withSets([
+ LevelSetList::UP_TO_PHP_80,
+ ]);
\ No newline at end of file
diff --git a/src/App/Adapters/ConsoleAppAdapter.php b/src/App/Adapters/ConsoleAppAdapter.php
index e38a9e796..1fe39ed27 100644
--- a/src/App/Adapters/ConsoleAppAdapter.php
+++ b/src/App/Adapters/ConsoleAppAdapter.php
@@ -26,7 +26,9 @@
use Quantum\Di\Exceptions\DiException;
use ReflectionException;
-if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
+if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+}
/**
* Class ConsoleAppAdapter
diff --git a/src/App/Adapters/WebAppAdapter.php b/src/App/Adapters/WebAppAdapter.php
index d15f77ccc..4b2247b43 100644
--- a/src/App/Adapters/WebAppAdapter.php
+++ b/src/App/Adapters/WebAppAdapter.php
@@ -113,7 +113,7 @@ public function start(): ?int
info(HookManager::getInstance()->getRegistered(), ['tab' => Debugger::HOOKS]);
if (current_middlewares()) {
- list($this->request, $this->response) = (new MiddlewareManager())->applyMiddlewares($this->request, $this->response);
+ [$this->request, $this->response] = (new MiddlewareManager())->applyMiddlewares($this->request, $this->response);
}
$viewCache = $this->setupViewCache();
diff --git a/src/App/Exceptions/AppException.php b/src/App/Exceptions/AppException.php
index 9fb05e1da..d37a5046e 100644
--- a/src/App/Exceptions/AppException.php
+++ b/src/App/Exceptions/AppException.php
@@ -1,5 +1,7 @@
publicDebugBarFolderPath) {
- if ($this->fs->makeDirectory($dst) === false) {
- throw FileSystemException::directoryNotWritable($dst);
- }
+ if ($dst != $this->publicDebugBarFolderPath && $this->fs->makeDirectory($dst) === false) {
+ throw FileSystemException::directoryNotWritable($dst);
}
if (is_resource($dir)) {
while (($file = readdir($dir))) {
- if (($file != '.') && ($file != '..')) {
+ if (($file !== '.') && ($file !== '..')) {
if ($this->fs->isDirectory($src . DS . $file)) {
$this->copyResources($src . DS . $file, $dst . DS . $file);
} else {
diff --git a/src/Console/Commands/EnvCommand.php b/src/Console/Commands/EnvCommand.php
index 60aa305d7..7f567f98c 100644
--- a/src/Console/Commands/EnvCommand.php
+++ b/src/Console/Commands/EnvCommand.php
@@ -70,11 +70,9 @@ public function exec()
$this->error('.env.example file not found');
}
- if ($fs->exists('.env') && !$this->getOption('yes')) {
- if (!$this->confirm("The operation will overwrite values of the existing .env and will create new one from .env.example. Continue?")) {
- $this->info('Operation was canceled!');
- return;
- }
+ if ($fs->exists('.env') && !$this->getOption('yes') && !$this->confirm("The operation will overwrite values of the existing .env and will create new one from .env.example. Continue?")) {
+ $this->info('Operation was canceled!');
+ return;
}
$fs->copy(
diff --git a/src/Console/Commands/KeyGenerateCommand.php b/src/Console/Commands/KeyGenerateCommand.php
index 6944afab2..a3a5d70c4 100644
--- a/src/Console/Commands/KeyGenerateCommand.php
+++ b/src/Console/Commands/KeyGenerateCommand.php
@@ -60,12 +60,10 @@ class KeyGenerateCommand extends QtCommand
*/
public function exec()
{
- if (Environment::getInstance()->hasKey('APP_KEY') && env('APP_KEY') !== "") {
- if (!$this->getOption('yes')) {
- if (!$this->confirm("The operation will remove the existing key and will create new one. Continue?")) {
- $this->info('Operation was canceled!');
- return;
- }
+ if (Environment::getInstance()->hasKey('APP_KEY') && env('APP_KEY') !== "" && !$this->getOption('yes')) {
+ if (!$this->confirm("The operation will remove the existing key and will create new one. Continue?")) {
+ $this->info('Operation was canceled!');
+ return;
}
}
diff --git a/src/Console/Commands/MigrationMigrateCommand.php b/src/Console/Commands/MigrationMigrateCommand.php
index ad1ef2add..6db852fed 100644
--- a/src/Console/Commands/MigrationMigrateCommand.php
+++ b/src/Console/Commands/MigrationMigrateCommand.php
@@ -71,11 +71,9 @@ public function exec()
$direction = $this->getArgument('direction') ?: MigrationManager::UPGRADE;
- if ($direction == 'down') {
- if (!$this->confirm("This operation will revert all the database changes, including the data. Continue?")) {
- $this->info('Operation was canceled!');
- return;
- }
+ if ($direction == 'down' && !$this->confirm("This operation will revert all the database changes, including the data. Continue?")) {
+ $this->info('Operation was canceled!');
+ return;
}
$step = (int)$this->getOption('step') ?: null;
diff --git a/src/Console/Commands/OpenApiCommand.php b/src/Console/Commands/OpenApiCommand.php
index 8ab0e3f40..17e35966e 100644
--- a/src/Console/Commands/OpenApiCommand.php
+++ b/src/Console/Commands/OpenApiCommand.php
@@ -148,7 +148,7 @@ private function copyResources()
if (is_resource($dir)) {
while (($file = readdir($dir))) {
- if (($file != '.') && ($file != '..') && !in_array($file, $this->excludeFileNames)) {
+ if (($file !== '.') && ($file !== '..') && !in_array($file, $this->excludeFileNames)) {
copy($this->vendorOpenApiFolderPath . DS . $file, $this->publicOpenApiFolderPath . DS . $file);
}
}
diff --git a/src/Console/Commands/ResourceCacheClearCommand.php b/src/Console/Commands/ResourceCacheClearCommand.php
index 6aa2ee3cf..03e7c07f7 100644
--- a/src/Console/Commands/ResourceCacheClearCommand.php
+++ b/src/Console/Commands/ResourceCacheClearCommand.php
@@ -162,7 +162,7 @@ private function importConfig(): void
*/
private function initModule(?string $moduleOption): void
{
- if (!empty($moduleOption)) {
+ if (!in_array($moduleOption, [null, '', '0'], true)) {
$this->importModules();
$module = strtolower($moduleOption);
@@ -181,7 +181,7 @@ private function initModule(?string $moduleOption): void
*/
private function initType(?string $typeOption): void
{
- if (!empty($typeOption)) {
+ if (!in_array($typeOption, [null, '', '0'], true)) {
$type = strtolower($typeOption);
if (in_array($type, $this->types)) {
diff --git a/src/Console/Commands/RouteListCommand.php b/src/Console/Commands/RouteListCommand.php
index 672f1a373..f48fe9d25 100644
--- a/src/Console/Commands/RouteListCommand.php
+++ b/src/Console/Commands/RouteListCommand.php
@@ -62,11 +62,9 @@ public function exec()
$module = $this->getOption('module');
if ($module) {
- $routes = array_filter($routes, function ($route) use ($module) {
- return strtolower($route['module']) === strtolower($module);
- });
+ $routes = array_filter($routes, fn($route) => strtolower($route['module']) === strtolower($module));
- if (empty($routes)) {
+ if ($routes === []) {
$this->error('The module is not found');
return;
}
diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php
index 5d6c3995a..71963616d 100644
--- a/src/Console/Commands/ServeCommand.php
+++ b/src/Console/Commands/ServeCommand.php
@@ -87,14 +87,12 @@ public function exec()
if (!$this->portAvailable()) {
$this->portOffset += 1;
$this->exec();
+ } elseif (!$this->openBrowserCommand()) {
+ $this->info('Starting development server at: ' . $this->host() . ':' . $this->port());
+ exec($this->runServerCommand(), $out);
} else {
- if (!$this->openBrowserCommand()) {
- $this->info('Starting development server at: ' . $this->host() . ':' . $this->port());
- exec($this->runServerCommand(), $out);
- } else {
- $this->info('Starting development server at: ' . $this->host() . ':' . $this->port());
- exec($this->openBrowserCommand() . ' && ' . $this->runServerCommand(), $out);
- }
+ $this->info('Starting development server at: ' . $this->host() . ':' . $this->port());
+ exec($this->openBrowserCommand() . ' && ' . $this->runServerCommand(), $out);
}
}
diff --git a/src/Debugger/Debugger.php b/src/Debugger/Debugger.php
index 07b7c34f5..b58640d18 100644
--- a/src/Debugger/Debugger.php
+++ b/src/Debugger/Debugger.php
@@ -112,8 +112,8 @@ public function __construct(DebuggerStore $store, DebugBar $debugBar, array $col
public static function getInstance(DebuggerStore $store = null, DebugBar $debugBar = null, ?array $collectors = []): Debugger
{
if (self::$instance === null) {
- $debugBar = $debugBar ?? new DebugBar();
- $store = $store ?? new DebuggerStore();
+ $debugBar ??= new DebugBar();
+ $store ??= new DebuggerStore();
$collectors = $collectors ?: self::getDefaultCollectors();
self::$instance = new self($store, $debugBar, $collectors);
@@ -213,7 +213,7 @@ protected function createTab(string $type)
$messages = $this->store->get($type);
- if (count($messages)) {
+ if (count($messages) > 0) {
foreach ($messages as $message) {
$fn = key($message);
$this->debugBar[$type]->$fn($message[$fn]);
diff --git a/src/Di/Di.php b/src/Di/Di.php
index be95475e7..8b2964451 100644
--- a/src/Di/Di.php
+++ b/src/Di/Di.php
@@ -230,7 +230,7 @@ private static function resolveParameters(array $parameters, array &$args = []):
*/
private static function resolveParameter(ReflectionParameter $param, ?array &$args = [])
{
- $type = $param->getType() ? $param->getType()->getName() : null;
+ $type = $param->getType() instanceof \ReflectionType ? $param->getType()->getName() : null;
$concrete = self::$dependencies[$type] ?? $type;
@@ -242,7 +242,7 @@ private static function resolveParameter(ReflectionParameter $param, ?array &$ar
return $args;
}
- if (!empty($args)) {
+ if ($args !== null && $args !== []) {
return array_shift($args);
}
diff --git a/src/Di/Exceptions/DiException.php b/src/Di/Exceptions/DiException.php
index 3f9751e44..9a6ee14bc 100644
--- a/src/Di/Exceptions/DiException.php
+++ b/src/Di/Exceptions/DiException.php
@@ -1,5 +1,7 @@
all();
- if (empty($data)) {
+ if ($data === []) {
return [];
}
diff --git a/src/Hook/Exceptions/HookException.php b/src/Hook/Exceptions/HookException.php
index defbf5599..8d90e3a99 100644
--- a/src/Hook/Exceptions/HookException.php
+++ b/src/Hook/Exceptions/HookException.php
@@ -1,5 +1,7 @@
$rawInputParams, 'files' => $rawInputFiles) = self::getRawInputParams();
+ ['params' => $rawInputParams, 'files' => $rawInputFiles] = self::getRawInputParams();
self::setRequestParams($rawInputParams);
self::setUploadedFiles($rawInputFiles);
@@ -185,7 +185,7 @@ public static function setMethod(string $method)
*/
public static function isMethod(string $method): bool
{
- return strcasecmp($method, self::$__method) == 0;
+ return strcasecmp($method, self::$__method) === 0;
}
/**
@@ -215,7 +215,7 @@ public static function getBaseUrl(bool $withModulePrefix = false): string
$baseUrl = config()->get('app.base_url');
$prefix = route_prefix();
- $modulePrefix = ($withModulePrefix && !empty($prefix)) ? '/' . $prefix : '';
+ $modulePrefix = ($withModulePrefix && !in_array($prefix, [null, '', '0'], true)) ? '/' . $prefix : '';
if ($baseUrl) {
return $baseUrl . $modulePrefix;
diff --git a/src/Http/Response/HttpResponse.php b/src/Http/Response/HttpResponse.php
index 2f5118702..6482479ec 100644
--- a/src/Http/Response/HttpResponse.php
+++ b/src/Http/Response/HttpResponse.php
@@ -83,7 +83,7 @@ public static function flush()
*/
public static function send()
{
- if (Environment::getInstance()->getAppEnv() != Env::TESTING) {
+ if (Environment::getInstance()->getAppEnv() !== Env::TESTING) {
while (ob_get_level() > 0) {
ob_end_clean();
}
diff --git a/src/Http/Traits/Request/Header.php b/src/Http/Traits/Request/Header.php
index 1631d6b7d..73724a244 100644
--- a/src/Http/Traits/Request/Header.php
+++ b/src/Http/Traits/Request/Header.php
@@ -34,7 +34,7 @@ trait Header
*/
public static function hasHeader(string $key): bool
{
- list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key);
+ [$keyWithHyphens, $keyWithUnderscores] = self::normalizeHeaderKey($key);
return isset(self::$__headers[$keyWithHyphens]) || isset(self::$__headers[$keyWithUnderscores]);
}
@@ -47,7 +47,7 @@ public static function hasHeader(string $key): bool
public static function getHeader(string $key): ?string
{
if (self::hasHeader($key)) {
- list($keyWithHyphens, $keyWithUnderscores) = self::normalizeHeaderKey($key);
+ [$keyWithHyphens, $keyWithUnderscores] = self::normalizeHeaderKey($key);
return self::$__headers[$keyWithHyphens] ?? self::$__headers[$keyWithUnderscores];
}
@@ -94,10 +94,8 @@ public static function getAuthorizationBearer(): ?string
$authorization = (string)self::getHeader('Authorization');
- if (self::hasHeader('Authorization')) {
- if (preg_match('/Bearer\s(\S+)/', $authorization, $matches)) {
- $bearerToken = $matches[1];
- }
+ if (self::hasHeader('Authorization') && preg_match('/Bearer\s(\S+)/', $authorization, $matches)) {
+ $bearerToken = $matches[1];
}
return $bearerToken;
@@ -127,7 +125,7 @@ public static function getBasicAuthCredentials(): ?array
$decoded = base64_decode($matches[1], true);
if ($decoded && strpos($decoded, ':') !== false) {
- list($username, $password) = explode(':', $decoded, 2);
+ [$username, $password] = explode(':', $decoded, 2);
return ['username' => $username, 'password' => $password];
}
}
diff --git a/src/Http/Traits/Request/Internal.php b/src/Http/Traits/Request/Internal.php
index 7108dd7b4..617fec6a3 100644
--- a/src/Http/Traits/Request/Internal.php
+++ b/src/Http/Traits/Request/Internal.php
@@ -84,7 +84,7 @@ public static function create(
self::detectAndSetContentType($server, $params, $files);
- if ($headers) {
+ if ($headers !== []) {
foreach ($headers as $name => $value) {
$server->set('HTTP_' . strtoupper(str_replace('-', '_', $name)), $value);
}
@@ -94,11 +94,11 @@ public static function create(
self::init($server);
- if ($params) {
+ if ($params !== []) {
self::setRequestParams($params);
}
- if ($files) {
+ if ($files !== []) {
self::setUploadedFiles(self::handleFiles($files));
}
}
diff --git a/src/Http/Traits/Request/Params.php b/src/Http/Traits/Request/Params.php
index 98b1b22ec..932cbc403 100644
--- a/src/Http/Traits/Request/Params.php
+++ b/src/Http/Traits/Request/Params.php
@@ -40,7 +40,7 @@ trait Params
*/
private static function getParams(): array
{
- if (empty($_GET)) {
+ if ($_GET === []) {
return [];
}
@@ -53,7 +53,7 @@ private static function getParams(): array
*/
private static function postParams(): array
{
- if (empty($_POST)) {
+ if ($_POST === []) {
return [];
}
diff --git a/src/Http/Traits/Request/Query.php b/src/Http/Traits/Request/Query.php
index bee986239..4c49317a9 100644
--- a/src/Http/Traits/Request/Query.php
+++ b/src/Http/Traits/Request/Query.php
@@ -52,6 +52,10 @@ public static function setQuery(string $query)
*/
public static function getQueryParam(string $key): ?string
{
+ if (self::$__query === null) {
+ return null;
+ }
+
$query = explode('&', self::$__query);
foreach ($query as $items) {
diff --git a/src/Http/Traits/Request/RawInput.php b/src/Http/Traits/Request/RawInput.php
index 67f3ffd19..91d398ee7 100644
--- a/src/Http/Traits/Request/RawInput.php
+++ b/src/Http/Traits/Request/RawInput.php
@@ -108,7 +108,7 @@ private static function processBlocks(array $blocks): array
switch ($type) {
case 'file':
- list($nameParam, $file) = self::getParsedFile($block);
+ [$nameParam, $file] = self::getParsedFile($block);
if (!$file) {
continue 2;
@@ -142,7 +142,7 @@ private static function addFileToCollection(array &$files, string $nameParam, Up
$arrayParam = self::arrayParam($nameParam);
if (is_array($arrayParam)) {
- list($name, $key) = $arrayParam;
+ [$name, $key] = $arrayParam;
if ($key === '') {
$files[$name][] = $file;
@@ -195,7 +195,7 @@ private static function getParsedStream(string $block): array
*/
private static function getParsedFile(string $block): ?array
{
- list($name, $filename, $type, $content) = self::parseFileData($block);
+ [$name, $filename, $type, $content] = self::parseFileData($block);
if (!$content) {
return null;
@@ -235,9 +235,9 @@ private static function parseFileData(string $block): array
return ['-unknown-', '-unknown-', ContentType::OCTET_STREAM, ''];
}
- list($rawHeaders, $content) = $parts;
+ [$rawHeaders, $content] = $parts;
- list($name, $filename, $contentType) = self::parseHeaders($rawHeaders);
+ [$name, $filename, $contentType] = self::parseHeaders($rawHeaders);
$content = substr($content, 0, strlen($content) - 2);
@@ -296,10 +296,8 @@ private static function parseHeaders(string $rawHeaders): array
}
}
- if (stripos($line, 'Content-Type') !== false) {
- if (preg_match('/Content-Type:\s*(.+)/i', $line, $match)) {
- $contentType = trim($match[1]);
- }
+ if (stripos($line, 'Content-Type') !== false && preg_match('/Content-Type:\s*(.+)/i', $line, $match)) {
+ $contentType = trim($match[1]);
}
}
@@ -313,10 +311,8 @@ private static function parseHeaders(string $rawHeaders): array
*/
private static function arrayParam(string $parameter)
{
- if (strpos($parameter, '[') !== false) {
- if (preg_match('/^([^[]*)\[([^]]*)\](.*)$/', $parameter, $match)) {
- return [$match[1], $match[2]];
- }
+ if (strpos($parameter, '[') !== false && preg_match('/^([^[]*)\[([^]]*)\](.*)$/', $parameter, $match)) {
+ return [$match[1], $match[2]];
}
return $parameter;
diff --git a/src/Http/Traits/Request/Url.php b/src/Http/Traits/Request/Url.php
index 9b106034d..494b5ad54 100644
--- a/src/Http/Traits/Request/Url.php
+++ b/src/Http/Traits/Request/Url.php
@@ -127,11 +127,7 @@ public static function getSegment(int $index): ?string
{
$segments = self::getAllSegments();
- if (isset($segments[$index])) {
- return $segments[$index];
- }
-
- return null;
+ return $segments[$index] ?? null;
}
/**
@@ -140,6 +136,10 @@ public static function getSegment(int $index): ?string
*/
public static function getAllSegments(): array
{
+ if (self::$__uri === null) {
+ return ['zero_segment'];
+ }
+
$segments = explode('/', trim(parse_url(self::$__uri)['path'], '/'));
array_unshift($segments, 'zero_segment');
return $segments;
diff --git a/src/Http/Traits/Response/Body.php b/src/Http/Traits/Response/Body.php
index 0f1a7e10b..c45ffc8fd 100644
--- a/src/Http/Traits/Response/Body.php
+++ b/src/Http/Traits/Response/Body.php
@@ -231,7 +231,7 @@ private static function composeXML(array $arr, SimpleXMLElement &$simpleXML)
$attributes = null;
if (strpos($key, '@') !== false) {
- list($tag, $attributes) = explode('@', $key);
+ [$tag, $attributes] = explode('@', $key);
$attributes = json_decode($attributes);
}
diff --git a/src/Libraries/Archive/Exceptions/ArchiveException.php b/src/Libraries/Archive/Exceptions/ArchiveException.php
index b605d8d71..1f87d90f5 100644
--- a/src/Libraries/Archive/Exceptions/ArchiveException.php
+++ b/src/Libraries/Archive/Exceptions/ArchiveException.php
@@ -1,5 +1,7 @@
store)) {
+ if ($this->store !== []) {
$this->setPriorityAssets();
$this->setRegularAssets();
diff --git a/src/Libraries/Asset/Exceptions/AssetException.php b/src/Libraries/Asset/Exceptions/AssetException.php
index d59fc4f2a..4745f46bb 100644
--- a/src/Libraries/Asset/Exceptions/AssetException.php
+++ b/src/Libraries/Asset/Exceptions/AssetException.php
@@ -1,5 +1,7 @@
authService = $authService;
$this->mailer = $mailer;
@@ -222,7 +222,7 @@ private function getUserFromRefreshToken(): ?User
$user = $this->checkRefreshToken();
- if ($user) {
+ if ($user instanceof \Quantum\Libraries\Auth\User) {
$this->setUpdatedTokens($user);
return $this->user();
}
diff --git a/src/Libraries/Auth/Exceptions/AuthException.php b/src/Libraries/Auth/Exceptions/AuthException.php
index 059a0caa7..1022aa483 100644
--- a/src/Libraries/Auth/Exceptions/AuthException.php
+++ b/src/Libraries/Auth/Exceptions/AuthException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'auth'));
}
- $adapter = $adapter ?? config()->get('auth.default');
+ $adapter ??= config()->get('auth.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/Auth/Traits/AuthTrait.php b/src/Libraries/Auth/Traits/AuthTrait.php
index 29a372cea..1885edfc9 100644
--- a/src/Libraries/Auth/Traits/AuthTrait.php
+++ b/src/Libraries/Auth/Traits/AuthTrait.php
@@ -316,8 +316,8 @@ protected function getVisibleFields(User $user): array
{
$userData = $user->getData();
- if (count($this->visibleFields)) {
- foreach ($userData as $field => $value) {
+ if (count($this->visibleFields) > 0) {
+ foreach (array_keys($userData) as $field) {
if (!in_array($field, $this->visibleFields)) {
unset($userData[$field]);
}
@@ -334,7 +334,7 @@ protected function getVisibleFields(User $user): array
*/
protected function isActivated(User $user): bool
{
- return empty($user->getFieldValue($this->keyFields[AuthKeys::ACTIVATION_TOKEN]));
+ return in_array($user->getFieldValue($this->keyFields[AuthKeys::ACTIVATION_TOKEN]), [null, '', '0'], true);
}
/**
diff --git a/src/Libraries/Auth/User.php b/src/Libraries/Auth/User.php
index 5f46058ae..6234bfa7c 100644
--- a/src/Libraries/Auth/User.php
+++ b/src/Libraries/Auth/User.php
@@ -100,7 +100,7 @@ public function setFieldValue(string $field, ?string $value): self
*/
public function hasField(string $field): bool
{
- return key_exists($field, $this->data);
+ return array_key_exists($field, $this->data);
}
/**
diff --git a/src/Libraries/Cache/Adapters/MemcachedAdapter.php b/src/Libraries/Cache/Adapters/MemcachedAdapter.php
index 3f9b64dbc..393a87dd3 100644
--- a/src/Libraries/Cache/Adapters/MemcachedAdapter.php
+++ b/src/Libraries/Cache/Adapters/MemcachedAdapter.php
@@ -105,12 +105,7 @@ public function getMultiple($keys, $default = null)
public function has($key): bool
{
$cacheItem = $this->memcached->get($this->keyHash($key));
-
- if (!$cacheItem) {
- return false;
- }
-
- return true;
+ return (bool) $cacheItem;
}
/**
diff --git a/src/Libraries/Cache/Adapters/RedisAdapter.php b/src/Libraries/Cache/Adapters/RedisAdapter.php
index 075756eba..b261c44b8 100644
--- a/src/Libraries/Cache/Adapters/RedisAdapter.php
+++ b/src/Libraries/Cache/Adapters/RedisAdapter.php
@@ -100,12 +100,7 @@ public function getMultiple($keys, $default = null)
public function has($key): bool
{
$cacheItem = $this->redis->get($this->keyHash($key));
-
- if (!$cacheItem) {
- return false;
- }
-
- return true;
+ return (bool) $cacheItem;
}
/**
diff --git a/src/Libraries/Cache/Exceptions/CacheException.php b/src/Libraries/Cache/Exceptions/CacheException.php
index ad98c7b25..0371253be 100644
--- a/src/Libraries/Cache/Exceptions/CacheException.php
+++ b/src/Libraries/Cache/Exceptions/CacheException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'cache'));
}
- $adapter = $adapter ?? config()->get('cache.default');
+ $adapter ??= config()->get('cache.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/Captcha/Exceptions/CaptchaException.php b/src/Libraries/Captcha/Exceptions/CaptchaException.php
index 01649da90..78fef1e9f 100644
--- a/src/Libraries/Captcha/Exceptions/CaptchaException.php
+++ b/src/Libraries/Captcha/Exceptions/CaptchaException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'captcha'));
}
- $adapter = $adapter ?? config()->get('captcha.default');
+ $adapter ??= config()->get('captcha.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/Captcha/Traits/CaptchaTrait.php b/src/Libraries/Captcha/Traits/CaptchaTrait.php
index bd68d7eb8..ee05c1a63 100644
--- a/src/Libraries/Captcha/Traits/CaptchaTrait.php
+++ b/src/Libraries/Captcha/Traits/CaptchaTrait.php
@@ -128,10 +128,11 @@ public function addToForm(string $formIdentifier = '', array $attributes = []):
*/
public function verify(string $code): bool
{
- if (is_null($this->secretKey))
+ if (is_null($this->secretKey)) {
throw new Exception('The secret key is not set');
+ }
- if (empty($code)) {
+ if ($code === '' || $code === '0') {
$this->errorCodes = ['internal-empty-response'];
return false;
}
@@ -200,7 +201,7 @@ protected function getVisibleElement(array $attributes = []): string
*/
protected function getInvisibleElement(string $formIdentifier): string
{
- if (empty($formIdentifier)) {
+ if ($formIdentifier === '' || $formIdentifier === '0') {
throw new Exception('Form identifier is not provided to captcha element');
}
@@ -253,10 +254,6 @@ protected function extractAttributes(array $attributes)
*/
protected function detectReplayAttack(string $challengeTs): bool
{
- if (time() - strtotime($challengeTs) > self::MAX_TIME_DIFF) {
- return true;
- }
-
- return false;
+ return time() - strtotime($challengeTs) > self::MAX_TIME_DIFF;
}
}
\ No newline at end of file
diff --git a/src/Libraries/Cookie/Cookie.php b/src/Libraries/Cookie/Cookie.php
index 13df8be80..85eecf5f8 100644
--- a/src/Libraries/Cookie/Cookie.php
+++ b/src/Libraries/Cookie/Cookie.php
@@ -99,7 +99,7 @@ public function get(string $key)
public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
{
self::$storage[$key] = crypto_encode($value);
- setcookie($key, crypto_encode($value), $time ? time() + $time : $time, $path, $domain, $secure, $httponly);
+ setcookie($key, crypto_encode($value), ['expires' => $time !== 0 ? time() + $time : $time, 'path' => $path, 'domain' => $domain, 'secure' => $secure, 'httponly' => $httponly]);
}
/**
@@ -109,7 +109,7 @@ public function delete(string $key, string $path = '/')
{
if ($this->has($key)) {
unset(self::$storage[$key]);
- setcookie($key, '', time() - 3600, $path);
+ setcookie($key, '', ['expires' => time() - 3600, 'path' => $path]);
}
}
@@ -119,7 +119,7 @@ public function delete(string $key, string $path = '/')
public function flush()
{
if (count(self::$storage)) {
- foreach (self::$storage as $key => $value) {
+ foreach (array_keys(self::$storage) as $key) {
$this->delete($key, '/');
}
}
diff --git a/src/Libraries/Csrf/Exceptions/CsrfException.php b/src/Libraries/Csrf/Exceptions/CsrfException.php
index 8f8ccf701..b5478a92d 100644
--- a/src/Libraries/Csrf/Exceptions/CsrfException.php
+++ b/src/Libraries/Csrf/Exceptions/CsrfException.php
@@ -1,5 +1,7 @@
operators)) {
+ if (!array_key_exists($operator, $this->operators)) {
throw DatabaseException::operatorNotSupported($operator);
}
@@ -61,7 +61,7 @@ public function criterias(...$criterias): DbalInterface
*/
public function having(string $column, string $operator, ?string $value = null): DbalInterface
{
- if (!key_exists($operator, $this->operators)) {
+ if (!array_key_exists($operator, $this->operators)) {
throw DatabaseException::operatorNotSupported($operator);
}
@@ -100,9 +100,9 @@ public function isNotNull(string $column): DbalInterface
*/
protected function addCriteria(string $column, string $operator, $value, ?string $func = null)
{
- if ($operator == '#=#') {
+ if ($operator === '#=#') {
$this->getOrmModel()->where_raw($column . ' = ' . $value);
- } else if (is_array($value) && count($value) == 1 && key($value) == 'fn') {
+ } elseif (is_array($value) && count($value) === 1 && key($value) == 'fn') {
$this->getOrmModel()->where_raw($column . ' ' . $operator . ' ' . $value['fn']);
} else {
$this->getOrmModel()->$func($column, $value);
@@ -126,7 +126,7 @@ protected function orCriteria(array $orCriterias)
$clause .= '`' . $criteria[0] . '` ' . $criteria[1] . ' ?';
- if ($index == array_key_last($orCriterias)) {
+ if ($index === array_key_last($orCriterias)) {
$clause .= ')';
} else {
$clause .= ' OR ';
diff --git a/src/Libraries/Database/Adapters/Idiorm/Statements/Model.php b/src/Libraries/Database/Adapters/Idiorm/Statements/Model.php
index dfbf7ddbf..63d644b73 100644
--- a/src/Libraries/Database/Adapters/Idiorm/Statements/Model.php
+++ b/src/Libraries/Database/Adapters/Idiorm/Statements/Model.php
@@ -40,7 +40,7 @@ public function create(): DbalInterface
*/
public function prop(string $key, $value = null)
{
- if (func_num_args() == 2) {
+ if (func_num_args() === 2) {
$this->getOrmModel()->$key = $value;
} else {
return $this->getOrmModel()->$key ?? null;
diff --git a/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php b/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php
index 43f5dbaea..65191a5f8 100644
--- a/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php
+++ b/src/Libraries/Database/Adapters/Sleekdb/SleekDbal.php
@@ -166,7 +166,7 @@ class SleekDbal implements DbalInterface
*/
public function __construct(
string $table,
- string $modelName = null,
+ ?string $modelName = null,
string $idColumn = 'id',
array $foreignKeys = [],
array $hidden = []
@@ -179,7 +179,7 @@ public function __construct(
$this->hidden = $hidden;
}
- public function __get($key)
+ public function __get(string $key)
{
return $this->data[$key] ?? null;
}
@@ -308,27 +308,27 @@ public function getBuilder(): QueryBuilder
$this->queryBuilder = $this->getOrmModel()->createQueryBuilder();
}
- if (!empty($this->selected)) {
+ if ($this->selected !== []) {
$this->queryBuilder->select($this->selected);
}
- if (!empty($this->joins)) {
+ if ($this->joins !== []) {
$this->applyJoins();
}
- if (!empty($this->criterias)) {
+ if ($this->criterias !== []) {
$this->queryBuilder->where($this->criterias);
}
- if (!empty($this->havings)) {
+ if ($this->havings !== []) {
$this->queryBuilder->having($this->havings);
}
- if (!empty($this->grouped)) {
+ if ($this->grouped !== []) {
$this->queryBuilder->groupBy($this->grouped);
}
- if (!empty($this->ordered)) {
+ if ($this->ordered !== []) {
$this->queryBuilder->orderBy($this->ordered);
}
diff --git a/src/Libraries/Database/Adapters/Sleekdb/Statements/Criteria.php b/src/Libraries/Database/Adapters/Sleekdb/Statements/Criteria.php
index 3fcfec981..76234db51 100644
--- a/src/Libraries/Database/Adapters/Sleekdb/Statements/Criteria.php
+++ b/src/Libraries/Database/Adapters/Sleekdb/Statements/Criteria.php
@@ -99,7 +99,7 @@ protected function orCriteria(array $orCriterias)
foreach ($orCriterias as $index => $criteria) {
$this->criteria(...$criteria);
- if ($index != array_key_last($orCriterias)) {
+ if ($index !== array_key_last($orCriterias)) {
$this->criterias[] = 'OR';
}
}
@@ -129,9 +129,7 @@ protected function sanitizeValue($value)
];
if (is_array($value)) {
- return array_map(function ($v) use ($escapeMap) {
- return is_string($v) ? strtr($v, $escapeMap) : $v;
- }, $value);
+ return array_map(fn($v) => is_string($v) ? strtr($v, $escapeMap) : $v, $value);
}
return is_string($value) ? strtr($value, $escapeMap) : $value;
diff --git a/src/Libraries/Database/Adapters/Sleekdb/Statements/Model.php b/src/Libraries/Database/Adapters/Sleekdb/Statements/Model.php
index 519d72a8c..be5b20b38 100644
--- a/src/Libraries/Database/Adapters/Sleekdb/Statements/Model.php
+++ b/src/Libraries/Database/Adapters/Sleekdb/Statements/Model.php
@@ -44,11 +44,12 @@ public function create(): DbalInterface
*/
public function prop(string $key, $value = null)
{
- if (func_num_args() == 2) {
+ if (func_num_args() === 2) {
$this->modifiedFields[$key] = $value;
} else {
return $this->modifiedFields[$key] ?? null;
}
+ return null;
}
/**
diff --git a/src/Libraries/Database/Adapters/Sleekdb/Statements/Reducer.php b/src/Libraries/Database/Adapters/Sleekdb/Statements/Reducer.php
index 6d0173051..c7ae0b923 100644
--- a/src/Libraries/Database/Adapters/Sleekdb/Statements/Reducer.php
+++ b/src/Libraries/Database/Adapters/Sleekdb/Statements/Reducer.php
@@ -89,14 +89,12 @@ private function selectPatch(array $columns): array
foreach ($columns as &$column) {
$exploded = explode('.', $column);
- if (count($exploded) == 1) {
+ if (count($exploded) === 1) {
$column = $exploded[0];
+ } elseif ($exploded[0] == $this->getTable()) {
+ $column = $exploded[1];
} else {
- if ($exploded[0] == $this->getTable()) {
- $column = $exploded[1];
- } else {
- $column = $exploded[0] . '.0.' . $exploded[1];
- }
+ $column = $exploded[0] . '.0.' . $exploded[1];
}
}
diff --git a/src/Libraries/Database/Database.php b/src/Libraries/Database/Database.php
index fbae7870b..002760caa 100644
--- a/src/Libraries/Database/Database.php
+++ b/src/Libraries/Database/Database.php
@@ -73,7 +73,7 @@ private function __construct()
$adapter = config()->get('database.default');
- $this->ormClass = self::getAdapterClass($adapter);
+ $this->ormClass = $this->getAdapterClass($adapter);
$this->configs = config()->get('database.' . $adapter);
@@ -118,7 +118,7 @@ public function getConfigs(): ?array
* @return string
* @throws BaseException
*/
- private static function getAdapterClass(string $adapter): string
+ private function getAdapterClass(string $adapter): string
{
if (!array_key_exists($adapter, self::ADAPTERS)) {
throw DatabaseException::adapterNotSupported($adapter);
diff --git a/src/Libraries/Database/Exceptions/DatabaseException.php b/src/Libraries/Database/Exceptions/DatabaseException.php
index 6323f0c40..031e024bf 100644
--- a/src/Libraries/Database/Exceptions/DatabaseException.php
+++ b/src/Libraries/Database/Exceptions/DatabaseException.php
@@ -1,5 +1,7 @@
nullable = (!$indeed ? 'NOT ' : '') . 'NULL';
+ $this->nullable = ($indeed ? '' : 'NOT ') . 'NULL';
}
/**
diff --git a/src/Libraries/Database/Schemas/Table.php b/src/Libraries/Database/Schemas/Table.php
index eb4b153b8..a3a93065b 100644
--- a/src/Libraries/Database/Schemas/Table.php
+++ b/src/Libraries/Database/Schemas/Table.php
@@ -298,7 +298,7 @@ private function save()
{
$sql = $this->getSql();
- if ($sql) {
+ if ($sql !== '' && $sql !== '0') {
Database::execute($sql);
}
}
diff --git a/src/Libraries/Database/Traits/TableTrait.php b/src/Libraries/Database/Traits/TableTrait.php
index c88232094..090f55f00 100644
--- a/src/Libraries/Database/Traits/TableTrait.php
+++ b/src/Libraries/Database/Traits/TableTrait.php
@@ -33,7 +33,7 @@ protected function createTableSql(): string
$tableSchema = array_filter([$this->columnsSql(), $this->indexesSql()]);
$sql = '';
- if ($tableSchema) {
+ if ($tableSchema !== []) {
$sql = 'CREATE TABLE `' . $this->name . '` (';
$sql .= implode(', ', $tableSchema);
$sql .= ');';
@@ -51,7 +51,7 @@ protected function alterTableSql(): string
$tableSchema = array_filter([$this->columnsSql(), $this->indexesSql(), $this->dropIndexesSql()]);
$sql = '';
- if ($tableSchema) {
+ if ($tableSchema !== []) {
$sql = 'ALTER TABLE `' . $this->name . '` ';
$sql .= implode(', ', $tableSchema);
$sql .= ';';
@@ -108,7 +108,7 @@ protected function columnsSql(): string
$this->droppedIndexKeys[] = $entry['column']->get('indexDrop');
}
- if ($columnString) {
+ if ($columnString !== '' && $columnString !== '0') {
$columns[] = $columnString;
}
}
diff --git a/src/Libraries/Database/Traits/TransactionTrait.php b/src/Libraries/Database/Traits/TransactionTrait.php
index 4211dd8c2..9a48f72df 100644
--- a/src/Libraries/Database/Traits/TransactionTrait.php
+++ b/src/Libraries/Database/Traits/TransactionTrait.php
@@ -52,7 +52,7 @@ protected static function resolveTransaction(string $method)
$db = self::getInstance()->getOrmClass();
if (!method_exists($db, $method)) {
- throw DatabaseException::methodNotSupported($method, __CLASS__);
+ throw DatabaseException::methodNotSupported($method, self::class);
}
return $db::$method();
diff --git a/src/Libraries/Encryption/Exceptions/CryptorException.php b/src/Libraries/Encryption/Exceptions/CryptorException.php
index 386e2ccf0..b5697d762 100644
--- a/src/Libraries/Encryption/Exceptions/CryptorException.php
+++ b/src/Libraries/Encryption/Exceptions/CryptorException.php
@@ -1,5 +1,7 @@
algorithm = self::DEFAULT_ALGORITHM;
- $this->cost = self::DEFAULT_COST;
}
/**
diff --git a/src/Libraries/HttpClient/Exceptions/HttpClientException.php b/src/Libraries/HttpClient/Exceptions/HttpClientException.php
index 5002fefe9..b7c61ec92 100644
--- a/src/Libraries/HttpClient/Exceptions/HttpClientException.php
+++ b/src/Libraries/HttpClient/Exceptions/HttpClientException.php
@@ -1,5 +1,7 @@
get('lang.url_segment');
- if (!empty(route_prefix()) && $segmentIndex == 1) {
+ if (!in_array(route_prefix(), [null, '', '0'], true) && $segmentIndex === 1) {
$segmentIndex++;
}
diff --git a/src/Libraries/Logger/Exceptions/LoggerException.php b/src/Libraries/Logger/Exceptions/LoggerException.php
index b6ca26703..34fc70502 100644
--- a/src/Libraries/Logger/Exceptions/LoggerException.php
+++ b/src/Libraries/Logger/Exceptions/LoggerException.php
@@ -1,5 +1,7 @@
templatePath) {
$body = $this->createFromTemplate();
} else {
- $body = is_array($this->message) ? implode($this->message) : $this->message;
+ $body = is_array($this->message) ? implode('', $this->message) : $this->message;
}
$this->data['html'] = trim(str_replace("\n", "", $body));
diff --git a/src/Libraries/Mailer/Adapters/MandrillAdapter.php b/src/Libraries/Mailer/Adapters/MandrillAdapter.php
index fa482d009..b37076b5f 100644
--- a/src/Libraries/Mailer/Adapters/MandrillAdapter.php
+++ b/src/Libraries/Mailer/Adapters/MandrillAdapter.php
@@ -92,7 +92,7 @@ private function prepare()
if ($this->templatePath) {
$body = $this->createFromTemplate();
} else {
- $body = is_array($this->message) ? implode($this->message) : $this->message;
+ $body = is_array($this->message) ? implode('', $this->message) : $this->message;
}
$message['html'] = trim(str_replace("\n", "", $body));
diff --git a/src/Libraries/Mailer/Adapters/SendgridAdapter.php b/src/Libraries/Mailer/Adapters/SendgridAdapter.php
index 4b0cf7011..542aa4d72 100644
--- a/src/Libraries/Mailer/Adapters/SendgridAdapter.php
+++ b/src/Libraries/Mailer/Adapters/SendgridAdapter.php
@@ -88,7 +88,7 @@ public function prepare()
if ($this->templatePath) {
$body = $this->createFromTemplate();
} else {
- $body = is_array($this->message) ? implode($this->message) : $this->message;
+ $body = is_array($this->message) ? implode('', $this->message) : $this->message;
}
$this->data['content'] = [
diff --git a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php
index 3dc7b43e4..77fdb33ef 100644
--- a/src/Libraries/Mailer/Adapters/SendinblueAdapter.php
+++ b/src/Libraries/Mailer/Adapters/SendinblueAdapter.php
@@ -85,7 +85,7 @@ private function prepare()
if ($this->templatePath) {
$body = $this->createFromTemplate();
} else {
- $body = is_array($this->message) ? implode($this->message) : $this->message;
+ $body = is_array($this->message) ? implode('', $this->message) : $this->message;
}
$this->data['htmlContent'] = trim(str_replace("\n", "", $body));
diff --git a/src/Libraries/Mailer/Adapters/SmtpAdapter.php b/src/Libraries/Mailer/Adapters/SmtpAdapter.php
index 5bab38ecc..3ef3c7f02 100644
--- a/src/Libraries/Mailer/Adapters/SmtpAdapter.php
+++ b/src/Libraries/Mailer/Adapters/SmtpAdapter.php
@@ -247,7 +247,7 @@ private function prepare()
if ($this->templatePath) {
$body = $this->createFromTemplate();
} else {
- $body = is_array($this->message) ? implode($this->message) : $this->message;
+ $body = is_array($this->message) ? implode('', $this->message) : $this->message;
}
$this->mailer->Body = trim(str_replace("\n", "", $body));
@@ -268,7 +268,7 @@ private function prepare()
*/
private function fillProperties(string $method, array $fields = [])
{
- if (!empty($fields)) {
+ if ($fields !== []) {
foreach ($fields as $field) {
if (is_string($field)) {
$this->mailer->$method($field);
diff --git a/src/Libraries/Mailer/Exceptions/MailerException.php b/src/Libraries/Mailer/Exceptions/MailerException.php
index fe09b4a1a..9c0d23ea5 100644
--- a/src/Libraries/Mailer/Exceptions/MailerException.php
+++ b/src/Libraries/Mailer/Exceptions/MailerException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'mailer'));
}
- $adapter = $adapter ?? config()->get('mailer.default');
+ $adapter ??= config()->get('mailer.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/ResourceCache/Exceptions/ResourceCacheException.php b/src/Libraries/ResourceCache/Exceptions/ResourceCacheException.php
index 996716e1d..31e04eda1 100644
--- a/src/Libraries/ResourceCache/Exceptions/ResourceCacheException.php
+++ b/src/Libraries/ResourceCache/Exceptions/ResourceCacheException.php
@@ -1,5 +1,7 @@
getCacheFile($key);
-
- if (!$this->fs->exists($cacheFile) || $this->isExpired($cacheFile)) {
- return false;
- }
-
- return true;
+ return $this->fs->exists($cacheFile) && !$this->isExpired($cacheFile);
}
/**
diff --git a/src/Libraries/Session/Adapters/Database/DatabaseHandler.php b/src/Libraries/Session/Adapters/Database/DatabaseHandler.php
index b4b85a48e..e206da6f6 100644
--- a/src/Libraries/Session/Adapters/Database/DatabaseHandler.php
+++ b/src/Libraries/Session/Adapters/Database/DatabaseHandler.php
@@ -43,11 +43,7 @@ public function __construct(DbalInterface $sessionModel)
*/
public function open($path, $name): bool
{
- if ($this->sessionModel::getConnection()) {
- return true;
- }
-
- return false;
+ return (bool) $this->sessionModel::getConnection();
}
/**
@@ -55,11 +51,7 @@ public function open($path, $name): bool
*/
public function close(): bool
{
- if (!$this->sessionModel::getConnection()) {
- return true;
- }
-
- return false;
+ return !$this->sessionModel::getConnection();
}
/**
diff --git a/src/Libraries/Session/Adapters/Native/NativeSessionAdapter.php b/src/Libraries/Session/Adapters/Native/NativeSessionAdapter.php
index a4089fdf8..426d18c28 100644
--- a/src/Libraries/Session/Adapters/Native/NativeSessionAdapter.php
+++ b/src/Libraries/Session/Adapters/Native/NativeSessionAdapter.php
@@ -62,16 +62,12 @@ protected function initializeSession(?array $params = null): void
{
$timeout = $params['timeout'] ?? self::SESSION_TIMEOUT;
- if (session_status() !== PHP_SESSION_ACTIVE) {
- if (@session_start() === false) {
- throw SessionException::sessionNotStarted();
- }
+ if (session_status() !== PHP_SESSION_ACTIVE && @session_start() === false) {
+ throw SessionException::sessionNotStarted();
}
- if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > $timeout) {
- if (@session_destroy() === false) {
- throw SessionException::sessionNotDestroyed();
- }
+ if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > $timeout && @session_destroy() === false) {
+ throw SessionException::sessionNotDestroyed();
}
$_SESSION['LAST_ACTIVITY'] = time();
diff --git a/src/Libraries/Session/Exceptions/SessionException.php b/src/Libraries/Session/Exceptions/SessionException.php
index d7f16883b..46d894fe9 100644
--- a/src/Libraries/Session/Exceptions/SessionException.php
+++ b/src/Libraries/Session/Exceptions/SessionException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'session'));
}
- $adapter = $adapter ?? config()->get('session.default');
+ $adapter ??= config()->get('session.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php b/src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php
index 20d42cc3a..80c7c2c18 100644
--- a/src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php
+++ b/src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php
@@ -269,7 +269,7 @@ public function path(string $name): array
*/
private function accessTokenNeedsRefresh(int $code, ?object $message = null): bool
{
- if ($code != self::INVALID_TOKEN_ERROR_CODE) {
+ if ($code !== self::INVALID_TOKEN_ERROR_CODE) {
return false;
}
diff --git a/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveApp.php b/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveApp.php
index f5419a5dd..37816f2ab 100644
--- a/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveApp.php
+++ b/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveApp.php
@@ -194,7 +194,7 @@ public function rpcRequest(string $url, $params = [], string $method = 'POST', s
];
return $this->sendRequest($url, $params, $headers, $method);
}catch (Exception $e){
- throw new Exception($e->getMessage(), (int)$e->getCode());
+ throw new Exception($e->getMessage(), (int)$e->getCode(), $e);
}
}
@@ -219,10 +219,6 @@ public function getFileInfo(string $fileId, bool $media = false, array $params =
*/
private function accessTokenNeedsRefresh(int $code, ?object $message = null): bool
{
- if ($code != self::INVALID_TOKEN_ERROR_CODE) {
- return false;
- }
-
- return true;
+ return $code === self::INVALID_TOKEN_ERROR_CODE;
}
}
\ No newline at end of file
diff --git a/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php b/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php
index 5c30bec3b..4b116231a 100644
--- a/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php
+++ b/src/Libraries/Storage/Adapters/GoogleDrive/GoogleDriveFileSystemAdapter.php
@@ -171,7 +171,7 @@ public function lastModified(string $filename)
{
try {
$meta = (array)$this->googleDriveApp->getFileInfo($filename);
- return !empty($meta['modifiedTime']) ? strtotime($meta['modifiedTime']) : false;
+ return empty($meta['modifiedTime']) ? false : strtotime($meta['modifiedTime']);
} catch (Exception $e) {
return false;
}
diff --git a/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php b/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php
index a8153e344..af9e8c556 100644
--- a/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php
+++ b/src/Libraries/Storage/Adapters/Local/LocalFileSystemAdapter.php
@@ -63,7 +63,7 @@ public function getJson(string $filename)
{
$content = file_get_contents($filename);
- if (empty($content)) {
+ if (in_array($content, ['', '0', false], true)) {
return false;
}
@@ -164,7 +164,7 @@ public function listDirectory(string $dirname)
try {
foreach (scandir($dirname) as $item) {
- if ($item != '.' && $item != '..') {
+ if ($item !== '.' && $item !== '..') {
$entries[] = realpath($dirname . DS . $item);
}
}
diff --git a/src/Libraries/Storage/Exceptions/FileSystemException.php b/src/Libraries/Storage/Exceptions/FileSystemException.php
index 7d7c7a53d..b3b801b16 100644
--- a/src/Libraries/Storage/Exceptions/FileSystemException.php
+++ b/src/Libraries/Storage/Exceptions/FileSystemException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'fs'));
}
- $adapter = $adapter ?? config()->get('fs.default');
+ $adapter ??= config()->get('fs.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Libraries/Storage/UploadedFile.php b/src/Libraries/Storage/UploadedFile.php
index 919be58df..e160aba4b 100644
--- a/src/Libraries/Storage/UploadedFile.php
+++ b/src/Libraries/Storage/UploadedFile.php
@@ -251,7 +251,7 @@ public function getDimensions(): array
throw FileUploadException::fileTypeNotAllowed($this->getExtension());
}
- list($width, $height) = getimagesize($this->getPathname());
+ [$width, $height] = getimagesize($this->getPathname());
return [
'width' => $width,
@@ -370,7 +370,7 @@ public function isUploaded(): bool
*/
public function isImage($filePath): bool
{
- return !!getimagesize($filePath);
+ return (bool) getimagesize($filePath);
}
/**
@@ -382,12 +382,10 @@ protected function moveUploadedFile(string $filePath): bool
{
if ($this->remoteFileSystem) {
return (bool)$this->remoteFileSystem->put($filePath, $this->localFileSystem->get($this->getPathname()));
+ } elseif ($this->isUploaded()) {
+ return move_uploaded_file($this->getPathname(), $filePath);
} else {
- if ($this->isUploaded()) {
- return move_uploaded_file($this->getPathname(), $filePath);
- } else {
- return $this->localFileSystem->copy($this->getPathname(), $filePath);
- }
+ return $this->localFileSystem->copy($this->getPathname(), $filePath);
}
}
@@ -433,7 +431,7 @@ protected function loadAllowedMimeTypesFromConfig(): void
throw FileUploadException::incorrectMimeTypesConfig('uploads');
}
- if ($allowedMimeTypesMap) {
+ if ($allowedMimeTypesMap !== []) {
$this->setAllowedMimeTypesMap($allowedMimeTypesMap);
}
}
@@ -446,11 +444,7 @@ protected function loadAllowedMimeTypesFromConfig(): void
*/
protected function setAllowedMimeTypesMap(array $allowedMimeTypes, bool $merge = true): void
{
- if ($merge) {
- $this->allowedMimeTypes = array_merge_recursive($this->allowedMimeTypes, $allowedMimeTypes);
- } else {
- $this->allowedMimeTypes = $allowedMimeTypes;
- }
+ $this->allowedMimeTypes = $merge ? array_merge_recursive($this->allowedMimeTypes, $allowedMimeTypes) : $allowedMimeTypes;
}
/**
diff --git a/src/Libraries/Validation/Traits/File.php b/src/Libraries/Validation/Traits/File.php
index c31322b64..2122d412c 100644
--- a/src/Libraries/Validation/Traits/File.php
+++ b/src/Libraries/Validation/Traits/File.php
@@ -34,7 +34,7 @@ trait File
public function fileSize(UploadedFile $file, int $maxSize, ?int $minSize = null): bool
{
$size = $file->getSize();
- $minSize = $minSize ?? 0;
+ $minSize ??= 0;
return $size >= $minSize && $size <= $maxSize;
}
@@ -73,7 +73,7 @@ public function imageDimensions(UploadedFile $file, ?int $width = null, ?int $he
{
$dimensions = $file->getDimensions();
- if (empty($dimensions)) {
+ if ($dimensions === []) {
return true;
}
diff --git a/src/Libraries/Validation/Traits/General.php b/src/Libraries/Validation/Traits/General.php
index e756436cc..bd1d9e9f6 100644
--- a/src/Libraries/Validation/Traits/General.php
+++ b/src/Libraries/Validation/Traits/General.php
@@ -37,7 +37,7 @@ trait General
*/
protected function required(string $value): bool
{
- return !empty($value);
+ return $value !== '' && $value !== '0';
}
/**
@@ -70,7 +70,7 @@ protected function creditCard(string $value): bool
for ($i = 0; $i < $length; ++$i) {
$digit = $number[$i];
- if ($i % 2 == $parity) {
+ if ($i % 2 === $parity) {
$digit *= 2;
if ($digit > 9) {
@@ -81,7 +81,7 @@ protected function creditCard(string $value): bool
$total += $digit;
}
- return $total % 10 == 0;
+ return $total % 10 === 0;
}
/**
@@ -174,7 +174,7 @@ protected function date(string $value, ?string $format = null): bool
*/
protected function starts(string $value, ?string $text = null): bool
{
- return strpos($value, $text) === 0;
+ return strpos($value, (string) $text) === 0;
}
/**
diff --git a/src/Libraries/Validation/Traits/Lists.php b/src/Libraries/Validation/Traits/Lists.php
index ccde926b8..5a41c4630 100644
--- a/src/Libraries/Validation/Traits/Lists.php
+++ b/src/Libraries/Validation/Traits/Lists.php
@@ -45,9 +45,7 @@ protected function containsList(string $value, string ...$list): bool
{
$value = trim(strtolower($value));
- $list = array_map(function ($item) {
- return trim(strtolower($item));
- }, $list);
+ $list = array_map(fn($item) => trim(strtolower($item)), $list);
return in_array($value, $list);
}
@@ -62,9 +60,7 @@ protected function doesntContainsList(string $value, string ...$list): bool
{
$value = trim(strtolower($value));
- $list = array_map(function ($item) {
- return trim(strtolower($item));
- }, $list);
+ $list = array_map(fn($item) => trim(strtolower($item)), $list);
return !in_array($value, $list);
}
diff --git a/src/Libraries/Validation/Validator.php b/src/Libraries/Validation/Validator.php
index c9a61dae1..77bcdeb9f 100644
--- a/src/Libraries/Validation/Validator.php
+++ b/src/Libraries/Validation/Validator.php
@@ -105,7 +105,7 @@ public function updateRule(string $field, array $rule)
* @param string|null $rule Specific rule to delete; if null deletes all rules for field
* @return void
*/
- public function deleteRule(string $field, string $rule = null): void
+ public function deleteRule(string $field, ?string $rule = null): void
{
if (!isset($this->rules[$field])) {
return;
@@ -142,7 +142,7 @@ public function isValid(array $data): bool
$this->data = $data;
$this->flushErrors();
- if (empty($this->rules)) {
+ if ($this->rules === []) {
return true;
}
@@ -174,7 +174,7 @@ public function isValid(array $data): bool
}
}
- return empty($this->errors);
+ return $this->errors === [];
}
/**
@@ -185,7 +185,7 @@ public function isValid(array $data): bool
*/
public function addRule(string $rule, Closure $function): void
{
- if (empty($rule) || !is_callable($function)) {
+ if ($rule === '' || $rule === '0' || !is_callable($function)) {
return;
}
@@ -198,7 +198,7 @@ public function addRule(string $rule, Closure $function): void
*/
public function getErrors(): array
{
- if (empty($this->errors)) {
+ if ($this->errors === []) {
return [];
}
diff --git a/src/Loader/Exceptions/LoaderException.php b/src/Loader/Exceptions/LoaderException.php
index 419f7500b..95d29d161 100644
--- a/src/Loader/Exceptions/LoaderException.php
+++ b/src/Loader/Exceptions/LoaderException.php
@@ -1,5 +1,7 @@
getMiddleware($request, $response);
- list($request, $response) = $currentMiddleware->apply($request, $response, function ($request, $response) {
+ [$request, $response] = $currentMiddleware->apply($request, $response, function ($request, $response) {
next($this->middlewares);
return [$request, $response];
});
diff --git a/src/Migration/Exceptions/MigrationException.php b/src/Migration/Exceptions/MigrationException.php
index 8b80433a9..71fe7cdae 100644
--- a/src/Migration/Exceptions/MigrationException.php
+++ b/src/Migration/Exceptions/MigrationException.php
@@ -1,5 +1,7 @@
getMigratedEntries();
$migrationFiles = $this->getMigrationFiles();
- if (empty($migratedEntries) && empty($migrationFiles)) {
+ if ($migratedEntries === [] && $migrationFiles === []) {
throw MigrationException::nothingToMigrate();
}
@@ -277,7 +277,7 @@ private function prepareDownMigrations(?int $step = null)
{
$migratedEntries = $this->getMigratedEntries();
- if (empty($migratedEntries)) {
+ if ($migratedEntries === []) {
throw MigrationException::nothingToMigrate();
}
diff --git a/src/Model/Exceptions/ModelException.php b/src/Model/Exceptions/ModelException.php
index 054d0268f..a2e82f776 100644
--- a/src/Model/Exceptions/ModelException.php
+++ b/src/Model/Exceptions/ModelException.php
@@ -1,5 +1,7 @@
processModels();
- $this->models = array_filter($this->models, function ($m) use ($model) {
- return $m !== $model;
- });
+ $this->models = array_filter($this->models, fn($m) => $m !== $model);
$this->originalModels = $this->models;
@@ -148,7 +146,7 @@ public function last(): ?QtModel
*/
public function isEmpty(): bool
{
- return $this->first() === null;
+ return !$this->first() instanceof \Quantum\Model\QtModel;
}
/**
diff --git a/src/Model/QtModel.php b/src/Model/QtModel.php
index e5417331e..98dd5e028 100644
--- a/src/Model/QtModel.php
+++ b/src/Model/QtModel.php
@@ -118,9 +118,7 @@ public function relations(): array
*/
public function get(): ModelCollection
{
- $models = array_map(function ($item) {
- return wrapToModel($item, static::class);
- }, $this->ormInstance->get());
+ $models = array_map(fn($item) => wrapToModel($item, static::class), $this->ormInstance->get());
return new ModelCollection($models);
}
diff --git a/src/Module/Exceptions/ModuleException.php b/src/Module/Exceptions/ModuleException.php
index c886170c7..d1230d1cc 100644
--- a/src/Module/Exceptions/ModuleException.php
+++ b/src/Module/Exceptions/ModuleException.php
@@ -1,5 +1,7 @@
data();
- if (empty($data)) {
+ if ($data === []) {
return null;
}
@@ -78,7 +78,7 @@ public function lastItem()
{
$data = $this->data();
- if (empty($data)) {
+ if ($data === []) {
return null;
}
diff --git a/src/Paginator/Adapters/ModelPaginator.php b/src/Paginator/Adapters/ModelPaginator.php
index 9aaac6286..0e1f07912 100644
--- a/src/Paginator/Adapters/ModelPaginator.php
+++ b/src/Paginator/Adapters/ModelPaginator.php
@@ -63,9 +63,7 @@ public function data(): ModelCollection
->get();
if($this->modelClass != '@anonymous') {
- $result = array_map(function ($item) {
- return wrapToModel($item->getOrmInstance(), $this->modelClass);
- }, iterator_to_array($result));
+ $result = array_map(fn($item) => wrapToModel($item->getOrmInstance(), $this->modelClass), iterator_to_array($result));
}
return new ModelCollection($result);
diff --git a/src/Paginator/Exceptions/PaginatorException.php b/src/Paginator/Exceptions/PaginatorException.php
index 8f00153df..faab9486c 100644
--- a/src/Paginator/Exceptions/PaginatorException.php
+++ b/src/Paginator/Exceptions/PaginatorException.php
@@ -1,5 +1,7 @@
links($withBaseUrl);
- list($startPage, $endPage) = $this->calculateStartEndPages($currentPage, $totalPages, $pageItemsCount);
+ [$startPage, $endPage] = $this->calculateStartEndPages($currentPage, $totalPages, $pageItemsCount);
$pagination[] = $this->addFirstPageLink($startPage);
$pagination[] = $this->getItemsLinks($startPage, $endPage, $currentPage, $links);
@@ -260,7 +260,7 @@ protected function getUri(bool $withBaseUrl = false): string
*/
protected function getPageLink(?int $pageNumber, bool $withBaseUrl = false): ?string
{
- if (!empty($pageNumber)) {
+ if ($pageNumber !== null && $pageNumber !== 0) {
return $this->getUri($withBaseUrl) . Pagination::PER_PAGE . '=' . $this->perPage . '&' . Pagination::PAGE . '=' . $pageNumber;
}
@@ -276,7 +276,7 @@ protected function getNextPageItem(?string $nextPageLink): string
{
$link = '';
- if (!empty($nextPageLink)) {
+ if (!in_array($nextPageLink, [null, '', '0'], true)) {
$link = '' . t('common.pagination.next') . '';
}
@@ -292,7 +292,7 @@ protected function getPreviousPageItem(?string $previousPageLink): string
{
$link = '';
- if (!empty($previousPageLink)) {
+ if (!in_array($previousPageLink, [null, '', '0'], true)) {
$link = '' . t('common.pagination.prev') . '';
}
@@ -309,10 +309,10 @@ protected function getPreviousPageItem(?string $previousPageLink): string
*/
protected function getItemsLinks(int $startPage, int $endPage, int $currentPage, array $links): string
{
- $pagination = '';
+ $pagination = [];
for ($i = $startPage; $i <= $endPage; $i++) {
- $active = $i == $currentPage ? 'class="' . Pagination::PAGINATION_CLASS_ACTIVE . '"' : '';
+ $active = $i === $currentPage ? 'class="' . Pagination::PAGINATION_CLASS_ACTIVE . '"' : '';
$pagination .= '' . $i . '';
}
diff --git a/src/Renderer/Adapters/HtmlAdapter.php b/src/Renderer/Adapters/HtmlAdapter.php
index da14ed26b..ef413a1f7 100644
--- a/src/Renderer/Adapters/HtmlAdapter.php
+++ b/src/Renderer/Adapters/HtmlAdapter.php
@@ -69,7 +69,7 @@ public function render(string $view, array $params = []): string
ob_start();
ob_implicit_flush(0);
- if (!empty($params)) {
+ if ($params !== []) {
extract($params);
}
diff --git a/src/Renderer/Exceptions/RendererException.php b/src/Renderer/Exceptions/RendererException.php
index db97a3976..7edf03aa1 100644
--- a/src/Renderer/Exceptions/RendererException.php
+++ b/src/Renderer/Exceptions/RendererException.php
@@ -1,5 +1,7 @@
import(new Setup('config', 'view'));
}
- $adapter = $adapter ?? config()->get('view.default');
+ $adapter ??= config()->get('view.default');
$adapterClass = self::getAdapterClass($adapter);
diff --git a/src/Router/Exceptions/RouteControllerException.php b/src/Router/Exceptions/RouteControllerException.php
index 32293957b..d5bb3d845 100644
--- a/src/Router/Exceptions/RouteControllerException.php
+++ b/src/Router/Exceptions/RouteControllerException.php
@@ -1,5 +1,7 @@
currentRoute = [
- 'route' => !empty($this->moduleOptions['prefix']) ? $this->moduleOptions['prefix'] . '/' . $route : $route,
+ 'route' => empty($this->moduleOptions['prefix']) ? $route : $this->moduleOptions['prefix'] . '/' . $route,
'prefix' => $this->moduleOptions['prefix'] ?? '',
'method' => $method,
'module' => $this->moduleName,
@@ -185,18 +185,14 @@ public function group(string $groupName, Closure $callback): Route
public function middlewares(array $middlewares = []): Route
{
if (!$this->isGroup) {
- end($this->virtualRoutes['*']);
- $lastKey = key($this->virtualRoutes['*']);
+ $lastKey = array_key_last($this->virtualRoutes['*']);
$this->assignMiddlewaresToRoute($this->virtualRoutes['*'][$lastKey], $middlewares);
return $this;
}
-
- end($this->virtualRoutes);
- $lastKeyOfFirstRound = key($this->virtualRoutes);
+ $lastKeyOfFirstRound = array_key_last($this->virtualRoutes);
if (!$this->isGroupMiddlewares) {
- end($this->virtualRoutes[$lastKeyOfFirstRound]);
- $lastKeyOfSecondRound = key($this->virtualRoutes[$lastKeyOfFirstRound]);
+ $lastKeyOfSecondRound = array_key_last($this->virtualRoutes[$lastKeyOfFirstRound]);
$this->assignMiddlewaresToRoute($this->virtualRoutes[$lastKeyOfFirstRound][$lastKeyOfSecondRound], $middlewares);
return $this;
}
@@ -224,8 +220,7 @@ public function cacheable(bool $shouldCache, ?int $ttl = null): Route
}
if (!$this->isGroup) {
- end($this->virtualRoutes['*']);
- $lastKey = key($this->virtualRoutes['*']);
+ $lastKey = array_key_last($this->virtualRoutes['*']);
$this->virtualRoutes['*'][$lastKey]['cache_settings']['shouldCache'] = $shouldCache;
@@ -235,9 +230,7 @@ public function cacheable(bool $shouldCache, ?int $ttl = null): Route
return $this;
}
-
- end($this->virtualRoutes);
- $lastKeyOfFirstRound = key($this->virtualRoutes);
+ $lastKeyOfFirstRound = array_key_last($this->virtualRoutes);
foreach ($this->virtualRoutes[$lastKeyOfFirstRound] as &$route) {
$route['cache_settings']['shouldCache'] = $shouldCache;
@@ -258,7 +251,7 @@ public function cacheable(bool $shouldCache, ?int $ttl = null): Route
*/
public function name(string $name): Route
{
- if (empty($this->currentRoute)) {
+ if ($this->currentRoute === []) {
throw RouteException::nameBeforeDefinition();
}
@@ -312,7 +305,7 @@ public function getVirtualRoutes(): array
*/
private function assignMiddlewaresToRoute(array &$route, array $middlewares)
{
- if (!key_exists('middlewares', $route)) {
+ if (!array_key_exists('middlewares', $route)) {
$route['middlewares'] = $middlewares;
} else {
$middlewares = array_reverse($middlewares);
diff --git a/src/Router/RouteDispatcher.php b/src/Router/RouteDispatcher.php
index cad4f67b5..f9204d9f9 100644
--- a/src/Router/RouteDispatcher.php
+++ b/src/Router/RouteDispatcher.php
@@ -38,7 +38,7 @@ public static function handle(Request $request): void
{
$callback = route_callback();
- if ($callback) {
+ if ($callback instanceof \Closure) {
self::callControllerMethod($callback);
return;
}
diff --git a/src/Router/Router.php b/src/Router/Router.php
index d1ecad8c4..8ec103f38 100644
--- a/src/Router/Router.php
+++ b/src/Router/Router.php
@@ -84,7 +84,7 @@ public function findRoute()
$this->matchedRoutes = $this->findMatches($uri);
- if (empty($this->matchedRoutes)) {
+ if ($this->matchedRoutes === []) {
stop(function () {
page_not_found();
});
@@ -179,7 +179,7 @@ private function findMatches(string $uri): array
$matches = [];
foreach (self::$routes as $route) {
- list($pattern, $params) = $this->handleRoutePattern($route);
+ [$pattern, $params] = $this->handleRoutePattern($route);
if (preg_match("/^" . $this->escape($pattern) . "$/u", $requestUri, $matchedParams)) {
$route['uri'] = $uri;
@@ -210,7 +210,7 @@ private function handleRoutePattern(array $route): array
foreach ($routeSegments as $index => $segment) {
$segmentParam = $this->getSegmentParam($segment, $index, $lastIndex);
- if (!empty($segmentParam)) {
+ if ($segmentParam !== []) {
$this->checkParamName($routeParams, $segmentParam['name']);
$routeParams[] = [
@@ -221,7 +221,7 @@ private function handleRoutePattern(array $route): array
$routePattern = $this->normalizePattern($routePattern, $segmentParam, $index, $lastIndex);
} else {
- $routePattern .= $segment . ($index != $lastIndex ? '(\/)' : '');
+ $routePattern .= $segment . ($index !== $lastIndex ? '(\/)' : '');
}
}
@@ -241,10 +241,10 @@ private function handleRoutePattern(array $route): array
*/
private function normalizePattern(string $routePattern, array $segmentParam, int $index, int $lastIndex): string
{
- if ($index == $lastIndex) {
- if (mb_substr($routePattern, -5) == '(\/)?') {
+ if ($index === $lastIndex) {
+ if (mb_substr($routePattern, -5) === '(\/)?') {
$routePattern = mb_substr($routePattern, 0, mb_strlen($routePattern) - 5);
- } elseif (mb_substr($routePattern, -4) == '(\/)') {
+ } elseif (mb_substr($routePattern, -4) === '(\/)') {
$routePattern = mb_substr($routePattern, 0, mb_strlen($routePattern) - 4);
}
}
@@ -264,7 +264,7 @@ private function routeParams(array $params, array $arguments): array
foreach ($params as &$param) {
$param['value'] = $arguments[$param['name']] ?? null;
- if (mb_substr($param['name'], 0, 1) == '_') {
+ if (mb_substr($param['name'], 0, 1) === '_') {
$param['name'] = null;
}
}
@@ -328,9 +328,9 @@ private function getParamPattern(array $match, string $expr, int $index, int $la
}
if (isset($match[5]) && $match[5] == '?') {
- $pattern = ($index == $lastIndex ? '(\/)?' . $pattern : $pattern . '(\/)?');
+ $pattern = ($index === $lastIndex ? '(\/)?' . $pattern : $pattern . '(\/)?');
} else {
- $pattern = ($index == $lastIndex ? '(\/)' . $pattern : $pattern . '(\/)');
+ $pattern = ($index === $lastIndex ? '(\/)' . $pattern : $pattern . '(\/)');
}
return [
diff --git a/src/Service/Exceptions/ServiceException.php b/src/Service/Exceptions/ServiceException.php
index 7ea4afa17..c89ac6fe3 100644
--- a/src/Service/Exceptions/ServiceException.php
+++ b/src/Service/Exceptions/ServiceException.php
@@ -1,5 +1,7 @@
getTrace() as $item) {
- if (($item['class'] ?? null) === __CLASS__) {
+ if (($item['class'] ?? null) === self::class) {
continue;
}
diff --git a/src/View/Exceptions/ViewException.php b/src/View/Exceptions/ViewException.php
index 43791bdac..f70c3e5fe 100644
--- a/src/View/Exceptions/ViewException.php
+++ b/src/View/Exceptions/ViewException.php
@@ -1,5 +1,7 @@
convertToHtml($content);
- if ($purifier) {
+ if ($purifier instanceof \HTMLPurifier) {
return $purifier->purify($html);
}
diff --git a/src/View/QtView.php b/src/View/QtView.php
index 43f0c4fcd..d6c299a38 100644
--- a/src/View/QtView.php
+++ b/src/View/QtView.php
@@ -107,7 +107,7 @@ public function setLayout(?string $layoutFile, array $assets = [])
{
$this->layoutFile = $layoutFile;
- if(!empty($assets)) {
+ if($assets !== []) {
$this->assets = array_merge($this->assets, $assets);
}
}
@@ -211,13 +211,13 @@ public function render(string $viewFile, array $params = []): ?string
throw ViewException::noLayoutSet();
}
- if (!empty($params)) {
+ if ($params !== []) {
$this->params = array_merge($this->params, $params);
}
$this->viewContent = $this->renderFile($viewFile);
- if (!empty($this->assets)) {
+ if ($this->assets !== []) {
$this->assetManager->register($this->assets);
}
@@ -244,7 +244,7 @@ public function render(string $viewFile, array $params = []): ?string
*/
public function renderPartial(string $viewFile, array $params = []): string
{
- if (!empty($params)) {
+ if ($params !== []) {
$this->params = array_merge($this->params, $params);
}
diff --git a/tests/Unit/Http/Helpers/HttpHelperTest.php b/tests/Unit/Http/Helpers/HttpHelperTest.php
index 23d371d47..c9dfac3c0 100644
--- a/tests/Unit/Http/Helpers/HttpHelperTest.php
+++ b/tests/Unit/Http/Helpers/HttpHelperTest.php
@@ -12,6 +12,7 @@
class HttpHelperTest extends AppTestCase
{
+ public $session;
private $request;
private $response;
diff --git a/tests/Unit/Libraries/Auth/AuthTestCase.php b/tests/Unit/Libraries/Auth/AuthTestCase.php
index e4f1c0f31..425d6250a 100644
--- a/tests/Unit/Libraries/Auth/AuthTestCase.php
+++ b/tests/Unit/Libraries/Auth/AuthTestCase.php
@@ -86,7 +86,7 @@ public function setUp(): void
Environment::getInstance()->load(new Setup('config', 'env'));
- $this->authService = Mockery::mock('Quantum\Libraries\Auth\Contracts\AuthServiceInterface');
+ $this->authService = Mockery::mock(\Quantum\Libraries\Auth\Contracts\AuthServiceInterface::class);
$this->authService->shouldReceive('userSchema')->andReturn($this->userSchema);
diff --git a/tests/Unit/Libraries/Captcha/Adapters/HcaptchaAdapterTest.php b/tests/Unit/Libraries/Captcha/Adapters/HcaptchaAdapterTest.php
index 94241aeeb..1498787ab 100644
--- a/tests/Unit/Libraries/Captcha/Adapters/HcaptchaAdapterTest.php
+++ b/tests/Unit/Libraries/Captcha/Adapters/HcaptchaAdapterTest.php
@@ -11,6 +11,7 @@
class HcaptchaAdapterTest extends AppTestCase
{
+ public $httpClientMock;
private $secretKey = '10000000-ffff-ffff-ffff-000000000001';
private $siteKey = '0x0000000000000000000000000000000000000000';
diff --git a/tests/Unit/Libraries/Captcha/Adapters/RecaptchaAdapterTest.php b/tests/Unit/Libraries/Captcha/Adapters/RecaptchaAdapterTest.php
index 9c87c8002..c281dcfd5 100644
--- a/tests/Unit/Libraries/Captcha/Adapters/RecaptchaAdapterTest.php
+++ b/tests/Unit/Libraries/Captcha/Adapters/RecaptchaAdapterTest.php
@@ -12,6 +12,7 @@
class RecaptchaAdapterTest extends AppTestCase
{
+ public $httpClientMock;
private $secretKey = '10000000-ffff-ffff-ffff-000000000001';
private $siteKey = '0x0000000000000000000000000000000000000000';
diff --git a/tests/Unit/Libraries/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php b/tests/Unit/Libraries/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php
index 166bd593c..92b4948a0 100644
--- a/tests/Unit/Libraries/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php
+++ b/tests/Unit/Libraries/Database/Adapters/Sleekdb/Statements/CriteriaSleekTest.php
@@ -8,6 +8,7 @@
class CriteriaSleekTest extends SleekDbalTestCase
{
+ public $userProfileModel;
public function testSleekCriteriaEquals()
{
$this->userProfileModel = new SleekDbal('profiles');
diff --git a/tests/Unit/Libraries/Database/Factories/TableFactoryTest.php b/tests/Unit/Libraries/Database/Factories/TableFactoryTest.php
index 4d47ad173..8d1813bdc 100644
--- a/tests/Unit/Libraries/Database/Factories/TableFactoryTest.php
+++ b/tests/Unit/Libraries/Database/Factories/TableFactoryTest.php
@@ -31,7 +31,7 @@ public function setUp(): void
$this->tableFactory = new TableFactory();
Mockery::getConfiguration()->setConstantsMap([
- 'Quantum\Libraries\Database\Schemas\Table' => [
+ \Quantum\Libraries\Database\Schemas\Table::class => [
'CREATE' => 1,
'ALTER' => 2,
'DROP' => 3,
@@ -41,13 +41,9 @@ public function setUp(): void
$this->table = Mockery::mock('overload:Quantum\Libraries\Database\Schemas\Table');
- $this->table->shouldReceive('setAction')->andReturnUsing(function ($action) {
- return $this->table;
- });
+ $this->table->shouldReceive('setAction')->andReturnUsing(fn($action) => $this->table);
- $this->table->shouldReceive('getAction')->andReturnUsing(function () {
- return $this->table->action;
- });
+ $this->table->shouldReceive('getAction')->andReturnUsing(fn() => $this->table->action);
$this->table->shouldReceive('save')->andReturn(0);
}
diff --git a/tests/Unit/Libraries/HttpClient/HttpClientTest.php b/tests/Unit/Libraries/HttpClient/HttpClientTest.php
index 1e21b5452..eae7a6a33 100644
--- a/tests/Unit/Libraries/HttpClient/HttpClientTest.php
+++ b/tests/Unit/Libraries/HttpClient/HttpClientTest.php
@@ -245,7 +245,7 @@ public function testHttpClientGetError()
$this->assertEquals(6, $errors['code']);
- $this->assertEquals('Couldn\'t resolve host name (CURLE_COULDNT_RESOLVE_HOST): Could not resolve host: test.comx', $errors['message']);
+ $this->assertStringContainsString('CURLE_COULDNT_RESOLVE_HOST', $errors['message']);
}
public function testHttpClientMultiRequestGetError()
@@ -264,7 +264,7 @@ public function testHttpClientMultiRequestGetError()
$this->assertEquals(6, $errors[0]['code']);
- $this->assertEquals('Couldn\'t resolve host name (CURLE_COULDNT_RESOLVE_HOST): Could not resolve host: test.comx', $errors[0]['message']);
+ $this->assertStringContainsString('CURLE_COULDNT_RESOLVE_HOST', $errors[0]['message']);
}
public function testHttpClientCurlInfo()
diff --git a/tests/Unit/Libraries/Mailer/Adapters/MailgunAdapterTest.php b/tests/Unit/Libraries/Mailer/Adapters/MailgunAdapterTest.php
index a8afd36dc..34408a53a 100644
--- a/tests/Unit/Libraries/Mailer/Adapters/MailgunAdapterTest.php
+++ b/tests/Unit/Libraries/Mailer/Adapters/MailgunAdapterTest.php
@@ -8,9 +8,6 @@
class MailgunAdapterTest extends MailerTestCase
{
-
- protected $adapter;
-
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Mailer/Adapters/MandrillAdapterTest.php b/tests/Unit/Libraries/Mailer/Adapters/MandrillAdapterTest.php
index e69ee078e..b4e695eec 100644
--- a/tests/Unit/Libraries/Mailer/Adapters/MandrillAdapterTest.php
+++ b/tests/Unit/Libraries/Mailer/Adapters/MandrillAdapterTest.php
@@ -8,9 +8,6 @@
class MandrillAdapterTest extends MailerTestCase
{
-
- protected $adapter;
-
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Mailer/Adapters/SendgridAdapterTest.php b/tests/Unit/Libraries/Mailer/Adapters/SendgridAdapterTest.php
index 6eddc4f07..934f8ccbe 100644
--- a/tests/Unit/Libraries/Mailer/Adapters/SendgridAdapterTest.php
+++ b/tests/Unit/Libraries/Mailer/Adapters/SendgridAdapterTest.php
@@ -8,9 +8,6 @@
class SendgridAdapterTest extends MailerTestCase
{
-
- protected $adapter;
-
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Mailer/Adapters/SendinblueAdapterTest.php b/tests/Unit/Libraries/Mailer/Adapters/SendinblueAdapterTest.php
index 751b0f424..d4f2532bd 100644
--- a/tests/Unit/Libraries/Mailer/Adapters/SendinblueAdapterTest.php
+++ b/tests/Unit/Libraries/Mailer/Adapters/SendinblueAdapterTest.php
@@ -8,9 +8,6 @@
class SendinblueAdapterTest extends MailerTestCase
{
-
- protected $adapter;
-
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Mailer/Adapters/SmtpAdapterTest.php b/tests/Unit/Libraries/Mailer/Adapters/SmtpAdapterTest.php
index cd9814477..85f9c7e69 100644
--- a/tests/Unit/Libraries/Mailer/Adapters/SmtpAdapterTest.php
+++ b/tests/Unit/Libraries/Mailer/Adapters/SmtpAdapterTest.php
@@ -9,9 +9,6 @@
class SmtpAdapterTest extends MailerTestCase
{
-
- protected $adapter;
-
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Mailer/MailerTestCase.php b/tests/Unit/Libraries/Mailer/MailerTestCase.php
index 776a9b761..5f74d3033 100644
--- a/tests/Unit/Libraries/Mailer/MailerTestCase.php
+++ b/tests/Unit/Libraries/Mailer/MailerTestCase.php
@@ -7,6 +7,7 @@
abstract class MailerTestCase extends AppTestCase
{
+ protected $adapter;
public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/Unit/Libraries/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php b/tests/Unit/Libraries/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
index b96d0ffe0..e8ddf7051 100644
--- a/tests/Unit/Libraries/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
+++ b/tests/Unit/Libraries/Storage/Adapters/Dropbox/DropboxFileSystemAdapterTest.php
@@ -60,9 +60,7 @@ public function setUp(): void
$dropboxAppMock
->shouldReceive('path')
- ->andReturnUsing(function ($path) {
- return ['path' => '/' . trim($path, '/')];
- });
+ ->andReturnUsing(fn($path) => ['path' => '/' . trim($path, '/')]);
$this->fs = new DropboxFileSystemAdapter($dropboxAppMock);
}
diff --git a/tests/Unit/Libraries/Storage/FileSystemTest.php b/tests/Unit/Libraries/Storage/FileSystemTest.php
index 9458c0bd5..c7634bdd6 100644
--- a/tests/Unit/Libraries/Storage/FileSystemTest.php
+++ b/tests/Unit/Libraries/Storage/FileSystemTest.php
@@ -16,6 +16,7 @@
class FileSystemTest extends AppTestCase
{
+ public $googleDriveAppMock;
private $dropboxAppMock;
public function setUp(): void
diff --git a/tests/Unit/Libraries/Storage/HttpClientTestCase.php b/tests/Unit/Libraries/Storage/HttpClientTestCase.php
index 5e9bd1953..8352d7538 100644
--- a/tests/Unit/Libraries/Storage/HttpClientTestCase.php
+++ b/tests/Unit/Libraries/Storage/HttpClientTestCase.php
@@ -43,17 +43,11 @@ protected function mockHttpClient()
return $httpClientMock;
});
- $httpClientMock->shouldReceive('getErrors')->andReturnUsing(function () {
- return (array)$this->response[$this->url]['errors'];
- });
+ $httpClientMock->shouldReceive('getErrors')->andReturnUsing(fn() => (array)$this->response[$this->url]['errors']);
- $httpClientMock->shouldReceive('getResponseBody')->andReturnUsing(function () {
- return $this->response[$this->url]['body'];
- });
+ $httpClientMock->shouldReceive('getResponseBody')->andReturnUsing(fn() => $this->response[$this->url]['body']);
- $httpClientMock->shouldReceive('url')->andReturnUsing(function() {
- return $this->url;
- });
+ $httpClientMock->shouldReceive('url')->andReturnUsing(fn() => $this->url);
return $httpClientMock;
}
diff --git a/tests/Unit/Libraries/Validation/Traits/FileRuleTest.php b/tests/Unit/Libraries/Validation/Traits/FileRuleTest.php
index f0f584078..40b9a9c3e 100644
--- a/tests/Unit/Libraries/Validation/Traits/FileRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/FileRuleTest.php
@@ -10,6 +10,7 @@
class FileRuleTest extends AppTestCase
{
+ public $validator;
private $request;
public function setUp(): void
diff --git a/tests/Unit/Libraries/Validation/Traits/GeneralRuleTest.php b/tests/Unit/Libraries/Validation/Traits/GeneralRuleTest.php
index eef44c0f1..ab5d159b8 100644
--- a/tests/Unit/Libraries/Validation/Traits/GeneralRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/GeneralRuleTest.php
@@ -13,6 +13,7 @@
class GeneralRuleTest extends AppTestCase
{
+ public $validator;
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Validation/Traits/LengthRuleTest.php b/tests/Unit/Libraries/Validation/Traits/LengthRuleTest.php
index f689a560e..b717b2ec0 100644
--- a/tests/Unit/Libraries/Validation/Traits/LengthRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/LengthRuleTest.php
@@ -9,6 +9,7 @@
class LengthRuleTest extends AppTestCase
{
+ public $validator;
private $request;
public function setUp(): void
diff --git a/tests/Unit/Libraries/Validation/Traits/ListRuleTest.php b/tests/Unit/Libraries/Validation/Traits/ListRuleTest.php
index 72e2bf9ac..8e08ec336 100644
--- a/tests/Unit/Libraries/Validation/Traits/ListRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/ListRuleTest.php
@@ -9,6 +9,7 @@
class ListRuleTest extends AppTestCase
{
+ public $validator;
private $request;
public function setUp(): void
diff --git a/tests/Unit/Libraries/Validation/Traits/ResourceRuleTest.php b/tests/Unit/Libraries/Validation/Traits/ResourceRuleTest.php
index fb2f145c7..384744afb 100644
--- a/tests/Unit/Libraries/Validation/Traits/ResourceRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/ResourceRuleTest.php
@@ -9,6 +9,7 @@
class ResourceRuleTest extends AppTestCase
{
+ public $validator;
private $request;
public function setUp(): void
diff --git a/tests/Unit/Libraries/Validation/Traits/TypeRuleTest.php b/tests/Unit/Libraries/Validation/Traits/TypeRuleTest.php
index f0d64a44d..bb4575fe1 100644
--- a/tests/Unit/Libraries/Validation/Traits/TypeRuleTest.php
+++ b/tests/Unit/Libraries/Validation/Traits/TypeRuleTest.php
@@ -9,6 +9,7 @@
class TypeRuleTest extends AppTestCase
{
+ public $validator;
public function setUp(): void
{
parent::setUp();
diff --git a/tests/Unit/Libraries/Validation/ValidatorTest.php b/tests/Unit/Libraries/Validation/ValidatorTest.php
index 5f4318cb9..827e92d6d 100644
--- a/tests/Unit/Libraries/Validation/ValidatorTest.php
+++ b/tests/Unit/Libraries/Validation/ValidatorTest.php
@@ -169,9 +169,7 @@ public function testDifferentMultipleFields()
public function testCustomValidator()
{
- $this->validator->addRule('checkName', function ($value, $param = null) {
- return $value == $param;
- });
+ $this->validator->addRule('checkName', fn($value, $param = null) => $value == $param);
$this->validator->setRules([
'name' => [
diff --git a/tests/Unit/Module/ModuleLoaderTest.php b/tests/Unit/Module/ModuleLoaderTest.php
index beeb2dfa2..3c562ea2b 100644
--- a/tests/Unit/Module/ModuleLoaderTest.php
+++ b/tests/Unit/Module/ModuleLoaderTest.php
@@ -8,6 +8,7 @@
class ModuleLoaderTest extends AppTestCase
{
+ public $moduleLoader;
public function setUp(): void
{
parent::setUp();
@@ -46,11 +47,11 @@ public function testLoadModulesDependencies()
$this->assertIsArray($deps);
- $this->assertArrayHasKey("Quantum\Libraries\Transformer\Contracts\TransformerInterface", $deps);
- $this->assertSame("Quantum\Tests\_root\modules\Test\Transformers\PostTransformer", $deps["Quantum\Libraries\Transformer\Contracts\TransformerInterface"]);
+ $this->assertArrayHasKey(\Quantum\Libraries\Transformer\Contracts\TransformerInterface::class, $deps);
+ $this->assertSame(\Quantum\Tests\_root\modules\Test\Transformers\PostTransformer::class, $deps[\Quantum\Libraries\Transformer\Contracts\TransformerInterface::class]);
- $this->assertArrayHasKey("Quantum\Libraries\Storage\Contracts\TokenServiceInterface", $deps);
- $this->assertSame("Quantum\Tests\_root\shared\Services\TokenService", $deps["Quantum\Libraries\Storage\Contracts\TokenServiceInterface"]);
+ $this->assertArrayHasKey(\Quantum\Libraries\Storage\Contracts\TokenServiceInterface::class, $deps);
+ $this->assertSame(\Quantum\Tests\_root\shared\Services\TokenService::class, $deps[\Quantum\Libraries\Storage\Contracts\TokenServiceInterface::class]);
}
public function testGetModuleConfigs()
diff --git a/tests/_root/shared/config/cache.php b/tests/_root/shared/config/cache.php
index 8ba4ace1a..326bcbeb3 100644
--- a/tests/_root/shared/config/cache.php
+++ b/tests/_root/shared/config/cache.php
@@ -3,25 +3,25 @@
'default' => 'file',
'file' => [
- 'prefix' => str_replace(' ', '', env('APP_NAME')),
+ 'prefix' => str_replace(' ', '', env('APP_NAME') ?? ''),
'path' => base_dir() . DS . 'cache' . DS . 'data',
'ttl' => 600
],
'database' => [
- 'prefix' => str_replace(' ', '', env('APP_NAME')),
+ 'prefix' => str_replace(' ', '', env('APP_NAME') ?? ''),
'table' => 'cache',
'ttl' => 60
],
'memcached' => [
- 'prefix' => str_replace(' ', '', env('APP_NAME')),
+ 'prefix' => str_replace(' ', '', env('APP_NAME') ?? ''),
'host' => '127.0.0.1',
'port' => 11211,
'ttl' => 60
],
'redis' => [
- 'prefix' => str_replace(' ', '', env('APP_NAME')),
+ 'prefix' => str_replace(' ', '', env('APP_NAME') ?? ''),
'host' => '127.0.0.1',
'port' => 6379,
'ttl' => 60
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 31fdc78e7..5dd247e20 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,10 +1,14 @@