Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow numeric-strings beeing returned for non-empty-string
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Bug7265; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param literal-string $assetPath e.g. css/cmsfasttrack.css or js/fasttrack.js | ||
* @return non-empty-string | ||
*/ | ||
static public function assetId(string $assetPath) | ||
{ | ||
if (strpos($assetPath, 'css/') !== 0 && strpos($assetPath, 'js/') !== 0 && strpos($assetPath, 'img/') !== 0) { | ||
throw new \RuntimeException('Invalid asset path "' . $assetPath . '"'); | ||
} | ||
|
||
$mtime = filemtime($assetPath); | ||
|
||
if ($mtime === false) { | ||
throw new \RuntimeException('Unable to get filemtime for asset path "' . $assetPath . '"'); | ||
} | ||
|
||
return (string)$mtime; | ||
} | ||
} |