Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php8.1 #101

Merged
merged 16 commits into from
Jan 5, 2024
23 changes: 10 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,24 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
php-version: ['8.1', '8.2', 8.3]
db-type: [sqlite, mysql, pgsql]
prefer-lowest: ['']
exclude:
- php-version: '7.4'
- php-version: '8.1'
db-type: 'sqlite'
- php-version: '7.4'
- php-version: '8.1'
db-type: 'pgsql'
include:
- php-version: '7.4'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'
- php-version: '8.0'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'
- php-version: '8.1'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'
- php-version: '8.2'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'
- php-version: '8.3'
db-type: 'mysql'
prefer-lowest: 'prefer-lowest'

steps:
- name: Setup Database
Expand Down Expand Up @@ -89,7 +86,7 @@ jobs:
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export db_dsn='postgres://postgres:[email protected]/test'; fi

if [[ ${{ matrix.php-version }} == '8.0' ]]; then
export XDEBUG_MODE=coverage && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml
export XDEBUG_MODE=coverage && vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
Expand Down Expand Up @@ -140,11 +137,11 @@ jobs:

testsuite-windows:
runs-on: windows-2019
name: Windows - PHP 7.4
name: Windows - PHP 8.2

env:
EXTENSIONS: mbstring, intl, pdo_mysql
PHP_VERSION: '7.4'
PHP_VERSION: '8.2'

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -178,4 +175,4 @@ jobs:
env:
db_dsn: 'mysql://root@localhost/test'
run: |
vendor/bin/phpunit --verbose --group mysql
vendor/bin/phpunit --group mysql
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# 2.x branch
## 2.13 branch
### 2.13.0
* requires at least PHP 8.1, PHPUnit 10 and CakePHP 5.0;
* added tests for PHP 8.3.

## 2.12 branch
### 2.12.3
* updated for `php-tools` 1.8.
Expand Down
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
}
],
"require": {
"php": ">=7.4.0",
"php": ">=8.1",
"ext-fileinfo": "*",
"cakephp/cakephp": "^4.0",
"mirko-pagliai/php-tools": "^1.7.4"
"cakephp/cakephp": "^5.0",
"mirko-pagliai/php-tools": "~1.9.2",
"symfony/process": "^6.0|^7.0"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^4.4",
"cakephp/migrations": "^3.2",
"phpunit/phpunit": "^9.1|^9.5",
"cakephp/cakephp-codesniffer": "^5.0",
"cakephp/migrations": "^4.0",
"phpunit/phpunit": "^10.1.0 <=10.5.3",
"phpstan/phpstan": "^1.10.38",
"vimeo/psalm": "^5.15.0"
},
Expand All @@ -44,12 +45,12 @@
"@test",
"@stan"
],
"cs-check": "phpcs --standard=phpcs.xml.dist",
"cs-fix": "phpcbf --standard=phpcs.xml.dist",
"cs-check": "phpcs --standard=phpcs.xml",
"cs-fix": "phpcbf --standard=phpcs.xml",
"test": "rm -f -r /tmp/cake* && phpunit && driver_test=sqlite phpunit && driver_test=postgres phpunit",
"coverage": "XDEBUG_MODE=coverage phpunit --coverage-html=coverage",
"phpstan": "phpstan.phar analyse",
"psalm": "psalm.phar --php-version=8.0",
"phpstan": "phpstan analyse",
"psalm": "psalm --php-version=8.2",
"stan": [
"@phpstan",
"@psalm"
Expand Down
16 changes: 16 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset name="cakephp-database-backup">
<arg value="p"/>
<arg name="colors"/>

<file>.</file>

<rule ref="./vendor/mirko-pagliai/php-tools/sniffer-ruleset.xml"/>

<rule ref="CakePHP.Commenting.TypeHint.IncorrectFormat">
<severity>0</severity>
</rule>
<rule ref="CakePHP.Functions.ClosureDeclaration.SpaceAfterFunction">
<severity>0</severity>
</rule>
</ruleset>
7 changes: 0 additions & 7 deletions phpcs.xml.dist

This file was deleted.

21 changes: 13 additions & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<files psalm-version="5.18.0@b113f3ed0259fd6e212d87c3df80eec95a6abf19">
<file src="src/Driver/AbstractDriver.php">
<MissingTemplateParam>
<code>EventDispatcherTrait</code>
</MissingTemplateParam>
</file>
<file src="src/Driver/Mysql.php">
<RedundantPropertyInitializationCheck occurrences="2">
<code>$this-&gt;auth</code>
<code>TMP . uniqid('auth')</code>
<RedundantPropertyInitializationCheck>
<code><![CDATA[$this->auth]]></code>
<code><![CDATA[TMP . uniqid('auth')]]></code>
</RedundantPropertyInitializationCheck>
</file>
<file src="src/TestSuite/DriverTestCase.php">
<TypeDoesNotContainType occurrences="1">
<code>empty($this-&gt;Driver)</code>
<TypeDoesNotContainType>
<code><![CDATA[empty($this->Driver)]]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Utility/AbstractBackupUtility.php">
<TypeDoesNotContainType occurrences="1">
<code>empty($this-&gt;Driver)</code>
<TypeDoesNotContainType>
<code><![CDATA[empty($this->Driver)]]></code>
</TypeDoesNotContainType>
</file>
</files>
2 changes: 1 addition & 1 deletion src/Driver/AbstractDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function getBinary(string $name): string
* @return mixed Config value or `null` if the key doesn't exist
* @since 2.3.0
*/
protected function getConfig(string $key)
protected function getConfig(string $key): mixed
{
return $this->getConnection()->config()[$key] ?? null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/AbstractBackupUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class AbstractBackupUtility
* @since 2.12.0
* @throw \LogicException
*/
public function __get(string $name)
public function __get(string $name): mixed
{
if (!property_exists($this, $name)) {
$class = &$this;
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/BackupExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function send(?string $recipient = null)
* @see \DatabaseBackup\Driver\AbstractDriver::beforeExport()
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupExport-utility#export
*/
public function export()
public function export(): string|false
{
if (empty($this->filename)) {
$this->extension ??= $this->defaultExtension;
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/BackupImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function filename(string $filename)
* @see \DatabaseBackup\Driver\AbstractDriver::beforeImport()
* @see https://github.com/mirko-pagliai/cakephp-database-backup/wiki/How-to-use-the-BackupImport-utility#import
*/
public function import()
public function import(): string|false
{
if (empty($this->filename)) {
throw new LogicException(__d('database_backup', 'You must first set the filename'));
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/BackupTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BackupTraitTest extends TestCase
* Fixtures
* @var array<string>
*/
public $fixtures = ['core.Articles', 'core.Comments'];
public array $fixtures = ['core.Articles', 'core.Comments'];

/**
* @inheritDoc
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Utility/BackupExportAndImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BackupExportAndImportTest extends TestCase
/**
* @var array<string>
*/
public $fixtures = ['core.Articles', 'core.Comments'];
public array $fixtures = ['core.Articles', 'core.Comments'];

/**
* Internal method to get all records from the database
Expand Down
10 changes: 0 additions & 10 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,6 @@

echo 'Running tests for `' . (new BackupManager())->getDriverName() . '` driver ' . PHP_EOL;

/**
* @todo remove on CakePHP >= 5
*/
if (!trait_exists('Cake\Console\TestSuite\ConsoleIntegrationTestTrait')) {
class_alias('Cake\TestSuite\ConsoleIntegrationTestTrait', 'Cake\Console\TestSuite\ConsoleIntegrationTestTrait');
}
if (!class_exists('Cake\Console\TestSuite\StubConsoleOutput')) {
class_alias('Cake\TestSuite\Stub\ConsoleOutput', 'Cake\Console\TestSuite\StubConsoleOutput');
}

if (!function_exists('createBackup')) {
/**
* Global function to create a backup file
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.12.3
2.13.0