Skip to content

fix(rules): stop false ForbiddenPropertyType on Uid, Embeddable VO and shared Enum / убрать ложные срабатывания сниффера VO - #137

Merged
prikotov merged 13 commits into
masterfrom
task/vo-sniff-dependency-false-positives
Nov 25, 2026
Merged

prikotov merged 13 commits into
masterfrom
task/vo-sniff-dependency-false-positives

Conversation

@prikotov

Copy link
Copy Markdown
Owner

TASK-fix-vo-sniff-dependency-false-positives

Аудит ValueObjectStructureSniff (после #136) на проекте-потребителе TasK выявил, что сниффер строже конвенции в трёх местах: 27 из 41 ForbiddenPropertyType — ложные срабатывания.

Что исправлено

Кейс Причина Фикс
Symfony\Component\Uid\Uuid (22) allowlist знал только Ramsey\Uuid, хотя конвенция разрешает Uuid и её примеры сами используют Symfony Uid добавлен префикс symfony\component\uid\
Embeddable VO Domain\Entity\ValueObject\ (2) группа = первый сегмент после слоя → Entity → запрет, хотя конвенция такое размещение разрешает группа = последняя категория перед именем класса: …\Entity\ValueObject\XVo → valueobject, …\Entity\XModel → entity
Общие Enum {Project}\Common\… (3) нет Module-сегмента → запрет, хотя enum.md разрешает общие Enum в Common\Enum разрешены Common\{Enum|Component|ValueObject}\… без Module

Честные нарушения сохранены: ORM-модели, Domain\Service, другие слои и модули.

Конвенция value-object.md

Раздел «Зависимости» теперь явно перечисляет разрешённое (Uuid любой реализации, общие, Embeddable) и запрещённое (Entity/Service, другие модули и слои — включая Infrastructure-VO → Domain, что раньше следовало лишь косвенно). Чек-лист ревью обновлён.

Проверки

  • Пробы: 3 ложных кейса → 0 ошибок; ORM / Service / другой слой / другой модуль → ошибка
  • Фикстуры: позитивные кейсы на Symfony Uid, Common\Enum, Common\Component\…Enum, Embeddable VO
  • composer check зелёный
  • Повторный прогон на TasK: ForbiddenPropertyType 41 → 14 (все честные), NonPrivateProperty 138 без изменений

Refs: TASK-fix-vo-sniff-dependency-false-positives

…d shared Enum / убрать ложные ForbiddenPropertyType на Uid, Embeddable VO и общих Enum

ValueObjectStructureSniff was stricter than the convention in three places,
found by auditing the consumer project TasK (27 of 41 ForbiddenPropertyType
were false positives):

- Symfony\Component\Uid\Uuid was not in the vendor allowlist (only Ramsey\Uuid),
  although the convention allows Uuid and its own examples use Symfony Uid;
- Embeddable VO in Domain\Entity\ValueObject\ were rejected because the group
  was taken as the first segment after the layer (Entity). The group is now
  the last category segment before the class name, so
  Domain\Entity\ValueObject\XVo resolves to valueobject while
  Domain\Entity\XModel still resolves to entity;
- module-independent types in {Project}\Common\Enum, {Project}\Common\Component
  and {Project}\Common\ValueObject were rejected for lacking a Module segment,
  although enum.md allows shared enums there.

Honest violations (ORM models, Domain\Service, other layers and modules)
are preserved; on TasK ForbiddenPropertyType drops from 41 to 14, all genuine.

Refs: TASK-fix-vo-sniff-dependency-false-positives
… явно описать разрешённые и запрещённые зависимости VO

Make the Dependencies section explicit: Uuid of any implementation, shared
(module-independent) Enum/VO under Common\, Embeddable VO of the module are
allowed; Entity models, Domain\Service, other modules and layers (including
Infrastructure VO -> Domain types) are forbidden. Review checklist updated.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…вление ложных срабатываний сниффера VO
…ew / указать PR и перевести задачу в review
… / не привязывать Uuid к реализации в зависимостях

Do not name concrete Uid implementations in the convention — which one to use
is debatable and belongs to the project. The sniff allows both known
implementations, the convention stays as it was: Uuid.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…имость VO от Embeddable VO

Embeddable VO (Domain\Entity\ValueObject\…) are a persistence part of the
entity: they carry Doctrine mapping attributes and are not domain types.
A domain VO depending on them violates "no ORM/DB dependencies" transitively
(the consumer project TasK uses such embeddables from Application mappers,
service interfaces and command handlers).

The previous commit of this task briefly allowed them by resolving the group
as the last category segment; that conflated "where to place" with "what to
inject". Now any `entity` segment in the dependency path makes the type
forbidden, while nested ValueObject groups (Domain\ValueObject\Group\…Vo)
and same-layer enums stay allowed. Fixtures cover both.

BREAKING CHANGE: VO properties typed with Embeddable VO now fail phpcs with
ForbiddenPropertyType.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…ть Embeddable VO как зависимости VO

Explain in the Dependencies section why embeddables are not domain types
(they carry ORM mapping and belong to their entity) and that other VO must
not depend on them; the Location section now states embeddables are used
only inside entity models. Review checklist updated.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…ровать решение по Embeddable в задаче
…ble reuse across entities / сделать список запретов неисчерпывающим, разрешить переиспользование Embeddable в сущностях

Per review: enumerating examples next to "forbidden" implies everything not
listed is allowed — the sentence now states the list is non-exhaustive and only
what is listed as allowed is permitted. Removed the over-restrictive "only
inside its own entity": embeddables may be reused by other entities of the
domain; they just are not a dependency for VO. Checklist aligned.

Refs: TASK-fix-vo-sniff-dependency-false-positives
… / убрать ссылку на снифф и лишние уточнения

Per review: a convention must not know about the code that validates it —
the sniff implements the convention, not the other way around. Removed the
"classified by namespace" sentence, the non-exhaustive-list remark and the
parenthetical examples; the checklist item now simply refers to the section.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…/ перенести определение Embeddable VO в конвенцию сущности

Per review: what an Embeddable VO *is* (a persistence part of the entity, not
a domain type) belongs to the Entity convention, not to the VO location list.
The VO convention now only references the Entity convention for the rationale
and keeps the placement rule; Entity gains the definition (ORM mapping, used
inside entity models, reusable across entities of the domain) and a checklist
item.

Refs: TASK-fix-vo-sniff-dependency-false-positives
…равило про Embeddable VO под стиль документации

Refs: TASK-fix-vo-sniff-dependency-false-positives
… о ложных срабатываниях сниффера VO
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.

1 participant