Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.2",
"deptrac/deptrac": "^2.0",
"deptrac/deptrac": "^4.7",
"php-code-archeology/php-code-archeology": "^2.11",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.5",
Expand Down
8 changes: 4 additions & 4 deletions src/Deptrac/CrossModuleDomainRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace PrikotovCodingStandard\Deptrac;

use Qossmic\Deptrac\Contract\Analyser\EventHelper;
use Qossmic\Deptrac\Contract\Analyser\ProcessEvent;
use Qossmic\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Qossmic\Deptrac\Contract\Ast\DependencyType;
use Deptrac\Deptrac\Contract\Analyser\EventHelper;
use Deptrac\Deptrac\Contract\Analyser\ProcessEvent;
use Deptrac\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyType;

/**
* Custom Deptrac rule that forbids cross-module access entirely,
Expand Down
20 changes: 10 additions & 10 deletions src/Deptrac/MetricsJsonOutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace PrikotovCodingStandard\Deptrac;

use Qossmic\Deptrac\Contract\OutputFormatter\OutputFormatterInput;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputFormatterInterface;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputInterface;
use Qossmic\Deptrac\Contract\Result\Allowed;
use Qossmic\Deptrac\Contract\Result\CoveredRuleInterface;
use Qossmic\Deptrac\Contract\Result\OutputResult;
use Qossmic\Deptrac\Contract\Result\RuleInterface;
use Qossmic\Deptrac\Contract\Result\SkippedViolation;
use Qossmic\Deptrac\Contract\Result\Uncovered;
use Qossmic\Deptrac\Contract\Result\Violation;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputFormatterInput;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputFormatterInterface;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputInterface;
use Deptrac\Deptrac\Contract\Result\Allowed;
use Deptrac\Deptrac\Contract\Result\CoveredRuleInterface;
use Deptrac\Deptrac\Contract\Result\OutputResult;
use Deptrac\Deptrac\Contract\Result\RuleInterface;
use Deptrac\Deptrac\Contract\Result\SkippedViolation;
use Deptrac\Deptrac\Contract\Result\Uncovered;
use Deptrac\Deptrac\Contract\Result\Violation;
use RuntimeException;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Deptrac/ReservedLayerSegmentRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace PrikotovCodingStandard\Deptrac;

use Qossmic\Deptrac\Contract\Analyser\PostProcessEvent;
use Qossmic\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Qossmic\Deptrac\Contract\Result\Error;
use Qossmic\Deptrac\Core\Ast\AstMapExtractor;
use Deptrac\Deptrac\Contract\Analyser\PostProcessEvent;
use Deptrac\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Deptrac\Deptrac\Contract\Result\Error;
use Deptrac\Deptrac\Core\Ast\AstMapExtractor;

/**
* Custom Deptrac rule that forbids reserved layer names as nested namespace segments.
Expand Down
8 changes: 4 additions & 4 deletions src/Deptrac/ServiceContractDependencyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace PrikotovCodingStandard\Deptrac;

use Qossmic\Deptrac\Contract\Analyser\EventHelper;
use Qossmic\Deptrac\Contract\Analyser\ProcessEvent;
use Qossmic\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Qossmic\Deptrac\Contract\Ast\DependencyType;
use Deptrac\Deptrac\Contract\Analyser\EventHelper;
use Deptrac\Deptrac\Contract\Analyser\ProcessEvent;
use Deptrac\Deptrac\Contract\Analyser\ViolationCreatingInterface;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyType;

/**
* Custom Deptrac rule that enforces service contract boundaries.
Expand Down
42 changes: 26 additions & 16 deletions tests/Deptrac/CrossModuleDomainRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@

use PHPUnit\Framework\TestCase;
use PrikotovCodingStandard\Deptrac\CrossModuleDomainRule;
use Qossmic\Deptrac\Contract\Analyser\AnalysisResult;
use Qossmic\Deptrac\Contract\Analyser\EventHelper;
use Qossmic\Deptrac\Contract\Analyser\ProcessEvent;
use Qossmic\Deptrac\Contract\Ast\DependencyContext;
use Qossmic\Deptrac\Contract\Ast\DependencyType;
use Qossmic\Deptrac\Contract\Ast\FileOccurrence;
use Qossmic\Deptrac\Contract\Layer\LayerProvider;
use Qossmic\Deptrac\Contract\Result\RuleInterface;
use Qossmic\Deptrac\Contract\Result\SkippedViolation;
use Qossmic\Deptrac\Contract\Result\Violation;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeReference;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken;
use Qossmic\Deptrac\Core\Dependency\Dependency;
use Deptrac\Deptrac\Contract\Analyser\AnalysisResult;
use Deptrac\Deptrac\Contract\Analyser\EventHelper;
use Deptrac\Deptrac\Contract\Analyser\ProcessEvent;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyContext;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyType;
use Deptrac\Deptrac\Contract\Ast\AstMap\FileOccurrence;
use Deptrac\Deptrac\Core\Layer\LayerProvider;
use Deptrac\Deptrac\Contract\OutputFormatter\BaselineMapperInterface;
use Deptrac\Deptrac\Contract\Result\RuleInterface;
use Deptrac\Deptrac\Contract\Result\SkippedViolation;
use Deptrac\Deptrac\Contract\Result\Violation;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeReference;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeToken;
use Deptrac\Deptrac\DefaultBehavior\Dependency\Helpers\Dependency;

/**
* @see CrossModuleDomainRule
Expand Down Expand Up @@ -536,11 +537,11 @@ public function testCrossModuleDependencyHonorsSkipViolations(): void
'App\Common\Module\User\Domain\Service\Account\FindAccountServiceInterface',
DependencyType::PARAMETER,
);
$rule = new CrossModuleDomainRule(new EventHelper([
$rule = new CrossModuleDomainRule($this->createEventHelper([
'App\Common\Module\Billing\Domain\Service\Invoice\CreateInvoiceService' => [
'App\Common\Module\User\Domain\Service\Account\FindAccountServiceInterface',
],
], new LayerProvider([])));
]));

$rule->onProcessEvent($event);

Expand All @@ -551,7 +552,16 @@ public function testCrossModuleDependencyHonorsSkipViolations(): void
/** @param array<string, list<string>> $skippedViolations */
private function createRule(array $skippedViolations = []): CrossModuleDomainRule
{
return new CrossModuleDomainRule(new EventHelper($skippedViolations, new LayerProvider([])));
return new CrossModuleDomainRule($this->createEventHelper($skippedViolations));
}

/** @param array<string, list<string>> $skippedViolations */
private function createEventHelper(array $skippedViolations): EventHelper
{
$baselineMapper = $this->createStub(BaselineMapperInterface::class);
$baselineMapper->method('loadViolations')->willReturn($skippedViolations);

return new EventHelper(new LayerProvider([]), $baselineMapper);
}

private function createProcessEvent(
Expand Down
24 changes: 12 additions & 12 deletions tests/Deptrac/MetricsJsonOutputFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

use PHPUnit\Framework\TestCase;
use PrikotovCodingStandard\Deptrac\MetricsJsonOutputFormatter;
use Qossmic\Deptrac\Contract\Analyser\AnalysisResult;
use Qossmic\Deptrac\Contract\Ast\DependencyContext;
use Qossmic\Deptrac\Contract\Ast\DependencyType;
use Qossmic\Deptrac\Contract\Ast\FileOccurrence;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputFormatterInput;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputFormatterInterface;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputInterface;
use Qossmic\Deptrac\Contract\OutputFormatter\OutputStyleInterface;
use Qossmic\Deptrac\Contract\Result\Allowed;
use Qossmic\Deptrac\Contract\Result\OutputResult;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken;
use Qossmic\Deptrac\Core\Dependency\Dependency;
use Deptrac\Deptrac\Contract\Analyser\AnalysisResult;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyContext;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyType;
use Deptrac\Deptrac\Contract\Ast\AstMap\FileOccurrence;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputFormatterInput;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputFormatterInterface;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputInterface;
use Deptrac\Deptrac\Contract\OutputFormatter\OutputStyleInterface;
use Deptrac\Deptrac\Contract\Result\Allowed;
use Deptrac\Deptrac\Contract\Result\OutputResult;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeToken;
use Deptrac\Deptrac\DefaultBehavior\Dependency\Helpers\Dependency;
use RuntimeException;

final class MetricsJsonOutputFormatterTest extends TestCase
Expand Down
12 changes: 6 additions & 6 deletions tests/Deptrac/ReservedLayerSegmentRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use PHPUnit\Framework\TestCase;
use PrikotovCodingStandard\Deptrac\ReservedLayerSegmentRule;
use Qossmic\Deptrac\Contract\Analyser\AnalysisResult;
use Qossmic\Deptrac\Contract\Analyser\PostProcessEvent;
use Qossmic\Deptrac\Core\Ast\AstMap\AstMap;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeReference;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken;
use Qossmic\Deptrac\Core\Ast\AstMapExtractor;
use Deptrac\Deptrac\Contract\Analyser\AnalysisResult;
use Deptrac\Deptrac\Contract\Analyser\PostProcessEvent;
use Deptrac\Deptrac\Core\Ast\AstMap;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeReference;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeToken;
use Deptrac\Deptrac\Core\Ast\AstMapExtractor;

/**
* @see ReservedLayerSegmentRule
Expand Down
42 changes: 26 additions & 16 deletions tests/Deptrac/ServiceContractDependencyRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@

use PHPUnit\Framework\TestCase;
use PrikotovCodingStandard\Deptrac\ServiceContractDependencyRule;
use Qossmic\Deptrac\Contract\Analyser\AnalysisResult;
use Qossmic\Deptrac\Contract\Analyser\EventHelper;
use Qossmic\Deptrac\Contract\Analyser\ProcessEvent;
use Qossmic\Deptrac\Contract\Ast\DependencyContext;
use Qossmic\Deptrac\Contract\Ast\DependencyType;
use Qossmic\Deptrac\Contract\Ast\FileOccurrence;
use Qossmic\Deptrac\Contract\Layer\LayerProvider;
use Qossmic\Deptrac\Contract\Result\RuleInterface;
use Qossmic\Deptrac\Contract\Result\SkippedViolation;
use Qossmic\Deptrac\Contract\Result\Violation;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeReference;
use Qossmic\Deptrac\Core\Ast\AstMap\ClassLike\ClassLikeToken;
use Qossmic\Deptrac\Core\Dependency\Dependency;
use Deptrac\Deptrac\Contract\Analyser\AnalysisResult;
use Deptrac\Deptrac\Contract\Analyser\EventHelper;
use Deptrac\Deptrac\Contract\Analyser\ProcessEvent;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyContext;
use Deptrac\Deptrac\Contract\Ast\AstMap\DependencyType;
use Deptrac\Deptrac\Contract\Ast\AstMap\FileOccurrence;
use Deptrac\Deptrac\Core\Layer\LayerProvider;
use Deptrac\Deptrac\Contract\OutputFormatter\BaselineMapperInterface;
use Deptrac\Deptrac\Contract\Result\RuleInterface;
use Deptrac\Deptrac\Contract\Result\SkippedViolation;
use Deptrac\Deptrac\Contract\Result\Violation;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeReference;
use Deptrac\Deptrac\Contract\Ast\AstMap\ClassLikeToken;
use Deptrac\Deptrac\DefaultBehavior\Dependency\Helpers\Dependency;

/**
* @see ServiceContractDependencyRule
Expand Down Expand Up @@ -618,11 +619,11 @@ public function testServiceContractDependencyHonorsSkipViolations(): void
'App\Common\Module\User\Domain\Service\Account\FindAccountServiceInterface',
DependencyType::PARAMETER,
);
$rule = new ServiceContractDependencyRule(new EventHelper([
$rule = new ServiceContractDependencyRule($this->createEventHelper([
'App\Common\Module\Billing\Integration\Service\User\FindUserService' => [
'App\Common\Module\User\Domain\Service\Account\FindAccountServiceInterface',
],
], new LayerProvider([])));
]));

$rule->onProcessEvent($event);

Expand All @@ -633,7 +634,16 @@ public function testServiceContractDependencyHonorsSkipViolations(): void
/** @param array<string, list<string>> $skippedViolations */
private function createRule(array $skippedViolations = []): ServiceContractDependencyRule
{
return new ServiceContractDependencyRule(new EventHelper($skippedViolations, new LayerProvider([])));
return new ServiceContractDependencyRule($this->createEventHelper($skippedViolations));
}

/** @param array<string, list<string>> $skippedViolations */
private function createEventHelper(array $skippedViolations): EventHelper
{
$baselineMapper = $this->createStub(BaselineMapperInterface::class);
$baselineMapper->method('loadViolations')->willReturn($skippedViolations);

return new EventHelper(new LayerProvider([]), $baselineMapper);
}

private function createProcessEvent(
Expand Down
88 changes: 88 additions & 0 deletions todo/done/TASK-support-deptrac-4.todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
type: refactor
created: 2026-09-10 03:49:39 (1789012179)
due:
started: 2026-09-10 03:49:39 (1789012179)
completed: 2026-09-10 03:54:01 (1789012441)
cancelled:
value: V2
complexity: C2
priority: P2
cost_plan:
cost_fact:
depends_on:
epic:
author: Бэкендер Левша (pi)
assignee: Бэкендер Левша (pi)
branch: task/support-deptrac-4
pr: https://github.com/prikotov/coding-standard/pull/125
status: done
---

# TASK-support-deptrac-4: Поддержать Deptrac 4

## 0. Простое описание (Human Brief)

### Проблема простыми словами (Problem)
- Кастомные правила и форматтер метрик используют пространства имён и контракты Deptrac 2, поэтому не загружаются с Deptrac 4.
- Это блокирует обновление Deptrac в проектах-потребителях, включая `task-orchestrator`.

### Варианты или путь решения (Solution Sketch)
- Перейти на пространства имён и контракты Deptrac 4.
- Адаптировать тестовые зависимости `EventHelper` к новому конструктору через `BaselineMapperInterface`.

### Ожидаемый результат (Expected Result)
- Все расширения пакета загружаются и сохраняют прежнее поведение с Deptrac 4.7.

## 1. Концепция и Цель (Concept and Goal)

### История (User Story)
> Как сопровождающий проекта-потребителя, я хочу использовать актуальный Deptrac 4 вместе с `prikotov/coding-standard`, чтобы получать исправления анализатора без потери проектных архитектурных правил.

### Цель по SMART (Goal)
- Обеспечить совместимость всех четырёх интеграций Deptrac с версией 4.7 и подтвердить её полным `composer check`.

## 2. Контекст и Границы (Context and Scope)
- **Где делаем:** `src/Deptrac/`, соответствующие тесты и ограничение `deptrac/deptrac` в `composer.json`.
- **Вне границ:** изменение семантики архитектурных правил, миграция PHPUnit, поддержка Deptrac 2 и 3.

## 3. Требования, MoSCoW (Requirements)
### 🔴 Обязательно (Must Have)
- [x] Пакет разработки требует `deptrac/deptrac ^4.7`.
- [x] Правила и форматтер используют контракты Deptrac 4.
- [x] Тесты учитывают новый контракт `EventHelper`.
- [x] Полный `composer check` проходит успешно.
### ⚫ Won't Have (Не будем делать)
- Одновременная поддержка несовместимых внутренних контрактов нескольких основных версий Deptrac.

## 4. План реализации (Implementation Plan)
1. [x] Обновить ограничение Deptrac до `^4.7`.
2. [x] Перенести импорты на пространства имён Deptrac 4.
3. [x] Адаптировать тестовые объекты и проверку `skip_violations`.
4. [x] Выполнить `composer check`.

## 5. Критерии приёмки (Definition of Done)
- [x] `composer check` завершается без ошибок.
- [x] Все 287 тестов расширений и правил проходят.
- [x] Пакет можно установить совместно с Deptrac 4.7.

## 6. Самопроверка (Verification)
```bash
composer validate --strict
composer check
```

## 7. Риски и зависимости (Risks and Dependencies)
- Изменение несовместимо с Deptrac 2, поэтому требует повышения minor-версии пакета в линии `0.x`.
- `EventHelper` остаётся внутренним контрактом Deptrac и может потребовать новой адаптации при следующем основном обновлении.

## 8. Источники (Sources)
- Исходный код контрактов установленного `deptrac/deptrac 4.7.1`.

## 9. Комментарии (Comments)
- Изменение подготовлено как предварительное условие полного обновления зависимостей `task-orchestrator`.

## История изменений (Change History)
| Дата | Автор (роль) | Изменение |
| :--- | :--- | :--- |
| 2026-09-10 03:49:39 (1789012179) | Бэкендер Левша (pi) | Создание задачи |
Loading