diff --git a/composer.json b/composer.json index b6fb0a72..05fe7393 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,12 @@ "email": "wolfy-j@spiralscout.com" }, { - "name": "Aleksei Gagarin (roxblnfk)", - "email": "alexey.gagarin@spiralscout.com" + "name": "Aleksei Gagarin", + "homepage": "https://github.com/roxblnfk" }, { - "name": "Pavel Butchnev (butschster)", - "email": "pavel.buchnev@spiralscout.com" + "name": "Pavel Butchnev", + "homepage": "https://github.com/butschster" }, { "name": "Maksim Smakouz (msmakouz)", @@ -38,20 +38,20 @@ ], "require": { "php": ">=8.1", - "cycle/database": "^2.16", - "cycle/orm": "^2.15", - "cycle/schema-builder": "^2.11.1", - "spiral/attributes": "^2.8|^3.0", - "spiral/tokenizer": "^2.8|^3.0", - "doctrine/inflector": "^2.0" + "cycle/database": "^2.20", + "cycle/orm": "^2.18", + "cycle/schema-builder": "^2.12", + "spiral/attributes": "^2.8 || ^3.1", + "spiral/tokenizer": "^2.8 || ^3.17", + "doctrine/inflector": "^2.1" }, "require-dev": { "buggregator/trap": "^1.15", - "doctrine/annotations": "^1.14.3 || ^2.0.1", - "phpunit/phpunit": "^10.1", - "spiral/code-style": "^2.2", + "doctrine/annotations": "^1.14 || ^2.0", + "phpunit/phpunit": "^10.5", + "spiral/code-style": "^2.3", "spiral/dumper": "^3.3", - "vimeo/psalm": "^5.26 || ^6.0" + "vimeo/psalm": "^5.26 || ^6.16" }, "autoload": { "psr-4": { diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ecb12747..6359999f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -112,6 +112,14 @@ + + + + + + + + diff --git a/resources/relations.meta-storm.xml b/resources/relations.meta-storm.xml index 079f7feb..9df3a63d 100644 --- a/resources/relations.meta-storm.xml +++ b/resources/relations.meta-storm.xml @@ -138,12 +138,12 @@ - + - + @@ -151,7 +151,30 @@ - + + + + + + + + + + + + + + + + + + + + + + + + @@ -161,12 +184,12 @@ - + - + @@ -174,7 +197,7 @@ - + @@ -184,12 +207,12 @@ - + - + @@ -197,7 +220,7 @@ - + diff --git a/src/Annotation/Relation/Morphed/RefersToMorphed.php b/src/Annotation/Relation/Morphed/RefersToMorphed.php new file mode 100644 index 00000000..d9f0728d --- /dev/null +++ b/src/Annotation/Relation/Morphed/RefersToMorphed.php @@ -0,0 +1,58 @@ +inverse = $inverse; + + parent::__construct($target, $load); + } +} diff --git a/tests/Annotated/Fixtures/RefersToMorphed/Comment.php b/tests/Annotated/Fixtures/RefersToMorphed/Comment.php new file mode 100644 index 00000000..80f791a9 --- /dev/null +++ b/tests/Annotated/Fixtures/RefersToMorphed/Comment.php @@ -0,0 +1,28 @@ + [__DIR__ . '/../../../../../Fixtures/RefersToMorphed'], + 'exclude' => [], + ])))->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + $this->assertArrayHasKey('parent', $schema['comment'][Schema::RELATIONS]); + $this->assertSame( + Relation::REFERS_TO_MORPHED, + $schema['comment'][Schema::RELATIONS]['parent'][Relation::TYPE], + ); + $this->assertSame( + MorphedParentInterface::class, + $schema['comment'][Schema::RELATIONS]['parent'][Relation::TARGET], + ); + + // Morphed refers-to stores the outer key and the target role on the source entity. + $this->assertContains('parent_id', $schema['comment'][Schema::COLUMNS]); + $this->assertContains('parent_role', $schema['comment'][Schema::COLUMNS]); + } +} diff --git a/tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/RefersToMorphedTest.php b/tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/RefersToMorphedTest.php new file mode 100644 index 00000000..30442dfe --- /dev/null +++ b/tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/RefersToMorphedTest.php @@ -0,0 +1,16 @@ +