Skip to content

Commit b2f95a2

Browse files
committed
Upgrade to PHP 8.3+ and implement typed constants and Override attributes
- Update minimum PHP version from 8.2 to 8.3 in composer.json - Update CI workflow to test PHP 8.3, 8.4, and 8.5 - Add typed class constants (PHP 8.3 feature) to all Writer classes - Add #[\Override] attributes (PHP 8.3 feature) to all methods that override parent/interface methods - Improve type safety and catch potential refactoring errors at compile time 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 21e888e commit b2f95a2

22 files changed

+51
-19
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php-versions: ['8.2', '8.3', '8.4']
10+
php-versions: ['8.3', '8.4', '8.5']
1111
fail-fast: false
1212
steps:
1313
- uses: actions/checkout@v4

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"php": "^8.2",
15+
"php": "^8.3",
1616
"bacon/bacon-qr-code": "^3.0"
1717
},
1818
"require-dev": {

src/Writer/AbstractGdWriter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ protected function getMatrix(QrCodeInterface $qrCode): MatrixInterface
2727
return $matrixFactory->create($qrCode);
2828
}
2929

30+
#[\Override]
3031
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
3132
{
3233
if (!extension_loaded('gd')) {
@@ -195,6 +196,7 @@ private function addLabel(LabelInterface $label, GdResult $result): GdResult
195196
return new GdResult($result->getMatrix(), $targetImage);
196197
}
197198

199+
#[\Override]
198200
public function validateResult(ResultInterface $result, string $expectedData): void
199201
{
200202
$string = $result->getString();

src/Writer/BinaryWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
final readonly class BinaryWriter implements WriterInterface
1515
{
16+
#[\Override]
1617
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
1718
{
1819
$matrixFactory = new MatrixFactory();

src/Writer/ConsoleWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
final readonly class ConsoleWriter implements WriterInterface
1515
{
16+
#[\Override]
1617
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, $options = []): ResultInterface
1718
{
1819
$matrixFactory = new MatrixFactory();

src/Writer/DebugWriter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
final readonly class DebugWriter implements WriterInterface, ValidatingWriterInterface
1515
{
16+
#[\Override]
1617
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
1718
{
1819
$matrixFactory = new MatrixFactory();
@@ -21,6 +22,7 @@ public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?Lab
2122
return new DebugResult($matrix, $qrCode, $logo, $label, $options);
2223
}
2324

25+
#[\Override]
2426
public function validateResult(ResultInterface $result, string $expectedData): void
2527
{
2628
if (!$result instanceof DebugResult) {

src/Writer/EpsWriter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313

1414
final readonly class EpsWriter implements WriterInterface
1515
{
16-
public const DECIMAL_PRECISION = 10;
16+
public const int DECIMAL_PRECISION = 10;
1717

18+
#[\Override]
1819
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
1920
{
2021
$matrixFactory = new MatrixFactory();

src/Writer/GifWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
final readonly class GifWriter extends AbstractGdWriter
1515
{
16+
#[\Override]
1617
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
1718
{
1819
/** @var GdResult $gdResult */

src/Writer/PdfWriter.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
final readonly class PdfWriter implements WriterInterface
1515
{
16-
public const WRITER_OPTION_UNIT = 'unit';
17-
public const WRITER_OPTION_PDF = 'fpdf';
18-
public const WRITER_OPTION_X = 'x';
19-
public const WRITER_OPTION_Y = 'y';
20-
public const WRITER_OPTION_LINK = 'link';
16+
public const string WRITER_OPTION_UNIT = 'unit';
17+
public const string WRITER_OPTION_PDF = 'fpdf';
18+
public const string WRITER_OPTION_X = 'x';
19+
public const string WRITER_OPTION_Y = 'y';
20+
public const string WRITER_OPTION_LINK = 'link';
2121

22+
#[\Override]
2223
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
2324
{
2425
$matrixFactory = new MatrixFactory();

src/Writer/PngWriter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
final readonly class PngWriter extends AbstractGdWriter
1515
{
16-
public const WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
17-
public const WRITER_OPTION_NUMBER_OF_COLORS = 'number_of_colors';
16+
public const string WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
17+
public const string WRITER_OPTION_NUMBER_OF_COLORS = 'number_of_colors';
1818

19+
#[\Override]
1920
public function write(QrCodeInterface $qrCode, ?LogoInterface $logo = null, ?LabelInterface $label = null, array $options = []): ResultInterface
2021
{
2122
if (!isset($options[self::WRITER_OPTION_COMPRESSION_LEVEL])) {

0 commit comments

Comments
 (0)