@@ -263,11 +263,13 @@ |
||
263 | 263 | global $text_domains; |
264 | 264 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
265 | 265 | if (substr(php_uname(), 0, 7) == "Windows") { |
266 | - if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/') |
|
267 | - $path .= '\\'; |
|
266 | + if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/') { |
|
267 | + $path .= '\\'; |
|
268 | + } |
|
268 | 269 | } else { |
269 | - if ($path[strlen($path) - 1] != '/') |
|
270 | - $path .= '/'; |
|
270 | + if ($path[strlen($path) - 1] != '/') { |
|
271 | + $path .= '/'; |
|
272 | + } |
|
271 | 273 | } |
272 | 274 | if (!array_key_exists($domain, $text_domains)) { |
273 | 275 | // Initialize an empty domain object. |
@@ -282,16 +282,22 @@ discard block |
||
282 | 282 | $p = 0; |
283 | 283 | while (true) { |
284 | 284 | $p0 = strpos($this->template, '<!--', $p); |
285 | - if ($p0 === false) break; |
|
285 | + if ($p0 === false) { |
|
286 | + break; |
|
287 | + } |
|
286 | 288 | $p = strpos($this->template, '-->', $p0); |
287 | 289 | if ($p === false) { |
288 | 290 | $this->triggerError("Invalid HTML comment in template at offset $p0."); |
289 | 291 | return false; } |
290 | 292 | $p += 3; |
291 | 293 | $cmdL = substr($this->template, $p0 + 4, $p - $p0 - 7); |
292 | - if (!$this->processTemplateCommand($cmdL, $p0, $p, $resumeFromStart)) |
|
293 | - return false; |
|
294 | - if ($resumeFromStart) $p = $p0; } |
|
294 | + if (!$this->processTemplateCommand($cmdL, $p0, $p, $resumeFromStart)) { |
|
295 | + return false; |
|
296 | + } |
|
297 | + if ($resumeFromStart) { |
|
298 | + $p = $p0; |
|
299 | + } |
|
300 | + } |
|
295 | 301 | return true; } |
296 | 302 | |
297 | 303 | /** |
@@ -302,20 +308,25 @@ discard block |
||
302 | 308 | $resumeFromStart = false; |
303 | 309 | $p = 0; |
304 | 310 | $cmd = ''; |
305 | - if (!$this->parseWord($cmdL, $p, $cmd)) return true; |
|
311 | + if (!$this->parseWord($cmdL, $p, $cmd)) { |
|
312 | + return true; |
|
313 | + } |
|
306 | 314 | $parms = substr($cmdL, $p); |
307 | 315 | switch (strtoupper($cmd)) { |
308 | 316 | case '$BEGINBLOCK': |
309 | - if (!$this->processBeginBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
310 | - return false; |
|
317 | + if (!$this->processBeginBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) { |
|
318 | + return false; |
|
319 | + } |
|
311 | 320 | break; |
312 | 321 | case '$ENDBLOCK': |
313 | - if (!$this->processEndBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
314 | - return false; |
|
322 | + if (!$this->processEndBlockCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) { |
|
323 | + return false; |
|
324 | + } |
|
315 | 325 | break; |
316 | 326 | case '$INCLUDE': |
317 | - if (!$this->processincludeCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) |
|
318 | - return false; |
|
327 | + if (!$this->processincludeCmd($parms, $cmdTPosBegin, $cmdTPosEnd)) { |
|
328 | + return false; |
|
329 | + } |
|
319 | 330 | $resumeFromStart = true; |
320 | 331 | break; |
321 | 332 | default: |
@@ -387,8 +398,9 @@ discard block |
||
387 | 398 | $btr = & $this->blockTab[$blockNo]; |
388 | 399 | $btr = array(); |
389 | 400 | $btr['blockName'] = $blockName; |
390 | - if (!$this->lookupBlockName($blockName, $btr['nextWithSameName'])) |
|
391 | - $btr['nextWithSameName'] = -1; |
|
401 | + if (!$this->lookupBlockName($blockName, $btr['nextWithSameName'])) { |
|
402 | + $btr['nextWithSameName'] = -1; |
|
403 | + } |
|
392 | 404 | $btr['definitionIsOpen'] = true; |
393 | 405 | $btr['instances'] = 0; |
394 | 406 | $btr['firstBlockInstNo'] = -1; |
@@ -438,7 +450,9 @@ discard block |
||
438 | 450 | if (strlen($this->template) > $this->maxInclTemplateSize) { |
439 | 451 | $this->triggerError("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters."); |
440 | 452 | return false; } |
441 | - if (!$this->loadSubtemplate($subtemplateName, $subtemplate)) return false; |
|
453 | + if (!$this->loadSubtemplate($subtemplateName, $subtemplate)) { |
|
454 | + return false; |
|
455 | + } |
|
442 | 456 | // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator, |
443 | 457 | // a table could be used that contains references to the string fragments.) |
444 | 458 | $this->template = substr($this->template, 0, $tPos1).$subtemplate.substr($this->template, $tPos2); |
@@ -473,8 +487,9 @@ discard block |
||
473 | 487 | * @access private |
474 | 488 | */ |
475 | 489 | function registerVariableReference($varName, $tPosBegin, $tPosEnd) { |
476 | - if (!$this->lookupVariableName($varName, $varNo)) |
|
477 | - $this->registerVariable($varName, $varNo); |
|
490 | + if (!$this->lookupVariableName($varName, $varNo)) { |
|
491 | + $this->registerVariable($varName, $varNo); |
|
492 | + } |
|
478 | 493 | $varRefNo = $this->varRefTabCnt++; |
479 | 494 | $vrtr = & $this->varRefTab[$varRefNo]; |
480 | 495 | $vrtr = array(); |
@@ -514,12 +529,14 @@ discard block |
||
514 | 529 | $nextBlockNo += 1; |
515 | 530 | continue; }} |
516 | 531 | $btr = & $this->blockTab[$activeBlockNo]; |
517 | - if ($varRefTPos < $btr['tPosBegin']) |
|
518 | - $this->programLogicError(1); |
|
532 | + if ($varRefTPos < $btr['tPosBegin']) { |
|
533 | + $this->programLogicError(1); |
|
534 | + } |
|
519 | 535 | $blockVarNo = $btr['blockVarCnt']++; |
520 | 536 | $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo; |
521 | - if ($btr['firstVarRefNo'] == -1) |
|
522 | - $btr['firstVarRefNo'] = $varRefNo; |
|
537 | + if ($btr['firstVarRefNo'] == -1) { |
|
538 | + $btr['firstVarRefNo'] = $varRefNo; |
|
539 | + } |
|
523 | 540 | $vrtr['blockNo'] = $activeBlockNo; |
524 | 541 | $vrtr['blockVarNo'] = $blockVarNo; |
525 | 542 | $varRefNo += 1; }} |
@@ -535,8 +552,9 @@ discard block |
||
535 | 552 | * @access public |
536 | 553 | */ |
537 | 554 | function reset() { |
538 | - for ($varNo = 0; $varNo < $this->varTabCnt; $varNo++) |
|
539 | - $this->varTab[$varNo]['varValue'] = ''; |
|
555 | + for ($varNo = 0; $varNo < $this->varTabCnt; $varNo++) { |
|
556 | + $this->varTab[$varNo]['varValue'] = ''; |
|
557 | + } |
|
540 | 558 | for ($blockNo = 0; $blockNo < $this->blockTabCnt; $blockNo++) { |
541 | 559 | $btr = & $this->blockTab[$blockNo]; |
542 | 560 | $btr['instances'] = 0; |
@@ -563,7 +581,9 @@ discard block |
||
563 | 581 | function setVariable($variableName, $variableValue, $isOptional = false) { |
564 | 582 | if (!$this->templateValid) {$this->triggerError("Template not valid."); return false; } |
565 | 583 | if (!$this->lookupVariableName($variableName, $varNo)) { |
566 | - if ($isOptional) return true; |
|
584 | + if ($isOptional) { |
|
585 | + return true; |
|
586 | + } |
|
567 | 587 | $this->triggerError("Variable \"$variableName\" not defined in template."); |
568 | 588 | return false; } |
569 | 589 | $this->varTab[$varNo]['varValue'] = $variableValue; |
@@ -631,20 +651,23 @@ discard block |
||
631 | 651 | $btr = & $this->blockTab[$blockNo]; |
632 | 652 | $this->registerBlockInstance($blockInstNo); |
633 | 653 | $bitr = & $this->blockInstTab[$blockInstNo]; |
634 | - if ($btr['firstBlockInstNo'] == -1) |
|
635 | - $btr['firstBlockInstNo'] = $blockInstNo; |
|
636 | - if ($btr['lastBlockInstNo'] != -1) |
|
637 | - $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
654 | + if ($btr['firstBlockInstNo'] == -1) { |
|
655 | + $btr['firstBlockInstNo'] = $blockInstNo; |
|
656 | + } |
|
657 | + if ($btr['lastBlockInstNo'] != -1) { |
|
658 | + $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; |
|
659 | + } |
|
638 | 660 | // set forward pointer of chain |
639 | 661 | $btr['lastBlockInstNo'] = $blockInstNo; |
640 | 662 | $parentBlockNo = $btr['parentBlockNo']; |
641 | 663 | $blockVarCnt = $btr['blockVarCnt']; |
642 | 664 | $bitr['blockNo'] = $blockNo; |
643 | 665 | $bitr['instanceLevel'] = $btr['instances']++; |
644 | - if ($parentBlockNo == -1) |
|
645 | - $bitr['parentInstLevel'] = -1; |
|
646 | - else |
|
647 | - $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
666 | + if ($parentBlockNo == -1) { |
|
667 | + $bitr['parentInstLevel'] = -1; |
|
668 | + } else { |
|
669 | + $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; |
|
670 | + } |
|
648 | 671 | $bitr['nextBlockInstNo'] = -1; |
649 | 672 | $bitr['blockVarTab'] = array(); |
650 | 673 | // copy instance variables for this block |
@@ -691,7 +714,9 @@ discard block |
||
691 | 714 | */ |
692 | 715 | function generateOutputToFile($fileName) { |
693 | 716 | $fh = fopen($fileName, "wb"); |
694 | - if ($fh === false) return false; |
|
717 | + if ($fh === false) { |
|
718 | + return false; |
|
719 | + } |
|
695 | 720 | $this->outputMode = 1; |
696 | 721 | $this->outputFileHandle = $fh; |
697 | 722 | $ok = $this->generateOutputPage(); |
@@ -721,14 +746,18 @@ discard block |
||
721 | 746 | */ |
722 | 747 | function generateOutputPage() { |
723 | 748 | if (!$this->templateValid) {$this->triggerError("Template not valid."); return false; } |
724 | - if ($this->blockTab[0]['instances'] == 0) |
|
725 | - $this->addBlockByNo(0); // add main block |
|
749 | + if ($this->blockTab[0]['instances'] == 0) { |
|
750 | + $this->addBlockByNo(0); |
|
751 | + } |
|
752 | + // add main block |
|
726 | 753 | for ($blockNo = 0; $blockNo < $this->blockTabCnt; $blockNo++) { |
727 | 754 | $btr = & $this->blockTab[$blockNo]; |
728 | 755 | $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; } |
729 | 756 | $this->outputError = false; |
730 | 757 | $this->writeBlockInstances(0, -1); |
731 | - if ($this->outputError) return false; |
|
758 | + if ($this->outputError) { |
|
759 | + return false; |
|
760 | + } |
|
732 | 761 | return true; } |
733 | 762 | |
734 | 763 | /** |
@@ -741,11 +770,16 @@ discard block |
||
741 | 770 | $btr = & $this->blockTab[$blockNo]; |
742 | 771 | while (!$this->outputError) { |
743 | 772 | $blockInstNo = $btr['currBlockInstNo']; |
744 | - if ($blockInstNo == -1) break; |
|
773 | + if ($blockInstNo == -1) { |
|
774 | + break; |
|
775 | + } |
|
745 | 776 | $bitr = & $this->blockInstTab[$blockInstNo]; |
746 | - if ($bitr['parentInstLevel'] < $parentInstLevel) |
|
747 | - $this->programLogicError(2); |
|
748 | - if ($bitr['parentInstLevel'] > $parentInstLevel) break; |
|
777 | + if ($bitr['parentInstLevel'] < $parentInstLevel) { |
|
778 | + $this->programLogicError(2); |
|
779 | + } |
|
780 | + if ($bitr['parentInstLevel'] > $parentInstLevel) { |
|
781 | + break; |
|
782 | + } |
|
749 | 783 | $this->writeBlockInstance($blockInstNo); |
750 | 784 | $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }} |
751 | 785 | |
@@ -778,15 +812,17 @@ discard block |
||
778 | 812 | if ($subBtr['tPosBegin'] < $tPos2) { |
779 | 813 | $tPos2 = $subBtr['tPosBegin']; |
780 | 814 | $kind = 2; }} |
781 | - if ($tPos2 > $tPos) |
|
782 | - $this->writeString(substr($this->template, $tPos, $tPos2 - $tPos)); |
|
815 | + if ($tPos2 > $tPos) { |
|
816 | + $this->writeString(substr($this->template, $tPos, $tPos2 - $tPos)); |
|
817 | + } |
|
783 | 818 | switch ($kind) { |
784 | 819 | case 0: // end of block |
785 | 820 | return; |
786 | 821 | case 1: // variable |
787 | 822 | $vrtr = & $this->varRefTab[$varRefNo]; |
788 | - if ($vrtr['blockNo'] != $blockNo) |
|
789 | - $this->programLogicError(4); |
|
823 | + if ($vrtr['blockNo'] != $blockNo) { |
|
824 | + $this->programLogicError(4); |
|
825 | + } |
|
790 | 826 | $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']]; |
791 | 827 | $this->writeString($variableValue); |
792 | 828 | $tPos = $vrtr['tPosEnd']; |
@@ -794,8 +830,9 @@ discard block |
||
794 | 830 | break; |
795 | 831 | case 2: // sub block |
796 | 832 | $subBtr = & $this->blockTab[$subBlockNo]; |
797 | - if ($subBtr['parentBlockNo'] != $blockNo) |
|
798 | - $this->programLogicError(3); |
|
833 | + if ($subBtr['parentBlockNo'] != $blockNo) { |
|
834 | + $this->programLogicError(3); |
|
835 | + } |
|
799 | 836 | $this->writeBlockInstances($subBlockNo, $bitr['instanceLevel']); // recursive call |
800 | 837 | $tPos = $subBtr['tPosEnd']; |
801 | 838 | $subBlockNo += 1; |
@@ -805,15 +842,20 @@ discard block |
||
805 | 842 | * @access private |
806 | 843 | */ |
807 | 844 | function writeString($s) { |
808 | - if ($this->outputError) return; |
|
845 | + if ($this->outputError) { |
|
846 | + return; |
|
847 | + } |
|
809 | 848 | switch ($this->outputMode) { |
810 | 849 | case 0: // output to PHP output stream |
811 | - if (!print($s)) |
|
812 | - $this->outputError = true; |
|
850 | + if (!print($s)) { |
|
851 | + $this->outputError = true; |
|
852 | + } |
|
813 | 853 | break; |
814 | 854 | case 1: // output to file |
815 | 855 | $rc = fwrite($this->outputFileHandle, $s); |
816 | - if ($rc === false) $this->outputError = true; |
|
856 | + if ($rc === false) { |
|
857 | + $this->outputError = true; |
|
858 | + } |
|
817 | 859 | break; |
818 | 860 | case 2: // output to string |
819 | 861 | $this->outputString .= $s; |
@@ -828,7 +870,9 @@ discard block |
||
828 | 870 | */ |
829 | 871 | function lookupVariableName($varName, &$varNo) { |
830 | 872 | $x = & $this->varNameToNoMap[strtoupper($varName)]; |
831 | - if (!isset($x)) return false; |
|
873 | + if (!isset($x)) { |
|
874 | + return false; |
|
875 | + } |
|
832 | 876 | $varNo = $x; |
833 | 877 | return true; } |
834 | 878 | |
@@ -841,7 +885,9 @@ discard block |
||
841 | 885 | */ |
842 | 886 | function lookupBlockName($blockName, &$blockNo) { |
843 | 887 | $x = & $this->blockNameToNoMap[strtoupper($blockName)]; |
844 | - if (!isset($x)) return false; |
|
888 | + if (!isset($x)) { |
|
889 | + return false; |
|
890 | + } |
|
845 | 891 | $blockNo = $x; |
846 | 892 | return true; } |
847 | 893 | |
@@ -855,15 +901,21 @@ discard block |
||
855 | 901 | function readFileIntoString($fileName, &$s) { |
856 | 902 | if (function_exists('version_compare') && version_compare(phpversion(), "4.3.0", ">=")) { |
857 | 903 | $s = file_get_contents($fileName); |
858 | - if ($s === false) return false; |
|
904 | + if ($s === false) { |
|
905 | + return false; |
|
906 | + } |
|
859 | 907 | return true; } |
860 | 908 | $fh = fopen($fileName, "rb"); |
861 | - if ($fh === false) return false; |
|
909 | + if ($fh === false) { |
|
910 | + return false; |
|
911 | + } |
|
862 | 912 | $fileSize = filesize($fileName); |
863 | 913 | if ($fileSize === false) {fclose($fh); return false; } |
864 | 914 | $s = fread($fh, $fileSize); |
865 | 915 | fclose($fh); |
866 | - if (strlen($s) != $fileSize) return false; |
|
916 | + if (strlen($s) != $fileSize) { |
|
917 | + return false; |
|
918 | + } |
|
867 | 919 | return true; } |
868 | 920 | |
869 | 921 | /** |
@@ -891,12 +943,22 @@ discard block |
||
891 | 943 | */ |
892 | 944 | function parseQuotedString($s, &$p, &$w) { |
893 | 945 | $sLen = strlen($s); |
894 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++; |
|
895 | - if ($p >= $sLen) return false; |
|
896 | - if (substr($s, $p, 1) != '"') return false; |
|
946 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
947 | + $p++; |
|
948 | + } |
|
949 | + if ($p >= $sLen) { |
|
950 | + return false; |
|
951 | + } |
|
952 | + if (substr($s, $p, 1) != '"') { |
|
953 | + return false; |
|
954 | + } |
|
897 | 955 | $p++; $p0 = $p; |
898 | - while ($p < $sLen && $s{$p} != '"') $p++; |
|
899 | - if ($p >= $sLen) return false; |
|
956 | + while ($p < $sLen && $s{$p} != '"') { |
|
957 | + $p++; |
|
958 | + } |
|
959 | + if ($p >= $sLen) { |
|
960 | + return false; |
|
961 | + } |
|
900 | 962 | $w = substr($s, $p0, $p - $p0); |
901 | 963 | $p++; |
902 | 964 | return true; } |
@@ -907,25 +969,36 @@ discard block |
||
907 | 969 | */ |
908 | 970 | function parseWordOrQuotedString($s, &$p, &$w) { |
909 | 971 | $sLen = strlen($s); |
910 | - while ($p < $sLen && ord($s{$p}) <= 32) $p++; |
|
911 | - if ($p >= $sLen) return false; |
|
912 | - if (substr($s, $p, 1) == '"') |
|
913 | - return $this->parseQuotedString($s, $p, $w); |
|
914 | - else |
|
915 | - return $this->parseWord($s, $p, $w); } |
|
972 | + while ($p < $sLen && ord($s{$p}) <= 32) { |
|
973 | + $p++; |
|
974 | + } |
|
975 | + if ($p >= $sLen) { |
|
976 | + return false; |
|
977 | + } |
|
978 | + if (substr($s, $p, 1) == '"') { |
|
979 | + return $this->parseQuotedString($s, $p, $w); |
|
980 | + } else { |
|
981 | + return $this->parseWord($s, $p, $w); |
|
982 | + } |
|
983 | + } |
|
916 | 984 | |
917 | 985 | /** |
918 | 986 | * Combine two file system paths. |
919 | 987 | * @access private |
920 | 988 | */ |
921 | 989 | function combineFileSystemPath($path1, $path2) { |
922 | - if ($path1 == '' || $path2 == '') return $path2; |
|
990 | + if ($path1 == '' || $path2 == '') { |
|
991 | + return $path2; |
|
992 | + } |
|
923 | 993 | $s = $path1; |
924 | - if (substr($s, -1) != '\\' && substr($s, -1) != '/') $s = $s."/"; |
|
925 | - if (substr($path2, 0, 1) == '\\' || substr($path2, 0, 1) == '/') |
|
926 | - $s = $s.substr($path2, 1); |
|
927 | - else |
|
928 | - $s = $s.$path2; |
|
994 | + if (substr($s, -1) != '\\' && substr($s, -1) != '/') { |
|
995 | + $s = $s."/"; |
|
996 | + } |
|
997 | + if (substr($path2, 0, 1) == '\\' || substr($path2, 0, 1) == '/') { |
|
998 | + $s = $s.substr($path2, 1); |
|
999 | + } else { |
|
1000 | + $s = $s.$path2; |
|
1001 | + } |
|
929 | 1002 | return $s; } |
930 | 1003 | |
931 | 1004 | /** |
@@ -225,8 +225,9 @@ discard block |
||
225 | 225 | |
226 | 226 | $width = count($frame); |
227 | 227 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
228 | - for ($maskNo = 0; $maskNo < 8; $maskNo++) |
|
229 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | + for ($maskNo = 0; $maskNo < 8; $maskNo++) { |
|
229 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
230 | + } |
|
230 | 231 | } |
231 | 232 | |
232 | 233 | QRtools::markTime('after_build_cache'); |
@@ -1591,8 +1592,9 @@ discard block |
||
1591 | 1592 | $chunks = (int) ($payload / 11); |
1592 | 1593 | $remain = $payload - $chunks * 11; |
1593 | 1594 | $size = $chunks * 2; |
1594 | - if ($remain >= 6) |
|
1595 | - $size++; |
|
1595 | + if ($remain >= 6) { |
|
1596 | + $size++; |
|
1597 | + } |
|
1596 | 1598 | break; |
1597 | 1599 | case QR_MODE_8: |
1598 | 1600 | $size = (int) ($payload / 8); |
@@ -2231,16 +2233,22 @@ discard block |
||
2231 | 2233 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
2232 | 2234 | case QR_MODE_AN: $length = $this->eatAn(); break; |
2233 | 2235 | case QR_MODE_KANJI: |
2234 | - if ($this->modeHint == QR_MODE_KANJI) |
|
2235 | - $length = $this->eatKanji(); |
|
2236 | - else $length = $this->eat8(); |
|
2236 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
2237 | + $length = $this->eatKanji(); |
|
2238 | + } else { |
|
2239 | + $length = $this->eat8(); |
|
2240 | + } |
|
2237 | 2241 | break; |
2238 | 2242 | default: $length = $this->eat8(); break; |
2239 | 2243 | |
2240 | 2244 | } |
2241 | 2245 | |
2242 | - if ($length == 0) return 0; |
|
2243 | - if ($length < 0) return -1; |
|
2246 | + if ($length == 0) { |
|
2247 | + return 0; |
|
2248 | + } |
|
2249 | + if ($length < 0) { |
|
2250 | + return -1; |
|
2251 | + } |
|
2244 | 2252 | |
2245 | 2253 | $this->dataStr = substr($this->dataStr, $length); |
2246 | 2254 | } |
@@ -566,8 +566,9 @@ |
||
566 | 566 | $chunks = (int) ($payload / 11); |
567 | 567 | $remain = $payload - $chunks * 11; |
568 | 568 | $size = $chunks * 2; |
569 | - if ($remain >= 6) |
|
570 | - $size++; |
|
569 | + if ($remain >= 6) { |
|
570 | + $size++; |
|
571 | + } |
|
571 | 572 | break; |
572 | 573 | case QR_MODE_8: |
573 | 574 | $size = (int) ($payload / 8); |
@@ -266,16 +266,22 @@ |
||
266 | 266 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
267 | 267 | case QR_MODE_AN: $length = $this->eatAn(); break; |
268 | 268 | case QR_MODE_KANJI: |
269 | - if ($this->modeHint == QR_MODE_KANJI) |
|
270 | - $length = $this->eatKanji(); |
|
271 | - else $length = $this->eat8(); |
|
269 | + if ($this->modeHint == QR_MODE_KANJI) { |
|
270 | + $length = $this->eatKanji(); |
|
271 | + } else { |
|
272 | + $length = $this->eat8(); |
|
273 | + } |
|
272 | 274 | break; |
273 | 275 | default: $length = $this->eat8(); break; |
274 | 276 | |
275 | 277 | } |
276 | 278 | |
277 | - if ($length == 0) return 0; |
|
278 | - if ($length < 0) return -1; |
|
279 | + if ($length == 0) { |
|
280 | + return 0; |
|
281 | + } |
|
282 | + if ($length < 0) { |
|
283 | + return -1; |
|
284 | + } |
|
279 | 285 | |
280 | 286 | $this->dataStr = substr($this->dataStr, $length); |
281 | 287 | } |
@@ -92,8 +92,9 @@ |
||
92 | 92 | |
93 | 93 | $width = count($frame); |
94 | 94 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
95 | - for ($maskNo = 0; $maskNo < 8; $maskNo++) |
|
96 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
95 | + for ($maskNo = 0; $maskNo < 8; $maskNo++) { |
|
96 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
97 | + } |
|
97 | 98 | } |
98 | 99 | |
99 | 100 | QRtools::markTime('after_build_cache'); |