From 286cb4f2b130ba30bfb154ed66e4519be2fb33fa Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 4 Jan 2024 10:25:11 +0000 Subject: [PATCH 1/4] Apply fixes from StyleCI --- src/Mapper/DatabaseMapper.php | 2 +- src/Schema.php | 2 +- src/Transaction/UnitOfWork.php | 20 +++++++++---------- tests/ORM/Unit/Command/DeleteCommandTest.php | 2 +- tests/ORM/Unit/Command/InsertCommandTest.php | 2 +- tests/ORM/Unit/Command/UpdateCommandTest.php | 4 ++-- .../ORM/Unit/Parser/CompositeTypecastTest.php | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Mapper/DatabaseMapper.php b/src/Mapper/DatabaseMapper.php index b50250cc..e640aa6b 100644 --- a/src/Mapper/DatabaseMapper.php +++ b/src/Mapper/DatabaseMapper.php @@ -98,7 +98,7 @@ public function cast(array $data): array public function uncast(array $data): array { - if (! $this->typecast instanceof UncastableInterface) { + if (!$this->typecast instanceof UncastableInterface) { return $data; } diff --git a/src/Schema.php b/src/Schema.php index 5f77e1b8..599a4a07 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -365,7 +365,7 @@ private function compareManyToMany(array $relation, array $targetRelation): bool return false; } // Optional fields - return ! (($schema[Relation::WHERE] ?? []) !== ($targetSchema[Relation::WHERE] ?? []) + return !(($schema[Relation::WHERE] ?? []) !== ($targetSchema[Relation::WHERE] ?? []) || ($schema[Relation::THROUGH_WHERE] ?? []) !== ($targetSchema[Relation::THROUGH_WHERE] ?? [])); } diff --git a/src/Transaction/UnitOfWork.php b/src/Transaction/UnitOfWork.php index b8ef6a8d..9ebbab7f 100644 --- a/src/Transaction/UnitOfWork.php +++ b/src/Transaction/UnitOfWork.php @@ -207,7 +207,7 @@ private function walkPool(): void * @var Tuple $tuple */ foreach ($this->pool->openIterator() as $tuple) { - if ($tuple->task === Tuple::TASK_FORCE_DELETE && ! $tuple->cascade) { + if ($tuple->task === Tuple::TASK_FORCE_DELETE && !$tuple->cascade) { // currently we rely on db to delete all nested records (or soft deletes) $command = $this->commandGenerator->generateDeleteCommand($this->orm, $tuple); $this->runCommand($command); @@ -222,7 +222,7 @@ private function walkPool(): void private function resolveMasterRelations(Tuple $tuple, RelationMap $map): int { - if (! $map->hasDependencies()) { + if (!$map->hasDependencies()) { return self::RELATIONS_RESOLVED; } @@ -262,7 +262,7 @@ private function resolveMasterRelations(Tuple $tuple, RelationMap $map): int private function resolveSlaveRelations(Tuple $tuple, RelationMap $map): int { - if (! $map->hasSlaves()) { + if (!$map->hasSlaves()) { return self::RELATIONS_RESOLVED; } $changedFields = array_keys($tuple->state->getChanges()); @@ -296,8 +296,8 @@ private function resolveSlaveRelations(Tuple $tuple, RelationMap $map): int if ($relationStatus !== RelationInterface::STATUS_PREPARE && $relationStatus !== RelationInterface::STATUS_RESOLVED - && ! $isWaitingKeys - && ! $hasChangedKeys + && !$isWaitingKeys + && !$hasChangedKeys && \count(array_intersect($innerKeys, array_keys($transactData))) === \count($innerKeys) ) { $child ??= $tuple->state->getRelation($name); @@ -313,8 +313,8 @@ private function resolveSlaveRelations(Tuple $tuple, RelationMap $map): int private function resolveSelfWithEmbedded(Tuple $tuple, RelationMap $map, bool $hasDeferredRelations): void { - if (! $map->hasEmbedded() && ! $tuple->state->hasChanges()) { - $tuple->status = ! $hasDeferredRelations + if (!$map->hasEmbedded() && !$tuple->state->hasChanges()) { + $tuple->status = !$hasDeferredRelations ? Tuple::STATUS_PROCESSED : max(Tuple::STATUS_DEFERRED, $tuple->status); @@ -322,7 +322,7 @@ private function resolveSelfWithEmbedded(Tuple $tuple, RelationMap $map, bool $h } $command = $this->commandGenerator->generateStoreCommand($this->orm, $tuple); - if (! $map->hasEmbedded()) { + if (!$map->hasEmbedded()) { // Not embedded but has changes $this->runCommand($command); @@ -349,7 +349,7 @@ private function resolveSelfWithEmbedded(Tuple $tuple, RelationMap $map, bool $h } $this->runCommand($command); - $tuple->status = $tuple->status === Tuple::STATUS_PREPROCESSED || ! $hasDeferredRelations + $tuple->status = $tuple->status === Tuple::STATUS_PREPROCESSED || !$hasDeferredRelations ? Tuple::STATUS_PROCESSED : max(Tuple::STATUS_DEFERRED, $tuple->status); } @@ -389,7 +389,7 @@ private function resolveRelations(Tuple $tuple): void : $this->resolveMasterRelations($tuple, $map); } - if (! $isDependenciesResolved && $tuple->status === Tuple::STATUS_PREPROCESSED) { + if (!$isDependenciesResolved && $tuple->status === Tuple::STATUS_PREPROCESSED) { $tuple->status = Tuple::STATUS_UNPROCESSED; } } diff --git a/tests/ORM/Unit/Command/DeleteCommandTest.php b/tests/ORM/Unit/Command/DeleteCommandTest.php index 68f47d5a..66b2ca2d 100644 --- a/tests/ORM/Unit/Command/DeleteCommandTest.php +++ b/tests/ORM/Unit/Command/DeleteCommandTest.php @@ -21,7 +21,7 @@ public function testNoScope(): void { $this->expectException(CommandException::class); - $this->mapper = \Mockery::mock(MapperInterface::class); + $this->mapper = m::mock(MapperInterface::class); $state = new State(Node::SCHEDULED_DELETE, []); $cmd = new Delete( m::mock(DatabaseInterface::class), diff --git a/tests/ORM/Unit/Command/InsertCommandTest.php b/tests/ORM/Unit/Command/InsertCommandTest.php index b9f00e19..266e5f63 100644 --- a/tests/ORM/Unit/Command/InsertCommandTest.php +++ b/tests/ORM/Unit/Command/InsertCommandTest.php @@ -29,7 +29,7 @@ protected function setUp(): void { parent::setUp(); - $this->mapper = \Mockery::mock(MapperInterface::class); + $this->mapper = m::mock(MapperInterface::class); $this->cmd = new Insert( $this->db = m::mock(DatabaseInterface::class), diff --git a/tests/ORM/Unit/Command/UpdateCommandTest.php b/tests/ORM/Unit/Command/UpdateCommandTest.php index b0a4cf81..7b7fbeea 100644 --- a/tests/ORM/Unit/Command/UpdateCommandTest.php +++ b/tests/ORM/Unit/Command/UpdateCommandTest.php @@ -25,7 +25,7 @@ protected function setUp(): void { parent::setUp(); - $this->mapper = \Mockery::mock(MapperInterface::class); + $this->mapper = m::mock(MapperInterface::class); $this->state = new State(Node::SCHEDULED_UPDATE, ['foo' => 'bar']); $this->cmd = new Update( @@ -106,7 +106,7 @@ public function testExecuteWithAppendix() $this->db->shouldReceive('update') ->once() ->with('table', ['column' => 'value'], ['key' => 'scope']) - ->andReturn($query = \Mockery::mock(UpdateQuery::class)); + ->andReturn($query = m::mock(UpdateQuery::class)); $query->shouldReceive('run')->once()->andReturn(5); diff --git a/tests/ORM/Unit/Parser/CompositeTypecastTest.php b/tests/ORM/Unit/Parser/CompositeTypecastTest.php index 53e57c46..8e0d9096 100644 --- a/tests/ORM/Unit/Parser/CompositeTypecastTest.php +++ b/tests/ORM/Unit/Parser/CompositeTypecastTest.php @@ -108,7 +108,7 @@ public function testSetRules(array $casters): void } $typecast = new CompositeTypecast( - ... array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) + ...array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) ); $this->assertSame(self::RULES_RESULT, $typecast->setRules(self::RULES_INITIAL)); @@ -135,7 +135,7 @@ public function testCast(array $casters): void } $typecast = new CompositeTypecast( - ... array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) + ...array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) ); $this->assertSame(self::CAST_RESULT, $typecast->cast(self::CAST_INITIAL)); @@ -163,7 +163,7 @@ public function testUncast(array $casters): void } $typecast = new CompositeTypecast( - ... array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) + ...array_map(static fn (array $data) => $data[self::OPT_TYPECAST], $casters) ); $this->assertSame(self::UNCAST_RESULT, $typecast->uncast(self::UNCAST_INITIAL)); From e53b2ca4c7dba8c9843e9b49801b019ff0025f06 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Thu, 4 Jan 2024 12:30:09 +0200 Subject: [PATCH 2/4] Add PHP 8.3 to GitHub actions --- .github/workflows/ci-mssql.yml | 14 ++++++++++---- .github/workflows/ci-mysql.yml | 7 ++++--- .github/workflows/ci-pgsql.yml | 7 ++++--- .github/workflows/main.yml | 14 ++++++++------ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index a61c166d..307ad83e 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -26,7 +26,13 @@ jobs: extensions: pdo, pdo_sqlsrv mssql: 'server:2019-latest' - php: '8.1' - extensions: pdo, pdo_sqlsrv-5.11.1 + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '8.2' + extensions: pdo, pdo_sqlsrv + mssql: 'server:2019-latest' + - php: '8.3' + extensions: pdo, pdo_sqlsrv mssql: 'server:2019-latest' services: @@ -67,11 +73,11 @@ jobs: run: composer self-update - name: Install dependencies with composer - if: matrix.php != '8.2' + if: matrix.php != '8.3' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.2 - if: matrix.php == '8.2' + - name: Install dependencies with composer php 8.3 + if: matrix.php == '8.3' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run tests with phpunit without coverage diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index a6fcd7d4..be859e4d 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -25,6 +25,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" mysql-version: - "5.7" @@ -81,11 +82,11 @@ jobs: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: Install dependencies with composer - if: matrix.php-version != '8.2' + if: matrix.php-version != '8.3' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.2 - if: matrix.php-version == '8.2' + - name: Install dependencies with composer php 8.3 + if: matrix.php-version == '8.3' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run mysql tests with phpunit diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 1afa5283..2b97d8a7 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -24,6 +24,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" pgsql-version: - "10" @@ -82,11 +83,11 @@ jobs: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: Install dependencies with composer - if: matrix.php-version != '8.2' + if: matrix.php-version != '8.3' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.2 - if: matrix.php-version == '8.2' + - name: Install dependencies with composer php 8.3 + if: matrix.php-version == '8.3' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run pgsql tests with phpunit diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76387c2b..3d9d9f5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" steps: - name: Checkout uses: actions/checkout@v2 @@ -46,10 +47,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Install dependencies with composer - if: matrix.php-version != '8.2' + if: matrix.php-version != '8.3' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.2 - if: matrix.php-version == '8.2' + - name: Install dependencies with composer php 8.3 + if: matrix.php-version == '8.3' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Execute Tests run: | @@ -79,6 +80,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" steps: - name: Checkout uses: actions/checkout@v2 @@ -100,11 +102,11 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install dependencies with composer - if: matrix.php-version != '8.2' + if: matrix.php-version != '8.3' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.2 - if: matrix.php-version == '8.2' + - name: Install dependencies with composer php 8.3 + if: matrix.php-version == '8.3' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Execute Tests From 747adf1f62b4ae30b64a146138d2a15f9df49bad Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Thu, 4 Jan 2024 13:16:52 +0200 Subject: [PATCH 3/4] Remove unused code --- src/Relation/BelongsTo.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Relation/BelongsTo.php b/src/Relation/BelongsTo.php index b1a7c094..014071a5 100644 --- a/src/Relation/BelongsTo.php +++ b/src/Relation/BelongsTo.php @@ -116,11 +116,7 @@ private function shouldPull(Tuple $tuple, Tuple $rTuple): bool if ($rTuple->status < $minStatus) { return false; } - $faitFields = \array_intersect($this->outerKeys, $rTuple->state->getWaitingFields()); - // Skip waited fields they are not required hard - if ($faitFields !== [] && \array_sum($faitFields) > 0) { - return false; - } + // Check bidirected relation: when related entity has been removed from HasSome relation $oldData = $tuple->node->getData(); $newData = $rTuple->state->getTransactionData(); From 52bcd76cb256a23f890c31af2cf14832ad0b4da3 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Thu, 4 Jan 2024 14:01:26 +0200 Subject: [PATCH 4/4] Fix actions --- .github/workflows/ci-mssql.yml | 6 +++--- .github/workflows/ci-mysql.yml | 6 +++--- .github/workflows/ci-pgsql.yml | 6 +++--- .github/workflows/main.yml | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 307ad83e..281855aa 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -73,11 +73,11 @@ jobs: run: composer self-update - name: Install dependencies with composer - if: matrix.php != '8.3' + if: matrix.php != '8.4' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.3 - if: matrix.php == '8.3' + - name: Install dependencies with composer php 8.4 + if: matrix.php == '8.4' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run tests with phpunit without coverage diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index be859e4d..1b4e8ca4 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -82,11 +82,11 @@ jobs: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: Install dependencies with composer - if: matrix.php-version != '8.3' + if: matrix.php-version != '8.4' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' + - name: Install dependencies with composer php 8.4 + if: matrix.php-version == '8.4' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run mysql tests with phpunit diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 2b97d8a7..456fe83f 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -83,11 +83,11 @@ jobs: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: Install dependencies with composer - if: matrix.php-version != '8.3' + if: matrix.php-version != '8.4' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' + - name: Install dependencies with composer php 8.4 + if: matrix.php-version == '8.4' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Run pgsql tests with phpunit diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3d9d9f5e..d08d6b36 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,10 +47,10 @@ jobs: key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - name: Install dependencies with composer - if: matrix.php-version != '8.3' + if: matrix.php-version != '8.4' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' + - name: Install dependencies with composer php 8.4 + if: matrix.php-version == '8.4' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Execute Tests run: | @@ -102,11 +102,11 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install dependencies with composer - if: matrix.php-version != '8.3' + if: matrix.php-version != '8.4' run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' + - name: Install dependencies with composer php 8.4 + if: matrix.php-version == '8.4' run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - name: Execute Tests