To close a file created with SplFileObject, the variable should be set to NULL. For example:
class X {
public function wrt (
): void {
$sfo = new SplFileObject('junk.txt', FopenMode::WRITE);
$sfo->fwrite('Some text');
// Close the file.
$sfo = NULL;
}
}
The line with $sfo = NULL; is flagged by SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable.
It would be nice if the rule could detect this situation and not trigger an error for it.
To close a file created with
SplFileObject
, the variable should be set to NULL. For example:The line with
$sfo = NULL;
is flagged by SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable.It would be nice if the rule could detect this situation and not trigger an error for it.