Searches for directories containing stopword files.

@param string $token

@return string[]
356998
public function findTokenDirectories(string $token) : array
    {
        $tokenFinder = $this->finderFactory->build();
        $tokenFinder->in($this->environment->getRootDirectory())->files()->name($token);
        $rawExcludePathsByToken = $this->finderToRealPathConverter
            ->finderToArrayOfPaths($tokenFinder);
        return array_map('dirname', $rawExcludePathsByToken);
    }
901000
public static function isOperator($token)
    {
        if (!\is_string($token)) {
            return false;
        }

        return \strpos(self::MISC_OPERATORS, $token) !== false;
    }
83031
public function getDirectoryFiles(string $path, string $postfix = '')
    {
        if (!is_dir($path)) {
            return [];
        }

        $results = [];
        $files   = array_diff(scandir($path), ['..', '.']);
        foreach ($files as $file) {
            $absolutePath = $path.DIRECTORY_SEPARATOR.$file;
            if (!is_dir($absolutePath) && empty($postfix) || Str::endsWith($file, $postfix)) {
                $results[] = $absolutePath;
            }
        }

        return $results;
    }
254322
public static function getHeader(string $token, string $secret): array
    {
        $parser = self::parser($token, $secret);

        return $parser->validate()->parse()->getHeader();
    }
756245
public static function findByEmailToken($token)
    {
        if (!static::isEmailTokenValid($token)) {
            return null;
        }
        return static::find()->where(['email_token' => $token, 'status' => self::STATUS_ACTIVE])->limit(1)->one();
    }
1212470
public function getFilesWithExtension($path, $ext = 'php')
    {
        if (is_dir($path)) {
            return new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
            ), '/^.+\.'.$ext.'$/i', RecursiveRegexIterator::GET_MATCH);
        } else {
            return [];
        }
    }
1257721
public static function get_include_files( $directory, $exclude_underscore = false ) {
		$return = [
			'files'       => [],
			'directories' => [],
		];

		if ( ! is_dir( $directory ) ) {
			return $return;
		}

		$directory_iterator = new \DirectoryIterator( $directory );

		foreach ( $directory_iterator as $file ) {
			if ( $file->isDot() ) {
				continue;
			}

			if ( $file->isDir() ) {
				$return['directories'][] = $file->getPathname();
				continue;
			}

			if ( 'php' !== $file->getExtension() ) {
				continue;
			}

			if ( $exclude_underscore ) {
				if ( 0 === strpos( $file->getBasename(), '_' ) ) {
					continue;
				}
			}

			$return['files'][] = $file->getPathname();
		}

		return $return;
	}
818234
public static function tokenHasExtraWhiteSpaces($token)
    {
        return \strpos($token[Tokenizer::TOKEN_VALUE], ' ') !== false
        || \strpos($token[Tokenizer::TOKEN_VALUE], "\n") !== false
        || \strpos($token[Tokenizer::TOKEN_VALUE], "\t") !== false;
    }
1027230
public function getStringRolesFromToken(TokenInterface $token)
    {
        $roles = array();

        foreach ($token->getRoles() as $role) {
            $roles[] = $role->getRole();
        }

        return $roles;
    }
1177140
protected function lexDirectiveLocations(): array
    {
        $this->skip(TokenKindEnum::PIPE);

        $locations = [];

        do {
            $locations[] = $this->lexDirectiveLocation();
        } while ($this->skip(TokenKindEnum::PIPE));

        return $locations;
    }
1153734
protected function getFileIterator($path, $pattern = '/^.+\.php$/')
    {
        if (is_dir($path)) {
            return new \RegexIterator(new \DirectoryIterator($path), $pattern, \RegexIterator::GET_MATCH);
        }
        if (is_file($path) && 1 === preg_match($pattern, $path)) {
            return [new \SplFileInfo($path)];
        }
        return [];
    }
110440
private function _checkProhibitedKeywordsRegex($token) {
		if ($this->_isActive('checkProhibitedKeywordsRegex')) {

			foreach ($this->_prohibitedKeywordsRegex as $pattern) {

				preg_match_all($pattern, $token->text, $matches);
				$matches = $matches[0];
				if (!empty($matches)) {
					foreach ($matches as $key => $value) {
						$msg = $this->_getMessage('PROHIBITED_KEYWORD_REGEX', $value);
						$this->_writeError('checkProhibitedKeywordsRegex', $msg);
					}
				}
			}
		}
	}
678683
public function getHeaders($token = null)
    {
        if ($token) {
            return array_merge(
                $this->getDefaultHeaders(),
                $this->getAuthorizationHeaders($token)
            );
        }

        return $this->getDefaultHeaders();
    }
1207882
public function files($directory)
    {
        $this->checkDirectory($directory);

        $disk = $this->disk();

        // TODO: Add a feature to exclude unwanted files.
        $files = array_map(function ($filePath) use ($disk, $directory) {
            return [
                'name'         => str_replace("$directory/", '', $filePath),
                'path'         => $filePath,
                'url'          => $disk->url($filePath),
                'mimetype'     => $disk->mimeType($filePath),
                'lastModified' => Carbon::createFromTimestamp($disk->lastModified($filePath))->toDateTimeString(),
                'visibility'   => $disk->getVisibility($filePath),
                'size'         => $disk->size($filePath),
            ];
        }, $disk->files($directory));

        return FileCollection::make($files)->exclude($this->getExcludedFiles());
    }
589983
protected function getTokenData(Token $token)
    {
        return [
            'id' => $token->getId(),
            'expires' => $token->getExpiresAt()->format(\DateTime::ISO8601),
        ];
    }
1297607
protected function _searchFiles()
    {
        $pattern = false;
        if (!empty($this->_exclude)) {
            $exclude = [];
            foreach ($this->_exclude as $e) {
                if (DIRECTORY_SEPARATOR !== '\\' && $e[0] !== DIRECTORY_SEPARATOR) {
                    $e = DIRECTORY_SEPARATOR . $e;
                }
                $exclude[] = preg_quote($e, '/');
            }
            $pattern = '/' . implode('|', $exclude) . '/';
        }
        foreach ($this->_paths as $path) {
            $path = realpath($path) . DIRECTORY_SEPARATOR;
            $Folder = new Folder($path);
            $files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true);
            if (!empty($pattern)) {
                $files = preg_grep($pattern, $files, PREG_GREP_INVERT);
                $files = array_values($files);
            }
            $this->_files = array_merge($this->_files, $files);
        }
        $this->_files = array_unique($this->_files);
    }
1096530
public function getStopwords()
    {
        if(!empty($this->stopWords)) {
            return $this->stopWords;
        }
                
        foreach($this->getFilePaths() as $filePath)
        {
            $content = $this->getFileContent($filePath);
            $doc = new TokensDocument((new GeneralTokenizer())
                    ->tokenize($content) );
            $doc->applyTransformation(new LowerCaseFilter())
                ->applyTransformation(new PossessiveNounFilter())
                ->applyTransformation(new PunctuationFilter())
                ->applyTransformation(new CharFilter());
            
            if($this->mode === self::MODE_FREQ) {
                $this->computeUsingFreqDist($doc->getDocumentData());
            }
            
        }
        arsort($this->stopWords);
        return $this->stopWords;                        
    }