Skip to content

Add RefersToMorphed relation attribute#123

Merged
roxblnfk merged 5 commits into
4.xfrom
feature/refers-to-morphed
Jun 15, 2026
Merged

Add RefersToMorphed relation attribute#123
roxblnfk merged 5 commits into
4.xfrom
feature/refers-to-morphed

Conversation

@roxblnfk

Copy link
Copy Markdown
Member

Add the #[RefersToMorphed] (and @RefersToMorphed) attribute, the morphed
counterpart of RefersTo, mirroring BelongsToMorphed. It compiles to the
refersToMorphed relation type and allows self-linked / cyclic morphed
references that BelongsToMorphed cannot persist in a single transaction.

Adds functional tests across all four drivers verifying the relation is
generated as Relation::REFERS_TO_MORPHED with the morph and inner key columns.

Requires cycle/orm with Relation::REFERS_TO_MORPHED and cycle/schema-builder
with the refersToMorphed schema generator.

roxblnfk and others added 3 commits June 15, 2026 22:12
Add the #[RefersToMorphed] (and @RefersToMorphed) attribute, the morphed
counterpart of RefersTo, mirroring BelongsToMorphed. It compiles to the
`refersToMorphed` relation type and allows self-linked / cyclic morphed
references that BelongsToMorphed cannot persist in a single transaction.

Adds functional tests across all four drivers verifying the relation is
generated as Relation::REFERS_TO_MORPHED with the morph and inner key columns.

Requires cycle/orm with Relation::REFERS_TO_MORPHED and cycle/schema-builder
with the `refersToMorphed` schema generator.
Add the #[RefersToMorphed] IDE metadata (relations.meta-storm.xml) mirroring
BelongsToMorphed, and require cycle/orm ^2.18 and cycle/schema-builder ^2.12
which ship the REFERS_TO_MORPHED relation type the attribute compiles to.
Suppress the same DeprecatedClass (NamedArgumentConstructor) and
InvalidClassConstantType (TYPE) issues already baselined for the sibling
relation annotations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.93%. Comparing base (4c15bdd) to head (a5aa920).

Additional details and impacted files
@@             Coverage Diff              @@
##                4.x     #123      +/-   ##
============================================
+ Coverage     91.90%   91.93%   +0.02%     
- Complexity      329      330       +1     
============================================
  Files            38       39       +1     
  Lines           840      843       +3     
============================================
+ Hits            772      775       +3     
  Misses           68       68              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new morphed relation attribute #[RefersToMorphed] (and @RefersToMorphed) to generate Cycle ORM relations of type Relation::REFERS_TO_MORPHED, enabling deferred/self-referential morphed references. Includes new functional tests (per driver) plus fixtures to validate the generated relation type and expected morph/inner key columns, and bumps required package versions to pick up the underlying ORM/schema-builder support.

Changes:

  • Introduces Cycle\Annotated\Annotation\Relation\Morphed\RefersToMorphed relation attribute/annotation.
  • Adds cross-driver functional coverage + fixtures to assert the compiled schema produces REFERS_TO_MORPHED with *_id and *_role columns.
  • Updates PhpStorm meta-storm relations metadata and bumps composer dependency constraints.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Annotation/Relation/Morphed/RefersToMorphed.php Adds the new morphed relation attribute/annotation class compiling to refersToMorphed.
tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php Common functional assertion that the schema contains a REFERS_TO_MORPHED relation and expected columns.
tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/RefersToMorphedTest.php MySQL driver wrapper for the common test case.
tests/Annotated/Functional/Driver/Postgres/Relation/Morphed/RefersToMorphedTest.php Postgres driver wrapper for the common test case.
tests/Annotated/Functional/Driver/SQLite/Relation/Morphed/RefersToMorphedTest.php SQLite driver wrapper for the common test case.
tests/Annotated/Functional/Driver/SQLServer/Relation/Morphed/RefersToMorphedTest.php SQLServer driver wrapper for the common test case.
tests/Annotated/Fixtures/RefersToMorphed/Comment.php Fixture entity defining the RefersToMorphed relation.
tests/Annotated/Fixtures/RefersToMorphed/Post.php Fixture entity implementing the morphed parent interface.
tests/Annotated/Fixtures/RefersToMorphed/MorphedParentInterface.php Fixture interface used as the morphed target contract.
resources/relations.meta-storm.xml Adds PhpStorm meta-storm constructor argument hints for RefersToMorphed.
composer.json Updates dependency constraints to versions expected to support REFERS_TO_MORPHED and related generators.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread resources/relations.meta-storm.xml
roxblnfk and others added 2 commits June 16, 2026 00:23
The meta-storm `argument` attribute is the 0-based constructor parameter
position (confirmed by the docs and the ManyToMany mapping). The morphed
constructor is (target, cascade, nullable, innerKey, outerKey, ...), so the
correct indexes are target=0, innerKey=3, outerKey=4 - not the 1/1/2 that were
mirrored from the (buggy) sibling morphed entries. Without this, the IDE would
offer entity completion for the `cascade`/`nullable` parameters instead of
`target`/`innerKey`/`outerKey`.

Addresses the Copilot review comment on PR #123.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BelongsToMorphed, MorphedHasOne and MorphedHasMany had the same incorrect
meta-storm argument indexes as RefersToMorphed: target/innerKey/outerKey were
mapped to 1/1/2 while the morphed constructor is
(target, cascade, nullable, innerKey, outerKey, ...), i.e. positions 0/3/4.
Align all four morphed relations so the IDE offers entity completion for the
target and column completion for the real innerKey/outerKey arguments.
@roxblnfk roxblnfk force-pushed the feature/refers-to-morphed branch from 14a398e to a5aa920 Compare June 15, 2026 20:51
@roxblnfk roxblnfk merged commit e04328c into 4.x Jun 15, 2026
11 checks passed
@roxblnfk roxblnfk deleted the feature/refers-to-morphed branch June 15, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants