Skip to content

Commit

Permalink
Remove the need for AllowDynamicProperties in LazyOpenStream (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWolla authored Feb 15, 2023
1 parent ddb46ae commit 58d0734
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/LazyOpenStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* Lazily reads or writes to a file that is opened only after an IO operation
* take place on the stream.
*/
#[\AllowDynamicProperties]
final class LazyOpenStream implements StreamInterface
{
use StreamDecoratorTrait;
Expand All @@ -21,6 +20,11 @@ final class LazyOpenStream implements StreamInterface
/** @var string */
private $mode;

/**
* @var StreamInterface
*/
private $stream;

/**
* @param string $filename File to lazily open
* @param string $mode fopen mode to use when opening the stream
Expand All @@ -29,6 +33,10 @@ public function __construct(string $filename, string $mode)
{
$this->filename = $filename;
$this->mode = $mode;

// unsetting the property forces the first access to go through
// __get().
unset($this->stream);
}

/**
Expand Down

0 comments on commit 58d0734

Please sign in to comment.