Skip to content

Commit

Permalink
🛀 clean-up (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Nov 27, 2023
1 parent 2d2a00f commit 00800ef
Show file tree
Hide file tree
Showing 44 changed files with 93 additions and 114 deletions.
4 changes: 3 additions & 1 deletion examples/authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

use chillerlan\Authenticator\{Authenticator, AuthenticatorOptionsTrait};
use chillerlan\Authenticator\Authenticators\AuthenticatorInterface;
use chillerlan\Settings\SettingsContainerAbstract;
use chillerlan\QRCode\{QRCode, QROptionsTrait};
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\Settings\SettingsContainerAbstract;

require_once __DIR__.'/../vendor/autoload.php';

Expand All @@ -35,6 +36,7 @@
*/
$options->version = 7;
$options->addQuietzone = false;
$options->outputInterface = QRMarkupSVG::class;
$options->outputBase64 = false;
$options->svgAddXmlHeader = false;
$options->cssClass = 'my-qrcode';
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_output.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function prepareModuleValue(mixed $value):mixed{
/**
* @inheritDoc
*/
protected function getDefaultModuleValue(bool $isDark){
protected function getDefaultModuleValue(bool $isDark):mixed{
// TODO: Implement getDefaultModuleValue() method. (abstract)
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions examples/imageWithRoundedShapes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
* @noinspection PhpComposerExtensionStubsInspection
*/

use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRGdImagePNG;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use chillerlan\Settings\SettingsContainerInterface;

require_once __DIR__ . '/../vendor/autoload.php';
Expand Down
3 changes: 1 addition & 2 deletions examples/imagickConvertSVGtoPNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
* @license MIT
*/

use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
4 changes: 1 addition & 3 deletions examples/imagickImageAsBackground.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
* @license MIT
*/

use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\Output\QRImagick;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QRCodeException;
use chillerlan\QRCode\QROptions;

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
3 changes: 1 addition & 2 deletions examples/multimode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* @license MIT
*/

use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\{QRCode, QROptions};

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
3 changes: 1 addition & 2 deletions examples/qrcode-interactive.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* @noinspection PhpComposerExtensionStubsInspection
*/

use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;

require_once '../vendor/autoload.php';

Expand Down
3 changes: 1 addition & 2 deletions examples/reflectance.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
* @license MIT
*/

use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
4 changes: 1 addition & 3 deletions examples/svgConvertViaCanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
* @license MIT
*/


use chillerlan\QRCode\{QRCode, QROptions};
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
2 changes: 1 addition & 1 deletion examples/svgRoundQuietzone.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* @noinspection PhpIllegalPsrClassPathInspection
*/

use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};
use chillerlan\QRCode\Common\EccLevel;
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRMarkupSVG;
use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};

require_once __DIR__.'/../vendor/autoload.php';

Expand Down
6 changes: 2 additions & 4 deletions src/Common/BitBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ final class BitBuffer{

/**
* BitBuffer constructor.
*
* @param int[]|null $bytes
*/
public function __construct(array $bytes = null){
$this->buffer = ($bytes ?? []);
public function __construct(array $bytes = []){
$this->buffer = $bytes;
$this->length = count($this->buffer);
}

Expand Down
1 change: 0 additions & 1 deletion src/Common/EccLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\QRCodeException;

use function array_column;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Common/GDLuminanceSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class GDLuminanceSource extends LuminanceSourceAbstract{
*
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
*/
public function __construct(GdImage $gdImage, SettingsContainerInterface|QROptions $options = null){
public function __construct(GdImage $gdImage, SettingsContainerInterface|QROptions $options = new QROptions){
parent::__construct(imagesx($gdImage), imagesy($gdImage), $options);

$this->gdImage = $gdImage;
Expand Down Expand Up @@ -71,12 +71,12 @@ private function setLuminancePixels():void{
}

/** @inheritDoc */
public static function fromFile(string $path, SettingsContainerInterface $options = null):static{
public static function fromFile(string $path, SettingsContainerInterface|QROptions $options = new QROptions):static{
return new self(imagecreatefromstring(file_get_contents(self::checkFile($path))), $options);
}

/** @inheritDoc */
public static function fromBlob(string $blob, SettingsContainerInterface $options = null):static{
public static function fromBlob(string $blob, SettingsContainerInterface|QROptions $options = new QROptions):static{
return new self(imagecreatefromstring($blob), $options);
}

Expand Down
1 change: 0 additions & 1 deletion src/Common/GenericGFPoly.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\QRCodeException;

use function array_fill, array_slice, array_splice, count;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Common/IMagickLuminanceSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class IMagickLuminanceSource extends LuminanceSourceAbstract{
/**
* IMagickLuminanceSource constructor.
*/
public function __construct(Imagick $imagick, SettingsContainerInterface|QROptions $options = null){
public function __construct(Imagick $imagick, SettingsContainerInterface|QROptions $options = new QROptions){
parent::__construct($imagick->getImageWidth(), $imagick->getImageHeight(), $options);

$this->imagick = $imagick;
Expand Down Expand Up @@ -64,12 +64,12 @@ private function setLuminancePixels():void{
}

/** @inheritDoc */
public static function fromFile(string $path, SettingsContainerInterface $options = null):static{
public static function fromFile(string $path, SettingsContainerInterface|QROptions $options = new QROptions):static{
return new self(new Imagick(self::checkFile($path)), $options);
}

/** @inheritDoc */
public static function fromBlob(string $blob, SettingsContainerInterface $options = null):static{
public static function fromBlob(string $blob, SettingsContainerInterface|QROptions $options = new QROptions):static{
$im = new Imagick;
$im->readImageBlob($blob);

Expand Down
6 changes: 3 additions & 3 deletions src/Common/LuminanceSourceAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\Decoder\QRCodeDecoderException;
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Decoder\QRCodeDecoderException;
use chillerlan\Settings\SettingsContainerInterface;
use function array_slice, array_splice, file_exists, is_file, is_readable, realpath;

Expand All @@ -33,10 +33,10 @@ abstract class LuminanceSourceAbstract implements LuminanceSourceInterface{
/**
*
*/
public function __construct(int $width, int $height, SettingsContainerInterface|QROptions $options = null){
public function __construct(int $width, int $height, SettingsContainerInterface|QROptions $options = new QROptions){
$this->width = $width;
$this->height = $height;
$this->options = ($options ?? new QROptions);
$this->options = $options;

$this->luminances = [];
}
Expand Down
7 changes: 5 additions & 2 deletions src/Common/LuminanceSourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\QROptions;
use chillerlan\Settings\SettingsContainerInterface;

/**
*/
interface LuminanceSourceInterface{
Expand Down Expand Up @@ -51,11 +54,11 @@ public function getRow(int $y):array;
/**
* Creates a LuminanceSource instance from the given file
*/
public static function fromFile(string $path):static;
public static function fromFile(string $path, SettingsContainerInterface|QROptions $options = new QROptions):static;

/**
* Creates a LuminanceSource instance from the given data blob
*/
public static function fromBlob(string $blob):static;
public static function fromBlob(string $blob, SettingsContainerInterface|QROptions $options = new QROptions):static;

}
2 changes: 1 addition & 1 deletion src/Common/MaskPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace chillerlan\QRCode\Common;

use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\QRCodeException;
use chillerlan\QRCode\Data\QRMatrix;
use Closure;
use function abs, array_column, array_search, intdiv, min;

Expand Down
1 change: 0 additions & 1 deletion src/Data/AlphaNum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, Mode};

use function array_flip, ceil, intdiv, str_split;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Data/Byte.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, Mode};

use function chr, ord;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Data/Hanzi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, Mode};

use Throwable;
use function chr, implode, intdiv, is_string, mb_convert_encoding, mb_detect_encoding,
mb_detect_order, mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
Expand Down Expand Up @@ -96,7 +95,7 @@ public static function validateString(string $string):bool{
try{
$string = self::convertEncoding($string);
}
catch(Throwable $e){
catch(Throwable){
return false;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Data/Kanji.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, Mode};

use Throwable;
use function chr, implode, intdiv, is_string, mb_convert_encoding, mb_detect_encoding,
mb_detect_order, mb_internal_encoding, mb_strlen, ord, sprintf, strlen;
Expand Down Expand Up @@ -89,7 +88,7 @@ public static function validateString(string $string):bool{
try{
$string = self::convertEncoding($string);
}
catch(Throwable $e){
catch(Throwable){
return false;
}

Expand Down
1 change: 0 additions & 1 deletion src/Data/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, Mode};

use function array_flip, ceil, intdiv, str_split, substr, unpack;

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Data/QRData.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

namespace chillerlan\QRCode\Data;

use chillerlan\QRCode\Common\{BitBuffer, EccLevel, Mode, Version};
use chillerlan\QRCode\QROptions;
use chillerlan\QRCode\Common\{BitBuffer, EccLevel, Mode, Version};
use chillerlan\Settings\SettingsContainerInterface;

use function count;
use function sprintf;
use function count, sprintf;

/**
* Processes the binary data and maps it on a QRMatrix which is then being returned
Expand Down
6 changes: 1 addition & 5 deletions src/Data/QRDataModeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ interface QRDataModeInterface{
/**
* the current data mode: Number, Alphanum, Kanji, Hanzi, Byte, ECI
*
* tbh I hate this constant here, but it's part of the interface, so I can't just declare it in the abstract class.
* (phan will complain about a PhanAccessOverridesFinalConstant)
*
* @see https://wiki.php.net/rfc/final_class_const
* Note: do not call this constant from the interface, but rather from one of the child classes
*
* @var int
* @see \chillerlan\QRCode\Common\Mode
* @internal do not call this constant from the interface, but rather from one of the child classes
*/
public const DATAMODE = -1;

Expand Down
6 changes: 3 additions & 3 deletions src/Data/ReedSolomonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ final class ReedSolomonEncoder{
private Version $version;
private EccLevel $eccLevel;

private array $interleavedData;
private int $interleavedDataIndex;
private array $interleavedData;
private int $interleavedDataIndex;

/**
* ReedSolomonDecoder constructor
Expand All @@ -35,7 +35,7 @@ public function __construct(Version $version, EccLevel $eccLevel){
}

/**
* ECC interleaving
* ECC encoding and interleaving
*
* @throws \chillerlan\QRCode\QRCodeException
*/
Expand Down
1 change: 0 additions & 1 deletion src/Decoder/BitMatrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public function mirrorDiagonal():static{
// mirror vertically
$this->matrix = array_reverse($this->matrix);
// rotate by 90 degrees clockwise
/** @phan-suppress-next-line PhanTypeMismatchReturnSuperType */
return $this->rotate90();
}

Expand Down
Loading

0 comments on commit 00800ef

Please sign in to comment.