codemasher 5 лет назад
Родитель
Сommit
d13f3af5d2

+ 2 - 0
examples/MyCustomOutput.php

@@ -28,6 +28,8 @@ class MyCustomOutput extends QROutputAbstract{
 			for($col = 0; $col < $this->moduleCount; $col++){
 				$output .= (int)$this->matrix->check($col, $row);
 			}
+
+			$output .= \PHP_EOL;
 		}
 
 		return $output;

+ 6 - 3
src/Data/QRMatrix.php

@@ -617,6 +617,9 @@ final class QRMatrix{
 	/**
 	 * ISO/IEC 18004:2000 Section 8.8.1
 	 *
+	 * Note that some versions of the QR code standard have had errors in the section about mask patterns.
+	 * The information below has been corrected. (https://www.thonky.com/qr-code-tutorial/mask-patterns)
+	 *
 	 * @see \chillerlan\QRCode\QRMatrix::mapData()
 	 *
 	 * @internal
@@ -631,10 +634,10 @@ final class QRMatrix{
 
 		return [
 			0b000 => fn($x, $y):int => ($x + $y) % 2,
-			0b001 => fn($x, $y):int => $x % 2,
-			0b010 => fn($x, $y):int => $y % 3,
+			0b001 => fn($x, $y):int => $y % 2,
+			0b010 => fn($x, $y):int => $x % 3,
 			0b011 => fn($x, $y):int => ($x + $y) % 3,
-			0b100 => fn($x, $y):int => ((int)($x / 2) + (int)($y / 3)) % 2,
+			0b100 => fn($x, $y):int => ((int)($y / 2) + (int)($x / 3)) % 2,
 			0b101 => fn($x, $y):int => (($x * $y) % 2) + (($x * $y) % 3),
 			0b110 => fn($x, $y):int => ((($x * $y) % 2) + (($x * $y) % 3)) % 2,
 			0b111 => fn($x, $y):int => ((($x * $y) % 3) + (($x + $y) % 2)) % 2,

+ 0 - 16
tests/Output/QROutputTestAbstract.php

@@ -12,7 +12,6 @@
 
 namespace chillerlan\QRCodeTest\Output;
 
-use chillerlan\QRCodeExamples\MyCustomOutput;
 use chillerlan\QRCode\{QRCode, QROptions};
 use chillerlan\QRCode\Data\{Byte, QRMatrix};
 use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
@@ -131,19 +130,4 @@ abstract class QROutputTestAbstract extends TestCase{
 		);
 	}
 
-	/**
-	 * covers the custom output functionality via an example
-	 */
-	public function testCustomOutput():void{
-		$this->options->version         = 5;
-		$this->options->eccLevel        = QRCode::ECC_L;
-		$this->options->outputType      = QRCode::OUTPUT_CUSTOM;
-		$this->options->outputInterface = MyCustomOutput::class;
-
-		$this::assertSame(
-			trim(file_get_contents(__DIR__.'/samples/custom')),
-			(new QRCode($this->options))->render('test')
-		);
-	}
-
 }

+ 16 - 0
tests/Output/QRStringTest.php

@@ -12,6 +12,7 @@
 
 namespace chillerlan\QRCodeTest\Output;
 
+use chillerlan\QRCodeExamples\MyCustomOutput;
 use chillerlan\QRCode\{QRCode, QROptions};
 use chillerlan\QRCode\Output\{QROutputInterface, QRString};
 
@@ -57,4 +58,19 @@ class QRStringTest extends QROutputTestAbstract{
 		$this::assertStringContainsString('B', $data);
 	}
 
+	/**
+	 * covers the custom output functionality via an example
+	 */
+	public function testCustomOutput():void{
+		$this->options->version         = 5;
+		$this->options->eccLevel        = QRCode::ECC_L;
+		$this->options->outputType      = QRCode::OUTPUT_CUSTOM;
+		$this->options->outputInterface = MyCustomOutput::class;
+
+		$this::assertSame(
+			file_get_contents(__DIR__.'/samples/custom'),
+			(new QRCode($this->options))->render('test')
+		);
+	}
+
 }

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
tests/Output/samples/custom


Некоторые файлы не были показаны из-за большого количества измененных файлов