소스 검색

:shower: QROutputAbstract::collectModules(): don't mess with the field value, also add modified value as param to transform, docblock

smiley 3 년 전
부모
커밋
4f454cb4ff
1개의 변경된 파일12개의 추가작업 그리고 4개의 파일을 삭제
  1. 12 4
      src/Output/QROutputAbstract.php

+ 12 - 4
src/Output/QROutputAbstract.php

@@ -134,6 +134,13 @@ abstract class QROutputAbstract implements QROutputInterface{
 	/**
 	/**
 	 * collects the modules per QRMatrix::M_* type and runs a $transform functio on each module and
 	 * collects the modules per QRMatrix::M_* type and runs a $transform functio on each module and
 	 * returns an array with the transformed modules
 	 * returns an array with the transformed modules
+	 *
+	 * The transform callback is called with the following parameters:
+	 *
+	 *   $x            - current column
+	 *   $y            - current row
+	 *   $M_TYPE       - field value
+	 *   $M_TYPE_LAYER - (possibly modified) field value that acts as layer id
 	 */
 	 */
 	protected function collectModules(Closure $transform):array{
 	protected function collectModules(Closure $transform):array{
 		$paths = [];
 		$paths = [];
@@ -141,18 +148,19 @@ abstract class QROutputAbstract implements QROutputInterface{
 		// collect the modules for each type
 		// collect the modules for each type
 		foreach($this->matrix->matrix() as $y => $row){
 		foreach($this->matrix->matrix() as $y => $row){
 			foreach($row as $x => $M_TYPE){
 			foreach($row as $x => $M_TYPE){
+				$M_TYPE_LAYER = $M_TYPE;
 
 
 				if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){
 				if($this->options->connectPaths && $this->matrix->checkTypeNotIn($x, $y, $this->options->excludeFromConnect)){
-					// to connect paths we'll redeclare the $M_TYPE to data only
-					$M_TYPE = QRMatrix::M_DATA;
+					// to connect paths we'll redeclare the $M_TYPE_LAYER to data only
+					$M_TYPE_LAYER = QRMatrix::M_DATA;
 
 
 					if($this->matrix->check($x, $y)){
 					if($this->matrix->check($x, $y)){
-						$M_TYPE |= QRMatrix::IS_DARK;
+						$M_TYPE_LAYER |= QRMatrix::IS_DARK;
 					}
 					}
 				}
 				}
 
 
 				// collect the modules per $M_TYPE
 				// collect the modules per $M_TYPE
-				$paths[$M_TYPE][] = $transform($x, $y, $M_TYPE);
+				$paths[$M_TYPE_LAYER][] = $transform($x, $y, $M_TYPE, $M_TYPE_LAYER);
 			}
 			}
 		}
 		}