[UTIL][TemporaryFile] Ensure resource is neither false nor null when attempting to cleanup, otherwise getRealPath returns false and we get sad

This commit is contained in:
Hugo Sales 2021-10-28 17:36:02 +01:00
parent 458c09485a
commit 44454ac28a
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -126,8 +126,11 @@ class TemporaryFile extends SplFileInfo
*/
protected function cleanup(): void
{
if ($this->resource !== false) {
if (!\is_null($this->resource) && $this->resource !== false) {
$path = $this->getRealPath();
if ($path === false) {
throw new BugFoundException();
}
$this->close();
if (file_exists($path)) {
@unlink($path);