shouldExcludeFile.php
Table of Contents
Functions
- shouldExcludeFile() : bool
- Checks if a file path should be excluded based on an array of patterns.
Functions
shouldExcludeFile()
Checks if a file path should be excluded based on an array of patterns.
shouldExcludeFile(string $filePath, array<string|int, string> $excludePatterns) : bool
This function supports two types of patterns:
- Glob patterns (e.g., '.log', 'config/.php'). These are matched using fnmatch().
- PCRE regular expressions (e.g., '/^temp-\d+.tmp$/i'). The function auto-detects regex patterns by checking if they are enclosed in matching delimiter characters.
For each pattern, the function attempts to match it against both the full file path and the basename of the file. The match is successful if any pattern matches. The glob matching is performed with the FNM_PATHNAME flag, meaning wildcards will not match directory separators (/).
Parameters
- $filePath : string
-
The absolute or relative path to the file to check.
- $excludePatterns : array<string|int, string>
-
An array of glob or PCRE patterns.
Tags
Return values
bool —Returns true
if the file path matches any of the exclusion patterns, false
otherwise.