Glob
API reference › Scaffold › Manifest › Glob
Matches forward-slash paths against manifest glob patterns: * and ? within one path segment, ** across
segments, single-level {a,b} alternatives, and byte-exact literals for everything else.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
lookup() static | Returns the value of the first key of $map that matches $path; an exact key wins over globs, which match in declaration order. | Glob |
matches() static | Returns whether $pattern matches the whole of $path. | Glob |
matchesAny() static | Returns whether any of $patterns matches the whole of $path. | Glob |
prunes() static | Returns whether a <dir>/** pattern of $patterns excludes every descendant of $directory, so a walk can skip it. | Glob |
toRegex() static | Converts a glob pattern into an anchored PCRE regex, for example #^config/[^/]*\ for config/*.php. | Glob |
Method details
Section titled “Method details”lookup()
Section titled “lookup() ”public static function lookup(array<array-key, PHPForge\Scaffold\Manifest\TValue> $map, string $path): PHPForge\Scaffold\Manifest\TValue|nullReturns the value of the first key of $map that matches $path; an exact key wins over globs, which match in
declaration order.
Parameters
| Parameter | Type | Description |
|---|---|---|
$map | array<array-key, | Values keyed by glob pattern; integer-like patterns are integer keys. |
$path | string | Relative path with forward slashes. |
Returns
PHPForge\Scaffold\Manifest\TValue|null: Value of the matching pattern, or null when no pattern matches.
matches()
Section titled “matches() ”public static function matches(string $pattern, string $path): boolReturns whether $pattern matches the whole of $path.
Parameters
| Parameter | Type | Description |
|---|---|---|
$pattern | string | Glob pattern to match against. |
$path | string | Relative path with forward slashes; this method does not convert backslashes. |
Returns
bool: true when the pattern matches the full path, false otherwise.
matchesAny()
Section titled “matchesAny() ”public static function matchesAny(list<string> $patterns, string $path): boolReturns whether any of $patterns matches the whole of $path.
Parameters
| Parameter | Type | Description |
|---|---|---|
$patterns | list<string> | Glob patterns. |
$path | string | Relative path with forward slashes. |
Returns
bool: true when at least one pattern matches the path, false otherwise.
prunes()
Section titled “prunes() ”public static function prunes(list<string> $patterns, string $directory): boolReturns whether a <dir>/** pattern of $patterns excludes every descendant of $directory, so a walk can skip
it.
Parameters
| Parameter | Type | Description |
|---|---|---|
$patterns | list<string> | Glob patterns. |
$directory | string | Relative directory path with forward slashes. |
Returns
bool: true when $patterns holds <directory>/**, false otherwise.
toRegex()
Section titled “toRegex() ”public static function toRegex(string $pattern): stringConverts a glob pattern into an anchored PCRE regex, for example #^config/[^/]*\.php$# for config/*.php.
Parameters
| Parameter | Type | Description |
|---|---|---|
$pattern | string | Glob pattern to convert. |
Returns
string: PCRE regex with the # delimiter, anchored to match the full string.