Skip to content

Commit

Permalink
Fix static analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Aug 28, 2023
1 parent e1b5482 commit a122b85
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2022 (c) Jeroen van den Enden
Copyright 2023 (c) Jeroen van den Enden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function build(): ResultInterface
*
* @return mixed
*/
private function buildObject(string $class, string|null $optionsPrefix = null)
private function buildObject(string $class, string $optionsPrefix = null)
{
/** @var \ReflectionClass<object> $reflectionClass */
$reflectionClass = new \ReflectionClass($class);
Expand Down
8 changes: 4 additions & 4 deletions src/Label/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ final class Label implements LabelInterface

public function __construct(
private string $text,
FontInterface|null $font = null,
LabelAlignmentInterface|null $alignment = null,
MarginInterface|null $margin = null,
ColorInterface|null $textColor = null
FontInterface $font = null,
LabelAlignmentInterface $alignment = null,
MarginInterface $margin = null,
ColorInterface $textColor = null
) {
$this->font = $font ?? new Font(__DIR__.'/../../assets/noto_sans.otf', 16);
$this->alignment = $alignment ?? new LabelAlignmentCenter();
Expand Down
10 changes: 5 additions & 5 deletions src/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ final class QrCode implements QrCodeInterface

public function __construct(
private string $data,
EncodingInterface|null $encoding = null,
ErrorCorrectionLevelInterface|null $errorCorrectionLevel = null,
EncodingInterface $encoding = null,
ErrorCorrectionLevelInterface $errorCorrectionLevel = null,
private int $size = 300,
private int $margin = 10,
RoundBlockSizeModeInterface|null $roundBlockSizeMode = null,
ColorInterface|null $foregroundColor = null,
ColorInterface|null $backgroundColor = null
RoundBlockSizeModeInterface $roundBlockSizeMode = null,
ColorInterface $foregroundColor = null,
ColorInterface $backgroundColor = null
) {
$this->encoding = $encoding ?? new Encoding('UTF-8');
$this->errorCorrectionLevel = $errorCorrectionLevel ?? new ErrorCorrectionLevelLow();
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/AbstractGdWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

abstract class AbstractGdWriter implements WriterInterface, ValidatingWriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
if (!extension_loaded('gd')) {
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/BinaryWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class BinaryWriter implements WriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/ConsoleWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class ConsoleWriter implements WriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/DebugWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class DebugWriter implements WriterInterface, ValidatingWriterInterface
{
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/EpsWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class EpsWriter implements WriterInterface
{
public const DECIMAL_PRECISION = 10;

public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/GifWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

final class GifWriter extends AbstractGdWriter
{
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
/** @var GdResult $gdResult */
$gdResult = parent::write($qrCode, $logo, $label, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/PdfWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class PdfWriter implements WriterInterface
public const WRITER_OPTION_Y = 'y';
public const WRITER_OPTION_LINK = 'link';

public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
$matrixFactory = new MatrixFactory();
$matrix = $matrixFactory->create($qrCode);
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/PngWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class PngWriter extends AbstractGdWriter
{
public const WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';

public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_COMPRESSION_LEVEL])) {
$options[self::WRITER_OPTION_COMPRESSION_LEVEL] = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/SvgWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class SvgWriter implements WriterInterface
public const WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT = 'exclude_svg_width_and_height';
public const WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';

public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_BLOCK_ID])) {
$options[self::WRITER_OPTION_BLOCK_ID] = 'block';
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/WebPWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class WebPWriter extends AbstractGdWriter
{
public const WRITER_OPTION_QUALITY = 'quality';

public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
{
if (!isset($options[self::WRITER_OPTION_QUALITY])) {
$options[self::WRITER_OPTION_QUALITY] = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/Writer/WriterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
interface WriterInterface
{
/** @param array<string, mixed> $options */
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface;
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface;
}
4 changes: 2 additions & 2 deletions tests/QrCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testQrCode(WriterInterface $writer, string $resultClass, string
$this->assertStringContainsString('data:'.$result->getMimeType().';base64,', $result->getDataUri());
}

public function writerProvider(): iterable
public static function writerProvider(): iterable
{
yield [new BinaryWriter(), BinaryResult::class, 'text/plain'];
yield [new ConsoleWriter(), ConsoleResult::class, 'text/plain'];
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testSetSizeRounded(int $size, int $margin, RoundBlockSizeModeInt
$this->assertTrue(imagesy($image) === $expectedSize);
}

public function roundedSizeProvider()
public static function roundedSizeProvider(): iterable
{
yield [400, 0, new RoundBlockSizeModeEnlarge(), 406];
yield [400, 5, new RoundBlockSizeModeEnlarge(), 416];
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testReadability(string $name, string $data): void
$this->assertEquals('image/png', $result->getMimeType());
}

public function dataProvider(): iterable
public static function dataProvider(): iterable
{
yield ['small data', 'Tiny'];
yield ['data containing spaces', 'This one has spaces'];
Expand Down

0 comments on commit a122b85

Please sign in to comment.