Skip to content

Commit 88cb02f

Browse files
committed
improved PHPDoc descriptions
1 parent 7a78c69 commit 88cb02f

19 files changed

Lines changed: 72 additions & 58 deletions

src/Assets/Asset.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
/**
7-
* Base asset interface with minimal API.
7+
* Represents a web asset (image, script, stylesheet, font, etc.).
88
* @property-read string $url The public URL
99
* @property-read ?string $file The local file path if available
1010
*/
@@ -14,7 +14,7 @@ interface Asset
1414
//public ?string $file { get; }
1515

1616
/**
17-
* Allows direct echoing of the object to get the URL.
17+
* Returns the asset URL.
1818
*/
1919
public function __toString(): string;
2020
}

src/Assets/AudioAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
/**
9-
* Audio asset.
9+
* Audio file with lazy-loaded duration.
1010
*/
1111
class AudioAsset implements Asset, HtmlRenderable
1212
{

src/Assets/EntryAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
/**
7-
* Entry point asset implementation that can represent both script and style entry points.
7+
* Vite entry point asset that carries its CSS imports and JS preloads as dependencies.
88
*/
99
class EntryAsset extends ScriptAsset
1010
{

src/Assets/FilesystemMapper.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public function __construct(
2525

2626

2727
/**
28-
* Resolves a relative reference to an asset within the configured base path.
29-
* Attempts to find a matching extension if configured and applies versioning if enabled.
30-
* Available options: 'version' => bool: Whether to apply versioning (defaults to true)
28+
* Returns the asset for the given relative reference.
29+
* Tries configured extensions in order and appends a version query parameter if enabled.
30+
* Supported option: 'version' => bool (overrides the mapper-level versioning setting)
3131
*/
3232
public function getAsset(string $reference, array $options = []): Asset
3333
{
@@ -47,6 +47,9 @@ public function getAsset(string $reference, array $options = []): Asset
4747
}
4848

4949

50+
/**
51+
* Appends a ?v={filemtime} (or &v={filemtime}) version parameter to the URL.
52+
*/
5053
protected function applyVersion(string $url, string $path): string
5154
{
5255
if (is_int($version = filemtime($path))) {
@@ -57,7 +60,7 @@ protected function applyVersion(string $url, string $path): string
5760

5861

5962
/**
60-
* Searches for an existing file by appending configured extensions to the base path.
63+
* Returns the first matching file extension (with dot) from the configured list, or '' if none match.
6164
*/
6265
private function findExtension(string $basePath): string
6366
{
@@ -78,18 +81,12 @@ private function findExtension(string $basePath): string
7881
}
7982

8083

81-
/**
82-
* Returns the base URL for this mapper.
83-
*/
8484
public function getBaseUrl(): string
8585
{
8686
return $this->baseUrl;
8787
}
8888

8989

90-
/**
91-
* Returns the base path for this mapper.
92-
*/
9390
public function getBasePath(): string
9491
{
9592
return $this->basePath;

src/Assets/FontAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
/**
9-
* Font asset.
9+
* Web font file (WOFF, WOFF2, TTF, etc.).
1010
*/
1111
class FontAsset implements Asset, HtmlRenderable
1212
{

src/Assets/GenericAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
/**
7-
* Generic asset for any general file type.
7+
* Asset for file types without a dedicated asset class.
88
*/
99
class GenericAsset implements Asset
1010
{

src/Assets/Helpers.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
/**
10-
* Static helper class providing utility functions for working with assets.
10+
* Asset utility functions.
1111
*/
1212
final class Helpers
1313
{
@@ -24,9 +24,10 @@ final class Helpers
2424

2525

2626
/**
27-
* Creates an Asset instance. The asset type is detected by 'mimeType' if provided in $args,
28-
* otherwise is guessed from the file extension of $path or $url.
29-
* @param array<string, mixed> $args parameters passed to the asset constructor
27+
* Creates an Asset of the appropriate type for the given URL.
28+
* The type is determined from the 'mimeType' key in $args if provided,
29+
* otherwise guessed from the file extension of $path or $url.
30+
* @param array<string, mixed> $args additional constructor arguments for the asset
3031
*/
3132
public static function createAssetFromUrl(string $url, ?string $path = null, array $args = []): Asset
3233
{
@@ -47,6 +48,9 @@ public static function createAssetFromUrl(string $url, ?string $path = null, arr
4748
}
4849

4950

51+
/**
52+
* Guesses the MIME type from the file extension in the given URL or path, or null if unknown.
53+
*/
5054
public static function guessMimeTypeFromExtension(string $url): ?string
5155
{
5256
return preg_match('~\.([a-z0-9]{1,5})([?#]|$)~i', $url, $m)
@@ -120,6 +124,9 @@ public static function guessMP3Duration(string $path): float
120124
}
121125

122126

127+
/**
128+
* Reads the Vite dev server URL from the given info file, or returns null if unavailable.
129+
*/
123130
public static function detectDevServer(string $infoFile): ?string
124131
{
125132
return ($info = @file_get_contents($infoFile)) // @ file may not exists

src/Assets/HtmlRenderable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77

88
/**
9-
* Interface for assets that can be rendered as HTML elements.
9+
* Asset renderable as an HTML element.
1010
*/
1111
interface HtmlRenderable extends Asset
1212
{
1313
/**
14-
* Returns HTML tag name and attributes for rendering the asset.
14+
* Returns the HTML element used to import the asset (img, script, link rel="stylesheet", etc.).
1515
*/
1616
public function getImportElement(): Html;
1717

1818
/**
19-
* Returns HTML tag name and attributes for preloading the asset.
19+
* Returns the HTML element used to preload the asset (link rel="preload" or rel="modulepreload").
2020
*/
2121
public function getPreloadElement(): Html;
2222
}

src/Assets/ImageAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
/**
10-
* Image asset.
10+
* Image file with lazy-loaded dimensions and MIME type.
1111
*/
1212
class ImageAsset implements Asset, HtmlRenderable
1313
{

src/Assets/Mapper.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55

66
/**
7-
* Defines the contract for resolving asset references to Asset objects.
8-
* Implementations handle specific storage backends (filesystem, CDN, etc.).
7+
* Resolves asset references to Asset objects for a specific storage backend.
98
*/
109
interface Mapper
1110
{
1211
/**
13-
* Retrieves an Asset instance for a given mapper-specific reference string.
14-
* @param array<string, mixed> $options mapper-specific options
12+
* Returns an Asset for the given reference.
13+
* @param array<string, mixed> $options mapper-specific options
1514
* @throws AssetNotFoundException when the asset cannot be found
1615
*/
1716
public function getAsset(string $reference, array $options = []): Asset;

0 commit comments

Comments
 (0)