codemasher 5 lat temu
rodzic
commit
65084283bc
2 zmienionych plików z 13 dodań i 10 usunięć
  1. 9 9
      src/Data/QRMatrix.php
  2. 4 1
      src/Output/QRImage.php

+ 9 - 9
src/Data/QRMatrix.php

@@ -585,8 +585,6 @@ final class QRMatrix{
 	 *
 	 * @link https://github.com/chillerlan/php-qrcode/issues/52
 	 *
-	 * @codeCoverageIgnore (for now)
-	 *
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	public function setLogoSpace(int $width, int $height, int $startX = null, int $startY = null):QRMatrix{
@@ -614,23 +612,25 @@ final class QRMatrix{
 		}
 
 		// quiet zone size
-		$qz     = ($this->moduleCount - $length) / 2;
-		$start  = $qz + 9;
-		$end    = $this->moduleCount - $qz;
+		$qz    = ($this->moduleCount - $length) / 2;
+		// skip quiet zone and the first 9 rows/columns (finder-, mode-, version- and timing patterns)
+		$start = $qz + 9;
+		// skip quiet zone
+		$end   = $this->moduleCount - $qz;
 
-		// determine start coordinates, try not to interfere with functional patterns
+		// determine start coordinates
 		$startX = ($startX !== null ? $startX : ($length - $width) / 2) + $qz;
 		$startY = ($startY !== null ? $startY : ($length - $height) / 2) + $qz;
 
 		// clear the space
 		foreach($this->matrix as $y => $row){
 			foreach($row as $x => $val){
-
+				// out of bounds, skip
 				if($x < $start || $y < $start ||$x >= $end || $y >= $end){
 					continue;
 				}
-
-				if($x >= $startX && $x < $startX + $width && $y >= $startY && $y < $startY + $height){
+				// a match
+				if($x >= $startX && $x < ($startX + $width) && $y >= $startY && $y < ($startY + $height)){
 					$this->set($x, $y, false, $this::M_LOGO);
 				}
 			}

+ 4 - 1
src/Output/QRImage.php

@@ -10,7 +10,6 @@
  * @license      MIT
  *
  * @noinspection PhpComposerExtensionStubsInspection
- * @noinspection PhpUnused
  */
 
 namespace chillerlan\QRCode\Output;
@@ -48,6 +47,8 @@ class QRImage extends QROutputAbstract{
 	 *
 	 * @see imagecreatetruecolor()
 	 * @var resource|\GdImage
+	 *
+	 * @phan-suppress PhanUndeclaredTypeProperty
 	 */
 	protected $image;
 
@@ -90,6 +91,8 @@ class QRImage extends QROutputAbstract{
 	 * @inheritDoc
 	 *
 	 * @return string|\GdImage
+	 *
+	 * @phan-suppress PhanUndeclaredTypeReturnType, PhanTypeMismatchReturn
 	 */
 	public function dump(string $file = null){
 		$file ??= $this->options->cachefile;