Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Closes an open file pointer
<?php fclose(resource $stream): bool
<?php $this->assertIsResource($readStream);
$this->assertEquals('contents', $contents);
fclose($readStream);
});
}
<?php $adapter->writeStream('path.txt', $writeStream, new Config());
if (is_resource($writeStream)) {
fclose($writeStream);
};
$readStream = $adapter->readStream('path.txt');
<?php $this->assertIsResource($readStream);
$contents = stream_get_contents($readStream);
fclose($readStream);
$this->assertEquals('contents', $contents);
});
}
<?php $resource = $adapter->readStream('path.txt');
$metadata = stream_get_meta_data($resource);
fclose($resource);
$this->assertTrue($metadata['seekable']);
}
<?php $resource = $adapter->readStream('path.txt');
$metadata = stream_get_meta_data($resource);
fclose($resource);
$this->assertEquals($seekable, $metadata['seekable']);
}
<?php $resource = $adapter->readStream('path.txt');
$metadata = stream_get_meta_data($resource);
fclose($resource);
$this->assertTrue($metadata['seekable']);
}
<?php public function invalidStreamInput(): Generator
{
$handle = tmpfile();
fclose($handle);
yield "resource that is not open" => [$handle];
yield "something that is not a resource" => [false];
}
<?php $this->filesystem->writeStream('path.txt', $writeStream);
$readStream = $this->filesystem->readStream('path.txt');
fclose($writeStream);
$this->assertIsResource($readStream);
$this->assertEquals('contents', stream_get_contents($readStream));
<?php $this->assertIsResource($readStream);
$this->assertEquals('contents', stream_get_contents($readStream));
fclose($readStream);
}
<?php try {
$filesystem->writeStream('../path.txt', $stream);
} finally {
fclose($stream);
}
}];
yield [function (FilesystemOperator $filesystem) {
<?php rewind($writeStream);
$this->writeStream($path, $writeStream, $config);
} finally {
isset($writeStream) && is_resource($writeStream) && fclose($writeStream);
}
}
<?php {
$readStream = $this->readStream($path);
$contents = stream_get_contents($readStream);
fclose($readStream);
return $contents;
}
<?php $result = @ftp_fget($this->connection(), $stream, $location, $this->connectionOptions->transferMode());
if ( ! $result) {
fclose($stream);
throw UnableToReadFile::fromLocation($path);
}
<?php $this->writeStream($destination, $readStream, new Config(compact('visibility')));
} catch (Throwable $exception) {
if (isset($readStream) && is_resource($readStream)) {
@fclose($readStream);
}
throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
}
<?php $this->adapter()->write(self::PATH, 'contents', new Config());
$contents = $this->adapter()->readStream(self::PATH);
$this->assertEquals('contents', stream_get_contents($contents));
fclose($contents);
}