Ir al contenido

Stream not closed (ARCH7081)

Esta página aún no está disponible en tu idioma.

Key php.performance.stream-not-closed · Severity warning · Category performance

A file handle opened with fopen() that is never closed leaks file descriptors and may leave data unflushed. Close it with fclose() when done.

<?php
function appendLine(string $path, string $line): void
{
$fh = fopen($path, 'a');
fwrite($fh, $line . "\n");
}
<?php
function appendLine(string $path, string $line): void
{
$fh = fopen($path, 'a');
fwrite($fh, $line . "\n");
fclose($fh);
}

Close stream and file handles with fclose() as soon as you are done with them.