Skip to content

Commit

Permalink
ContainerFactory - checking for duplicate files is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 20, 2022
1 parent ec5b633 commit 4cdb806
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static function begin(
$paths = array_map(static fn (string $path): string => $currentWorkingDirectoryFileHelper->normalizePath($currentWorkingDirectoryFileHelper->absolutizePath($path)), $paths);

$analysedPathsFromConfig = [];
$containerFactory = new ContainerFactory($currentWorkingDirectory);
$containerFactory = new ContainerFactory($currentWorkingDirectory, true);
$projectConfig = null;
if ($projectConfigFile !== null) {
if (!is_file($projectConfigFile)) {
Expand Down
6 changes: 5 additions & 1 deletion src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ContainerFactory
private string $configDirectory;

/** @api */
public function __construct(private string $currentWorkingDirectory)
public function __construct(private string $currentWorkingDirectory, private bool $checkDuplicateFiles = false)
{
$this->fileHelper = new FileHelper($currentWorkingDirectory);

Expand Down Expand Up @@ -235,6 +235,10 @@ private function detectDuplicateIncludedFiles(
return $normalized;
}

if (!$this->checkDuplicateFiles) {
return $normalized;
}

$duplicateFiles = array_unique(array_diff_key($normalized, $deduplicated));

throw new DuplicateIncludedFilesException($duplicateFiles);
Expand Down

0 comments on commit 4cdb806

Please sign in to comment.