Skip to content

Commit 66b7361

Browse files
authored
Added support for Laravel 10 (#19)
⚠️ Backward compatibility break: Monolog interfaces have changed - $record is now a LogRecord, not an array
1 parent 8cf44e4 commit 66b7361

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+286
-403
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
matrix:
2828
operating_system: [ubuntu-latest]
29-
php_versions: ['7.4']
29+
php_versions: ['8.1']
3030
fail-fast: false
3131
env:
3232
PHP_CS_FIXER_FUTURE_MODE: '0'
@@ -68,31 +68,12 @@ jobs:
6868
strategy:
6969
fail-fast: false
7070
matrix:
71-
coverage: [false]
71+
coverage: [true]
7272
experimental: [false]
7373
operating_system: [ubuntu-latest]
74-
postgres: ['11']
75-
laravel: ['^6.0', '^7.0', '^8.0']
76-
php_versions: ['7.3', '7.4']
77-
include:
78-
- operating_system: ubuntu-latest
79-
postgres: '11'
80-
php_versions: '7.4'
81-
experimental: false
82-
laravel: '^8.0'
83-
coverage: true
84-
- operating_system: ubuntu-latest
85-
postgres: '12'
86-
php_versions: '8.0'
87-
laravel: '^8.0'
88-
experimental: false
89-
coverage: false
90-
- operating_system: ubuntu-latest
91-
postgres: '13'
92-
php_versions: '8.0'
93-
laravel: '^8.0'
94-
experimental: true
95-
coverage: false
74+
postgres: ['11', '12', '13', '14', '15']
75+
laravel: ['^10']
76+
php_versions: ['8.1', '8.2']
9677
runs-on: '${{ matrix.operating_system }}'
9778
services:
9879
postgres:
@@ -152,9 +133,9 @@ jobs:
152133
-e "s/\${HOST}/${{ env.DB_HOST }}/" \
153134
phpunit.xml.dist > phpunit.xml
154135
if [[ ${{ matrix.coverage }} == true ]]; then
155-
./vendor/bin/phpunit --verbose --stderr --coverage-clover build/logs/clover.xml --coverage-text
136+
./vendor/bin/phpunit --stderr --coverage-clover build/logs/clover.xml --coverage-text
156137
else
157-
./vendor/bin/phpunit --verbose --stderr
138+
./vendor/bin/phpunit --stderr
158139
fi
159140
working-directory: './'
160141
- name: 'Upload coverage results to Coveralls'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ phpunit.xml
66
.phpunit.result.cache
77
.DS_Store
88
composer.lock
9+
/.phpunit.cache

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313

1414

1515
## Installation
16-
```
16+
17+
```shell
1718
composer require umbrellio/php-table-sync
1819
```
1920

2021
## Usage
22+
2123
Let's describe the model that needs to be synchronized using an example `User.php`
22-
```
24+
25+
```php
2326
...
2427
User extends Model implements SyncableModel
2528
{
@@ -48,15 +51,15 @@ When the model changes, the data will be sent according to the rules of `TableSy
4851
## Logging
4952
Logging based on the Monolog package and contains some extensions for it.
5053
- specify the logging channel in `config/table_sync.php`
51-
```
54+
```php
5255
...
5356
'log' => [
5457
'channel' => 'table_sync',
5558
],
5659
...
5760
```
5861
- and describe this channel in `config/logging.php`
59-
```
62+
```php
6063
...
6164
'table_sync' => [
6265
'driver' => 'stack',
@@ -80,7 +83,7 @@ Logging based on the Monolog package and contains some extensions for it.
8083
##### You can use the built-in `LineTableSyncFormatter::class` with the available parameters: `%datetime%` `%message%` `%direction%` `%model%` `%event%` `%routing%` `%attributes%` `%exception%`
8184

8285
###### Driver `influxdb` is an additional option and is not required to add in config
83-
```
86+
```php
8487
...
8588
'table_sync' => [
8689
'driver' => 'daily',

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313
"license": "MIT",
1414
"type": "library",
1515
"require": {
16-
"php": "^7.3|^7.4|^8.0",
16+
"php": "^8.1",
1717
"ext-json": "*",
18-
"php-amqplib/php-amqplib": "^2.8 || ^3.0",
19-
"laravel/framework": "^5.8|^6.0|^7.0|^8.0|^9.0",
20-
"thecodingmachine/safe": "^0.1.6|^1.0",
21-
"umbrellio/laravel-heavy-jobs": "^1.0.3|^2.0|^3.0",
22-
"monolog/monolog": "^1.1|^2.0",
18+
"ext-posix": "*",
19+
"php-amqplib/php-amqplib": "^3.0",
20+
"laravel/framework": "^10.0",
21+
"thecodingmachine/safe": "^2.0",
22+
"umbrellio/laravel-heavy-jobs": "^3.0",
23+
"monolog/monolog": "^3.0",
2324
"influxdb/influxdb-php": "^1.15"
2425
},
2526
"require-dev": {
26-
"phpunit/phpunit": "^7.3|^8.5|^9.4",
27+
"phpunit/phpunit": "^10.0",
2728
"php-mock/php-mock": "^2.0",
28-
"orchestra/testbench": "^3.8|^4.8|^5.7|^6.2|^7.0",
29+
"orchestra/testbench": "^8.0",
2930
"mockery/mockery": "^1.0",
3031
"mikey179/vfsstream": "^1.6",
31-
"umbrellio/code-style-php": "^1.0",
32-
"symplify/easy-coding-standard": "^9.3.15",
32+
"symplify/easy-coding-standard": "^11.0",
3333
"laravel/legacy-factories": "*",
3434
"php-coveralls/php-coveralls": "^2.1",
3535
"squizlabs/php_codesniffer": "^3.5"

ecs.php

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,53 @@
22

33
declare(strict_types=1);
44

5-
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
5+
use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff;
6+
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer;
7+
use PhpCsFixer\Fixer\ClassNotation\SingleTraitInsertPerStatementFixer;
8+
use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer;
9+
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
10+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
11+
use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
12+
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer;
613
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
7-
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
8-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
9-
10-
return static function (ContainerConfigurator $containerConfigurator): void {
11-
$containerConfigurator->import(__DIR__ . '/vendor/umbrellio/code-style-php/umbrellio-cs.php');
12-
13-
$services = $containerConfigurator->services();
14-
15-
$services->set(PhpUnitTestAnnotationFixer::class)
16-
->call('configure', [[
17-
'style' => 'annotation',
18-
]]);
19-
20-
$services->set(DeclareStrictTypesFixer::class);
21-
22-
$services->set(BinaryOperatorSpacesFixer::class)
23-
->call('configure', [[
24-
'default' => 'single_space',
25-
]]);
26-
27-
$parameters = $containerConfigurator->parameters();
28-
29-
$parameters->set('cache_directory', '.ecs_cache');
30-
31-
$parameters->set('exclude_files', ['vendor/*', 'database/*']);
14+
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer;
15+
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
16+
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
17+
use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer;
18+
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
19+
use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer;
20+
use Symplify\EasyCodingStandard\Config\ECSConfig;
21+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
22+
23+
return static function (ECSConfig $ecsConfig): void {
24+
$ecsConfig->paths([__DIR__ . '/app', __DIR__ . '/tests']);
25+
$ecsConfig->parallel();
26+
27+
$ecsConfig->sets([SetList::PSR_12]);
28+
$ecsConfig->sets([SetList::CLEAN_CODE]);
29+
$ecsConfig->sets([SetList::COMMON]);
30+
$ecsConfig->sets([SetList::SYMPLIFY]);
31+
$ecsConfig->sets([SetList::STRICT]);
32+
33+
$ecsConfig->skip([
34+
'vendor/*',
35+
'database/*',
36+
'.ecs_cache/*',
37+
38+
ArrayIndentationFixer::class,
39+
MethodArgumentSpaceFixer::class,
40+
SingleTraitInsertPerStatementFixer::class,
41+
PhpdocTrimFixer::class,
42+
AssignmentInConditionSniff::class,
43+
MethodChainingNewlineFixer::class,
44+
ArrayOpenerAndCloserNewlineFixer::class,
45+
NotOperatorWithSuccessorSpaceFixer::class,
46+
PhpdocLineSpanFixer::class,
47+
MethodChainingIndentationFixer::class,
48+
ClassAttributesSeparationFixer::class,
49+
LineLengthFixer::class,
50+
NoSuperfluousPhpdocTagsFixer::class,
51+
ExplicitStringVariableFixer::class,
52+
PhpUnitTestAnnotationFixer::class,
53+
]);
3254
};

ecs.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
bootstrap="vendor/autoload.php"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
processIsolation="false"
4+
colors="true" processIsolation="false"
95
stopOnFailure="false"
10-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
6+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
7+
cacheDirectory=".phpunit.cache"
118
>
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="true">
9+
<coverage>
10+
<include>
1411
<directory suffix=".php">./src</directory>
15-
<exclude>
16-
<directory suffix=".php">./database</directory>
17-
</exclude>
18-
</whitelist>
19-
</filter>
12+
</include>
13+
<exclude>
14+
<directory suffix=".php">./database</directory>
15+
</exclude>
16+
</coverage>
2017
<php>
2118
<env name="APP_ENV" value="testing"/>
22-
<ini name="error_reporting" value="-1" />
19+
<ini name="error_reporting" value="-1"/>
2320
<var name="db_type" value="pdo_pgsql"/>
24-
<var name="db_host" value="${HOST}" />
25-
<var name="db_username" value="${USERNAME}" />
26-
<var name="db_password" value="${PASSWORD}" />
27-
<var name="db_database" value="${DATABASE}" />
21+
<var name="db_host" value="${HOST}"/>
22+
<var name="db_username" value="${USERNAME}"/>
23+
<var name="db_password" value="${PASSWORD}"/>
24+
<var name="db_database" value="${DATABASE}"/>
2825
<var name="db_port" value="5432"/>
2926
</php>
3027
<testsuites>

src/Integration/Laravel/Console/PidManager.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
class PidManager
1010
{
11-
private $pathToPidFile;
12-
13-
public function __construct(string $pathToPidFile)
14-
{
15-
$this->pathToPidFile = $pathToPidFile;
11+
public function __construct(
12+
private readonly string $pathToPidFile
13+
) {
1614
}
1715

1816
public function pidExists(): bool

src/Integration/Laravel/Console/ProcessManagerCommand.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88

99
abstract class ProcessManagerCommand extends Command
1010
{
11-
protected $pidManager;
12-
13-
public function __construct(PidManager $pidManager)
14-
{
11+
public function __construct(
12+
protected PidManager $pidManager
13+
) {
1514
parent::__construct();
16-
17-
$this->pidManager = $pidManager;
1815
}
1916
}

src/Integration/Laravel/InfluxDBLogChannel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Log\LogManager;
88
use InfluxDB\Database;
9+
use Monolog\Level;
910
use Monolog\Logger;
1011
use Psr\Log\LoggerInterface;
1112
use Umbrellio\TableSync\Monolog\Handler\InfluxDBHandler;
@@ -17,7 +18,7 @@ public function __invoke(array $config): LoggerInterface
1718
$handler = new InfluxDBHandler(
1819
$this->app->make(Database::class),
1920
$config['measurement'] ?? null,
20-
$config['level'] ?? Logger::INFO,
21+
$config['level'] ?? Level::Info,
2122
$config['bubble'] ?? true
2223
);
2324

src/Integration/Laravel/Jobs/PublishJob.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ final class PublishJob implements ShouldQueue, ShouldStorePayload
1616
use HeavyJobsEnabledTrait;
1717
use Queueable;
1818

19-
private $publisherClass;
20-
private $message;
21-
22-
public function __construct(string $publisherClass, PublishMessage $message)
23-
{
19+
public function __construct(
20+
private readonly string $publisherClass,
21+
private PublishMessage $message
22+
) {
2423
$this->queue = Config::get('table_sync.publish_job_queue', '');
25-
$this->publisherClass = $publisherClass;
26-
$this->message = $message;
2724
}
2825

2926
public function handle(): void

src/Integration/Laravel/Jobs/ReceiveMessage.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ final class ReceiveMessage implements ShouldQueue, ShouldStorePayload
1616
use HeavyJobsEnabledTrait;
1717
use Queueable;
1818

19-
private $message;
20-
21-
public function __construct(ReceivedMessage $message)
22-
{
19+
public function __construct(
20+
private readonly ReceivedMessage $message
21+
) {
2322
$this->queue = Config::get('table_sync.receive_job_queue', '');
24-
$this->message = $message;
2523
}
2624

2725
public function handle(Receiver $receiver): void

src/Integration/Laravel/Publishers/EnsureConsistencyPublisher.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
final class EnsureConsistencyPublisher implements Publisher
1313
{
14-
private $publisher;
15-
16-
public function __construct(Publisher $publisher)
17-
{
18-
$this->publisher = $publisher;
14+
public function __construct(
15+
private readonly Publisher $publisher
16+
) {
1917
}
2018

2119
public function publish(PublishMessage $message): void

0 commit comments

Comments
 (0)