Phar::isValidPharFilename

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 1.2.0)

Phar::isValidPharFilenameInforma se o nome de arquivo fornecido é um nome de arquivo phar válido

Descrição

final public static Phar::isValidPharFilename(string $filename, bool $executable = true): bool

Retorna se o nome de arquivo fornecido é um nome de arquivo PHAR válido que será reconhecido como um arquivo PHAR pela extensão PHAR. Isso pode ser usado para testar um nome sem precisar instanciar um arquivo PHAR e capturar a inevitável exceção que será gerada se um nome inválido for especificado.

Parâmetros

filename

O nome ou caminho completo para um arquivo phar ainda não criado

executable

Este parâmetro determina se o nome do arquivo deve ser tratado como um arquivo executável phar ou um arquivo não executável de dados.

Valor Retornado

Retorna true se o nome do arquivo for válido, false caso contrário.

adicione uma nota

Notas Enviadas por Usuários (em inglês) 2 notes

up
0
kevin dot sours at internetbrands dot com
9 months ago
This appears to return true for the running phar file regardless of the file extension. This is undocumented (as is the fact that PHP will run phar files perfectly fine with a php extension). This allows, for instance, reading the metadata for the running phar.
up
0
sebastian dot krebs dot berlin at googlemail dot com
13 years ago
Note, that this method accepts _everything_ (=> returns 'true'), when $executable is 'false' as long as the filename contains at least a dot

var_dump(\PharData::isValidPharFilename('randomstring.y', false));
bool(true)

This is not wrong at all, because I can name an archive like I want, but it makes the method completely useless (when $executable == false).
To Top