1 | <?php |
||
26 | abstract class Scanner { |
||
27 | |||
28 | /** |
||
29 | * Scan result |
||
30 | * @var Status |
||
31 | */ |
||
32 | protected $status; |
||
33 | |||
34 | /** |
||
35 | * If scanning was done part by part |
||
36 | * the first detected infected part is stored here |
||
37 | * @var Status |
||
38 | */ |
||
39 | protected $infectedStatus; |
||
40 | |||
41 | /** @var int */ |
||
42 | protected $byteCount; |
||
43 | |||
44 | /** @var resource */ |
||
45 | protected $writeHandle; |
||
46 | |||
47 | /** @var \OCA\Files_Antivirus\AppConfig */ |
||
48 | protected $appConfig; |
||
49 | |||
50 | /** @var string */ |
||
51 | protected $lastChunk; |
||
52 | |||
53 | /** @var bool */ |
||
54 | protected $isLogUsed = false; |
||
55 | |||
56 | /** @var bool */ |
||
57 | protected $isAborted = false; |
||
58 | |||
59 | /** |
||
60 | * Close used resources |
||
61 | */ |
||
62 | abstract protected function shutdownScanner(); |
||
63 | |||
64 | |||
65 | 4 | public function getStatus(){ |
|
74 | |||
75 | /** |
||
76 | * Synchronous scan |
||
77 | * @param IScannable $item |
||
78 | * @return Status |
||
79 | */ |
||
80 | 2 | public function scan(IScannable $item) { |
|
90 | |||
91 | /** |
||
92 | * Async scan - new portion of data is available |
||
93 | * @param string $data |
||
94 | */ |
||
95 | 2 | public function onAsyncData($data){ |
|
98 | |||
99 | /** |
||
100 | * Async scan - resource is closed |
||
101 | * @return Status |
||
102 | */ |
||
103 | 2 | public function completeAsyncScan(){ |
|
107 | |||
108 | /** |
||
109 | * Open write handle. etc |
||
110 | */ |
||
111 | 4 | public function initScanner(){ |
|
118 | |||
119 | /** |
||
120 | * @param string $chunk |
||
121 | */ |
||
122 | 4 | protected function writeChunk($chunk){ |
|
127 | |||
128 | /** |
||
129 | * @param string $data |
||
130 | */ |
||
131 | 4 | protected final function fwrite($data){ |
|
162 | |||
163 | /** |
||
164 | * @return bool |
||
165 | */ |
||
166 | 4 | protected function retry(){ |
|
173 | |||
174 | /** |
||
175 | * @param $data |
||
176 | * @return bool |
||
177 | */ |
||
178 | 4 | protected function writeRaw($data){ |
|
188 | |||
189 | /** |
||
190 | * Get a resource to write data into |
||
191 | * @return resource |
||
192 | */ |
||
193 | 4 | protected function getWriteHandle(){ |
|
196 | |||
197 | /** |
||
198 | * Prepare chunk (if required) |
||
199 | * @param string $data |
||
200 | * @return string |
||
201 | */ |
||
202 | 2 | protected function prepareChunk($data){ |
|
205 | } |
||
206 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: