@@ -83,19 +83,23 @@ class QRMatrix{
8383 ];
8484
8585 /**
86- * the used mask pattern, set via QRMatrix::mask()
86+ * the matrix version - always set in QRMatrix, may be null in BitMatrix
8787 */
88- protected ?MaskPattern $ maskPattern = null ;
88+ protected ?Version $ version = null ;
8989
9090 /**
91- * the current ECC level
91+ * the current ECC level - always set in QRMatrix, may be null in BitMatrix
9292 */
9393 protected ?EccLevel $ eccLevel = null ;
9494
9595 /**
96- * a Version instance
96+ * the mask pattern that was used in the most recent operation, set via:
97+ *
98+ * - QRMatrix::setFormatInfo()
99+ * - QRMatrix::mask()
100+ * - BitMatrix::readFormatInformation()
97101 */
98- protected ?Version $ version = null ;
102+ protected ?MaskPattern $ maskPattern = null ;
99103
100104 /**
101105 * the size (side length) of the matrix, including quiet zone (if created)
@@ -112,10 +116,9 @@ class QRMatrix{
112116 /**
113117 * QRMatrix constructor.
114118 */
115- public function __construct (Version $ version , EccLevel $ eccLevel, MaskPattern $ maskPattern ){
119+ public function __construct (Version $ version , EccLevel $ eccLevel ){
116120 $ this ->version = $ version ;
117121 $ this ->eccLevel = $ eccLevel ;
118- $ this ->maskPattern = $ maskPattern ;
119122 $ this ->moduleCount = $ this ->version ->getDimension ();
120123 $ this ->matrix = $ this ->createMatrix ($ this ->moduleCount , $ this ::M_NULL );
121124 }
@@ -502,12 +505,16 @@ public function setVersionNumber():self{
502505 }
503506
504507 /**
505- * Draws the format info along the finder patterns
508+ * Draws the format info along the finder patterns. If no $maskPattern, all format info modules will be set to false.
506509 *
507510 * ISO/IEC 18004:2000 Section 8.9
508511 */
509- public function setFormatInfo ():self {
510- $ bits = $ this ->eccLevel ->getformatPattern ($ this ->maskPattern );
512+ public function setFormatInfo (MaskPattern $ maskPattern = null ):self {
513+ $ this ->maskPattern = $ maskPattern ;
514+
515+ $ bits = ($ this ->maskPattern instanceof MaskPattern)
516+ ? $ this ->eccLevel ->getformatPattern ($ this ->maskPattern )
517+ : 0 ; // sets all format fields to false (test mode)
511518
512519 for ($ i = 0 ; $ i < 15 ; $ i ++){
513520 $ v = (($ bits >> $ i ) & 1 ) === 1 ;
@@ -703,8 +710,9 @@ public function writeCodewords(BitBuffer $bitBuffer):self{
703710 *
704711 * ISO/IEC 18004:2000 Section 8.8.1
705712 */
706- public function mask ():self {
707- $ mask = $ this ->maskPattern ->getMask ();
713+ public function mask (MaskPattern $ maskPattern ):self {
714+ $ this ->maskPattern = $ maskPattern ;
715+ $ mask = $ this ->maskPattern ->getMask ();
708716
709717 foreach ($ this ->matrix as $ y => $ row ){
710718 foreach ($ row as $ x => $ val ){
0 commit comments