diff --git a/php/src/file.php b/php/src/file.php index 6b2e65c..6bd1928 100644 --- a/php/src/file.php +++ b/php/src/file.php @@ -28,12 +28,16 @@ class file { * "file.yml" existe, alors file::try("file.yaml", ".yml") * 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;