PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/GuzzleHttp/Psr7/LazyOpenStream.php +12 -8 1.2.7 → 1.4.2 View file →
@@ -1,6 +1,7 @@
1 1 <?php
2 2
3 +declare (strict_types=1);
3 4 namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7;
4 5
5 6 use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface;
6 7 /**
@@ -5,33 +6,36 @@
5 6 use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface;
6 7 /**
7 8 * Lazily reads or writes to a file that is opened only after an IO operation
8 9 * take place on the stream.
9 - *
10 - * @final
11 10 */
12 -class LazyOpenStream implements StreamInterface
11 +final class LazyOpenStream implements StreamInterface
13 12 {
14 13 use StreamDecoratorTrait;
15 - /** @var string File to open */
14 + /** @var string */
16 15 private $filename;
17 16 /** @var string */
18 17 private $mode;
19 18 /**
19 + * @var StreamInterface
20 + */
21 + private $stream;
22 + /**
20 23 * @param string $filename File to lazily open
21 24 * @param string $mode fopen mode to use when opening the stream
22 25 */
23 - public function __construct($filename, $mode)
26 + public function __construct(string $filename, string $mode)
24 27 {
25 28 $this->filename = $filename;
26 29 $this->mode = $mode;
30 + // unsetting the property forces the first access to go through
31 + // __get().
32 + unset($this->stream);
27 33 }
28 34 /**
29 35 * Creates the underlying stream lazily when required.
30 - *
31 - * @return StreamInterface
32 36 */
33 - protected function createStream()
37 + protected function createStream() : StreamInterface
34 38 {
35 39 return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
36 40 }
37 41 }