@@ -333,9 +333,9 @@ public function getBarcode(string $code): Barcode
333333 throw new BarcodeException ('Routing code unknown ' );
334334 }
335335
336- $ binary_code = bcmul ($ binary_code , 10 );
336+ $ binary_code = bcmul ($ binary_code , strval ( 10 ) );
337337 $ binary_code = bcadd ($ binary_code , $ tracking_number [0 ]);
338- $ binary_code = bcmul ($ binary_code , 5 );
338+ $ binary_code = bcmul ($ binary_code , strval ( 5 ) );
339339 $ binary_code = bcadd ($ binary_code , $ tracking_number [1 ]);
340340 $ binary_code .= substr ($ tracking_number , 2 , 18 );
341341
@@ -360,11 +360,11 @@ public function getBarcode(string $code): Barcode
360360 // convert binary data to codewords
361361 $ codewords = [];
362362 $ data = $ this ->hex_to_dec ($ binary_code_102bit );
363- $ codewords [0 ] = bcmod ($ data , 636 ) * 2 ;
364- $ data = bcdiv ($ data , 636 );
363+ $ codewords [0 ] = bcmod ($ data , strval ( 636 ) ) * 2 ;
364+ $ data = bcdiv ($ data , strval ( 636 ) );
365365 for ($ i = 1 ; $ i < 9 ; ++$ i ) {
366- $ codewords [$ i ] = bcmod ($ data , 1365 );
367- $ data = bcdiv ($ data , 1365 );
366+ $ codewords [$ i ] = bcmod ($ data , strval ( 1365 ) );
367+ $ data = bcdiv ($ data , strval ( 1365 ) );
368368 }
369369 $ codewords [9 ] = $ data ;
370370 if (($ fcs >> 10 ) == 1 ) {
@@ -440,7 +440,7 @@ protected function dec_to_hex($number)
440440 $ hex = [];
441441
442442 while ($ number > 0 ) {
443- array_push ( $ hex, strtoupper (dechex (bcmod ($ number , '16 ' ))));
443+ $ hex[] = strtoupper (dechex (intval ( bcmod (strval ( $ number) , '16 ' ))));
444444 $ number = bcdiv ($ number , '16 ' , 0 );
445445 }
446446 $ hex = array_reverse ($ hex );
@@ -501,8 +501,8 @@ protected function hex_to_dec($hex)
501501 $ bitval = 1 ;
502502 $ len = strlen ($ hex );
503503 for ($ pos = ($ len - 1 ); $ pos >= 0 ; --$ pos ) {
504- $ dec = bcadd ($ dec , bcmul (hexdec ($ hex [$ pos ]), $ bitval ));
505- $ bitval = bcmul ($ bitval , 16 );
504+ $ dec = bcadd ($ dec , bcmul (strval ( hexdec ($ hex [$ pos ])), strval ( $ bitval) ));
505+ $ bitval = bcmul ($ bitval , ' 16 ' );
506506 }
507507
508508 return $ dec ;
0 commit comments