Skip to content

Conversation

@beberlei
Copy link
Member

@beberlei beberlei commented Dec 12, 2021

This adds a new mapping case that are possible because of nesting attributes in PHP 8.1

  • Using #[AssociationOverrides] and #[AttributeOverrides]

We initially thought to also add nested supported for #[JoinTable(joinColumns: ...)] and #[Table(indexes: ...)] as is possible with annotaitons. However during documentation and test adjustment found that its getting super clumsy and complicated.

Fixes #9240

@beberlei beberlei requested a review from greg0ire December 12, 2021 12:24
…edConstructorArguments with AnnotationDriver.
Supported/new attributes are #[AttributeOverrides], #[AssociationOverrides], #[JoinTable] with nested joinColumns, inverseJoinColumns.
@greg0ire
Copy link
Member

Is this worth documenting anywhere?

@SenseException
Copy link
Member

@derrabus
Copy link
Member

I must admit, I like the flattened version of the attribute mapping that has been built for PHP 8.0. Why do we want to nest attributes again? 🤔

@beberlei
Copy link
Member Author

@derrabus you mean for JoinTable and Table? I wouldn't mind either just keeping the 8.0 way, just was thinking about consistency. We do need the overrides though, but the other too could stay the way they were.

@beberlei
Copy link
Member Author

@greg0ire added docs now

self::assertEquals(255, $valueField['length']);
}

public function testCompositeKeyForJoinTableInManyToManyCreation(): void
Copy link
Member Author

Choose a reason for hiding this comment

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

This is unrelated, but made tests fail due to PHP 8,0 and no nesting. Saw the original DDC3711Test.php where this came from re-executed all YamlMappingDriver tests again, so this skips about 50 tests here that were duplicated.

*/
public function testAssociationOverridesMapping(): void
{
if (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This kind of condition is annoying, but required for some models we interact with. This skips all assocation/attribute override tests on PHP 8, but since we also run against 7.4 and 8.1 this is not a problem.

as part of the lifecycle of the instance variables entity-class.

Required attributes:
Required parameters:
Copy link
Member Author

Choose a reason for hiding this comment

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

This renames are unrelated, but seemed sane to do, since naming the fields attributes on Attribute classes is redundant and confusing as @greg0ire pointed out.

@beberlei beberlei added this to the 2.11.0 milestone Dec 17, 2021
@derrabus
Copy link
Member

Shall we backport the documentation fixes to 2.10?

@beberlei beberlei merged commit 6d306c1 into doctrine:2.11.x Dec 18, 2021
@beberlei
Copy link
Member Author

@derrabus Yes I can do that.

@beberlei beberlei linked an issue Dec 18, 2021 that may be closed by this pull request
derrabus added a commit to derrabus/orm that referenced this pull request Dec 26, 2021
* 2.11.x:
  Enable UnusedUse sniff again (doctrine#9267)
  Whitelist composer plugins used by this repository (doctrine#9286)
  Fix XML export for `change-tracking-policy` (doctrine#9285)
  Allow symfony/cache 6 (doctrine#9283)
  Put actual value instead of index inside $originalEntityData. (doctrine#9244)
  Fix return types of cache interfaces (doctrine#9271)
  Better explain limitations of DQL "DELETE" (doctrine#9281)
  Fix docblocks on nullable EM properties (doctrine#9273)
  Docs: use canonical order for phpdoc tags, add missed semicolon (doctrine#9190)
  Make PrimaryReadReplicaConnection enforcement explicit (doctrine#9239)
  Regenerate Psalm baseline (doctrine#9272)
  Improve compatibility with Doctrine DBAL 4 (doctrine#9266)
  [docs] Fix wording for attributes=>parameters. (doctrine#9265)
  Support for nesting attributes with PHP 8.1 (doctrine#9241)
  Revert "Fix SchemaValidator with abstract child class in discriminator map (doctrine#9096)" (doctrine#9262)
  Docs: consistency for FQCN, spacing, etc (doctrine#9232)
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.

Support for nesting attributes with PHP 8.1

4 participants