codemasher 5 سال پیش
والد
کامیت
b11f4ef61e
3فایلهای تغییر یافته به همراه21 افزوده شده و 19 حذف شده
  1. 3 3
      src/Common/ReedSolomonEncoder.php
  2. 17 15
      src/Data/QRData.php
  3. 1 1
      src/Data/QRMatrix.php

+ 3 - 3
src/Common/ReedSolomonEncoder.php

@@ -85,17 +85,17 @@ final class ReedSolomonEncoder{
 
 
 		$rsPolyDegree = $rsPoly->getDegree();
 		$rsPolyDegree = $rsPoly->getDegree();
 
 
-		$num = (new GenericGFPoly($dataBytes, $rsPolyDegree))
+		$modCoefficients = (new GenericGFPoly($dataBytes, $rsPolyDegree))
 			->mod($rsPoly)
 			->mod($rsPoly)
 			->getCoefficients()
 			->getCoefficients()
 		;
 		;
 
 
 		$ecBytes = array_fill(0, $rsPolyDegree, 0);
 		$ecBytes = array_fill(0, $rsPolyDegree, 0);
-		$count   = count($num) - count($ecBytes);
+		$count   = count($modCoefficients) - $rsPolyDegree;
 
 
 		foreach($ecBytes as $i => &$val){
 		foreach($ecBytes as $i => &$val){
 			$modIndex = $i + $count;
 			$modIndex = $i + $count;
-			$val      = $modIndex >= 0 ? $num[$modIndex] : 0;
+			$val      = $modIndex >= 0 ? $modCoefficients[$modIndex] : 0;
 		}
 		}
 
 
 		return $ecBytes;
 		return $ecBytes;

+ 17 - 15
src/Data/QRData.php

@@ -23,6 +23,23 @@ use function range, sprintf;
  */
  */
 class QRData{
 class QRData{
 
 
+	/**
+	 * the options instance
+	 *
+	 * @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions
+	 */
+	protected SettingsContainerInterface $options;
+
+	/**
+	 * a BitBuffer instance
+	 */
+	protected BitBuffer $bitBuffer;
+
+	/**
+	 * an EccLevel instance
+	 */
+	protected EccLevel $eccLevel;
+
 	/**
 	/**
 	 * current QR Code version
 	 * current QR Code version
 	 */
 	 */
@@ -40,20 +57,6 @@ class QRData{
 	 */
 	 */
 	protected array $maxBitsForEcc;
 	protected array $maxBitsForEcc;
 
 
-	/**
-	 * the options instance
-	 *
-	 * @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions
-	 */
-	protected SettingsContainerInterface $options;
-
-	/**
-	 * a BitBuffer instance
-	 */
-	protected BitBuffer $bitBuffer;
-
-	protected EccLevel $eccLevel;
-
 	/**
 	/**
 	 * QRData constructor.
 	 * QRData constructor.
 	 *
 	 *
@@ -154,7 +157,6 @@ class QRData{
 			if($total <= $this->maxBitsForEcc[$version]){
 			if($total <= $this->maxBitsForEcc[$version]){
 				return $version;
 				return $version;
 			}
 			}
-
 		}
 		}
 
 
 		// it's almost impossible to run into this one as $this::estimateTotalBitLength() would throw first
 		// it's almost impossible to run into this one as $this::estimateTotalBitLength() would throw first

+ 1 - 1
src/Data/QRMatrix.php

@@ -495,7 +495,7 @@ final class QRMatrix{
 	 * @see \chillerlan\QRCode\Data\QRData::maskECC()
 	 * @see \chillerlan\QRCode\Data\QRData::maskECC()
 	 *
 	 *
 	 * @param \SplFixedArray<int> $data
 	 * @param \SplFixedArray<int> $data
-	 * @param int                $maskPattern
+	 * @param int                 $maskPattern
 	 *
 	 *
 	 * @return \chillerlan\QRCode\Data\QRMatrix
 	 * @return \chillerlan\QRCode\Data\QRMatrix
 	 */
 	 */