Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
phpVersion: 70400
level: 5
level: 6

paths:
- src
Expand Down
5 changes: 4 additions & 1 deletion src/App/Adapters/WebAppAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ public function start(): ?int

$this->loadLanguage();

info(HookManager::getInstance()->getRegistered(), ['tab' => Debugger::HOOKS]);
$debugger = Debugger::getInstance();
if ($debugger->isEnabled()) {
$debugger->addToStoreCell(Debugger::HOOKS, 'info', HookManager::getInstance()->getRegistered());
}

$middlewareManager = new MiddlewareManager($matchedRoute);

Expand Down
1 change: 1 addition & 0 deletions src/App/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function getAdapter(): AppInterface
}

/**
* @param array<mixed>|null $arguments
* @return mixed
* @throws BaseException
*/
Expand Down
3 changes: 3 additions & 0 deletions src/App/Factories/AppFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class AppFactory
App::CONSOLE => ConsoleAppAdapter::class,
];

/**
* @var array<string, App>
*/
private static array $instances = [];

/**
Expand Down
1 change: 1 addition & 0 deletions src/App/Helpers/dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function deleteDirectoryWithFiles(string $dir): bool

/**
* Gets directory classes
* @return array<string>
*/
function get_directory_classes(string $path): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/App/Helpers/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* Compose a message
* @param string|array $params
* @param string|array<string> $params
*/
function _message(string $subject, $params): string
{
Expand Down Expand Up @@ -109,7 +109,7 @@ function get_caller_function(int $index = 2): ?string

/**
* Exports the variable
* @param $var
* @param mixed $var
* @throws ExceptionInterface
*/
function export($var): string
Expand Down
2 changes: 1 addition & 1 deletion src/App/Traits/AppTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function getBaseDir(): string
/**
* @throws DiException
*/
protected function loadCoreDependencies()
protected function loadCoreDependencies(): void
{
$file = dirname(__DIR__) . DS . 'Config' . DS . 'dependencies.php';

Expand Down
2 changes: 1 addition & 1 deletion src/App/Traits/ConsoleAppTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ trait ConsoleAppTrait
* @throws EnvException
* @throws BaseException
*/
protected function loadEnvironment()
protected function loadEnvironment(): void
{
Environment::getInstance()
->setMutable(true)
Expand Down
2 changes: 1 addition & 1 deletion src/App/Traits/WebAppTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait WebAppTrait
* @throws EnvException
* @throws BaseException
*/
protected function loadEnvironment()
protected function loadEnvironment(): void
{
Environment::getInstance()->load(new Setup('config', 'env'));
}
Expand Down
3 changes: 3 additions & 0 deletions src/Archive/Adapters/ZipAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function addFromString(string $entryName, string $content): bool

/**
* @inheritDoc
* @param array<string, string> $fileNames
* @throws ArchiveException
*/
public function addMultipleFiles(array $fileNames): bool
Expand Down Expand Up @@ -146,6 +147,7 @@ public function count(): int

/**
* @inheritDoc
* @param array<string>|null $files
* @throws ArchiveException
*/
public function extractTo(string $pathToExtract, $files = null): bool
Expand Down Expand Up @@ -175,6 +177,7 @@ public function deleteFile(string $filename): bool

/**
* @inheritDoc
* @param array<string> $fileNames
* @throws ArchiveException
*/
public function deleteMultipleFiles(array $fileNames): bool
Expand Down
5 changes: 3 additions & 2 deletions src/Archive/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
* @method bool addEmptyDir(string $directory)
* @method bool addFile(string $filePath, string $entryName)
* @method bool addFromString(string $entryName, string $content)
* @method bool addMultipleFiles(array $fileNames)
* @method bool addMultipleFiles(array<string, string> $fileNames)
* @method int count()
* @method bool extractTo(string $pathToExtract, $files = null)
* @method bool deleteFile(string $filename)
* @method bool deleteMultipleFiles(array $fileNames)
* @method bool deleteMultipleFiles(array<string> $fileNames)
*/
class Archive
{
Expand All @@ -59,6 +59,7 @@ public function getAdapter(): ArchiveInterface
}

/**
* @param array<mixed>|null $arguments
* @return mixed
* @throws BaseException
*/
Expand Down
4 changes: 3 additions & 1 deletion src/Archive/Contracts/ArchiveInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function addFromString(string $entryName, string $content): bool;

/**
* Adds multiple files to the archive
* @param array<string, string> $fileNames
*/
public function addMultipleFiles(array $fileNames): bool;

Expand All @@ -54,7 +55,7 @@ public function count(): int;

/**
* Extracts the archive
* @param string|array $files
* @param string|array<string>|null $files
*/
public function extractTo(string $pathToExtract, $files = null): bool;

Expand All @@ -65,6 +66,7 @@ public function deleteFile(string $filename): bool;

/**
* Delete a multiple files
* @param array<string> $fileNames
*/
public function deleteMultipleFiles(array $fileNames): bool;
}
3 changes: 3 additions & 0 deletions src/Archive/Factories/ArchiveFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ArchiveFactory
Archive::ZIP => ZipAdapter::class,
];

/**
* @var array<string, Archive>
*/
private static array $instances = [];

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Asset/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Asset

private ?string $name;

/**
* @var array<string>|null
*/
private ?array $attributes;

private ?int $position;
Expand All @@ -53,6 +56,7 @@ class Asset

/**
* Asset constructor
* @param array<string>|null $attributes
*/
public function __construct(int $type, string $path, ?string $name = null, ?int $position = -1, ?array $attributes = [])
{
Expand Down Expand Up @@ -97,8 +101,9 @@ public function getPosition(): ?int

/**
* Gets asset attributes
* @return array<string>|null
*/
public function getAttributes(): array
public function getAttributes(): ?array
{
return $this->attributes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Asset/AssetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AssetManager

/**
* Published assets
* @var array[]
* @var array<int, array<int, Asset>>
*/
private array $published = [];

Expand Down
7 changes: 4 additions & 3 deletions src/Asset/Exceptions/AssetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@
namespace Quantum\Asset\Exceptions;

use Quantum\Asset\Enums\ExceptionMessages;
use Exception;

/**
* Class AssetException
* @package Quantum\Asset
*/
class AssetException extends \Exception
class AssetException extends Exception
{
public static function positionInUse(int $position, string $name): AssetException
{
return new self(
_message(ExceptionMessages::POSITION_IN_USE, [$position, $name]),
_message(ExceptionMessages::POSITION_IN_USE, [(string) $position, $name]),
E_WARNING
);
}

public static function nameInUse(?string $name): AssetException
{
return new self(
_message(ExceptionMessages::NAME_IN_USE, [$name]),
_message(ExceptionMessages::NAME_IN_USE, [(string) $name]),
E_WARNING
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Auth/Adapters/JwtAuthAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function refreshUser(string $uuid): bool
* Verify OTP
* @throws AuthException
* @throws JwtException
* @return array<string, string>
*/
public function verifyOtp(int $otp, string $otpToken): array
{
Expand All @@ -138,6 +139,7 @@ public function verifyOtp(int $otp, string $otpToken): array
/**
* Get Updated Tokens
* @throws JwtException
* @return array<string, string>
*/
protected function getUpdatedTokens(User $user): array
{
Expand All @@ -150,6 +152,7 @@ protected function getUpdatedTokens(User $user): array
/**
* Set Updated Tokens
* @throws JwtException
* @return array<string, string>
*/
protected function setUpdatedTokens(User $user): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Auth/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function getAdapter(): AuthenticatableInterface
}

/**
* @param array<mixed>|null $arguments
* @return mixed
* @throws BaseException
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Auth/Contracts/AuthServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ public function get(string $field, ?string $value): ?User;

/**
* Add
* @param array<string, mixed> $data
*/
public function add(array $data): User;

/**
* Update
* @param array<string, mixed> $data
*/
public function update(string $field, ?string $value, array $data): ?User;

/**
* User Schema
* @return array<string, mixed>
*/
public function userSchema(): array;
}
2 changes: 2 additions & 0 deletions src/Auth/Factories/AuthFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Quantum\Auth\Adapters\JwtAuthAdapter;
use Quantum\App\Exceptions\BaseException;
use Quantum\Di\Exceptions\DiException;
use Quantum\Service\QtService;
use Quantum\Hasher\Hasher;
use Quantum\Jwt\JwtToken;
use Quantum\Loader\Setup;
Expand Down Expand Up @@ -115,6 +116,7 @@ private static function createAuthService(string $adapter): AuthServiceInterface
{
$authServiceClass = config()->get('auth.' . $adapter . '.service');

/** @var class-string<QtService> $authServiceClass */
$authService = ServiceFactory::create($authServiceClass);

if (!$authService instanceof AuthServiceInterface) {
Expand Down
15 changes: 10 additions & 5 deletions src/Auth/Traits/AuthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ trait AuthTrait
protected $otpLength = 6;

/**
* @var array
* @var array<string, string>
*/
protected $keyFields = [];

/**
* @var array
* @var array<string>
*/
protected $visibleFields = [];

Expand All @@ -89,6 +89,8 @@ public function check(): bool

/**
* Sign Up
* @param array<string, mixed> $userData
* @param array<string, mixed>|null $customData
*/
public function signup(array $userData, ?array $customData = null): User
{
Expand Down Expand Up @@ -291,7 +293,8 @@ protected function verifyAndUpdateOtp(int $otp, string $otpToken): User
}

/**
* Filters and gets the visible fields
* Filters and gets visible fields
* @return array<string, mixed>
*/
protected function getVisibleFields(User $user): array
{
Expand Down Expand Up @@ -326,8 +329,9 @@ protected function generateToken(?string $val = null): string

/**
* Send email
* @param array<string, mixed> $body
*/
protected function sendMail(User $user, array $body)
protected function sendMail(User $user, array $body): void
{
$fullName = ($user->hasField('firstname') && $user->hasField('lastname')) ? $user->getFieldValue('firstname') . ' ' . $user->getFieldValue('lastname') : '';

Expand All @@ -342,9 +346,10 @@ protected function sendMail(User $user, array $body)

/**
* Verify user schema
* @param array<string, mixed> $schema
* @throws AuthException
*/
protected function verifySchema(array $schema)
protected function verifySchema(array $schema): void
{
$constants = (new ReflectionClass(AuthKeys::class))->getConstants();

Expand Down
Loading
Loading