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
6 changes: 3 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -15,7 +19,7 @@
}
],
"require": {
"php": ">=7.3",
"php": "^7.4 || ^8.0",
"ext-pdo": "*",
"ext-curl": "*",
"ext-json": "*",
Expand Down Expand Up @@ -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",
Expand All @@ -74,4 +79,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
verbose="true"
stderr="true"
stopOnFailure="false"
convertDeprecationsToExceptions="false"
>
<php>
<ini name="error_reporting" value="E_ALL &amp; ~E_DEPRECATED"/>
</php>

<testsuites>
<testsuite name="Quantum PHP Framework Test Suite">
<directory>./tests/Unit</directory>
Expand Down
15 changes: 15 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSets([
LevelSetList::UP_TO_PHP_80,
]);
4 changes: 3 additions & 1 deletion src/App/Adapters/ConsoleAppAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/App/Adapters/WebAppAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/App/Exceptions/AppException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Quantum PHP Framework
*
Expand Down
2 changes: 2 additions & 0 deletions src/App/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Quantum PHP Framework
*
Expand Down
2 changes: 2 additions & 0 deletions src/App/Exceptions/StopExecutionException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Quantum PHP Framework
*
Expand Down
2 changes: 1 addition & 1 deletion src/App/Helpers/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
function stop(?Closure $closure = null, ?int $code = 0)
{
if ($closure) {
if ($closure instanceof \Closure) {
$closure();
}

Expand Down
2 changes: 1 addition & 1 deletion src/App/Helpers/dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function deleteDirectoryWithFiles(string $dir): bool
return false;
}

$files = array_diff(scandir($dir), array('.', '..'));
$files = array_diff(scandir($dir), ['.', '..']);

foreach ($files as $file) {
$path = $dir . DS . $file;
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 @@ -57,7 +57,7 @@ function random_number(int $length = 10): int
{
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= rand(0, 9);
$randomString .= random_int(0, 9);
}
return (int)$randomString;
}
Expand All @@ -75,7 +75,7 @@ function slugify(string $text): string
$text = trim($text, '-');
$text = mb_strtolower($text);

if (empty($text)) {
if ($text === '' || $text === '0') {
return 'n-a';
}

Expand Down
2 changes: 2 additions & 0 deletions src/Config/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Quantum PHP Framework
*
Expand Down
8 changes: 3 additions & 5 deletions src/Console/Commands/DebugBarCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,13 @@ private function copyResources(string $src, string $dst)
{
$dir = opendir($src);

if ($dst != $this->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 {
Expand Down
8 changes: 3 additions & 5 deletions src/Console/Commands/EnvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 4 additions & 6 deletions src/Console/Commands/KeyGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/Console/Commands/MigrationMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/OpenApiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Commands/ResourceCacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)) {
Expand Down
6 changes: 2 additions & 4 deletions src/Console/Commands/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 5 additions & 7 deletions src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading
Loading