applicationServiceFiles() as $file) { $violations = $this->collectInstantiationViolations( $file, self::USE_CASE_OR_POLICY_FRAGMENTS, $this->isUseCaseOrPolicyClass(...), ); $this->assertNoArchitectureViolations( $violations, $this->fileRuleMessage(self::MESSAGE_APPLICATION_SERVICE_DI_ONLY, $file), ); } } public function testControllersDoNotInstantiateApplicationOrDomainDependenciesDirectly(): void { foreach ($this->uiControllerFiles() as $file) { $violations = $this->collectInstantiationViolations( $file, self::APPLICATION_OR_DOMAIN_FRAGMENTS, $this->isApplicationOrDomainClass(...), ); $this->assertNoArchitectureViolations( $violations, $this->fileRuleMessage(self::MESSAGE_CONTROLLER_DI_ONLY, $file), ); } } public function testUiLayerDoesNotInstantiateInfrastructureOrRepositoryImplementationsDirectly(): void { foreach ($this->uiFiles() as $file) { $violations = $this->collectInstantiationViolations( $file, self::INFRASTRUCTURE_INSTANTIATION_FRAGMENTS, $this->isInfrastructureOrRepositoryClass(...), ); $this->assertNoArchitectureViolations( $violations, $this->fileRuleMessage(self::MESSAGE_UI_NO_INFRA_INSTANTIATION, $file), ); } } public function testApplicationLayerDoesNotInstantiateInfrastructureOrRepositoryImplementationsDirectly(): void { foreach ($this->applicationFiles() as $file) { $violations = $this->collectInstantiationViolations( $file, self::INFRASTRUCTURE_INSTANTIATION_FRAGMENTS, $this->isInfrastructureOrRepositoryClass(...), ); $this->assertNoArchitectureViolations( $violations, $this->fileRuleMessage(self::MESSAGE_APPLICATION_NO_INFRA_INSTANTIATION, $file), ); } } }