Strings or PCRE patterns can be used:
$finder->notContains('Lorem ipsum')
$finder->notContains('/Lorem ipsum/i')
public notContains ( string $pattern ) : |
||
$pattern | string | A pattern (string or regexp) |
Résultat | The current Finder instance |
/** * @param $type * @param $name * * @return PhpFileInfo|null */ protected function findDefinitionFileByRegex($type, $name) { $namespaceParts = explode('\\', $name); $definition = sprintf('%s %s[;\\{\\s]', $type, array_pop($namespaceParts)); if (count($namespaceParts) > 0) { $namespace = sprintf('namespace %s', implode('\\\\', $namespaceParts)); } else { $namespace = ''; } $files = new Finder(); $files->name('*.php')->contains(sprintf('/%s.*%s/s', $namespace, $definition))->in($this->sourcePaths); if (!$namespace) { $files->notContains('/namespace\\s[^;]+/'); } $file = current(iterator_to_array($files)); if (!$file instanceof SplFileInfo) { return; } $baseFile = PhpFileInfo::create($file); return $this->usageParser->parseFile($baseFile); }
/** * @param InputInterface $input * @return Finder */ public function createFinder(InputInterface $input) { $finder = new Finder(); $finder->files(); foreach ($input->getArgument('directory') as $dir) { $finder->in($dir); } foreach ($input->getOption('not-dir') as $ignoreDir) { $finder->exclude($ignoreDir); } foreach ($input->getOption('file-name') as $pattern) { $finder->name($pattern); } foreach ($input->getOption('not-file-name') as $pattern) { $finder->notName($pattern); } foreach ($input->getOption('contains') as $pattern) { $finder->contains($pattern); } foreach ($input->getOption('not-contains') as $pattern) { $finder->notContains($pattern); } foreach ($input->getOption('path') as $pattern) { $finder->path($pattern); } foreach ($input->getOption('not-path') as $pattern) { $finder->notPath($pattern); } if ($size = $input->getOption('size')) { $finder->size($size); } if ($modified = $input->getOption('modified')) { $finder->date($modified); } if ($depth = $input->getOption('depth')) { $finder->depth($depth); } return $finder; }
/** * @return Finder */ public function notContains($pattern) { return parent::notContains($pattern); }