final class SourceFetcher
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Downloads an upstream grammar or keyword source, keeping a copy for the next build.

Methods§

public function __construct(private string|null $cacheDirectory = null)

Parameters

$cacheDirectorystring|nullWhere downloaded files are kept, or null to keep none
public function fetch(string $url): string

Answers the contents of a URL, from the cache when it was fetched before.

Parameters

$urlstringWhere the source is published

Returns

string The contents

Throws

RuntimeException When the source cannot be fetched
Test cases 2
Calls 9
public function download(string $url): string|null

Downloads a URL, quietly answering null when it cannot be reached.

Parameters

$urlstringWhere the source is published

Returns

string|null The contents, or null when the download fails
Test cases 1
Called from 1
Calls 4
  • function-call stream_context_create line 64
  • function-call set_error_handler line 65
  • function-call file_get_contents line 67
  • function-call restore_error_handler line 69
public function cachePath(string $url): string|null

Answers where the copy of a URL is kept.

Parameters

$urlstringWhere the source is published

Returns

string|null The cache path, or null when nothing is kept
Test cases 2
Called from 1
Calls 3

Private surface 1§

Implementation details, listed for orientation only.

private string|null $cacheDirectory = null

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4