Forráskód Böngészése

:fire: phan v6-dev

smiley 1 hónapja
szülő
commit
22e6c4b75f

+ 1 - 1
.github/workflows/ci.yml

@@ -32,7 +32,7 @@ jobs:
           - "8.2"
           - "8.2"
           - "8.3"
           - "8.3"
           - "8.4"
           - "8.4"
-#          - "8.5"
+          - "8.5"
 
 
     steps:
     steps:
       - name: "Checkout"
       - name: "Checkout"

+ 1 - 1
composer.json

@@ -55,7 +55,7 @@
 		"ext-fileinfo": "*",
 		"ext-fileinfo": "*",
 		"chillerlan/php-authenticator": "^5.2.1",
 		"chillerlan/php-authenticator": "^5.2.1",
 		"intervention/image": "^3.11",
 		"intervention/image": "^3.11",
-		"phan/phan": "^5.5.2",
+		"phan/phan": "v6.x-dev",
 		"phpbench/phpbench": "^1.4",
 		"phpbench/phpbench": "^1.4",
 		"phpunit/phpunit": "^11.5",
 		"phpunit/phpunit": "^11.5",
 		"phpmd/phpmd": "^2.15",
 		"phpmd/phpmd": "^2.15",

+ 11 - 11
examples/qrcode-interactive.php

@@ -23,6 +23,15 @@ function sendResponse(array $response):never{
 	exit;
 	exit;
 }
 }
 
 
+function parseHexValue(string $v):array|string|null{
+	if(preg_match('/[a-f\d]{6}/i', $v) === 1){
+		return in_array($_POST['output_type'], ['png', 'jpg', 'gif'], true)
+			? array_map('hexdec', str_split($v, 2))
+			: '#'.$v ;
+	}
+	return null;
+}
+
 try{
 try{
 
 
 	$moduleValues = [
 	$moduleValues = [
@@ -55,16 +64,6 @@ try{
 		QRMatrix::M_LOGO           => $_POST['m_logo_light'],
 		QRMatrix::M_LOGO           => $_POST['m_logo_light'],
 	];
 	];
 
 
-	$moduleValues = array_map(function($v){
-		if(preg_match('/[a-f\d]{6}/i', $v) === 1){
-			return in_array($_POST['output_type'], ['png', 'jpg', 'gif'], true)
-				? array_map('hexdec', str_split($v, 2))
-				: '#'.$v ;
-		}
-		return null;
-	}, $moduleValues);
-
-
 	$ecc = in_array($_POST['ecc'], ['L', 'M', 'Q', 'H'], true) ? $_POST['ecc'] : 'L';
 	$ecc = in_array($_POST['ecc'], ['L', 'M', 'Q', 'H'], true) ? $_POST['ecc'] : 'L';
 
 
 	$options = new QROptions([
 	$options = new QROptions([
@@ -73,7 +72,8 @@ try{
 		'maskPattern'      => (int)$_POST['maskpattern'],
 		'maskPattern'      => (int)$_POST['maskpattern'],
 		'addQuietzone'     => isset($_POST['quietzone']),
 		'addQuietzone'     => isset($_POST['quietzone']),
 		'quietzoneSize'    => (int)$_POST['quietzonesize'],
 		'quietzoneSize'    => (int)$_POST['quietzonesize'],
-		'moduleValues'     => $moduleValues,
+		/** @phan-suppress-next-line PhanTypeMismatchArgument (false positive) */
+		'moduleValues'     => array_map(parseHexValue(...), $moduleValues),
 		'outputType'       => $_POST['output_type'],
 		'outputType'       => $_POST['output_type'],
 		'scale'            => (int)$_POST['scale'],
 		'scale'            => (int)$_POST['scale'],
 		'outputBase64'     => true,
 		'outputBase64'     => true,

+ 4 - 3
tests/QRCodeReaderTestAbstract.php

@@ -172,14 +172,15 @@ abstract class QRCodeReaderTestAbstract extends TestCase{
 			$qrcode    = new QRCode($this->options);
 			$qrcode    = new QRCode($this->options);
 			$imagedata = $qrcode->render($expected);
 			$imagedata = $qrcode->render($expected);
 			$result    = $qrcode->readFromBlob($imagedata);
 			$result    = $qrcode->readFromBlob($imagedata);
+
+			$this::assertSame($expected, $result->data);
+			$this::assertSame($version->getVersionNumber(), $result->version->getVersionNumber());
+			$this::assertSame($ecc->getLevel(), $result->eccLevel->getLevel());
 		}
 		}
 		catch(Exception $e){
 		catch(Exception $e){
 			$this::markTestSkipped(sprintf('skipped version %s%s: %s', $version, $ecc, $e->getMessage()));
 			$this::markTestSkipped(sprintf('skipped version %s%s: %s', $version, $ecc, $e->getMessage()));
 		}
 		}
 
 
-		$this::assertSame($expected, $result->data);
-		$this::assertSame($version->getVersionNumber(), $result->version->getVersionNumber());
-		$this::assertSame($ecc->getLevel(), $result->eccLevel->getLevel());
 	}
 	}
 
 
 }
 }