Skip to content

Commit

Permalink
优化 FileStream 析构函数中自动关闭打开的文件
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Apr 26, 2020
1 parent 14fd821 commit 26fa40e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Util/Stream/FileStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public function __construct($uri, $mode = StreamMode::READ_WRITE)
}
}

public function __destruct()
{
if($this->stream)
{
$this->close();
}
}

/**
* Reads all data from the stream into a string, from the beginning to end.
*
Expand Down

0 comments on commit 26fa40e

Please sign in to comment.