mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-26 10:18:05 +00:00
:octocat: first round of deprecations
This commit is contained in:
@@ -56,6 +56,8 @@ return [
|
||||
'PhanAccessOverridesFinalConstant',
|
||||
'PhanDeprecatedClass',
|
||||
'PhanDeprecatedClassConstant',
|
||||
'PhanDeprecatedFunction',
|
||||
'PhanDeprecatedProperty',
|
||||
'PhanNoopNew',
|
||||
'PhanTypePossiblyInvalidDimOffset',
|
||||
],
|
||||
|
||||
+1026
-15
File diff suppressed because it is too large
Load Diff
@@ -84,6 +84,8 @@ final class BitBuffer{
|
||||
|
||||
/**
|
||||
* returns the current buffer length
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "BitBuffer::$length" instead.
|
||||
*/
|
||||
public function getLength():int{
|
||||
return $this->length;
|
||||
@@ -95,6 +97,8 @@ final class BitBuffer{
|
||||
* to debug: `array_map(fn($v) => sprintf('%08b', $v), $bitBuffer->getBuffer())`
|
||||
*
|
||||
* @return int[]
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "BitBuffer::$buffer" instead.
|
||||
*/
|
||||
public function getBuffer():array{
|
||||
return $this->buffer;
|
||||
|
||||
@@ -108,6 +108,7 @@ final class ECICharset{
|
||||
|
||||
/**
|
||||
* Returns the current character set ID
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "ECICharset::$charsetID" instead.
|
||||
*/
|
||||
public function getID():int{
|
||||
return $this->charsetID;
|
||||
|
||||
@@ -138,7 +138,7 @@ final class EccLevel{
|
||||
* Q: 0b11
|
||||
* H: 0b10
|
||||
*/
|
||||
private int $eccLevel;
|
||||
private int $level;
|
||||
|
||||
/**
|
||||
* @param int $eccLevel containing the two bits encoding a QR Code's error correction level
|
||||
@@ -151,7 +151,7 @@ final class EccLevel{
|
||||
throw new QRCodeException('invalid ECC level');
|
||||
}
|
||||
|
||||
$this->eccLevel = $eccLevel;
|
||||
$this->level = $eccLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,14 +163,16 @@ final class EccLevel{
|
||||
self::M => 'M',
|
||||
self::Q => 'Q',
|
||||
self::H => 'H',
|
||||
][$this->eccLevel];
|
||||
][$this->level];
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current ECC level
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "EccLevel::$level" instead.
|
||||
*/
|
||||
public function getLevel():int{
|
||||
return $this->eccLevel;
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +190,7 @@ final class EccLevel{
|
||||
self::M => 1,
|
||||
self::Q => 2,
|
||||
self::H => 3,
|
||||
][$this->eccLevel];
|
||||
][$this->level];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,6 +77,8 @@ final class GenericGFPoly{
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "GenericGFPoly::$coefficients" instead.
|
||||
*/
|
||||
public function getCoefficients():array{
|
||||
return $this->coefficients;
|
||||
|
||||
@@ -26,16 +26,22 @@ interface LuminanceSourceInterface{
|
||||
* @return int[] A row-major 2D array of luminance values. Do not use result $length as it may be
|
||||
* larger than $width * $height bytes on some platforms. Do not modify the contents
|
||||
* of the result.
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$luminances" instead.
|
||||
*/
|
||||
public function getLuminances():array;
|
||||
|
||||
/**
|
||||
* @return int The width of the bitmap.
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$width" instead.
|
||||
*/
|
||||
public function getWidth():int;
|
||||
|
||||
/**
|
||||
* @return int The height of the bitmap.
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "LuminanceSourceInterface::$height" instead.
|
||||
*/
|
||||
public function getHeight():int;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ final class MaskPattern{
|
||||
/**
|
||||
* The current mask pattern value (0-7)
|
||||
*/
|
||||
private int $maskPattern;
|
||||
private int $currentPattern;
|
||||
|
||||
/**
|
||||
* MaskPattern constructor.
|
||||
@@ -82,14 +82,16 @@ final class MaskPattern{
|
||||
throw new QRCodeException('invalid mask pattern');
|
||||
}
|
||||
|
||||
$this->maskPattern = $maskPattern;
|
||||
$this->currentPattern = $maskPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current mask pattern
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "MaskPattern::$currentPattern" instead.
|
||||
*/
|
||||
public function getPattern():int{
|
||||
return $this->maskPattern;
|
||||
return $this->currentPattern;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +114,7 @@ final class MaskPattern{
|
||||
self::PATTERN_101 => fn(int $x, int $y):bool => (($x * $y) % 6) === 0,
|
||||
self::PATTERN_110 => fn(int $x, int $y):bool => (($x * $y) % 6) < 3,
|
||||
self::PATTERN_111 => fn(int $x, int $y):bool => (($x + $y + (($x * $y) % 3)) % 2) === 0,
|
||||
][$this->maskPattern];
|
||||
][$this->currentPattern];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-9
@@ -218,7 +218,7 @@ final class Version{
|
||||
/**
|
||||
* QR Code version number
|
||||
*/
|
||||
private int $version;
|
||||
private int $versionNumber;
|
||||
|
||||
/**
|
||||
* Version constructor.
|
||||
@@ -231,35 +231,37 @@ final class Version{
|
||||
throw new QRCodeException('invalid version given');
|
||||
}
|
||||
|
||||
$this->version = $version;
|
||||
$this->versionNumber = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current version number as string
|
||||
*/
|
||||
public function __toString():string{
|
||||
return (string)$this->version;
|
||||
return (string)$this->versionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the current version number
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "Version::$versionNumber" instead.
|
||||
*/
|
||||
public function getVersionNumber():int{
|
||||
return $this->version;
|
||||
return $this->versionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* the matrix size for the given version
|
||||
*/
|
||||
public function getDimension():int{
|
||||
return (($this->version * 4) + 17);
|
||||
return (($this->versionNumber * 4) + 17);
|
||||
}
|
||||
|
||||
/**
|
||||
* the version pattern for the given version
|
||||
*/
|
||||
public function getVersionPattern():int|null{
|
||||
return (self::VERSION_PATTERN[$this->version] ?? null);
|
||||
return (self::VERSION_PATTERN[$this->versionNumber] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,21 +270,21 @@ final class Version{
|
||||
* @return int[]
|
||||
*/
|
||||
public function getAlignmentPattern():array{
|
||||
return self::ALIGNMENT_PATTERN[$this->version];
|
||||
return self::ALIGNMENT_PATTERN[$this->versionNumber];
|
||||
}
|
||||
|
||||
/**
|
||||
* returns ECC block information for the given $version and $eccLevel
|
||||
*/
|
||||
public function getRSBlocks(EccLevel $eccLevel):array{
|
||||
return self::RSBLOCKS[$this->version][$eccLevel->getOrdinal()];
|
||||
return self::RSBLOCKS[$this->versionNumber][$eccLevel->getOrdinal()];
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the maximum codewords for the current version
|
||||
*/
|
||||
public function getTotalCodewords():int{
|
||||
return self::TOTAL_CODEWORDS[$this->version];
|
||||
return self::TOTAL_CODEWORDS[$this->versionNumber];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ final class QRData{
|
||||
/**
|
||||
* Returns the current BitBuffer instance
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "QRData::$bitBuffer" instead.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getBitBuffer():BitBuffer{
|
||||
|
||||
+34
-1
@@ -12,13 +12,20 @@ declare(strict_types=1);
|
||||
namespace chillerlan\QRCode\Data;
|
||||
|
||||
use chillerlan\QRCode\Common\{BitBuffer, EccLevel, MaskPattern, Version};
|
||||
use function array_fill, array_map, array_reverse, count, intdiv;
|
||||
use chillerlan\QRCode\QRCodeException;
|
||||
use function array_fill, array_map, array_reverse, count, intdiv, in_array;
|
||||
|
||||
/**
|
||||
* Holds an array representation of the final QR Code that contains numerical values for later output modifications;
|
||||
* maps the ECC coded binary data and applies the mask pattern
|
||||
*
|
||||
* @see http://www.thonky.com/qr-code-tutorial/format-version-information
|
||||
*
|
||||
* @property Version|null $version
|
||||
* @property EccLevel|null $eccLevel
|
||||
* @property MaskPattern|null $maskPattern
|
||||
* @property int $moduleCount
|
||||
* @property int[][] $matrix
|
||||
*/
|
||||
class QRMatrix{
|
||||
|
||||
@@ -149,6 +156,22 @@ class QRMatrix{
|
||||
$this->matrix = $this->createMatrix($this->moduleCount, $this::M_NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* This magic getter serves as an upgrade path for the deprecated property getter methods,
|
||||
* which will be removed in v7 in favor of asymmetric visibility (PHP 8.4+).
|
||||
*
|
||||
* @throws \chillerlan\QRCode\QRCodeException
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __get(string $name):mixed{
|
||||
|
||||
if(in_array($name, ['matrix', 'version', 'eccLevel', 'maskPattern', 'moduleCount'], true)){
|
||||
return $this->{$name};
|
||||
}
|
||||
|
||||
throw new QRCodeException('invalid property access');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a 2-dimensional array (square) of the given $size
|
||||
*
|
||||
@@ -177,6 +200,8 @@ class QRMatrix{
|
||||
* Returns the data matrix
|
||||
*
|
||||
* @return int[][]
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "QRMatrix::$matrix" instead.
|
||||
*/
|
||||
public function getMatrix():array{
|
||||
return $this->matrix;
|
||||
@@ -200,6 +225,8 @@ class QRMatrix{
|
||||
|
||||
/**
|
||||
* Returns the current version number
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "QRMatrix::$version" instead.
|
||||
*/
|
||||
public function getVersion():Version|null{
|
||||
return $this->version;
|
||||
@@ -207,6 +234,8 @@ class QRMatrix{
|
||||
|
||||
/**
|
||||
* Returns the current ECC level
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "QRMatrix::$eccLevel" instead.
|
||||
*/
|
||||
public function getEccLevel():EccLevel|null{
|
||||
return $this->eccLevel;
|
||||
@@ -214,6 +243,8 @@ class QRMatrix{
|
||||
|
||||
/**
|
||||
* Returns the current mask pattern
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "QRMatrix::$maskPattern" instead.
|
||||
*/
|
||||
public function getMaskPattern():MaskPattern|null{
|
||||
return $this->maskPattern;
|
||||
@@ -223,6 +254,8 @@ class QRMatrix{
|
||||
* Returns the absoulute size of the matrix, including quiet zone (after setting it).
|
||||
*
|
||||
* size = version * 4 + 17 [ + 2 * quietzone size]
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7, use the property "QRMatrix::$moduleCount" instead.
|
||||
*/
|
||||
public function getSize():int{
|
||||
return $this->moduleCount;
|
||||
|
||||
@@ -38,6 +38,8 @@ final class Detector{
|
||||
|
||||
/**
|
||||
* @return \chillerlan\QRCode\Detector\FinderPattern[]
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "Detector::$finderPatterns" instead.
|
||||
*/
|
||||
public function getFinderPatterns():array{
|
||||
return $this->finderPatterns;
|
||||
|
||||
@@ -31,6 +31,9 @@ final class FinderPattern extends ResultPoint{
|
||||
$this->count = ($count ?? 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "FinderPattern::$count" instead.
|
||||
*/
|
||||
public function getCount():int{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,23 @@ abstract class ResultPoint{
|
||||
$this->estimatedModuleSize = $estimatedModuleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$x" instead.
|
||||
*/
|
||||
public function getX():float{
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$y" instead.
|
||||
*/
|
||||
public function getY():float{
|
||||
return $this->y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 6.0.1 This method will be removed. In v7, use the property "ResultPoint::$estimatedModuleSize" instead.
|
||||
*/
|
||||
public function getEstimatedModuleSize():float{
|
||||
return $this->estimatedModuleSize;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,13 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
*/
|
||||
protected int $length;
|
||||
|
||||
/**
|
||||
* The current module scale value (might have been modified)
|
||||
*
|
||||
* @see \chillerlan\QRCode\QROptions::$scale
|
||||
*/
|
||||
protected int $scale;
|
||||
|
||||
/**
|
||||
* an (optional) array of color values for the several QR matrix parts
|
||||
*
|
||||
@@ -57,25 +64,50 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$excludeFromConnect
|
||||
* @var int[]
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->excludeFromConnect` instead.
|
||||
*/
|
||||
protected array $excludeFromConnect;
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$keepAsSquare
|
||||
* @var int[]
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->keepAsSquare` instead.
|
||||
*/
|
||||
protected array $keepAsSquare;
|
||||
/** @see \chillerlan\QRCode\QROptions::$scale */
|
||||
protected int $scale;
|
||||
/** @see \chillerlan\QRCode\QROptions::$connectPaths */
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$connectPaths
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->connectPaths` instead.
|
||||
*/
|
||||
protected bool $connectPaths;
|
||||
/** @see \chillerlan\QRCode\QROptions::$eol */
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$eol
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->eol` instead.
|
||||
*/
|
||||
protected string $eol;
|
||||
/** @see \chillerlan\QRCode\QROptions::$drawLightModules */
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$drawLightModules
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->drawLightModules` instead.
|
||||
*/
|
||||
protected bool $drawLightModules;
|
||||
/** @see \chillerlan\QRCode\QROptions::$drawCircularModules */
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$drawCircularModules
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->drawCircularModules` instead.
|
||||
*/
|
||||
protected bool $drawCircularModules;
|
||||
/** @see \chillerlan\QRCode\QROptions::$circleRadius */
|
||||
|
||||
/**
|
||||
* @see \chillerlan\QRCode\QROptions::$circleRadius
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->circleRadius` instead.
|
||||
*/
|
||||
protected float $circleRadius;
|
||||
|
||||
/**
|
||||
* @deprecated 6.0.1 This property will be removed in v7, use `$this->options->circleRadius * 2` instead.
|
||||
*/
|
||||
protected float $circleDiameter;
|
||||
|
||||
/**
|
||||
@@ -104,6 +136,8 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
* in long loops for a significant performance increase.
|
||||
*
|
||||
* These variables are usually used in the "module" methods and are called up to 31329 times (at version 40).
|
||||
*
|
||||
* @deprecated 6.0.1 This method will be removed in v7 without replacement (unnecessary).
|
||||
*/
|
||||
protected function copyVars():void{
|
||||
|
||||
@@ -127,7 +161,7 @@ abstract class QROutputAbstract implements QROutputInterface{
|
||||
/**
|
||||
* Sets/updates the matrix dimensions
|
||||
*
|
||||
* Call this method if you modify the matrix from within your custom module in case the dimensions have been changed
|
||||
* Call this method if you modify the matrix from within your custom output class in case the dimensions have been changed
|
||||
*/
|
||||
protected function setMatrixDimensions():void{
|
||||
$this->moduleCount = $this->matrix->getSize();
|
||||
|
||||
Reference in New Issue
Block a user