1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebStream\IO; |
4
|
|
|
|
5
|
|
|
use WebStream\Exception\Extend\IOException; |
|
|
|
|
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* InputStream |
9
|
|
|
* ftellの戻り値仕様により32ビット数値を返すため2GB以上のファイルを読み込むと動かなくなる |
10
|
|
|
* C言語のftell仕様依存 |
11
|
|
|
* @author Ryuichi TANAKA. |
12
|
|
|
* @since 2016/02/05 |
13
|
|
|
* @version 0.7 |
14
|
|
|
*/ |
15
|
|
|
abstract class InputStream |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var mixed 入力ストリーム |
19
|
|
|
*/ |
20
|
|
|
protected $stream; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var int 現在のポインタ位置 |
24
|
|
|
*/ |
25
|
|
|
protected $cursorPosition; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var int markしたポインタ位置 |
29
|
|
|
*/ |
30
|
|
|
protected $markedPosition; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* constructor |
34
|
|
|
* @param mixed $stream 入力ストリーム |
35
|
|
|
*/ |
36
|
11 |
|
public function __construct($stream) |
37
|
|
|
{ |
38
|
11 |
|
$this->stream = $stream; |
39
|
11 |
|
$this->cursorPosition = 0; |
40
|
11 |
|
$this->markedPosition = 0; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* destructor |
45
|
|
|
*/ |
46
|
11 |
|
public function __destruct() |
47
|
|
|
{ |
48
|
11 |
|
$this->close(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* 入力ストリームを閉じる |
53
|
|
|
*/ |
54
|
|
|
abstract public function close(); |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* 入力ストリームからデータを読み込む |
58
|
|
|
* 引数に数値を指定した場合、指定数値バイトだけ読み込む |
59
|
|
|
* @param int length 読み込みバイト数 |
|
|
|
|
60
|
|
|
* @return string 読み込みデータ |
61
|
|
|
* @throws InvalidArgumentException |
62
|
|
|
* @throws IOException |
63
|
|
|
*/ |
64
|
|
|
abstract public function read($length = null); |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* 入力ストリームから行単位でデータを読み込む |
68
|
|
|
* 末尾に改行コードは含まない |
69
|
|
|
* @return string 読み込みデータ |
70
|
|
|
*/ |
71
|
|
|
abstract public function readLine(); |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* 入力ストリームから指定バイト数後方へポインタを移動する |
75
|
|
|
* @param int $pos 後方への移動バイト数(負数の場合は前方へ移動) |
76
|
|
|
* @return int $skipNum 移動したバイト数、移動に失敗した場合-1 |
77
|
|
|
*/ |
78
|
|
|
public function skip(int $pos) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
return -1; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* EOFかどうか返却する |
85
|
|
|
* @return bool EOFならtrue、EOF以外またはリードエラーの場合はfalse |
86
|
|
|
*/ |
87
|
|
|
abstract public function eof(); |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* 入力ストリームの現在位置にmarkを設定する |
91
|
|
|
* @param int マークするバイト位置 |
|
|
|
|
92
|
|
|
* @throws IOException |
93
|
|
|
*/ |
94
|
2 |
|
public function mark() |
95
|
|
|
{ |
96
|
2 |
|
if (!$this->isMarkSupported()) { |
97
|
|
|
throw new IOException(get_class($this) . " does not support mark."); |
98
|
|
|
} |
99
|
|
|
|
100
|
2 |
|
if ($this->stream === null) { |
101
|
|
|
return null; |
102
|
|
|
} |
103
|
|
|
|
104
|
2 |
|
$this->markedPosition = $this->cursorPosition; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* 最後にmarkされた位置に再配置する |
109
|
|
|
* @throws IOException |
110
|
|
|
*/ |
111
|
2 |
|
public function reset() |
112
|
|
|
{ |
113
|
2 |
|
if (!$this->isMarkSupported()) { |
114
|
|
|
throw new IOException(get_class($this) . " does not support mark and reset."); |
115
|
|
|
} |
116
|
|
|
|
117
|
2 |
|
if ($this->stream === null) { |
118
|
|
|
return null; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// mark位置を初期値に戻す |
122
|
2 |
|
$this->cursorPosition = $this->markedPosition; |
123
|
2 |
|
$this->markedPosition = 0; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* mark機能をサポートしているかどうか |
128
|
|
|
* @return boolean マークをサポートしていればtrue |
129
|
|
|
*/ |
130
|
|
|
public function isMarkSupported() |
131
|
|
|
{ |
132
|
|
|
return false; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths