Skip to content

Commit 4e5bcaf

Browse files
committed
#299 decbin type error in PHP8
#299
1 parent acf86e0 commit 4e5bcaf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

getid3/getid3.lib.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,17 @@ public static function BigEndian2String($number, $minbytes=1, $synchsafe=false,
427427
* @return string
428428
*/
429429
public static function Dec2Bin($number) {
430+
if (!is_numeric($number)) {
431+
// https://github.com/JamesHeinrich/getID3/issues/299
432+
trigger_error('TypeError: Dec2Bin(): Argument #1 ($number) must be numeric, '.gettype($number).' given', E_USER_WARNING);
433+
return '';
434+
}
430435
$bytes = array();
431436
while ($number >= 256) {
432-
$bytes[] = (($number / 256) - (floor($number / 256))) * 256;
437+
$bytes[] = (int) (($number / 256) - (floor($number / 256))) * 256;
433438
$number = floor($number / 256);
434439
}
435-
$bytes[] = $number;
440+
$bytes[] = (int) $number;
436441
$binstring = '';
437442
foreach ($bytes as $i => $byte) {
438443
$binstring = (($i == count($bytes) - 1) ? decbin($byte) : str_pad(decbin($byte), 8, '0', STR_PAD_LEFT)).$binstring;

getid3/getid3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class getID3
387387
*/
388388
protected $startup_warning = '';
389389

390-
const VERSION = '1.9.20-202105131611';
390+
const VERSION = '1.9.20-202106221748';
391391
const FREAD_BUFFER_SIZE = 32768;
392392

393393
const ATTACHMENTS_NONE = false;

0 commit comments

Comments
 (0)