You are here

public static function ClassMapGenerator::createMap in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/class-loader/ClassMapGenerator.php \Symfony\Component\ClassLoader\ClassMapGenerator::createMap()

Iterate over all files in the given directory searching for classes.

Parameters

\Iterator|string $dir The directory to search in or an iterator:

Return value

array A class map array

3 calls to ClassMapGenerator::createMap()
ClassMapGenerator::dump in vendor/symfony/class-loader/ClassMapGenerator.php
Generate a class map file.
ClassMapGeneratorTest::testCreateMap in vendor/symfony/class-loader/Tests/ClassMapGeneratorTest.php
@dataProvider getTestCreateMapTests
ClassMapGeneratorTest::testCreateMapFinderSupport in vendor/symfony/class-loader/Tests/ClassMapGeneratorTest.php

File

vendor/symfony/class-loader/ClassMapGenerator.php, line 54

Class

ClassMapGenerator
ClassMapGenerator.

Namespace

Symfony\Component\ClassLoader

Code

public static function createMap($dir) {
  if (is_string($dir)) {
    $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
  }
  $map = array();
  foreach ($dir as $file) {
    if (!$file
      ->isFile()) {
      continue;
    }
    $path = $file
      ->getRealPath();
    if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') {
      continue;
    }
    $classes = self::findClasses($path);
    foreach ($classes as $class) {
      $map[$class] = $path;
    }
  }
  return $map;
}