ConfigurationFile.php 766 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations\Configuration\Migration;
  4. use function dirname;
  5. use function realpath;
  6. abstract class ConfigurationFile implements ConfigurationLoader
  7. {
  8. /** @var string */
  9. protected $file;
  10. public function __construct(string $file)
  11. {
  12. $this->file = $file;
  13. }
  14. /**
  15. * @param array<string,string> $directories
  16. *
  17. * @return array<string,string>
  18. */
  19. final protected function getDirectoriesRelativeToFile(array $directories, string $file): array
  20. {
  21. foreach ($directories as $ns => $dir) {
  22. $path = realpath(dirname($file) . '/' . $dir);
  23. $directories[$ns] = $path !== false ? $path : $dir;
  24. }
  25. return $directories;
  26. }
  27. }