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
5 changes: 4 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: redis, memcached
ini-values: phar.readonly=0, error_reporting=E_ALL
ini-values: phar.readonly=0, error_reporting=E_ALL

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand All @@ -54,6 +54,9 @@ jobs:
- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHPStan
run: composer phpstan

- name: Run tests
run: composer test -- --fail-on-warning --fail-on-risky

Expand Down
22 changes: 12 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
"j4mie/paris": "^1.5",
"firebase/php-jwt": "^6.0",
"gumlet/php-image-resize": "^2.0",
"symfony/var-dumper": "^4.2",
"symfony/var-dumper": "^5.4",
"symfony/var-exporter": "^5.2",
"symfony/console": "^4.3",
"vlucas/phpdotenv": "^4.2",
"symfony/console": "^5.4",
"vlucas/phpdotenv": "^5.0",
"dflydev/dot-access-data": "^3.0",
"php-debugbar/php-debugbar": "^1.23",
"php-debugbar/php-debugbar": "^1.8",
"phpmailer/phpmailer": "^6.0",
"twig/twig": "^2.7",
"php-curl-class/php-curl-class": "^9.0",
"twig/twig": "^3.0",
"php-curl-class/php-curl-class": "^11.0",
"psr/log": "^1.1",
"rakibtg/sleekdb": "^2.13",
"swagger-api/swagger-ui": "^4.14",
Expand All @@ -47,7 +47,7 @@
"vaibhavpandeyvpz/phemail": "^1.1",
"doctrine/annotations": "^2.0",
"voku/html-min": "^4.5",
"league/commonmark": "^1.6",
"league/commonmark": "^2.0",
"ezyang/htmlpurifier": "^4.18",
"povils/figlet": "^0.1.0",
"ramsey/uuid": "^4.2"
Expand All @@ -56,7 +56,8 @@
"phpunit/phpunit": "^9.0",
"mockery/mockery": "^1.4",
"mikey179/vfsstream": "^1.6",
"rector/rector": "^2.3"
"rector/rector": "^2.3",
"phpstan/phpstan": "^2.1"
},
"suggest": {
"ext-dom": "Required for XML/HTML processing",
Expand All @@ -75,8 +76,9 @@
}
},
"scripts": {
"phpstan": "phpstan analyse --memory-limit=512M --no-progress --error-format=github",
"test": "vendor/bin/phpunit --stderr --testdox --coverage-clover coverage.xml"
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true
}
}
16 changes: 16 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
parameters:
phpVersion: 70400
level: 5

paths:
- src

ignoreErrors:
- identifier: trait.unused
path: src/Model/Traits

checkNullables: true
checkUninitializedProperties: true

checkDynamicProperties: false
treatPhpDocTypesAsCertain: false
9 changes: 6 additions & 3 deletions src/App/Exceptions/AppException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

namespace Quantum\App\Exceptions;
Expand All @@ -28,8 +28,11 @@ class AppException extends BaseException
/**
* @return AppException
*/
public static function missingAppKey(): AppException
public static function missingAppKey(): self
{
return new static(ExceptionMessages::APP_KEY_MISSING, E_ERROR);
return new self(
ExceptionMessages::APP_KEY_MISSING,
E_ERROR
);
}
}
49 changes: 29 additions & 20 deletions src/App/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

namespace Quantum\App\Exceptions;
Expand All @@ -23,15 +23,24 @@
* Class BaseException
* @package Quantum\App
*/
class BaseException extends Exception
abstract class BaseException extends Exception
{

/**
* @param string $message
* @param int $code
*/
final public function __construct(string $message = "", int $code = 0)
{
parent::__construct($message, $code);
}

/**
* @param string $methodName
* @param string $className
* @return self
* @return static
*/
public static function methodNotSupported(string $methodName, string $className): self
public static function methodNotSupported(string $methodName, string $className)
{
return new static(
_message(ExceptionMessages::METHOD_NOT_SUPPORTED, [$methodName, $className]),
Expand All @@ -41,9 +50,9 @@ public static function methodNotSupported(string $methodName, string $className)

/**
* @param string $name
* @return self
* @return static
*/
public static function adapterNotSupported(string $name): self
public static function adapterNotSupported(string $name)
{
return new static(
_message(ExceptionMessages::ADAPTER_NOT_SUPPORTED, [$name]),
Expand All @@ -53,9 +62,9 @@ public static function adapterNotSupported(string $name): self

/**
* @param string $name
* @return self
* @return static
*/
public static function driverNotSupported(string $name): self
public static function driverNotSupported(string $name)
{
return new static(
_message(ExceptionMessages::DRIVER_NOT_SUPPORTED, [$name]),
Expand All @@ -65,9 +74,9 @@ public static function driverNotSupported(string $name): self

/**
* @param string $name
* @return self
* @return static
*/
public static function fileNotFound(string $name): self
public static function fileNotFound(string $name)
{
return new static(
_message(ExceptionMessages::FILE_NOT_FOUND, [$name]),
Expand All @@ -78,9 +87,9 @@ public static function fileNotFound(string $name): self
/**
* @param string $subject
* @param string $name
* @return self
* @return static
*/
public static function notFound(string $subject, string $name): self
public static function notFound(string $subject, string $name)
{
return new static(
_message(ExceptionMessages::NOT_FOUND, [$subject, $name]),
Expand All @@ -91,9 +100,9 @@ public static function notFound(string $subject, string $name): self
/**
* @param string $instance
* @param string $name
* @return self
* @return static
*/
public static function notInstanceOf(string $instance, string $name): self
public static function notInstanceOf(string $instance, string $name)
{
return new static(
_message(ExceptionMessages::NOT_INSTANCE_OF, [$instance, $name]),
Expand All @@ -103,9 +112,9 @@ public static function notInstanceOf(string $instance, string $name): self

/**
* @param string $name
* @return self
* @return static
*/
public static function cantConnect(string $name): self
public static function cantConnect(string $name)
{
return new static(
_message(ExceptionMessages::CANT_CONNECT, [$name]),
Expand All @@ -115,10 +124,10 @@ public static function cantConnect(string $name): self

/**
* @param string $name
* @return self
* @return static
*/

public static function missingConfig(string $name): self
public static function missingConfig(string $name)
{
return new static(
_message(ExceptionMessages::MISSING_CONFIG, $name),
Expand All @@ -128,9 +137,9 @@ public static function missingConfig(string $name): self

/**
* @param string $name
* @return self
* @return static
*/
public static function requestMethodNotAvailable(string $name): self
public static function requestMethodNotAvailable(string $name)
{
return new static(
_message(ExceptionMessages::UNAVAILABLE_REQUEST_METHOD, [$name]),
Expand Down
9 changes: 6 additions & 3 deletions src/App/Exceptions/StopExecutionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

namespace Quantum\App\Exceptions;
Expand All @@ -29,8 +29,11 @@ class StopExecutionException extends BaseException
* @param int|null $code
* @return StopExecutionException
*/
public static function executionTerminated(?int $code): StopExecutionException
public static function executionTerminated(?int $code): self
{
return new static(ExceptionMessages::EXECUTION_TERMINATED, $code);
return new self(
ExceptionMessages::EXECUTION_TERMINATED,
$code
);
}
}
4 changes: 2 additions & 2 deletions src/App/Helpers/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 3.0.0
*/

use Quantum\App\Exceptions\StopExecutionException;
Expand All @@ -18,7 +18,7 @@
* Stops the app execution
* @param Closure|null $closure
* @param int|null $code
* @return mixed
* @return never
* @throws StopExecutionException
*/
function stop(?Closure $closure = null, ?int $code = 0)
Expand Down
19 changes: 6 additions & 13 deletions src/App/Helpers/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

use Symfony\Component\VarExporter\Exception\ExceptionInterface;
Expand Down Expand Up @@ -111,20 +111,13 @@ function get_caller_class(int $index = 2): ?string
*/
function get_caller_function(int $index = 2): ?string
{
$caller = debug_backtrace();
$caller = $caller[$index];
$trace = debug_backtrace();

return $caller['function'] ?? null;
}
if (!isset($trace[$index])) {
return null;
}

/**
* Checks if the entity is closure
* @param mixed $entity
* @return bool
*/
function is_closure($entity): bool
{
return $entity instanceof Closure;
return $trace[$index]['function'];
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/Config/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

namespace Quantum\Config\Exceptions;
Expand All @@ -30,8 +30,11 @@ class ConfigException extends BaseException
* @param string $name
* @return ConfigException
*/
public static function configCollision(string $name): ConfigException
public static function configCollision(string $name): self
{
return new static(_message(ExceptionMessages::CONFIG_COLLISION, [$name]), E_WARNING);
return new self(
_message(ExceptionMessages::CONFIG_COLLISION, [$name]),
E_WARNING
);
}
}
4 changes: 2 additions & 2 deletions src/Console/Commands/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.9
* @since 3.0.0
*/

namespace Quantum\Console\Commands;
Expand Down Expand Up @@ -41,7 +41,7 @@ class RouteListCommand extends QtCommand

/**
* Command options
* @var string
* @var array<int, array<int, string>>
*/
protected $options = [
['module', 'm', 'optional', 'Filter by module name'],
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.5
* @since 3.0.0
*/

namespace Quantum\Console\Commands;
Expand Down Expand Up @@ -71,7 +71,7 @@ class ServeCommand extends QtCommand

/**
* Command arguments
* @var \string[][]
* @var array<int, list<string|null>>
*/
protected $options = [
['host', null, 'optional', 'Host', '127.0.0.1'],
Expand Down
Loading