codemasher 7 лет назад
Родитель
Сommit
2aee933b1e

+ 0 - 2
examples/MyCustomOutput.php

@@ -14,8 +14,6 @@ namespace chillerlan\QRCodeExamples;
 
 
 use chillerlan\QRCode\Output\QROutputAbstract;
 use chillerlan\QRCode\Output\QROutputAbstract;
 
 
-/**
- */
 class MyCustomOutput extends QROutputAbstract{
 class MyCustomOutput extends QROutputAbstract{
 
 
 	protected function setModuleValues():void{
 	protected function setModuleValues():void{

+ 3 - 3
src/Data/AlphaNum.php

@@ -19,7 +19,7 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class AlphaNum extends QRDataAbstract{
 class AlphaNum extends QRDataAbstract{
 
 
-	const CHAR_MAP = [
+	public const CHAR_MAP = [
 		'0', '1', '2', '3', '4', '5', '6', '7',
 		'0', '1', '2', '3', '4', '5', '6', '7',
 		'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
 		'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
 		'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
 		'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
@@ -41,7 +41,7 @@ class AlphaNum extends QRDataAbstract{
 	/**
 	/**
 	 * @inheritdoc
 	 * @inheritdoc
 	 */
 	 */
-	protected function write(string $data){
+	protected function write(string $data):void{
 
 
 		for($i = 0; $i + 1 < $this->strlen; $i += 2){
 		for($i = 0; $i + 1 < $this->strlen; $i += 2){
 			$this->bitBuffer->put($this->getCharCode($data[$i]) * 45 + $this->getCharCode($data[$i + 1]), 11);
 			$this->bitBuffer->put($this->getCharCode($data[$i]) * 45 + $this->getCharCode($data[$i + 1]), 11);
@@ -59,7 +59,7 @@ class AlphaNum extends QRDataAbstract{
 	 * @return int
 	 * @return int
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
-	protected function getCharCode(string $chr):int {
+	protected function getCharCode(string $chr):int{
 		$i = array_search($chr, $this::CHAR_MAP);
 		$i = array_search($chr, $this::CHAR_MAP);
 
 
 		if($i !== false){
 		if($i !== false){

+ 1 - 1
src/Data/Byte.php

@@ -32,7 +32,7 @@ class Byte extends QRDataAbstract{
 	/**
 	/**
 	 * @inheritdoc
 	 * @inheritdoc
 	 */
 	 */
-	protected function write(string $data){
+	protected function write(string $data):void{
 		$i = 0;
 		$i = 0;
 
 
 		while($i < $this->strlen){
 		while($i < $this->strlen){

+ 1 - 1
src/Data/Kanji.php

@@ -42,7 +42,7 @@ class Kanji extends QRDataAbstract{
 	 * @return void
 	 * @return void
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
-	protected function write(string $data){
+	protected function write(string $data):void{
 		$len = strlen($data);
 		$len = strlen($data);
 
 
 		for($i = 0; $i + 1 < $len; $i += 2){
 		for($i = 0; $i + 1 < $len; $i += 2){

+ 1 - 1
src/Data/MaskPatternTester.php

@@ -201,7 +201,7 @@ class MaskPatternTester{
 	 *
 	 *
 	 * @return float
 	 * @return float
 	 */
 	 */
-	protected function testLevel4():float {
+	protected function testLevel4():float{
 		$count = 0;
 		$count = 0;
 
 
 		foreach($this->matrix->matrix() as $y => $row){
 		foreach($this->matrix->matrix() as $y => $row){

+ 3 - 3
src/Data/Number.php

@@ -19,7 +19,7 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class Number extends QRDataAbstract{
 class Number extends QRDataAbstract{
 
 
-	const CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
+	public const CHAR_MAP = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
 
 
 	/**
 	/**
 	 * @inheritdoc
 	 * @inheritdoc
@@ -34,7 +34,7 @@ class Number extends QRDataAbstract{
 	/**
 	/**
 	 * @inheritdoc
 	 * @inheritdoc
 	 */
 	 */
-	protected function write(string $data){
+	protected function write(string $data):void{
 		$i = 0;
 		$i = 0;
 
 
 		while($i + 2 < $this->strlen){
 		while($i + 2 < $this->strlen){
@@ -63,7 +63,7 @@ class Number extends QRDataAbstract{
 	 * @return int
 	 * @return int
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
-	protected function parseInt(string $string):int {
+	protected function parseInt(string $string):int{
 		$num = 0;
 		$num = 0;
 
 
 		$len = strlen($string);
 		$len = strlen($string);

+ 2 - 7
src/Data/QRCodeDataException.php

@@ -12,11 +12,6 @@
 
 
 namespace chillerlan\QRCode\Data;
 namespace chillerlan\QRCode\Data;
 
 
-use Exception;
+use chillerlan\QRCode\QRCodeException;
 
 
-/**
- * Placeholder
- */
-class QRCodeDataException extends Exception{
-
-}
+class QRCodeDataException extends QRCodeException{}

+ 11 - 11
src/Data/QRDataAbstract.php

@@ -150,7 +150,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @codeCoverageIgnore
 	 * @codeCoverageIgnore
 	 */
 	 */
-	protected function getLengthBits():int {
+	protected function getLengthBits():int{
 
 
 		 foreach([9, 26, 40] as $key => $breakpoint){
 		 foreach([9, 26, 40] as $key => $breakpoint){
 			 if($this->version <= $breakpoint){
 			 if($this->version <= $breakpoint){
@@ -200,7 +200,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 	 *
 	 *
 	 * @return void
 	 * @return void
 	 */
 	 */
-	abstract protected function write(string $data);
+	abstract protected function write(string $data):void;
 
 
 	/**
 	/**
 	 * writes the string data to the BitBuffer
 	 * writes the string data to the BitBuffer
@@ -210,7 +210,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 	 * @return \chillerlan\QRCode\Data\QRDataAbstract
 	 * @return \chillerlan\QRCode\Data\QRDataAbstract
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 */
 	 */
-	protected function writeBitBuffer(string $data):QRDataInterface {
+	protected function writeBitBuffer(string $data):QRDataInterface{
 		$this->bitBuffer = new BitBuffer;
 		$this->bitBuffer = new BitBuffer;
 
 
 		// @todo: fixme, get real length
 		// @todo: fixme, get real length
@@ -267,13 +267,13 @@ abstract class QRDataAbstract implements QRDataInterface{
 	 *
 	 *
 	 * @return array
 	 * @return array
 	 */
 	 */
-	protected function maskECC():array {
-		list($l1, $l2, $b1, $b2) = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
+	protected function maskECC():array{
+		[$l1, $l2, $b1, $b2] = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
 
 
-		$rsBlocks       = array_fill(0, $l1, [$b1, $b2]);
-		$rsCount        = $l1 + $l2;
-		$this->ecdata   = array_fill(0, $rsCount, null);
-		$this->dcdata   = $this->ecdata;
+		$rsBlocks     = array_fill(0, $l1, [$b1, $b2]);
+		$rsCount      = $l1 + $l2;
+		$this->ecdata = array_fill(0, $rsCount, null);
+		$this->dcdata = $this->ecdata;
 
 
 		if($l2 > 0){
 		if($l2 > 0){
 			$rsBlocks = array_merge($rsBlocks, array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
 			$rsBlocks = array_merge($rsBlocks, array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
@@ -285,7 +285,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 		$offset         = 0;
 		$offset         = 0;
 
 
 		foreach($rsBlocks as $key => $block){
 		foreach($rsBlocks as $key => $block){
-			list($rsBlockTotal, $dcCount) = $block;
+			[$rsBlockTotal, $dcCount] = $block;
 
 
 			$ecCount            = $rsBlockTotal - $dcCount;
 			$ecCount            = $rsBlockTotal - $dcCount;
 			$maxDcCount         = max($maxDcCount, $dcCount);
 			$maxDcCount         = max($maxDcCount, $dcCount);
@@ -296,7 +296,7 @@ abstract class QRDataAbstract implements QRDataInterface{
 				$this->dcdata[$key][$a] = 0xff & $this->bitBuffer->buffer[$a + $offset];
 				$this->dcdata[$key][$a] = 0xff & $this->bitBuffer->buffer[$a + $offset];
 			}
 			}
 
 
-			list($num, $add) = $this->poly($key, $ecCount);
+			[$num, $add] = $this->poly($key, $ecCount);
 
 
 			foreach($this->ecdata[$key] as $c => $_z){
 			foreach($this->ecdata[$key] as $c => $_z){
 				$modIndex               = $c + $add;
 				$modIndex               = $c + $add;

+ 7 - 4
src/Data/QRDataInterface.php

@@ -20,7 +20,8 @@ interface QRDataInterface{
 	/**
 	/**
 	 * @link http://www.qrcode.com/en/about/version.html
 	 * @link http://www.qrcode.com/en/about/version.html
 	 */
 	 */
-	const MAX_LENGTH =[ null, // start at 1
+	const MAX_LENGTH =[
+		null, // start at 1
 	//	[NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H  ], KANJI => [L, M, Q, H   ]]  // modules
 	//	[NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H  ], KANJI => [L, M, Q, H   ]]  // modules
 		[[  41,   34,   27,   17], [  25,   20,   16,   10], [  17,   14,   11,    7], [  10,    8,    7,    4]], //  21
 		[[  41,   34,   27,   17], [  25,   20,   16,   10], [  17,   14,   11,    7], [  10,    8,    7,    4]], //  21
 		[[  77,   63,   48,   34], [  47,   38,   29,   20], [  32,   26,   20,   14], [  20,   16,   12,    8]], //  25
 		[[  77,   63,   48,   34], [  47,   38,   29,   20], [  32,   26,   20,   14], [  20,   16,   12,    8]], //  25
@@ -64,7 +65,8 @@ interface QRDataInterface{
 		[[7089, 5596, 3993, 3057], [4296, 3391, 2420, 1852], [2953, 2331, 1663, 1273], [1817, 1435, 1024,  784]], // 177
 		[[7089, 5596, 3993, 3057], [4296, 3391, 2420, 1852], [2953, 2331, 1663, 1273], [1817, 1435, 1024,  784]], // 177
 	];
 	];
 
 
-	const MAX_BITS = [ null, // start at 1
+	const MAX_BITS = [
+		null, // start at 1
 		// MAX_BITS => [L, M, Q, H ]
 		// MAX_BITS => [L, M, Q, H ]
 		[  152,   128,   104,    72],
 		[  152,   128,   104,    72],
 		[  272,   224,   176,   128],
 		[  272,   224,   176,   128],
@@ -111,7 +113,8 @@ interface QRDataInterface{
 	/**
 	/**
 	 * @link http://www.thonky.com/qr-code-tutorial/error-correction-table
 	 * @link http://www.thonky.com/qr-code-tutorial/error-correction-table
 	 */
 	 */
-	const RSBLOCKS = [ null, // start at 1
+	const RSBLOCKS = [
+		null, // start at 1
 		[[ 1,  0,  26,  19], [ 1,  0, 26, 16], [ 1,  0, 26, 13], [ 1,  0, 26,  9]], //  1
 		[[ 1,  0,  26,  19], [ 1,  0, 26, 16], [ 1,  0, 26, 13], [ 1,  0, 26,  9]], //  1
 		[[ 1,  0,  44,  34], [ 1,  0, 44, 28], [ 1,  0, 44, 22], [ 1,  0, 44, 16]], //
 		[[ 1,  0,  44,  34], [ 1,  0, 44, 28], [ 1,  0, 44, 22], [ 1,  0, 44, 16]], //
 		[[ 1,  0,  70,  55], [ 1,  0, 70, 44], [ 2,  0, 35, 17], [ 2,  0, 35, 13]], //
 		[[ 1,  0,  70,  55], [ 1,  0, 70, 44], [ 2,  0, 35, 17], [ 2,  0, 35, 13]], //
@@ -159,7 +162,7 @@ interface QRDataInterface{
 	 *
 	 *
 	 * @return \chillerlan\QRCode\Data\QRDataInterface
 	 * @return \chillerlan\QRCode\Data\QRDataInterface
 	 */
 	 */
-	public function setData(string $data);
+	public function setData(string $data):QRDataInterface;
 
 
 	/**
 	/**
 	 * @param int  $maskPattern
 	 * @param int  $maskPattern

+ 22 - 21
src/Data/QRMatrix.php

@@ -19,24 +19,25 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class QRMatrix{
 class QRMatrix{
 
 
-	const M_NULL       = 0x00;
-	const M_DARKMODULE = 0x02;
-	const M_DATA       = 0x04;
-	const M_FINDER     = 0x06;
-	const M_SEPARATOR  = 0x08;
-	const M_ALIGNMENT  = 0x0a;
-	const M_TIMING     = 0x0c;
-	const M_FORMAT     = 0x0e;
-	const M_VERSION    = 0x10;
-	const M_QUIETZONE  = 0x12;
-	const M_LOGO       = 0x14; // @todo
-
-	const M_TEST       = 0xff;
+	public const M_NULL       = 0x00;
+	public const M_DARKMODULE = 0x02;
+	public const M_DATA       = 0x04;
+	public const M_FINDER     = 0x06;
+	public const M_SEPARATOR  = 0x08;
+	public const M_ALIGNMENT  = 0x0a;
+	public const M_TIMING     = 0x0c;
+	public const M_FORMAT     = 0x0e;
+	public const M_VERSION    = 0x10;
+	public const M_QUIETZONE  = 0x12;
+	public const M_LOGO       = 0x14; // @todo
+
+	public const M_TEST       = 0xff;
 
 
 	/**
 	/**
 	 * @link http://www.thonky.com/qr-code-tutorial/alignment-pattern-locations
 	 * @link http://www.thonky.com/qr-code-tutorial/alignment-pattern-locations
 	 */
 	 */
-	const alignmentPattern = [ null, // start at 1
+	protected const alignmentPattern = [
+		null, // start at 1
 		[],
 		[],
 		[6, 18],
 		[6, 18],
 		[6, 22],
 		[6, 22],
@@ -82,7 +83,7 @@ class QRMatrix{
 	/**
 	/**
 	 * @link http://www.thonky.com/qr-code-tutorial/format-version-tables
 	 * @link http://www.thonky.com/qr-code-tutorial/format-version-tables
 	 */
 	 */
-	const versionPattern = [
+	protected const versionPattern = [
 		// 1-based version index
 		// 1-based version index
 		null,
 		null,
 		// no version pattern for QR Codes < 7
 		// no version pattern for QR Codes < 7
@@ -92,7 +93,7 @@ class QRMatrix{
 		0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, 0x27541, 0x28c69,
 		0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, 0x27541, 0x28c69,
 	];
 	];
 
 
-	const formatPattern = [
+	protected const formatPattern = [
 		[0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976], // L
 		[0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976], // L
 		[0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0], // M
 		[0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0], // M
 		[0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed], // Q
 		[0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed], // Q
@@ -151,28 +152,28 @@ class QRMatrix{
 	/**
 	/**
 	 * @return array
 	 * @return array
 	 */
 	 */
-	public function matrix():array {
+	public function matrix():array{
 		return $this->matrix;
 		return $this->matrix;
 	}
 	}
 
 
 	/**
 	/**
 	 * @return int
 	 * @return int
 	 */
 	 */
-	public function version():int {
+	public function version():int{
 		return $this->version;
 		return $this->version;
 	}
 	}
 
 
 	/**
 	/**
 	 * @return int
 	 * @return int
 	 */
 	 */
-	public function eccLevel():int {
+	public function eccLevel():int{
 		return $this->eclevel;
 		return $this->eclevel;
 	}
 	}
 
 
 	/**
 	/**
 	 * @return int
 	 * @return int
 	 */
 	 */
-	public function maskPattern():int {
+	public function maskPattern():int{
 		return $this->maskPattern;
 		return $this->maskPattern;
 	}
 	}
 
 
@@ -539,7 +540,7 @@ class QRMatrix{
 	 * @return int
 	 * @return int
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
-	protected function getMask(int $x, int $y, int $maskPattern):int {
+	protected function getMask(int $x, int $y, int $maskPattern):int{
 		$a = $y + $x;
 		$a = $y + $x;
 		$m = $y * $x;
 		$m = $y * $x;
 
 

+ 0 - 4
src/Helpers/BitBuffer.php

@@ -12,10 +12,6 @@
 
 
 namespace chillerlan\QRCode\Helpers;
 namespace chillerlan\QRCode\Helpers;
 
 
-/**
- * @property int[] $buffer
- * @property int   $length
- */
 class BitBuffer{
 class BitBuffer{
 
 
 	/**
 	/**

+ 6 - 6
src/Helpers/Polynomial.php

@@ -22,7 +22,7 @@ class Polynomial{
 	/**
 	/**
 	 * @link http://www.thonky.com/qr-code-tutorial/log-antilog-table
 	 * @link http://www.thonky.com/qr-code-tutorial/log-antilog-table
 	 */
 	 */
-	const table = [
+	protected const table = [
 		[  1,   0], [  2,   0], [  4,   1], [  8,  25], [ 16,   2], [ 32,  50], [ 64,  26], [128, 198],
 		[  1,   0], [  2,   0], [  4,   1], [  8,  25], [ 16,   2], [ 32,  50], [ 64,  26], [128, 198],
 		[ 29,   3], [ 58, 223], [116,  51], [232, 238], [205,  27], [135, 104], [ 19, 199], [ 38,  75],
 		[ 29,   3], [ 58, 223], [116,  51], [232, 238], [205,  27], [135, 104], [ 19, 199], [ 38,  75],
 		[ 76,   4], [152, 100], [ 45, 224], [ 90,  14], [180,  52], [117, 141], [234, 239], [201, 129],
 		[ 76,   4], [152, 100], [ 45, 224], [ 90,  14], [180,  52], [117, 141], [234, 239], [201, 129],
@@ -75,7 +75,7 @@ class Polynomial{
 	/**
 	/**
 	 * @return array
 	 * @return array
 	 */
 	 */
-	public function getNum():array {
+	public function getNum():array{
 		return $this->num;
 		return $this->num;
 	}
 	}
 
 
@@ -85,7 +85,7 @@ class Polynomial{
 	 *
 	 *
 	 * @return \chillerlan\QRCode\Helpers\Polynomial
 	 * @return \chillerlan\QRCode\Helpers\Polynomial
 	 */
 	 */
-	public function setNum(array $num, int $shift = null):Polynomial {
+	public function setNum(array $num, int $shift = null):Polynomial{
 		$offset = 0;
 		$offset = 0;
 		$numCount = count($num);
 		$numCount = count($num);
 
 
@@ -107,7 +107,7 @@ class Polynomial{
 	 *
 	 *
 	 * @return \chillerlan\QRCode\Helpers\Polynomial
 	 * @return \chillerlan\QRCode\Helpers\Polynomial
 	 */
 	 */
-	public function multiply(array $e):Polynomial {
+	public function multiply(array $e):Polynomial{
 		$n = array_fill(0, count($this->num) + count($e) - 1, 0);
 		$n = array_fill(0, count($this->num) + count($e) - 1, 0);
 
 
 		foreach($this->num as $i => $vi){
 		foreach($this->num as $i => $vi){
@@ -153,7 +153,7 @@ class Polynomial{
 	 * @return int
 	 * @return int
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 */
 	 */
-	public function glog(int $n):int {
+	public function glog(int $n):int{
 
 
 		if($n < 1){
 		if($n < 1){
 			throw new QRCodeException('log('.$n.')');
 			throw new QRCodeException('log('.$n.')');
@@ -167,7 +167,7 @@ class Polynomial{
 	 *
 	 *
 	 * @return int
 	 * @return int
 	 */
 	 */
-	public function gexp(int $n):int {
+	public function gexp(int $n):int{
 
 
 		if($n < 0){
 		if($n < 0){
 			$n += 255;
 			$n += 255;

+ 3 - 8
src/Output/QRCodeOutputException.php

@@ -4,7 +4,7 @@
  *
  *
  * @filesource   QRCodeOutputException.php
  * @filesource   QRCodeOutputException.php
  * @created      09.12.2015
  * @created      09.12.2015
- * @package      chillerlan\QRCode
+ * @package      chillerlan\QRCode\Output
  * @author       Smiley <smiley@chillerlan.net>
  * @author       Smiley <smiley@chillerlan.net>
  * @copyright    2015 Smiley
  * @copyright    2015 Smiley
  * @license      MIT
  * @license      MIT
@@ -12,11 +12,6 @@
 
 
 namespace chillerlan\QRCode\Output;
 namespace chillerlan\QRCode\Output;
 
 
-use Exception;
+use chillerlan\QRCode\QRCodeException;
 
 
-/**
- * Placeholder
- */
-class QRCodeOutputException extends Exception{
-
-}
+class QRCodeOutputException extends QRCodeException{}

+ 7 - 2
src/Output/QRImage.php

@@ -15,15 +15,20 @@ namespace chillerlan\QRCode\Output;
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\QRCode;
 
 
 /**
 /**
- * Converts the matrix into images, raw or base64 output
+ * Converts the matrix into GD images, raw or base64 output
+ * requires ext-gd
+ * @link http://php.net/manual/book.image.php
  */
  */
 class QRImage extends QROutputAbstract{
 class QRImage extends QROutputAbstract{
 
 
-	const TRANSPARENCY_TYPES = [
+	protected const TRANSPARENCY_TYPES = [
 		QRCode::OUTPUT_IMAGE_PNG,
 		QRCode::OUTPUT_IMAGE_PNG,
 		QRCode::OUTPUT_IMAGE_GIF,
 		QRCode::OUTPUT_IMAGE_GIF,
 	];
 	];
 
 
+	/**
+	 * @var string
+	 */
 	protected $defaultMode  = QRCode::OUTPUT_IMAGE_PNG;
 	protected $defaultMode  = QRCode::OUTPUT_IMAGE_PNG;
 
 
 	/**
 	/**

+ 0 - 1
src/Output/QRImagick.php

@@ -45,7 +45,6 @@ class QRImagick extends QROutputAbstract{
 	 * @param string|null $file
 	 * @param string|null $file
 	 *
 	 *
 	 * @return string
 	 * @return string
-	 * @throws \chillerlan\QRCode\Output\QRCodeOutputException
 	 */
 	 */
 	public function dump(string $file = null):string{
 	public function dump(string $file = null):string{
 		$file    = $file ?? $this->options->cachefile;
 		$file    = $file ?? $this->options->cachefile;

+ 7 - 4
src/Output/QRMarkup.php

@@ -19,6 +19,9 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class QRMarkup extends QROutputAbstract{
 class QRMarkup extends QROutputAbstract{
 
 
+	/**
+	 * @var string
+	 */
 	protected $defaultMode = QRCode::OUTPUT_MARKUP_SVG;
 	protected $defaultMode = QRCode::OUTPUT_MARKUP_SVG;
 
 
 	/**
 	/**
@@ -43,9 +46,9 @@ class QRMarkup extends QROutputAbstract{
 	}
 	}
 
 
 	/**
 	/**
-	 * @return string|bool
+	 * @return string
 	 */
 	 */
-	protected function html(){
+	protected function html():string{
 		$html = '';
 		$html = '';
 
 
 		foreach($this->matrix->matrix() as $row){
 		foreach($this->matrix->matrix() as $row){
@@ -68,9 +71,9 @@ class QRMarkup extends QROutputAbstract{
 	/**
 	/**
 	 * @link https://github.com/codemasher/php-qrcode/pull/5
 	 * @link https://github.com/codemasher/php-qrcode/pull/5
 	 *
 	 *
-	 * @return string|bool
+	 * @return string
 	 */
 	 */
-	protected function svg(){
+	protected function svg():string{
 		$scale  = $this->options->scale;
 		$scale  = $this->options->scale;
 		$length = $this->moduleCount * $scale;
 		$length = $this->moduleCount * $scale;
 		$matrix = $this->matrix->matrix();
 		$matrix = $this->matrix->matrix();

+ 4 - 4
src/Output/QROutputAbstract.php

@@ -95,22 +95,22 @@ abstract class QROutputAbstract implements QROutputInterface{
 	 * @param string $data
 	 * @param string $data
 	 * @param string $file
 	 * @param string $file
 	 *
 	 *
-	 * @return bool|int
+	 * @return bool
 	 * @throws \chillerlan\QRCode\Output\QRCodeOutputException
 	 * @throws \chillerlan\QRCode\Output\QRCodeOutputException
 	 */
 	 */
-	protected function saveToFile(string $data, string $file) {
+	protected function saveToFile(string $data, string $file):bool{
 
 
 		if(!is_writable(dirname($file))){
 		if(!is_writable(dirname($file))){
 			throw new QRCodeOutputException('Could not write data to cache file: '.$file);
 			throw new QRCodeOutputException('Could not write data to cache file: '.$file);
 		}
 		}
 
 
-		return file_put_contents($file, $data);
+		return (bool)file_put_contents($file, $data);
 	}
 	}
 
 
 	/**
 	/**
 	 * @param string|null $file
 	 * @param string|null $file
 	 *
 	 *
-	 * @return string
+	 * @return string|mixed
 	 */
 	 */
 	public function dump(string $file = null){
 	public function dump(string $file = null){
 		$data = call_user_func([$this, $this->outputMode ?? $this->defaultMode]);
 		$data = call_user_func([$this, $this->outputMode ?? $this->defaultMode]);

+ 3 - 0
src/Output/QRString.php

@@ -19,6 +19,9 @@ use chillerlan\QRCode\QRCode;
  */
  */
 class QRString extends QROutputAbstract{
 class QRString extends QROutputAbstract{
 
 
+	/**
+	 * @var string
+	 */
 	protected $defaultMode = QRCode::OUTPUT_STRING_TEXT;
 	protected $defaultMode = QRCode::OUTPUT_STRING_TEXT;
 
 
 	/**
 	/**

+ 32 - 47
src/QRCode.php

@@ -32,54 +32,47 @@ class QRCode{
 	/**
 	/**
 	 * API constants
 	 * API constants
 	 */
 	 */
-	const OUTPUT_MARKUP_HTML  = 'html';
-	const OUTPUT_MARKUP_SVG   = 'svg';
-#	const OUTPUT_MARKUP_EPS   = 'eps';
-#	const OUTPUT_MARKUP_XML   = 'xml'; // anyone?
-
-	const OUTPUT_IMAGE_PNG    = 'png';
-	const OUTPUT_IMAGE_JPG    = 'jpg';
-	const OUTPUT_IMAGE_GIF    = 'gif';
-
-	const OUTPUT_STRING_JSON  = 'json';
-	const OUTPUT_STRING_TEXT  = 'text';
-
-	const OUTPUT_IMAGICK      = 'imagick';
-
-	const OUTPUT_CUSTOM       = 'custom';
-
-	const VERSION_AUTO        = -1;
-	const MASK_PATTERN_AUTO   = -1;
-
-	const ECC_L         = 0b01; // 7%.
-	const ECC_M         = 0b00; // 15%.
-	const ECC_Q         = 0b11; // 25%.
-	const ECC_H         = 0b10; // 30%.
-
-	const DATA_NUMBER   = 0b0001;
-	const DATA_ALPHANUM = 0b0010;
-	const DATA_BYTE     = 0b0100;
-	const DATA_KANJI    = 0b1000;
-
-	const ECC_MODES = [
+	public const OUTPUT_MARKUP_HTML = 'html';
+	public const OUTPUT_MARKUP_SVG  = 'svg';
+	public const OUTPUT_IMAGE_PNG   = 'png';
+	public const OUTPUT_IMAGE_JPG   = 'jpg';
+	public const OUTPUT_IMAGE_GIF   = 'gif';
+	public const OUTPUT_STRING_JSON = 'json';
+	public const OUTPUT_STRING_TEXT = 'text';
+	public const OUTPUT_IMAGICK     = 'imagick';
+	public const OUTPUT_CUSTOM      = 'custom';
+
+	public const VERSION_AUTO       = -1;
+	public const MASK_PATTERN_AUTO  = -1;
+
+	public const ECC_L         = 0b01; // 7%.
+	public const ECC_M         = 0b00; // 15%.
+	public const ECC_Q         = 0b11; // 25%.
+	public const ECC_H         = 0b10; // 30%.
+
+	public const DATA_NUMBER   = 0b0001;
+	public const DATA_ALPHANUM = 0b0010;
+	public const DATA_BYTE     = 0b0100;
+	public const DATA_KANJI    = 0b1000;
+
+	public const ECC_MODES = [
 		self::ECC_L => 0,
 		self::ECC_L => 0,
 		self::ECC_M => 1,
 		self::ECC_M => 1,
 		self::ECC_Q => 2,
 		self::ECC_Q => 2,
 		self::ECC_H => 3,
 		self::ECC_H => 3,
 	];
 	];
 
 
-	const DATA_MODES = [
+	public const DATA_MODES = [
 		self::DATA_NUMBER   => 0,
 		self::DATA_NUMBER   => 0,
 		self::DATA_ALPHANUM => 1,
 		self::DATA_ALPHANUM => 1,
 		self::DATA_BYTE     => 2,
 		self::DATA_BYTE     => 2,
 		self::DATA_KANJI    => 3,
 		self::DATA_KANJI    => 3,
 	];
 	];
 
 
-	const OUTPUT_MODES = [
+	public const OUTPUT_MODES = [
 		QRMarkup::class => [
 		QRMarkup::class => [
 			self::OUTPUT_MARKUP_SVG,
 			self::OUTPUT_MARKUP_SVG,
 			self::OUTPUT_MARKUP_HTML,
 			self::OUTPUT_MARKUP_HTML,
-#			self::OUTPUT_MARKUP_EPS,
 		],
 		],
 		QRImage::class => [
 		QRImage::class => [
 			self::OUTPUT_IMAGE_PNG,
 			self::OUTPUT_IMAGE_PNG,
@@ -136,10 +129,7 @@ class QRCode{
 	 * @return \chillerlan\QRCode\Data\QRMatrix
 	 * @return \chillerlan\QRCode\Data\QRMatrix
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
-	public function getMatrix(string $data):QRMatrix {
-		// https://github.com/chillerlan/php-qrcode/pull/15
-		// NOTE: input sanitization should be done outside
-		// $data = trim($data);
+	public function getMatrix(string $data):QRMatrix{
 
 
 		if(empty($data)){
 		if(empty($data)){
 			throw new QRCodeDataException('QRCode::getMatrix() No data given.');
 			throw new QRCodeDataException('QRCode::getMatrix() No data given.');
@@ -151,10 +141,7 @@ class QRCode{
 			? $this->getBestMaskPattern()
 			? $this->getBestMaskPattern()
 			: min(7, max(0, (int)$this->options->maskPattern));
 			: min(7, max(0, (int)$this->options->maskPattern));
 
 
-		$matrix = $this
-			->dataInterface
-			->initMatrix($maskPattern)
-		;
+		$matrix = $this->dataInterface->initMatrix($maskPattern);
 
 
 		if((bool)$this->options->addQuietzone){
 		if((bool)$this->options->addQuietzone){
 			$matrix->setQuietZone($this->options->quietzoneSize);
 			$matrix->setQuietZone($this->options->quietzoneSize);
@@ -174,9 +161,7 @@ class QRCode{
 		$penalties = [];
 		$penalties = [];
 
 
 		for($testPattern = 0; $testPattern < 8; $testPattern++){
 		for($testPattern = 0; $testPattern < 8; $testPattern++){
-			$matrix = $this
-				->dataInterface
-				->initMatrix($testPattern, true);
+			$matrix = $this->dataInterface->initMatrix($testPattern, true);
 
 
 			$penalties[$testPattern] = (new MaskPatternTester($matrix))->testPattern();
 			$penalties[$testPattern] = (new MaskPatternTester($matrix))->testPattern();
 		}
 		}
@@ -244,7 +229,7 @@ class QRCode{
 	 *
 	 *
 	 * @return bool
 	 * @return bool
 	 */
 	 */
-	public function isNumber(string $string):bool {
+	public function isNumber(string $string):bool{
 		return $this->checkString($string, Number::CHAR_MAP);
 		return $this->checkString($string, Number::CHAR_MAP);
 	}
 	}
 
 
@@ -255,7 +240,7 @@ class QRCode{
 	 *
 	 *
 	 * @return bool
 	 * @return bool
 	 */
 	 */
-	public function isAlphaNum(string $string):bool {
+	public function isAlphaNum(string $string):bool{
 		return $this->checkString($string, AlphaNum::CHAR_MAP);
 		return $this->checkString($string, AlphaNum::CHAR_MAP);
 	}
 	}
 
 
@@ -286,7 +271,7 @@ class QRCode{
 	 *
 	 *
 	 * @return bool
 	 * @return bool
 	 */
 	 */
-	public function isKanji(string $string):bool {
+	public function isKanji(string $string):bool{
 		$i   = 0;
 		$i   = 0;
 		$len = strlen($string);
 		$len = strlen($string);
 
 

+ 1 - 8
src/QRCodeException.php

@@ -12,11 +12,4 @@
 
 
 namespace chillerlan\QRCode;
 namespace chillerlan\QRCode;
 
 
-use Exception;
-
-/**
- * Placeholder
- */
-class QRCodeException extends Exception{
-
-}
+class QRCodeException extends \Exception{}

+ 1 - 3
tests/Data/DatainterfaceTestAbstract.php

@@ -12,9 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Data;
 namespace chillerlan\QRCodeTest\Data;
 
 
-use chillerlan\QRCode\Data\QRDataInterface;
-use chillerlan\QRCode\Data\QRMatrix;
-use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\{QROptions, Data\QRDataInterface, Data\QRMatrix};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 
 abstract class DatainterfaceTestAbstract extends QRTestAbstract{
 abstract class DatainterfaceTestAbstract extends QRTestAbstract{

+ 1 - 3
tests/Data/MaskPatternTesterTest.php

@@ -12,9 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Data;
 namespace chillerlan\QRCodeTest\Data;
 
 
-use chillerlan\QRCode\Data\Byte;
-use chillerlan\QRCode\Data\MaskPatternTester;
-use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\{QROptions, Data\Byte, Data\MaskPatternTester};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 
 class MaskPatternTesterTest extends QRTestAbstract{
 class MaskPatternTesterTest extends QRTestAbstract{

+ 4 - 4
tests/Data/QRMatrixTest.php

@@ -12,9 +12,9 @@
 
 
 namespace chillerlan\QRCodeTest\Data;
 namespace chillerlan\QRCodeTest\Data;
 
 
-use chillerlan\QRCode\Data\QRMatrix;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QRCode, Data\QRMatrix};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
+use ReflectionClass;
 
 
 class QRMatrixTest extends QRTestAbstract{
 class QRMatrixTest extends QRTestAbstract{
 
 
@@ -104,7 +104,7 @@ class QRMatrixTest extends QRTestAbstract{
 	public function testVersionPattern() {
 	public function testVersionPattern() {
 		foreach (self::VERSION_REF as $version => $mask) {
 		foreach (self::VERSION_REF as $version => $mask) {
 			$hexRef = base_convert(self::VERSION_REF[$version],2 ,16);
 			$hexRef = base_convert(self::VERSION_REF[$version],2 ,16);
-			$hexImpl = dechex(QRMatrix::versionPattern[$version]);
+			$hexImpl = dechex((new ReflectionClass(QRMatrix::class))->getConstant('versionPattern')[$version]);
 
 
 			$this->assertEquals($hexRef, $hexImpl);
 			$this->assertEquals($hexRef, $hexImpl);
 		}
 		}
@@ -157,7 +157,7 @@ class QRMatrixTest extends QRTestAbstract{
 			->setAlignmentPattern()
 			->setAlignmentPattern()
 		;
 		;
 
 
-		$alignmentPattern = QRMatrix::alignmentPattern[$this->version];
+		$alignmentPattern = (new ReflectionClass(QRMatrix::class))->getConstant('alignmentPattern')[$this->version];
 
 
 		foreach($alignmentPattern as $py){
 		foreach($alignmentPattern as $py){
 			foreach($alignmentPattern as $px){
 			foreach($alignmentPattern as $px){

+ 1 - 2
tests/Helpers/BitBufferTest.php

@@ -12,8 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Helpers;
 namespace chillerlan\QRCodeTest\Helpers;
 
 
-use chillerlan\QRCode\Helpers\BitBuffer;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QRCode, Helpers\BitBuffer};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 
 class BitBufferTest extends QRTestAbstract{
 class BitBufferTest extends QRTestAbstract{

+ 7 - 7
tests/Output/QRImageTest.php

@@ -12,8 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Output;
 namespace chillerlan\QRCodeTest\Output;
 
 
-use chillerlan\QRCode\Output\QRImage;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QRCode, Output\QRImage};
 
 
 class QRImageTest extends QROutputTestAbstract{
 class QRImageTest extends QROutputTestAbstract{
 
 
@@ -21,9 +20,9 @@ class QRImageTest extends QROutputTestAbstract{
 
 
 	public function types(){
 	public function types(){
 		return [
 		return [
-			[QRCode::OUTPUT_IMAGE_PNG],
-			[QRCode::OUTPUT_IMAGE_GIF],
-			[QRCode::OUTPUT_IMAGE_JPG],
+			'png' => [QRCode::OUTPUT_IMAGE_PNG],
+			'gif' => [QRCode::OUTPUT_IMAGE_GIF],
+			'jpg' => [QRCode::OUTPUT_IMAGE_JPG],
 		];
 		];
 	}
 	}
 
 
@@ -32,8 +31,9 @@ class QRImageTest extends QROutputTestAbstract{
 	 * @param $type
 	 * @param $type
 	 */
 	 */
 	public function testImageOutput($type){
 	public function testImageOutput($type){
-		$this->options->outputType = $type;
-		$this->options->cachefile  = $this::cachefile.$type;
+		$this->options->outputType  = $type;
+		$this->options->imageBase64 = false;
+
 		$this->setOutputInterface();
 		$this->setOutputInterface();
 		$this->outputInterface->dump($this::cachefile.$type);
 		$this->outputInterface->dump($this::cachefile.$type);
 		$img = $this->outputInterface->dump();
 		$img = $this->outputInterface->dump();

+ 1 - 2
tests/Output/QRMarkupTest.php

@@ -12,8 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Output;
 namespace chillerlan\QRCodeTest\Output;
 
 
-use chillerlan\QRCode\Output\QRMarkup;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QRCode, Output\QRMarkup};
 
 
 class QRMarkupTest extends QROutputTestAbstract{
 class QRMarkupTest extends QROutputTestAbstract{
 
 

+ 1 - 3
tests/Output/QROutputTestAbstract.php

@@ -12,9 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Output;
 namespace chillerlan\QRCodeTest\Output;
 
 
-use chillerlan\QRCode\Data\Byte;
-use chillerlan\QRCode\Output\QROutputInterface;
-use chillerlan\QRCode\QROptions;
+use chillerlan\QRCode\{QROptions, Data\Byte, Output\QROutputInterface};
 use chillerlan\QRCodeTest\QRTestAbstract;
 use chillerlan\QRCodeTest\QRTestAbstract;
 
 
 /**
 /**

+ 1 - 2
tests/Output/QRStringTest.php

@@ -12,8 +12,7 @@
 
 
 namespace chillerlan\QRCodeTest\Output;
 namespace chillerlan\QRCodeTest\Output;
 
 
-use chillerlan\QRCode\Output\QRString;
-use chillerlan\QRCode\QRCode;
+use chillerlan\QRCode\{QRCode, Output\QRString};
 
 
 class QRStringTest extends QROutputTestAbstract{
 class QRStringTest extends QROutputTestAbstract{
 
 

+ 7 - 7
tests/QRCodeTest.php

@@ -50,13 +50,13 @@ class QRCodeTest extends QRTestAbstract{
 
 
 	public function typeDataProvider(){
 	public function typeDataProvider(){
 		return [
 		return [
-			[QRCode::OUTPUT_IMAGE_PNG, 'data:image/png;base64,'],
-			[QRCode::OUTPUT_IMAGE_GIF, 'data:image/gif;base64,'],
-			[QRCode::OUTPUT_IMAGE_JPG, 'data:image/jpg;base64,'],
-			[QRCode::OUTPUT_MARKUP_SVG, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'],
-			[QRCode::OUTPUT_MARKUP_HTML, '<div><span style="background:'],
-			[QRCode::OUTPUT_STRING_TEXT, '⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕'.PHP_EOL],
-			[QRCode::OUTPUT_STRING_JSON, '[[18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18],'],
+			'png'  => [QRCode::OUTPUT_IMAGE_PNG, 'data:image/png;base64,'],
+			'gif'  => [QRCode::OUTPUT_IMAGE_GIF, 'data:image/gif;base64,'],
+			'jpg'  => [QRCode::OUTPUT_IMAGE_JPG, 'data:image/jpg;base64,'],
+			'svg'  => [QRCode::OUTPUT_MARKUP_SVG, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'],
+			'html' => [QRCode::OUTPUT_MARKUP_HTML, '<div><span style="background:'],
+			'text' => [QRCode::OUTPUT_STRING_TEXT, '⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕⭕'.PHP_EOL],
+			'json' => [QRCode::OUTPUT_STRING_JSON, '[[18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18],'],
 		];
 		];
 	}
 	}
 
 

+ 1 - 3
tests/QRTestAbstract.php

@@ -13,9 +13,7 @@
 namespace chillerlan\QRCodeTest;
 namespace chillerlan\QRCodeTest;
 
 
 use PHPUnit\Framework\TestCase;
 use PHPUnit\Framework\TestCase;
-use ReflectionClass;
-use ReflectionMethod;
-use ReflectionProperty;
+use ReflectionClass, ReflectionMethod, ReflectionProperty;
 
 
 abstract class QRTestAbstract extends TestCase{
 abstract class QRTestAbstract extends TestCase{