Symfony\Component\Finder\Finder::name PHP Метод

name() публичный Метод

You can use patterns (delimited with / sign), globs or simple strings. $finder->name('*.php') $finder->name('/\.php$/') // same as above $finder->name('test.php')
См. также: FilenameFilterIterator
public name ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp, a glob, or a string)
Результат Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance
    public function name($pattern)
    {
        $this->names[] = $pattern;

        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Create a map for a given path
  *
  * @param array $paths
  * @return array
  */
 public function createMap(...$paths)
 {
     $classes = [];
     $this->finder->files()->ignoreUnreadableDirs()->in($paths);
     foreach ($this->excludePathPatterns as $exclude) {
         $this->finder->notPath($exclude);
     }
     foreach ($this->inPathPatterns as $inPath) {
         $this->finder->path($inPath);
     }
     foreach ($this->names as $name) {
         $this->finder->name($name);
     }
     /** @var SplFileInfo $file */
     foreach ($this->finder as $file) {
         $content = file_get_contents($file->getPathname());
         preg_match('^\\s*class ([\\S]*)\\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);
         if (isset($match[1])) {
             $className = '\\' . trim($match[1][0]);
             $offset = $match[1][1];
         } else {
             continue;
         }
         preg_match('|\\s*namespace\\s*([\\S]*)\\s*;|', substr($content, 0, $offset), $match);
         if (isset($match[1]) && trim($match[1]) !== '') {
             $className = '\\' . trim($match[1]) . $className;
         }
         if ($className !== '\\') {
             $classes[$file->getPathname()] = $className;
         }
     }
     return $classes;
 }
All Usage Examples Of Symfony\Component\Finder\Finder::name