smiley 2 лет назад
Родитель
Сommit
63056190f7
2 измененных файлов с 6 добавлено и 11 удалено
  1. 2 3
      src/Data/QRMatrix.php
  2. 4 8
      src/Decoder/Binarizer.php

+ 2 - 3
src/Data/QRMatrix.php

@@ -578,9 +578,8 @@ class QRMatrix{
 		$startY = ((($startY !== null) ? $startY : ($length - $height) / 2) + $qz);
 
 		// clear the space
-		foreach($this->matrix as $y => $row){
-			/** @SuppressWarnings(PHPMD.UnusedLocalVariable) */
-			foreach($row as $x => $val){
+		for($y = 0; $y < $this->moduleCount; $y++){
+			for($x = 0; $x < $this->moduleCount; $x++){
 				// out of bounds, skip
 				if($x < $start || $y < $start ||$x >= $end || $y >= $end){
 					continue;

+ 4 - 8
src/Decoder/Binarizer.php

@@ -204,16 +204,12 @@ final class Binarizer{
 	 * @see http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0
 	 */
 	private function calculateBlackPoints(int $subWidth, int $subHeight, int $width, int $height):array{
-		$blackPoints = array_fill(0, $subHeight, 0);
-
-		/** @SuppressWarnings(PHPMD.UnusedLocalVariable) */
-		foreach($blackPoints as $key => $point){
-			$blackPoints[$key] = array_fill(0, $subWidth, 0);
-		}
+		$blackPoints = [];
 
 		for($y = 0; $y < $subHeight; $y++){
-			$yoffset    = ($y << self::BLOCK_SIZE_POWER);
-			$maxYOffset = ($height - self::BLOCK_SIZE);
+			$yoffset         = ($y << self::BLOCK_SIZE_POWER);
+			$maxYOffset      = ($height - self::BLOCK_SIZE);
+			$blackPoints[$y] = [];
 
 			if($yoffset > $maxYOffset){
 				$yoffset = $maxYOffset;