:octocat: fix the broken PHPCS config

This commit is contained in:
smiley
2024-07-22 13:32:43 +02:00
parent beecbe7ba5
commit c4ed672a84
28 changed files with 171 additions and 147 deletions
+3 -2
View File
@@ -68,8 +68,9 @@
}
},
"scripts": {
"phpunit": "@php vendor/bin/phpunit",
"phan": "@php vendor/bin/phan"
"phan": "@php vendor/bin/phan",
"phpcs": "@php vendor/bin/phpcs",
"phpunit": "@php vendor/bin/phpunit"
},
"config": {
"lock": false,
+1 -1
View File
@@ -55,7 +55,7 @@ $options->moduleValues = [
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ', __DIR__.'/qrcode.eps');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
// if viewed in the browser, we should push it as file download as EPS isn't usually supported
header('Content-type: application/postscript');
header('Content-Disposition: filename="qrcode.eps"');
+2 -2
View File
@@ -11,7 +11,7 @@ use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QROutputInterface;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__.'/../vendor/autoload.php';
$options = new QROptions;
@@ -53,7 +53,7 @@ $options->moduleValues = [
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: application/pdf');
}
+1 -1
View File
@@ -21,7 +21,7 @@ use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use chillerlan\Settings\SettingsContainerInterface;
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__.'/../vendor/autoload.php';
// --------------------
// Class definition
+2
View File
@@ -75,6 +75,8 @@ class ImagickWithLogoOptions extends QROptions{
*
* of course, we could accept other formats too.
* we're not checking for the file type either for simplicity reasons (assuming PNG)
*
* @throws \chillerlan\QRCode\QRCodeException
*/
protected function set_pngLogo(string $pngLogo):void{
+1 -1
View File
@@ -60,7 +60,7 @@ catch(Throwable $e){
}
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
+1 -1
View File
@@ -286,7 +286,7 @@ $options->svgDefs = '
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
+1 -1
View File
@@ -155,7 +155,7 @@ $out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgX
// dump the output
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('content-type: image/svg+xml');
}
+1 -1
View File
@@ -349,7 +349,7 @@ $options->keepAsSquare = [
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
+1 -1
View File
@@ -143,7 +143,7 @@ $options->svgDefs = '
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
+1 -1
View File
@@ -196,7 +196,7 @@ $options->svgDefs = '
$out = (new QRCode($options))->render('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
if(php_sapi_name() !== 'cli'){
if(PHP_SAPI !== 'cli'){
header('Content-type: image/svg+xml');
if(extension_loaded('zlib')){
+131 -112
View File
@@ -4,40 +4,117 @@
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>php-qrcode rules for phpcs</description>
<!--<file>benchmark</file>-->
<file>examples</file>
<file>src</file>
<file>tests</file>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="tab-width" value="4"/>
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>
<!--
PHPCS built-in https://tentyp.dev/library/php/phpcs/
-->
<rule ref="Generic">
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="Generic.CodeAnalysis.EmptyStatement" />
<exclude name="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
<exclude name="Generic.Commenting.Todo" />
<exclude name="Generic.ControlStructures.InlineControlStructure" />
<exclude name="Generic.Debug" />
<exclude name="Generic.Files.EndFileNoNewline" />
<exclude name="Generic.Files.LowercasedFilename" />
<exclude name="Generic.Formatting.SpaceBeforeCast" />
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman" />
<exclude name="Generic.NamingConventions.AbstractClassNamePrefix" />
<exclude name="Generic.NamingConventions.CamelCapsFunctionName" />
<exclude name="Generic.PHP.ClosingPHPTag" />
<exclude name="Generic.PHP.RequireStrictTypes" />
<exclude name="Generic.PHP.UpperCaseConstant" />
<exclude name="Generic.VersionControl" />
<exclude name="Generic.WhiteSpace.DisallowTabIndent" />
<exclude name="Generic." />
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<!--<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>-->
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Fixme"/>
<!--<rule ref="Generic.Commenting.Todo"/>-->
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<!--<rule ref="Generic.Formatting.MultipleStatementAlignment"/>-->
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.NamingConventions.InterfaceNameSuffix"/>
<rule ref="Generic.NamingConventions.TraitNameSuffix"/>
<rule ref="Generic.PHP.BacktickOperator"/>
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<rule ref="Generic.PHP.DisallowRequestSuperglobal"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.DiscourageGoto"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<rule ref="Generic.PHP.LowerCaseType"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<!--<rule ref="Generic.PHP.RequireStrictTypes"/>-->
<rule ref="Generic.PHP.SAPIUsage"/>
<rule ref="Generic.PHP.Syntax"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<!--<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>-->
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
<rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.Files.ClosingTag"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR12.Classes.AnonClassDeclaration"/>
<rule ref="PSR12.Classes.ClosingBrace"/>
<rule ref="PSR12.Files.OpenTag"/>
<rule ref="PSR12.Functions.NullableTypeDeclaration"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Classes.DuplicateProperty"/>
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
<rule ref="Squiz.Classes.SelfMemberReference"/>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
<rule ref="Squiz.Formatting.OperatorBracket"/>
<rule ref="Squiz.Functions.FunctionDeclaration"/>
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.EchoedStrings"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.PHP.GlobalKeyword">
<exclude-pattern>examples</exclude-pattern>
</rule>
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>examples</exclude-pattern>
<exclude-pattern>benchmark</exclude-pattern>
</rule>
<!--
Configurable built-in https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
-->
<rule ref="Generic.ControlStructures.InlineControlStructure">
<properties>
<property name="error" value="true"/>
@@ -46,10 +123,17 @@
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="130" />
<property name="lineLimit" value="140" />
<property name="absoluteLineLimit" value="160" />
<property name="ignoreComments" value="true" />
</properties>
<exclude-pattern>examples</exclude-pattern>
</rule>
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<rule ref="Generic.PHP.ForbiddenFunctions">
@@ -65,127 +149,62 @@
</properties>
</rule>
<rule ref="Generic.Formatting.SpaceAfterCast">
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="spacing" value="0" />
<property name="allowMultiline" value="true" />
</properties>
</rule>
<rule ref="Generic.Formatting.SpaceAfterNot">
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<properties>
<property name="spacing" value="0" />
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="tabIndent" value="true" />
<property name="ignoreIndentationTokens" type="array">
<element value="T_COMMENT"/>
<element value="T_DOC_COMMENT_OPEN_TAG"/>
</property>
</properties>
</rule>
<rule ref="PEAR">
<exclude name="PEAR.Classes" />
<exclude name="PEAR.Commenting" />
<exclude name="PEAR.ControlStructures" />
<exclude name="PEAR.Functions.FunctionCallSignature" />
<exclude name="PEAR.Functions.FunctionDeclaration" />
<exclude name="PEAR.NamingConventions" />
<exclude name="PEAR.WhiteSpace.ScopeIndent" />
</rule>
<rule ref="PEAR.Commenting.FunctionComment">
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement">
<properties>
<property name="minimumVisibility" value="public" />
<property name="allowOnly" value="first" />
</properties>
</rule>
<rule ref="PSR2">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="PSR2.Classes.ClassDeclaration" />
<exclude name="PSR2.ControlStructures.ControlStructureSpacing" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" />
<exclude name="PSR2.Methods.FunctionClosingBrace" />
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations" />
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse" />
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<type>error</type>
</rule>
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<type>error</type>
</rule>
<rule ref="PSR12">
<exclude name="PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword" />
<exclude name="PSR12.Classes.ClassInstantiation" />
<exclude name="PSR12.Classes.OpeningBraceSpace" />
<exclude name="PSR12.ControlStructures" />
<exclude name="PSR12.Files.FileHeader.SpacingInsideBlock" />
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock" />
<exclude name="PSR12.Functions.ReturnTypeDeclaration" />
<exclude name="PSR12.Operators.OperatorSpacing" />
<exclude name="PSR12.Traits.UseDeclaration.MultipleImport" />
</rule>
<rule ref="PSR12.Namespaces.CompoundNamespaceDepth">
<properties>
<property name="maxDepth" value="1" />
</properties>
</rule>
<rule ref="Squiz">
<exclude name="Squiz.Arrays.ArrayDeclaration.IndexNoNewline" />
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed" />
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
<exclude name="Squiz.Classes.ClassDeclaration" />
<exclude name="Squiz.Commenting" />
<exclude name="Squiz.ControlStructures.ControlSignature" />
<exclude name="Squiz.ControlStructures.ElseIfDeclaration" />
<exclude name="Squiz.ControlStructures.InlineIfDeclaration.NotSingleLine" />
<exclude name="Squiz.ControlStructures.SwitchDeclaration" />
<exclude name="Squiz.Files" />
<exclude name="Squiz.Functions" />
<exclude name="Squiz.NamingConventions.ValidVariableName.NotCamelCaps" />
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
<exclude name="Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps" />
<exclude name="Squiz.Objects.ObjectInstantiation.NotAssigned" />
<exclude name="Squiz.Operators.ComparisonOperatorUsage" />
<exclude name="Squiz.PHP.CommentedOutCode" />
<exclude name="Squiz.PHP.DisallowBooleanStatement" />
<exclude name="Squiz.PHP.DisallowComparisonAssignment" />
<exclude name="Squiz.PHP.DisallowInlineIf" />
<exclude name="Squiz.PHP.EmbeddedPhp" />
<exclude name="Squiz.Strings.ConcatenationSpacing" />
<exclude name="Squiz.WhiteSpace" />
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Squiz.Commenting.EmptyCatchComment" />
<!-- exclude some checks for the examples-->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>examples</exclude-pattern>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>examples</exclude-pattern>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>examples</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
<exclude-pattern>examples</exclude-pattern>
</rule>
<rule ref="Squiz.PHP.DiscouragedFunctions.Discouraged">
<exclude-pattern>examples</exclude-pattern>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="true" />
</properties>
</rule>
</ruleset>
+4 -1
View File
@@ -57,7 +57,10 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
return $this->height;
}
/** @inheritDoc */
/**
* @inheritDoc
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
*/
public function getRow(int $y):array{
if($y < 0 || $y >= $this->getHeight()){
+2
View File
@@ -27,7 +27,9 @@ final class AlphaNum extends QRDataModeAbstract{
* @var int[]
*/
private const CHAR_TO_ORD = [
// phpcs:ignore
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7,
// phpcs:ignore
'8' => 8, '9' => 9, 'A' => 10, 'B' => 11, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15,
'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, 'L' => 21, 'M' => 22, 'N' => 23,
'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, 'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31,
+1
View File
@@ -34,6 +34,7 @@ final class ECI extends QRDataModeAbstract{
/**
* @inheritDoc
* @throws \chillerlan\QRCode\Data\QRCodeDataException
* @noinspection PhpMissingParentConstructorInspection
*/
public function __construct(int $encoding){
+1
View File
@@ -64,6 +64,7 @@ final class Hanzi extends QRDataModeAbstract{
/**
* @inheritDoc
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public static function convertEncoding(string $string):string{
mb_detect_order([mb_internal_encoding(), 'UTF-8', 'GB2312', 'GB18030', 'CP936', 'EUC-CN', 'HZ']);
+1
View File
@@ -57,6 +57,7 @@ final class Kanji extends QRDataModeAbstract{
/**
* @inheritDoc
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public static function convertEncoding(string $string):string{
mb_detect_order([mb_internal_encoding(), 'UTF-8', 'SJIS', 'SJIS-2004']);
+1 -1
View File
@@ -207,7 +207,7 @@ final class QRData{
/**
* creates a BitBuffer and writes the string data to it
*
* @throws \chillerlan\QRCode\QRCodeException on data overflow
* @throws \chillerlan\QRCode\Data\QRCodeDataException on data overflow
*/
private function writeBitBuffer():void{
$MAX_BITS = $this->eccLevel->getMaxBitsForVersion($this->version);
+9 -9
View File
@@ -152,15 +152,15 @@ final class GridSampler{
// no need to try/catch as QRMatrix::set() will silently discard out of bounds values
# try{
for($x = 0; $x < $max; $x += 2){
// Black(-ish) pixel
$bits->set(
intdiv($x, 2),
$y,
$matrix->check((int)$this->points[$x], (int)$this->points[($x + 1)]),
QRMatrix::M_DATA
);
}
for($x = 0; $x < $max; $x += 2){
// Black(-ish) pixel
$bits->set(
intdiv($x, 2),
$y,
$matrix->check((int)$this->points[$x], (int)$this->points[($x + 1)]),
QRMatrix::M_DATA
);
}
# }
# catch(\Throwable $aioobe){//ArrayIndexOutOfBoundsException
// This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
+1 -1
View File
@@ -95,7 +95,7 @@ class QREps extends QROutputAbstract{
// CMYK
? '%f %f %f %f C'
// RGB
:'%f %f %f R';
: '%f %f %f R';
return sprintf($format, ...$values);
}
+1 -1
View File
@@ -110,7 +110,7 @@ class QRFpdf extends QROutputAbstract{
* Initializes an FPDF instance
*/
protected function initFPDF():FPDF{
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
$fpdf = new FPDF('P', $this->options->fpdfMeasureUnit, $this->getOutputDimensions());
$fpdf->AddPage();
return $fpdf;
+1 -1
View File
@@ -27,7 +27,7 @@ class QRStringJSON extends QROutputAbstract{
*/
public function dump(?string $file = null):string{
$matrix = $this->matrix->getMatrix($this->options->jsonAsBooleans);
$data = json_encode($matrix, $this->options->jsonFlags);;
$data = json_encode($matrix, $this->options->jsonFlags);
$this->saveToFile($data, $file);
-4
View File
@@ -462,8 +462,6 @@ class QRCode{
/**
* Reads a QR Code from a given file
*
* @noinspection PhpUndefinedMethodInspection
*/
public function readFromFile(string $path):DecoderResult{
return $this->readFromSource($this->luminanceSourceFQN::fromFile($path, $this->options));
@@ -471,8 +469,6 @@ class QRCode{
/**
* Reads a QR Code from the given data blob
*
* @noinspection PhpUndefinedMethodInspection
*/
public function readFromBlob(string $blob):DecoderResult{
return $this->readFromSource($this->luminanceSourceFQN::fromBlob($blob, $this->options));
-1
View File
@@ -42,7 +42,6 @@ $generator = new class () {
];
}
}
};
$test = new PerformanceTest(100);
-1
View File
@@ -51,7 +51,6 @@ $generator = new class () {
}
}
};
$test = new PerformanceTest(100);
-1
View File
@@ -61,7 +61,6 @@ $generator = new class () {
}
}
};
$test = new PerformanceTest(100);
+2 -1
View File
@@ -60,7 +60,6 @@ $generator = new class () {
}
}
};
$test = new PerformanceTest(100);
@@ -68,12 +67,14 @@ $json = [];
foreach($generator->dataProvider() as $key => [$version, $eccLevel, $dataModeInterface, $dataModeName, $data]){
// invovcation tests the performance of QRData::writeBitBuffer()
// phpcs:ignore
$test->run(fn() => new QRData(new QROptions(['version' => $version, 'eccLevel' => $eccLevel->getLevel()]), [new $dataModeInterface($data)]));
printf('%s encode: % 6.3fms', $key, $test->getResult());
$json[$dataModeName][(string)$eccLevel]['encode'][$version] = $test->getResult();
// writeMatrix includes QRMatrix::writeCodewords() and the ReedSolomonEncoder
// phpcs:ignore
$qrdata = new QRData(new QROptions(['version' => $version, 'eccLevel' => $eccLevel->getLevel()]), [new $dataModeInterface($data)]);
$test->run(fn() => $qrdata->writeMatrix());
+1 -1
View File
@@ -25,7 +25,7 @@ trait QRMaxLengthTrait{
*
* @var int[][][]
*/
private static array $MAX_LENGTH =[
private static array $MAX_LENGTH = [
// v => [NUMERIC => [L, M, Q, H ], ALPHANUM => [L, M, Q, H], BINARY => [L, M, Q, H ], KANJI => [L, M, Q, H ]]
1 => [[ 41, 34, 27, 17], [ 25, 20, 16, 10], [ 17, 14, 11, 7], [ 10, 8, 7, 4]],
2 => [[ 77, 63, 48, 34], [ 47, 38, 29, 20], [ 32, 26, 20, 14], [ 20, 16, 12, 8]],