From edf885823def44e34723e90f76c408e19a29860a Mon Sep 17 00:00:00 2001 From: codemasher Date: Wed, 31 Jul 2019 01:31:33 +0200 Subject: [PATCH] :sparkles: typed properties! --- src/Data/AlphaNum.php | 10 +- src/Data/Byte.php | 10 +- src/Data/Kanji.php | 10 +- src/Data/MaskPatternTester.php | 10 +- src/Data/Number.php | 10 +- src/Data/QRDataAbstract.php | 39 ++------ src/Data/QRMatrix.php | 27 ++---- src/Helpers/BitBuffer.php | 11 +-- src/Helpers/Polynomial.php | 5 +- src/Output/QRImage.php | 5 +- src/Output/QRMarkup.php | 5 +- src/Output/QROutputAbstract.php | 42 ++------- src/Output/QRString.php | 5 +- src/QRCode.php | 6 +- src/QROptionsTrait.php | 114 ++++++----------------- tests/Data/AlphaNumTest.php | 8 +- tests/Data/ByteTest.php | 8 +- tests/Data/DatainterfaceTestAbstract.php | 10 +- tests/Data/KanjiTest.php | 8 +- tests/Data/MaskPatternTesterTest.php | 2 +- tests/Data/NumberTest.php | 8 +- tests/Data/QRMatrixTest.php | 9 +- tests/Helpers/BitBufferTest.php | 5 +- tests/Helpers/PolynomialTest.php | 5 +- tests/Output/QRImageTest.php | 2 +- tests/Output/QRImagickTest.php | 2 +- tests/Output/QRMarkupTest.php | 2 +- tests/Output/QROutputTestAbstract.php | 22 ++--- tests/Output/QRStringTest.php | 2 +- tests/QRCodeTest.php | 2 +- tests/QROptionsTest.php | 7 +- tests/QRTestAbstract.php | 10 +- 32 files changed, 122 insertions(+), 299 deletions(-) diff --git a/src/Data/AlphaNum.php b/src/Data/AlphaNum.php index f3ad0dbb8..69086bde0 100644 --- a/src/Data/AlphaNum.php +++ b/src/Data/AlphaNum.php @@ -19,15 +19,9 @@ use chillerlan\QRCode\QRCode; */ class AlphaNum extends QRDataAbstract{ - /** - * @inheritdoc - */ - protected $datamode = QRCode::DATA_ALPHANUM; + protected int $datamode = QRCode::DATA_ALPHANUM; - /** - * @inheritdoc - */ - protected $lengthBits = [9, 11, 13]; + protected array $lengthBits = [9, 11, 13]; /** * @inheritdoc diff --git a/src/Data/Byte.php b/src/Data/Byte.php index bb5f33d1b..acf22ce9f 100644 --- a/src/Data/Byte.php +++ b/src/Data/Byte.php @@ -19,15 +19,9 @@ use chillerlan\QRCode\QRCode; */ class Byte extends QRDataAbstract{ - /** - * @inheritdoc - */ - protected $datamode = QRCode::DATA_BYTE; + protected int $datamode = QRCode::DATA_BYTE; - /** - * @inheritdoc - */ - protected $lengthBits = [8, 16, 16]; + protected array $lengthBits = [8, 16, 16]; /** * @inheritdoc diff --git a/src/Data/Kanji.php b/src/Data/Kanji.php index e5c01dfaa..5fa3e501e 100644 --- a/src/Data/Kanji.php +++ b/src/Data/Kanji.php @@ -19,15 +19,9 @@ use chillerlan\QRCode\QRCode; */ class Kanji extends QRDataAbstract{ - /** - * @inheritdoc - */ - protected $datamode = QRCode::DATA_KANJI; + protected int $datamode = QRCode::DATA_KANJI; - /** - * @inheritdoc - */ - protected $lengthBits = [8, 10, 12]; + protected array $lengthBits = [8, 10, 12]; /** * @inheritdoc diff --git a/src/Data/MaskPatternTester.php b/src/Data/MaskPatternTester.php index 1a91de8ed..9e2966c3a 100644 --- a/src/Data/MaskPatternTester.php +++ b/src/Data/MaskPatternTester.php @@ -19,15 +19,9 @@ namespace chillerlan\QRCode\Data; */ class MaskPatternTester{ - /** - * @var \chillerlan\QRCode\Data\QRMatrix - */ - protected $matrix; + protected QRMatrix $matrix; - /** - * @var int - */ - protected $moduleCount; + protected int $moduleCount; /** * Receives the matrix an sets the module count diff --git a/src/Data/Number.php b/src/Data/Number.php index fc21a0029..3e9199da9 100644 --- a/src/Data/Number.php +++ b/src/Data/Number.php @@ -19,15 +19,9 @@ use chillerlan\QRCode\QRCode; */ class Number extends QRDataAbstract{ - /** - * @inheritdoc - */ - protected $datamode = QRCode::DATA_NUMBER; + protected int $datamode = QRCode::DATA_NUMBER; - /** - * @inheritdoc - */ - protected $lengthBits = [10, 12, 14]; + protected array $lengthBits = [10, 12, 14]; /** * @inheritdoc diff --git a/src/Data/QRDataAbstract.php b/src/Data/QRDataAbstract.php index a26b4c0b9..e658f3786 100644 --- a/src/Data/QRDataAbstract.php +++ b/src/Data/QRDataAbstract.php @@ -23,62 +23,43 @@ abstract class QRDataAbstract implements QRDataInterface{ /** * the string byte count - * - * @var int */ - protected $strlen; + protected ?int $strlen = null; /** * the current data mode: Num, Alphanum, Kanji, Byte - * - * @var int */ - protected $datamode; + protected int $datamode; /** * mode length bits for the version breakpoints 1-9, 10-26 and 27-40 - * - * @var array */ - protected $lengthBits = [0, 0, 0]; + protected array $lengthBits = [0, 0, 0]; /** * current QR Code version - * - * @var int */ - protected $version; + protected int $version; /** * the raw data that's being passed to QRMatrix::mapData() - * - * @var array */ - protected $matrixdata; + protected array $matrixdata; /** * ECC temp data - * - * @var array */ - protected $ecdata; + protected array $ecdata; /** * ECC temp data - * - * @var array */ - protected $dcdata; + protected array $dcdata; - /** - * @var \chillerlan\QRCode\QROptions - */ - protected $options; + /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ + protected SettingsContainerInterface $options; - /** - * @var \chillerlan\QRCode\Helpers\BitBuffer - */ - protected $bitBuffer; + protected BitBuffer $bitBuffer; /** * QRDataInterface constructor. diff --git a/src/Data/QRMatrix.php b/src/Data/QRMatrix.php index 9ea5ac7c4..3fc908e63 100755 --- a/src/Data/QRMatrix.php +++ b/src/Data/QRMatrix.php @@ -167,30 +167,15 @@ class QRMatrix{ ], ]; - /** - * @var int - */ - protected $version; + protected int $version; - /** - * @var int - */ - protected $eclevel; + protected int $eclevel; - /** - * @var int - */ - protected $maskPattern = QRCode::MASK_PATTERN_AUTO; + protected int $maskPattern = QRCode::MASK_PATTERN_AUTO; - /** - * @var int - */ - protected $moduleCount; - - /** - * @var mixed[] - */ - protected $matrix; + protected int $moduleCount; + /** @var mixed[] */ + protected array $matrix; /** * QRMatrix constructor. diff --git a/src/Helpers/BitBuffer.php b/src/Helpers/BitBuffer.php index cd35fd60e..97f3783f0 100644 --- a/src/Helpers/BitBuffer.php +++ b/src/Helpers/BitBuffer.php @@ -14,15 +14,10 @@ namespace chillerlan\QRCode\Helpers; class BitBuffer{ - /** - * @var int[] - */ - public $buffer = []; + /** @var int[] */ + public array $buffer = []; - /** - * @var int - */ - public $length = 0; + public int $length = 0; /** * @return \chillerlan\QRCode\Helpers\BitBuffer diff --git a/src/Helpers/Polynomial.php b/src/Helpers/Polynomial.php index e032dab87..77bbe837a 100644 --- a/src/Helpers/Polynomial.php +++ b/src/Helpers/Polynomial.php @@ -57,10 +57,7 @@ class Polynomial{ [ 27, 116], [ 54, 214], [108, 244], [216, 234], [173, 168], [ 71, 80], [142, 88], [ 1, 175], ]; - /** - * @var array - */ - protected $num = []; + protected array $num = []; /** * Polynomial constructor. diff --git a/src/Output/QRImage.php b/src/Output/QRImage.php index 52531e144..427c408e3 100644 --- a/src/Output/QRImage.php +++ b/src/Output/QRImage.php @@ -26,10 +26,7 @@ class QRImage extends QROutputAbstract{ QRCode::OUTPUT_IMAGE_GIF, ]; - /** - * @var string - */ - protected $defaultMode = QRCode::OUTPUT_IMAGE_PNG; + protected string $defaultMode = QRCode::OUTPUT_IMAGE_PNG; /** * @see imagecreatetruecolor() diff --git a/src/Output/QRMarkup.php b/src/Output/QRMarkup.php index b970850ca..4b2ebc8af 100644 --- a/src/Output/QRMarkup.php +++ b/src/Output/QRMarkup.php @@ -19,10 +19,7 @@ use chillerlan\QRCode\QRCode; */ class QRMarkup extends QROutputAbstract{ - /** - * @var string - */ - protected $defaultMode = QRCode::OUTPUT_MARKUP_SVG; + protected string $defaultMode = QRCode::OUTPUT_MARKUP_SVG; /** * @see \sprintf() diff --git a/src/Output/QROutputAbstract.php b/src/Output/QROutputAbstract.php index 3e0736262..e52129574 100644 --- a/src/Output/QROutputAbstract.php +++ b/src/Output/QROutputAbstract.php @@ -20,45 +20,21 @@ use chillerlan\Settings\SettingsContainerInterface; */ abstract class QROutputAbstract implements QROutputInterface{ - /** - * @var int - */ - protected $moduleCount; + protected int $moduleCount; - /** - * @param \chillerlan\QRCode\Data\QRMatrix $matrix - */ - protected $matrix; + protected QRMatrix $matrix; + /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ + protected SettingsContainerInterface $options; - /** - * @var \chillerlan\QRCode\QROptions - */ - protected $options; + protected string $outputMode; - /** - * @var string - */ - protected $outputMode; + protected string $defaultMode; - /** - * @var string; - */ - protected $defaultMode; + protected int $scale; - /** - * @var int - */ - protected $scale; + protected int $length; - /** - * @var int - */ - protected $length; - - /** - * @var array - */ - protected $moduleValues; + protected array $moduleValues; /** * QROutputAbstract constructor. diff --git a/src/Output/QRString.php b/src/Output/QRString.php index 4fb4cdeed..987d4cbd0 100644 --- a/src/Output/QRString.php +++ b/src/Output/QRString.php @@ -19,10 +19,7 @@ use chillerlan\QRCode\QRCode; */ class QRString extends QROutputAbstract{ - /** - * @var string - */ - protected $defaultMode = QRCode::OUTPUT_STRING_TEXT; + protected string $defaultMode = QRCode::OUTPUT_STRING_TEXT; /** * @return void diff --git a/src/QRCode.php b/src/QRCode.php index 55774e41b..05da70393 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -91,18 +91,18 @@ class QRCode{ /** * @var \chillerlan\QRCode\QROptions */ - protected $options; + protected QROptions $options; /** * @var \chillerlan\QRCode\Data\QRDataInterface */ - protected $dataInterface; + protected QRDataInterface $dataInterface; /** * @see http://php.net/manual/function.mb-internal-encoding.php * @var string */ - protected $mbCurrentEncoding; + protected string $mbCurrentEncoding; /** * QRCode constructor. diff --git a/src/QROptionsTrait.php b/src/QROptionsTrait.php index a1d7fcfe0..c7bd793d7 100644 --- a/src/QROptionsTrait.php +++ b/src/QROptionsTrait.php @@ -17,25 +17,19 @@ trait QROptionsTrait{ /** * QR Code version number * - * [1 ... 40] or QRCode::VERSION_AUTO - * - * @var int + * [1 ... 40] or QRCode::VERSION_AUTO */ - protected $version = QRCode::VERSION_AUTO; + protected int $version = QRCode::VERSION_AUTO; /** * Minimum QR version (if $version = QRCode::VERSION_AUTO) - * - * @var int */ - protected $versionMin = 1; + protected int $versionMin = 1; /** * Maximum QR version - * - * @var int */ - protected $versionMax = 40; + protected int $versionMax = 40; /** * Error correct level @@ -45,97 +39,73 @@ trait QROptionsTrait{ * M => 15% * Q => 25% * H => 30% - * - * @var int */ - protected $eccLevel = QRCode::ECC_L; + protected int $eccLevel = QRCode::ECC_L; /** * Mask Pattern to use * * [0...7] or QRCode::MASK_PATTERN_AUTO - * - * @var int */ - protected $maskPattern = QRCode::MASK_PATTERN_AUTO; + protected int $maskPattern = QRCode::MASK_PATTERN_AUTO; /** * Add a "quiet zone" (margin) according to the QR code spec - * - * @var bool */ - protected $addQuietzone = true; + protected bool $addQuietzone = true; /** * Size of the quiet zone * * internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules - * - * @var int */ - protected $quietzoneSize = 4; + protected int $quietzoneSize = 4; /** * QRCode::OUTPUT_MARKUP_XXXX where XXXX = HTML, SVG * QRCode::OUTPUT_IMAGE_XXX where XXX = PNG, GIF, JPG * QRCode::OUTPUT_STRING_XXXX where XXXX = TEXT, JSON * QRCode::OUTPUT_CUSTOM - * - * @var string */ - protected $outputType = QRCode::OUTPUT_IMAGE_PNG; + protected string $outputType = QRCode::OUTPUT_IMAGE_PNG; /** * the FQCN of the custom QROutputInterface if $outputType is set to QRCode::OUTPUT_CUSTOM - * - * @var string */ - protected $outputInterface; + protected string $outputInterface; /** * /path/to/cache.file - * - * @var string */ - protected $cachefile; + protected string $cachefile; /** * newline string [HTML, SVG, TEXT] - * - * @var string */ - protected $eol = PHP_EOL; + protected string $eol = PHP_EOL; /** * size of a QR code pixel [SVG, IMAGE_*] * HTML -> via CSS - * - * @var int */ - protected $scale = 5; + protected int $scale = 5; /** * a common css class - * - * @var string */ - protected $cssClass; + protected string $cssClass; /** * SVG opacity - * - * @var float */ - protected $svgOpacity = 1.0; + protected float $svgOpacity = 1.0; /** * anything between * * @see https://developer.mozilla.org/docs/Web/SVG/Element/defs - * - * @var string */ - protected $svgDefs = ''; + protected string $svgDefs = ''; /** * SVG viewBox size. a single integer number which defines width/height of the viewBox attribute. @@ -143,101 +113,77 @@ trait QROptionsTrait{ * viewBox="0 0 x x" * * @see https://css-tricks.com/scale-svg/#article-header-id-3 - * - * @var int */ - protected $svgViewBoxSize; + protected int $svgViewBoxSize; /** * string substitute for dark - * - * @var string */ - protected $textDark = '🔴'; + protected string $textDark = '🔴'; /** * string substitute for light - * - * @var string */ - protected $textLight = '⭕'; + protected string $textLight = '⭕'; /** * markup substitute for dark (CSS value) - * - * @var string */ - protected $markupDark = '#000'; + protected string $markupDark = '#000'; /** * markup substitute for light (CSS value) - * - * @var string */ - protected $markupLight = '#fff'; + protected string $markupLight = '#fff'; /** * toggle base64 or raw image data - * - * @var bool */ - protected $imageBase64 = true; + protected bool $imageBase64 = true; /** * toggle transparency, not supported by jpg - * - * @var bool */ - protected $imageTransparent = true; + protected bool $imageTransparent = true; /** * @see imagecolortransparent() * - * @var array [R, G, B] + * [R, G, B] */ - protected $imageTransparencyBG = [255, 255, 255]; + protected array $imageTransparencyBG = [255, 255, 255]; /** * @see imagepng() - * - * @var int */ - protected $pngCompression = -1; + protected int $pngCompression = -1; /** * @see imagejpeg() - * - * @var int */ - protected $jpegQuality = 85; + protected int $jpegQuality = 85; /** * Imagick output format * * @see Imagick::setType() - * - * @var string */ - protected $imagickFormat = 'png'; + protected string $imagickFormat = 'png'; /** * Imagick background color (defaults to "transparent") * * @see \ImagickPixel::__construct() - * - * @var string */ - protected $imagickBG; + protected string $imagickBG; /** * Module values map * * HTML, IMAGICK: #ABCDEF, cssname, rgb(), rgba()... * IMAGE: [63, 127, 255] // R, G, B - * - * @var array */ - protected $moduleValues; + protected array $moduleValues; /** * set/clamp some special values, call the parent setter otherwise diff --git a/tests/Data/AlphaNumTest.php b/tests/Data/AlphaNumTest.php index c29b1f639..ae3981c0a 100644 --- a/tests/Data/AlphaNumTest.php +++ b/tests/Data/AlphaNumTest.php @@ -16,9 +16,11 @@ use chillerlan\QRCode\Data\{AlphaNum, QRCodeDataException}; class AlphaNumTest extends DatainterfaceTestAbstract{ - protected $FQCN = AlphaNum::class; - protected $testdata = '0 $%*+-./:'; - protected $expected = [ + protected string $FQCN = AlphaNum::class; + + protected string $testdata = '0 $%*+-./:'; + + protected array $expected = [ 32, 80, 36, 212, 252, 15, 175, 251, 176, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, diff --git a/tests/Data/ByteTest.php b/tests/Data/ByteTest.php index cbfe1fab2..270ac46b8 100644 --- a/tests/Data/ByteTest.php +++ b/tests/Data/ByteTest.php @@ -16,9 +16,11 @@ use chillerlan\QRCode\Data\Byte; class ByteTest extends DatainterfaceTestAbstract{ - protected $FQCN = Byte::class; - protected $testdata = '[¯\_(ツ)_/¯]'; - protected $expected = [ + protected string $FQCN = Byte::class; + + protected string $testdata = '[¯\_(ツ)_/¯]'; + + protected array $expected = [ 64, 245, 188, 42, 245, 197, 242, 142, 56, 56, 66, 149, 242, 252, 42, 245, 208, 236, 17, 236, 17, 236, 17, 236, diff --git a/tests/Data/DatainterfaceTestAbstract.php b/tests/Data/DatainterfaceTestAbstract.php index 19d74617a..af1cddbb2 100644 --- a/tests/Data/DatainterfaceTestAbstract.php +++ b/tests/Data/DatainterfaceTestAbstract.php @@ -18,13 +18,11 @@ use chillerlan\QRCodeTest\QRTestAbstract; abstract class DatainterfaceTestAbstract extends QRTestAbstract{ - /** - * @var \chillerlan\QRCode\Data\QRDataAbstract - */ - protected $dataInterface; + protected QRDataInterface $dataInterface; - protected $testdata; - protected $expected; + protected string $testdata; + + protected array $expected; protected function setUp():void{ parent::setUp(); diff --git a/tests/Data/KanjiTest.php b/tests/Data/KanjiTest.php index 108b8fed7..8677dd5b9 100644 --- a/tests/Data/KanjiTest.php +++ b/tests/Data/KanjiTest.php @@ -16,9 +16,11 @@ use chillerlan\QRCode\Data\{Kanji, QRCodeDataException}; class KanjiTest extends DatainterfaceTestAbstract{ - protected $FQCN = Kanji::class; - protected $testdata = '茗荷茗荷茗荷茗荷茗荷'; - protected $expected = [ + protected string $FQCN = Kanji::class; + + protected string $testdata = '茗荷茗荷茗荷茗荷茗荷'; + + protected array $expected = [ 128, 173, 85, 26, 95, 85, 70, 151, 213, 81, 165, 245, 84, 105, 125, 85, 26, 92, 0, 236, 17, 236, 17, 236, diff --git a/tests/Data/MaskPatternTesterTest.php b/tests/Data/MaskPatternTesterTest.php index 208ff4160..edf589b50 100644 --- a/tests/Data/MaskPatternTesterTest.php +++ b/tests/Data/MaskPatternTesterTest.php @@ -17,7 +17,7 @@ use chillerlan\QRCodeTest\QRTestAbstract; class MaskPatternTesterTest extends QRTestAbstract{ - protected $FQCN = MaskPatternTester::class; + protected string $FQCN = MaskPatternTester::class; // coverage public function testMaskpattern(){ diff --git a/tests/Data/NumberTest.php b/tests/Data/NumberTest.php index 983346a34..fb5ee89e2 100644 --- a/tests/Data/NumberTest.php +++ b/tests/Data/NumberTest.php @@ -16,9 +16,11 @@ use chillerlan\QRCode\Data\{Number, QRCodeDataException}; class NumberTest extends DatainterfaceTestAbstract{ - protected $FQCN = Number::class; - protected $testdata = '0123456789'; - protected $expected = [ + protected string $FQCN = Number::class; + + protected string $testdata = '0123456789'; + + protected array $expected = [ 16, 40, 12, 86, 106, 105, 0, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, diff --git a/tests/Data/QRMatrixTest.php b/tests/Data/QRMatrixTest.php index d077aafe3..22724288e 100755 --- a/tests/Data/QRMatrixTest.php +++ b/tests/Data/QRMatrixTest.php @@ -19,14 +19,11 @@ use ReflectionClass; class QRMatrixTest extends QRTestAbstract{ - protected $FQCN = QRMatrix::class; + protected string $FQCN = QRMatrix::class; - protected $version = 7; + protected int $version = 7; - /** - * @var \chillerlan\QRCode\Data\QRMatrix - */ - protected $matrix; + protected QRMatrix $matrix; protected function setUp():void{ parent::setUp(); diff --git a/tests/Helpers/BitBufferTest.php b/tests/Helpers/BitBufferTest.php index 25d1c3504..0dcd60f13 100644 --- a/tests/Helpers/BitBufferTest.php +++ b/tests/Helpers/BitBufferTest.php @@ -17,10 +17,7 @@ use chillerlan\QRCodeTest\QRTestAbstract; class BitBufferTest extends QRTestAbstract{ - /** - * @var \chillerlan\QRCode\Helpers\BitBuffer - */ - protected $bitBuffer; + protected BitBuffer $bitBuffer; protected function setUp():void{ $this->bitBuffer = new BitBuffer; diff --git a/tests/Helpers/PolynomialTest.php b/tests/Helpers/PolynomialTest.php index 7f6da303c..0ceb76923 100644 --- a/tests/Helpers/PolynomialTest.php +++ b/tests/Helpers/PolynomialTest.php @@ -18,10 +18,7 @@ use chillerlan\QRCodeTest\QRTestAbstract; class PolynomialTest extends QRTestAbstract{ - /** - * @var \chillerlan\QRCode\Helpers\Polynomial - */ - protected $polynomial; + protected Polynomial $polynomial; protected function setUp():void{ $this->polynomial = new Polynomial; diff --git a/tests/Output/QRImageTest.php b/tests/Output/QRImageTest.php index bc2d9685b..9a2f751a2 100644 --- a/tests/Output/QRImageTest.php +++ b/tests/Output/QRImageTest.php @@ -16,7 +16,7 @@ use chillerlan\QRCode\{QRCode, Output\QRImage}; class QRImageTest extends QROutputTestAbstract{ - protected $FQCN = QRImage::class; + protected string $FQCN = QRImage::class; public function types(){ return [ diff --git a/tests/Output/QRImagickTest.php b/tests/Output/QRImagickTest.php index 224fcc69f..d8a6782dd 100644 --- a/tests/Output/QRImagickTest.php +++ b/tests/Output/QRImagickTest.php @@ -16,7 +16,7 @@ use chillerlan\QRCode\{QRCode, Output\QRImagick}; class QRImagickTest extends QROutputTestAbstract{ - protected $FQCN = QRImagick::class; + protected string $FQCN = QRImagick::class; public function setUp():void{ diff --git a/tests/Output/QRMarkupTest.php b/tests/Output/QRMarkupTest.php index ef05c6b79..c8f6181c6 100644 --- a/tests/Output/QRMarkupTest.php +++ b/tests/Output/QRMarkupTest.php @@ -16,7 +16,7 @@ use chillerlan\QRCode\{QRCode, Output\QRMarkup}; class QRMarkupTest extends QROutputTestAbstract{ - protected $FQCN = QRMarkup::class; + protected string $FQCN = QRMarkup::class; public function types(){ return [ diff --git a/tests/Output/QROutputTestAbstract.php b/tests/Output/QROutputTestAbstract.php index 3a44a3349..276a3613e 100644 --- a/tests/Output/QROutputTestAbstract.php +++ b/tests/Output/QROutputTestAbstract.php @@ -13,30 +13,22 @@ namespace chillerlan\QRCodeTest\Output; use chillerlan\QRCode\QROptions; -use chillerlan\QRCode\Data\Byte; +use chillerlan\QRCode\Data\{Byte, QRMatrix}; use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface}; use chillerlan\QRCodeTest\QRTestAbstract; +use chillerlan\Settings\SettingsContainerInterface; /** */ abstract class QROutputTestAbstract extends QRTestAbstract{ - const cachefile = __DIR__.'/output_test.'; + protected const cachefile = __DIR__.'/output_test.'; - /** - * @var \chillerlan\QRCode\Output\QROutputInterface - */ - protected $outputInterface; + protected QROutputInterface $outputInterface; + /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ + protected SettingsContainerInterface $options; - /** - * @var \chillerlan\QRCode\QROptions - */ - protected $options; - - /** - * @var \chillerlan\QRCode\Data\QRMatrix - */ - protected $matrix; + protected QRMatrix $matrix; protected function setUp():void{ parent::setUp(); diff --git a/tests/Output/QRStringTest.php b/tests/Output/QRStringTest.php index 5dbd34010..5be6d3488 100644 --- a/tests/Output/QRStringTest.php +++ b/tests/Output/QRStringTest.php @@ -16,7 +16,7 @@ use chillerlan\QRCode\{QRCode, Output\QRString}; class QRStringTest extends QROutputTestAbstract{ - protected $FQCN = QRString::class; + protected string $FQCN = QRString::class; public function types(){ return [ diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index ce311edf5..3f4c59a70 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -19,7 +19,7 @@ use chillerlan\QRCodeExamples\MyCustomOutput; class QRCodeTest extends QRTestAbstract{ - protected $FQCN = QRCode::class; + protected string $FQCN = QRCode::class; /** * @var \chillerlan\QRCode\QRCode diff --git a/tests/QROptionsTest.php b/tests/QROptionsTest.php index 41bf69ced..440ea410c 100644 --- a/tests/QROptionsTest.php +++ b/tests/QROptionsTest.php @@ -12,15 +12,14 @@ namespace chillerlan\QRCodeTest; +use chillerlan\Settings\SettingsContainerInterface; use chillerlan\QRCode\{QRCode, QRCodeException, QROptions}; use PHPUnit\Framework\TestCase; class QROptionsTest extends TestCase{ - /** - * @var \chillerlan\QRCode\QROptions - */ - protected $options; + /** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\QRCode\QROptions */ + protected SettingsContainerInterface $options; public function testVersionClamp(){ $this->assertSame(40, (new QROptions(['version' => 42]))->version); diff --git a/tests/QRTestAbstract.php b/tests/QRTestAbstract.php index 7b9eb8049..a1030ca11 100644 --- a/tests/QRTestAbstract.php +++ b/tests/QRTestAbstract.php @@ -17,15 +17,9 @@ use ReflectionClass, ReflectionMethod, ReflectionProperty; abstract class QRTestAbstract extends TestCase{ - /** - * @var \ReflectionClass - */ - protected $reflection; + protected ReflectionClass $reflection; - /** - * @var string - */ - protected $FQCN; + protected string $FQCN; protected function setUp():void{ $this->reflection = new ReflectionClass($this->FQCN);