modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-06-03 06:25:52 +04:00
parent be6b7371e5
commit 278ffc7db1

View File

@ -28,12 +28,16 @@ class file {
* "file.yml" existe, alors <code>file::try("file.yaml", ".yml")</code>
* retourne "file.yml"
*
* par défaut, $replace_ext est initialisé à l'extension de $file. utiliser []
* pour désactiver cette fonctionnalité
*
* @param string|array $exts
* @param string|array $replace_ext
*/
static function try_ext(string $file, $exts=null, $replace_ext=null): ?string {
if (file_exists($file)) return $file;
if ($exts !== null) {
$replace_ext ??= path::ext($file);
foreach (cl::with($exts) as $ext) {
$tmpfile = path::ensure_ext($file, $ext, $replace_ext);
if (file_exists($tmpfile)) return $tmpfile;