Skip to content

Commit

Permalink
[REFACTOR] Fix private fields prefixes
Browse files Browse the repository at this point in the history
Change prefix of private fields to a single underscore. The double
underscore is reserved for PHP magic methods.
  • Loading branch information
ThomasWeinert committed Jul 28, 2019
1 parent d8026d4 commit 5379904
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/FluentDOM/Utility/ResourceWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ class ResourceWrapper {
/**
* @var array
*/
private static $__streams = [];
private static $_streams = [];

/**
* @var NULL|resource
*/
private $__stream;
private $_stream;
/**
* @var string
*/
private $__id = '';
private $_id = '';

/**
* @var resource
Expand All @@ -47,8 +47,8 @@ public static function createURI($stream, string $protocol = 'fluentdom-resource
self::register($protocol);
do {
$id = \uniqid('fd', TRUE);
} while(isset(self::$__streams[$id]));
self::$__streams[$id] = $stream;
} while(isset(self::$_streams[$id]));
self::$_streams[$id] = $stream;
return $protocol.'://'.$id;
}

Expand All @@ -72,7 +72,7 @@ public static function createContext($stream, string $protocol = 'fluentdom-reso
*
* @param string $protocol
*/
private static function register($protocol) {
private static function register(string $protocol) {
if (!\in_array($protocol, \stream_get_wrappers(), TRUE)) {
\stream_wrapper_register($protocol, __CLASS__);
}
Expand Down Expand Up @@ -107,12 +107,12 @@ public function stream_open(
isset($context[$protocol]['stream']) &&
\is_resource($context[$protocol]['stream'])
) {
$this->__stream = $context[$protocol]['stream'];
$this->_stream = $context[$protocol]['stream'];
return TRUE;
}
if (isset(self::$__streams[$id])) {
$this->__stream = self::$__streams[$id];
$this->__id = $id;
if (isset(self::$_streams[$id])) {
$this->_stream = self::$_streams[$id];
$this->_id = $id;
return TRUE;
}
return FALSE;
Expand All @@ -123,22 +123,22 @@ public function stream_open(
* @return bool|string
*/
public function stream_read(int $count) {
return \fread($this->__stream, $count);
return \fread($this->_stream, $count);
}

/**
* @param string $data
* @return bool|int
*/
public function stream_write(string $data) {
return \fwrite($this->__stream, $data);
return \fwrite($this->_stream, $data);
}

/**
* @return bool
*/
public function stream_eof(): bool {
return \feof($this->__stream);
return \feof($this->_stream);
}

/**
Expand All @@ -147,12 +147,12 @@ public function stream_eof(): bool {
* @return int
*/
public function stream_seek(int $offset, int $whence): int {
return \fseek($this->__stream, $offset, $whence);
return \fseek($this->_stream, $offset, $whence);
}

public function __destruct() {
if (isset($this->__id, self::$__streams[$this->__id])) {
unset(self::$__streams[$this->__id]);
if (isset($this->_id, self::$_streams[$this->_id])) {
unset(self::$_streams[$this->_id]);
}
}
}
Expand Down

0 comments on commit 5379904

Please sign in to comment.