From 185c95076b5d918dbf7ec1d836feedb35bb45df4 Mon Sep 17 00:00:00 2001 From: smiley Date: Wed, 18 Mar 2026 02:50:29 +0100 Subject: [PATCH] :octocat: DecoderResult: remove property getter in favor of asymmetric visibility --- src/Decoder/DecoderResult.php | 34 ++++++++-------------------------- tests/Data/ECITest.php | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/Decoder/DecoderResult.php b/src/Decoder/DecoderResult.php index 1a4f83a45..d315b1a78 100644 --- a/src/Decoder/DecoderResult.php +++ b/src/Decoder/DecoderResult.php @@ -20,27 +20,18 @@ use function property_exists; * Encapsulates the result of decoding a matrix of bits. This typically * applies to 2D barcode formats. For now, it contains the raw bytes obtained * as well as a String interpretation of those bytes, if applicable. - * - * @property string $data - * @property \chillerlan\QRCode\Common\EccLevel $eccLevel - * @property \chillerlan\QRCode\Detector\FinderPattern[] $finderPatterns - * @property \chillerlan\QRCode\Common\MaskPattern $maskPattern - * @property \chillerlan\QRCode\Common\BitBuffer $rawBytes - * @property int $structuredAppendParity - * @property int $structuredAppendSequence - * @property \chillerlan\QRCode\Common\Version $version */ final class DecoderResult{ - private string $data = ''; - private EccLevel $eccLevel; + private(set) string $data = ''; + private(set) EccLevel $eccLevel; /** @var \chillerlan\QRCode\Detector\FinderPattern[] */ - private array $finderPatterns = []; - private MaskPattern $maskPattern; - private BitBuffer $rawBytes; - private int $structuredAppendParity = -1; - private int $structuredAppendSequence = -1; - private Version $version; + private(set) array $finderPatterns = []; + private(set) MaskPattern $maskPattern; + private(set) BitBuffer $rawBytes; + private(set) int $structuredAppendParity = -1; + private(set) int $structuredAppendSequence = -1; + private(set) Version $version; /** * DecoderResult constructor. @@ -64,15 +55,6 @@ final class DecoderResult{ } - public function __get(string $property):mixed{ - - if(property_exists($this, $property)){ - return $this->{$property}; - } - - return null; - } - public function __toString():string{ return $this->data; } diff --git a/tests/Data/ECITest.php b/tests/Data/ECITest.php index 827c100ef..cf631bb72 100644 --- a/tests/Data/ECITest.php +++ b/tests/Data/ECITest.php @@ -112,7 +112,7 @@ final class ECITest extends TestCase{ $this::assertSame($lengthInBits, $eci->getLengthInBits()); $this::assertSame(Mode::ECI, $bitBuffer->read(4)); - $this::assertSame($id, $eci->parseValue($bitBuffer)->getID()); + $this::assertSame($id, $eci->parseValue($bitBuffer)->charsetID); } /**