Sometimes you need to use a primary key as a foreign key. I've heard that Doctrine ORM doesn't support this, so each table needs its own primary key. Actually, that's not necessary, because Doctrine ORM has supported it out of the box since version 2.1. All we need is the association-key attribute (when using XML mapping; use associationKey with YAML).
Unfortunately, this feature is not obvious. Judging by the search results, many people have trouble with it. So I decided to publish a short note about it to make the world a little better.
To use the primary key as a foreign key, we need to give both the same name:

As you can see, I defined the primary key task as an association key (association-key="true"). It references the task relation, which in turn references the task_id field. That's all there is to it. Note that the primary key has no generator configured (strategy="NONE").
You can use this only with Many-to-One and One-to-One relations.
More about identity through primary keys: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/tutorials/composite-primary-keys.html#identity-through-foreign-entities