equal
deleted
inserted
replaced
16 |
16 |
17 /** |
17 /** |
18 * PHP5 constructor. |
18 * PHP5 constructor. |
19 */ |
19 */ |
20 function __construct() { |
20 function __construct() { |
21 $this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); |
21 $this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated |
22 $this->_pos = 0; |
22 $this->_pos = 0; |
23 } |
23 } |
24 |
24 |
25 /** |
25 /** |
26 * PHP4 constructor. |
26 * PHP4 constructor. |
|
27 * |
|
28 * @deprecated 5.4.0 Use __construct() instead. |
|
29 * |
|
30 * @see POMO_Reader::__construct() |
27 */ |
31 */ |
28 public function POMO_Reader() { |
32 public function POMO_Reader() { |
|
33 _deprecated_constructor( self::class, '5.4.0', static::class ); |
29 self::__construct(); |
34 self::__construct(); |
30 } |
35 } |
31 |
36 |
32 /** |
37 /** |
33 * Sets the endianness of the file. |
38 * Sets the endianness of the file. |
34 * |
39 * |
35 * @param string $endian Set the endianness of the file. Accepts 'big', or 'little'. |
40 * @param string $endian Set the endianness of the file. Accepts 'big', or 'little'. |
36 */ |
41 */ |
37 function setEndian( $endian ) { |
42 function setEndian( $endian ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid |
38 $this->endian = $endian; |
43 $this->endian = $endian; |
39 } |
44 } |
40 |
45 |
41 /** |
46 /** |
42 * Reads a 32bit Integer from the Stream |
47 * Reads a 32bit Integer from the Stream |
47 function readint32() { |
52 function readint32() { |
48 $bytes = $this->read( 4 ); |
53 $bytes = $this->read( 4 ); |
49 if ( 4 != $this->strlen( $bytes ) ) { |
54 if ( 4 != $this->strlen( $bytes ) ) { |
50 return false; |
55 return false; |
51 } |
56 } |
52 $endian_letter = ( 'big' == $this->endian ) ? 'N' : 'V'; |
57 $endian_letter = ( 'big' === $this->endian ) ? 'N' : 'V'; |
53 $int = unpack( $endian_letter, $bytes ); |
58 $int = unpack( $endian_letter, $bytes ); |
54 return reset( $int ); |
59 return reset( $int ); |
55 } |
60 } |
56 |
61 |
57 /** |
62 /** |
64 function readint32array( $count ) { |
69 function readint32array( $count ) { |
65 $bytes = $this->read( 4 * $count ); |
70 $bytes = $this->read( 4 * $count ); |
66 if ( 4 * $count != $this->strlen( $bytes ) ) { |
71 if ( 4 * $count != $this->strlen( $bytes ) ) { |
67 return false; |
72 return false; |
68 } |
73 } |
69 $endian_letter = ( 'big' == $this->endian ) ? 'N' : 'V'; |
74 $endian_letter = ( 'big' === $this->endian ) ? 'N' : 'V'; |
70 return unpack( $endian_letter . $count, $bytes ); |
75 return unpack( $endian_letter . $count, $bytes ); |
71 } |
76 } |
72 |
77 |
73 /** |
78 /** |
74 * @param string $string |
79 * @param string $string |
142 |
147 |
143 /** |
148 /** |
144 * @param string $filename |
149 * @param string $filename |
145 */ |
150 */ |
146 function __construct( $filename ) { |
151 function __construct( $filename ) { |
147 parent::POMO_Reader(); |
152 parent::__construct(); |
148 $this->_f = fopen( $filename, 'rb' ); |
153 $this->_f = fopen( $filename, 'rb' ); |
149 } |
154 } |
150 |
155 |
151 /** |
156 /** |
152 * PHP4 constructor. |
157 * PHP4 constructor. |
|
158 * |
|
159 * @deprecated 5.4.0 Use __construct() instead. |
|
160 * |
|
161 * @see POMO_FileReader::__construct() |
153 */ |
162 */ |
154 public function POMO_FileReader( $filename ) { |
163 public function POMO_FileReader( $filename ) { |
|
164 _deprecated_constructor( self::class, '5.4.0', static::class ); |
155 self::__construct( $filename ); |
165 self::__construct( $filename ); |
156 } |
166 } |
157 |
167 |
158 /** |
168 /** |
159 * @param int $bytes |
169 * @param int $bytes |
220 |
230 |
221 /** |
231 /** |
222 * PHP5 constructor. |
232 * PHP5 constructor. |
223 */ |
233 */ |
224 function __construct( $str = '' ) { |
234 function __construct( $str = '' ) { |
225 parent::POMO_Reader(); |
235 parent::__construct(); |
226 $this->_str = $str; |
236 $this->_str = $str; |
227 $this->_pos = 0; |
237 $this->_pos = 0; |
228 } |
238 } |
229 |
239 |
230 /** |
240 /** |
231 * PHP4 constructor. |
241 * PHP4 constructor. |
|
242 * |
|
243 * @deprecated 5.4.0 Use __construct() instead. |
|
244 * |
|
245 * @see POMO_StringReader::__construct() |
232 */ |
246 */ |
233 public function POMO_StringReader( $str = '' ) { |
247 public function POMO_StringReader( $str = '' ) { |
|
248 _deprecated_constructor( self::class, '5.4.0', static::class ); |
234 self::__construct( $str ); |
249 self::__construct( $str ); |
235 } |
250 } |
236 |
251 |
237 /** |
252 /** |
238 * @param string $bytes |
253 * @param string $bytes |
283 class POMO_CachedFileReader extends POMO_StringReader { |
298 class POMO_CachedFileReader extends POMO_StringReader { |
284 /** |
299 /** |
285 * PHP5 constructor. |
300 * PHP5 constructor. |
286 */ |
301 */ |
287 function __construct( $filename ) { |
302 function __construct( $filename ) { |
288 parent::POMO_StringReader(); |
303 parent::__construct(); |
289 $this->_str = file_get_contents( $filename ); |
304 $this->_str = file_get_contents( $filename ); |
290 if ( false === $this->_str ) { |
305 if ( false === $this->_str ) { |
291 return false; |
306 return false; |
292 } |
307 } |
293 $this->_pos = 0; |
308 $this->_pos = 0; |
294 } |
309 } |
295 |
310 |
296 /** |
311 /** |
297 * PHP4 constructor. |
312 * PHP4 constructor. |
|
313 * |
|
314 * @deprecated 5.4.0 Use __construct() instead. |
|
315 * |
|
316 * @see POMO_CachedFileReader::__construct() |
298 */ |
317 */ |
299 public function POMO_CachedFileReader( $filename ) { |
318 public function POMO_CachedFileReader( $filename ) { |
|
319 _deprecated_constructor( self::class, '5.4.0', static::class ); |
300 self::__construct( $filename ); |
320 self::__construct( $filename ); |
301 } |
321 } |
302 } |
322 } |
303 endif; |
323 endif; |
304 |
324 |
309 class POMO_CachedIntFileReader extends POMO_CachedFileReader { |
329 class POMO_CachedIntFileReader extends POMO_CachedFileReader { |
310 /** |
330 /** |
311 * PHP5 constructor. |
331 * PHP5 constructor. |
312 */ |
332 */ |
313 public function __construct( $filename ) { |
333 public function __construct( $filename ) { |
314 parent::POMO_CachedFileReader( $filename ); |
334 parent::__construct( $filename ); |
315 } |
335 } |
316 |
336 |
317 /** |
337 /** |
318 * PHP4 constructor. |
338 * PHP4 constructor. |
|
339 * |
|
340 * @deprecated 5.4.0 Use __construct() instead. |
|
341 * |
|
342 * @see POMO_CachedIntFileReader::__construct() |
319 */ |
343 */ |
320 function POMO_CachedIntFileReader( $filename ) { |
344 function POMO_CachedIntFileReader( $filename ) { |
|
345 _deprecated_constructor( self::class, '5.4.0', static::class ); |
321 self::__construct( $filename ); |
346 self::__construct( $filename ); |
322 } |
347 } |
323 } |
348 } |
324 endif; |
349 endif; |
325 |
350 |