diff options
author | Chih-Hsuan Yen <[email protected]> | 2022-07-02 22:01:51 +0800 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2022-07-12 22:23:48 +0300 |
commit | 4b6161892000cb2b8392dce92a9cf2cabdf2d20e (patch) | |
tree | 5cad602010e4d13e1a48d6b922d4768c0893ac8b /vendor/chillerlan/php-qrcode/src/QROptionsTrait.php | |
parent | d9861038bcc3cb2f38c7153bdca7d5ab89597afa (diff) |
Update php-qrcode and php-settings-container for PHP 8.1
By running the following command after updating composer.json
```
composer update chillerlan/php-qrcode chillerlan/php-settings-container
```
This change fixes a deprecation warning from Preferences ->
Personal data / Authentication -> Authenticator (OTP).
```
Return type of chillerlan\Settings\SettingsContainerAbstract::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
1. vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php(19): ttrss_error_handler(Return type of chillerlan\Settings\SettingsContainerAbstract::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice, vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php)
2. vendor/composer/ClassLoader.php(571): include(/usr/share/webapps/tt-rss/vendor/chillerlan/php-settings-container/src/SettingsContainerAbstract.php)
3. vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile(/usr/share/webapps/tt-rss/vendor/composer/../chillerlan/php-settings-container/src/SettingsContainerAbstract.php)
4. vendor/chillerlan/php-qrcode/src/QROptions.php(59): loadClass(chillerlan\Settings\SettingsContainerAbstract)
5. vendor/composer/ClassLoader.php(571): include(/usr/share/webapps/tt-rss/vendor/chillerlan/php-qrcode/src/QROptions.php)
6. vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile(/usr/share/webapps/tt-rss/vendor/composer/../chillerlan/php-qrcode/src/QROptions.php)
7. vendor/chillerlan/php-qrcode/src/QRCode.php(113): loadClass(chillerlan\QRCode\QROptions)
8. classes/pref/prefs.php(958): __construct()
9. classes/pref/prefs.php(469): _get_otp_qrcode_img()
10. classes/pref/prefs.php(541): index_auth_2fa()
11. backend.php(136): index_auth()
```
The issue is fixed in php-settings-container 2.1.1 [1] Here I use the
latest php-qrcode version for another PHP 8.1 fix [2].
[1] https://github.com/chillerlan/php-settings-container/commit/68bc5019c8b38956c83906431ef879668366b036#diff-359c7f7a6d32d9935951e1b0742eb116fb654f4a932c8d40328bb5dcab2fa111L162
[2] https://github.com/chillerlan/php-qrcode/issues/97
Diffstat (limited to 'vendor/chillerlan/php-qrcode/src/QROptionsTrait.php')
-rw-r--r-- | vendor/chillerlan/php-qrcode/src/QROptionsTrait.php | 203 |
1 files changed, 68 insertions, 135 deletions
diff --git a/vendor/chillerlan/php-qrcode/src/QROptionsTrait.php b/vendor/chillerlan/php-qrcode/src/QROptionsTrait.php index 45d4cb415..74c384b13 100644 --- a/vendor/chillerlan/php-qrcode/src/QROptionsTrait.php +++ b/vendor/chillerlan/php-qrcode/src/QROptionsTrait.php @@ -8,146 +8,125 @@ * @author smiley <[email protected]> * @copyright 2018 smiley * @license MIT + * + * @noinspection PhpUnused */ namespace chillerlan\QRCode; -use function array_values, count, in_array, is_array, is_numeric, max, min, sprintf, strtolower; +use function array_values, count, in_array, is_numeric, max, min, sprintf, strtolower; +/** + * The QRCode plug-in settings & setter functionality + */ trait QROptionsTrait{ /** * QR Code version number * - * [1 ... 40] or QRCode::VERSION_AUTO - * - * @var int + * [1 ... 40] or QRCode::VERSION_AUTO */ - protected $version = QRCode::VERSION_AUTO; + protected int $version = QRCode::VERSION_AUTO; /** - * Minimum QR version (if $version = QRCode::VERSION_AUTO) + * Minimum QR version * - * @var int + * if $version = QRCode::VERSION_AUTO */ - protected $versionMin = 1; + protected int $versionMin = 1; /** * Maximum QR version - * - * @var int */ - protected $versionMax = 40; + protected int $versionMax = 40; /** * Error correct level * - * QRCode::ECC_X where X is - * L => 7% - * M => 15% - * Q => 25% - * H => 30% + * QRCode::ECC_X where X is: * - * @var int + * - L => 7% + * - M => 15% + * - Q => 25% + * - H => 30% */ - protected $eccLevel = QRCode::ECC_L; + protected int $eccLevel = QRCode::ECC_L; /** * Mask Pattern to use * - * [0...7] or QRCode::MASK_PATTERN_AUTO - * - * @var int + * [0...7] or QRCode::MASK_PATTERN_AUTO */ - protected $maskPattern = QRCode::MASK_PATTERN_AUTO; + protected int $maskPattern = QRCode::MASK_PATTERN_AUTO; /** * Add a "quiet zone" (margin) according to the QR code spec - * - * @var bool */ - protected $addQuietzone = true; + protected bool $addQuietzone = true; /** * Size of the quiet zone * - * internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules - * - * @var int + * internally clamped to [0 ... $moduleCount / 2], defaults to 4 modules */ - protected $quietzoneSize = 4; + protected int $quietzoneSize = 4; /** * Use this to circumvent the data mode detection and force the usage of the given mode. - * valid modes are: Number, AlphaNum, Kanji, Byte * - * @see https://github.com/chillerlan/php-qrcode/issues/39 + * valid modes are: Number, AlphaNum, Kanji, Byte (case insensitive) * - * @var string|null + * @see https://github.com/chillerlan/php-qrcode/issues/39 + * @see https://github.com/chillerlan/php-qrcode/issues/97 (changed default value to '') */ - protected $dataMode = null; + protected string $dataModeOverride = ''; /** - * QRCode::OUTPUT_MARKUP_XXXX where XXXX = HTML, SVG - * QRCode::OUTPUT_IMAGE_XXX where XXX = PNG, GIF, JPG - * QRCode::OUTPUT_STRING_XXXX where XXXX = TEXT, JSON - * QRCode::OUTPUT_CUSTOM + * The output type * - * @var string + * - QRCode::OUTPUT_MARKUP_XXXX where XXXX = HTML, SVG + * - QRCode::OUTPUT_IMAGE_XXX where XXX = PNG, GIF, JPG + * - QRCode::OUTPUT_STRING_XXXX where XXXX = TEXT, JSON + * - QRCode::OUTPUT_CUSTOM */ - protected $outputType = QRCode::OUTPUT_IMAGE_PNG; + protected string $outputType = QRCode::OUTPUT_IMAGE_PNG; /** * the FQCN of the custom QROutputInterface if $outputType is set to QRCode::OUTPUT_CUSTOM - * - * @var string|null */ - protected $outputInterface = null; + protected ?string $outputInterface = null; /** * /path/to/cache.file - * - * @var string|null */ - protected $cachefile = null; + protected ?string $cachefile = null; /** * newline string [HTML, SVG, TEXT] - * - * @var string */ - protected $eol = PHP_EOL; + protected string $eol = PHP_EOL; /** - * size of a QR code pixel [SVG, IMAGE_*] - * HTML -> via CSS - * - * @var int + * size of a QR code pixel [SVG, IMAGE_*], HTML via CSS */ - protected $scale = 5; + protected int $scale = 5; /** * a common css class - * - * @var string */ - protected $cssClass = ''; + protected string $cssClass = ''; /** * SVG opacity - * - * @var float */ - protected $svgOpacity = 1.0; + protected float $svgOpacity = 1.0; /** * anything between <defs> * * @see https://developer.mozilla.org/docs/Web/SVG/Element/defs - * - * @var string */ - protected $svgDefs = '<style>rect{shape-rendering:crispEdges}</style>'; + protected string $svgDefs = '<style>rect{shape-rendering:crispEdges}</style>'; /** * SVG viewBox size. a single integer number which defines width/height of the viewBox attribute. @@ -155,38 +134,28 @@ trait QROptionsTrait{ * viewBox="0 0 x x" * * @see https://css-tricks.com/scale-svg/#article-header-id-3 - * - * @var int|null */ - protected $svgViewBoxSize = null; + protected ?int $svgViewBoxSize = null; /** * string substitute for dark - * - * @var string */ - protected $textDark = '🔴'; + protected string $textDark = '🔴'; /** * string substitute for light - * - * @var string */ - protected $textLight = 'â•'; + protected string $textLight = 'â•'; /** * markup substitute for dark (CSS value) - * - * @var string */ - protected $markupDark = '#000'; + protected string $markupDark = '#000'; /** * markup substitute for light (CSS value) - * - * @var string */ - protected $markupLight = '#fff'; + protected string $markupLight = '#fff'; /** * Return the image resource instead of a render if applicable. @@ -194,7 +163,7 @@ trait QROptionsTrait{ * * Supported by the following modules: * - * - QRImage: resource + * - QRImage: resource (PHP < 8), GdImage * - QRImagick: Imagick * - QRFpdf: FPDF * @@ -202,85 +171,66 @@ trait QROptionsTrait{ * * @var bool */ - protected $returnResource = false; + protected bool $returnResource = false; /** * toggle base64 or raw image data - * - * @var bool */ - protected $imageBase64 = true; + protected bool $imageBase64 = true; /** * toggle transparency, not supported by jpg - * - * @var bool */ - protected $imageTransparent = true; + protected bool $imageTransparent = true; /** * @see imagecolortransparent() * - * @var array [R, G, B] + * [R, G, B] */ - protected $imageTransparencyBG = [255, 255, 255]; + protected array $imageTransparencyBG = [255, 255, 255]; /** * @see imagepng() - * - * @var int */ - protected $pngCompression = -1; + protected int $pngCompression = -1; /** * @see imagejpeg() - * - * @var int */ - protected $jpegQuality = 85; + protected int $jpegQuality = 85; /** * Imagick output format * - * @see Imagick::setType() - * - * @var string + * @see \Imagick::setType() */ - protected $imagickFormat = 'png'; + protected string $imagickFormat = 'png'; /** * Imagick background color (defaults to "transparent") * * @see \ImagickPixel::__construct() - * - * @var string|null */ - protected $imagickBG = null; + protected ?string $imagickBG = null; /** * Measurement unit for FPDF output: pt, mm, cm, in (defaults to "pt") * * @see \FPDF::__construct() */ - protected $fpdfMeasureUnit = 'pt'; + protected string $fpdfMeasureUnit = 'pt'; /** * Module values map * - * HTML, IMAGICK: #ABCDEF, cssname, rgb(), rgba()... - * IMAGE: [63, 127, 255] // R, G, B - * - * @var array|null + * - HTML, IMAGICK: #ABCDEF, cssname, rgb(), rgba()... + * - IMAGE: [63, 127, 255] // R, G, B */ - protected $moduleValues = null; + protected ?array $moduleValues = null; /** * clamp min/max version number - * - * @param int $versionMin - * @param int $versionMax - * - * @return void */ protected function setMinMaxVersion(int $versionMin, int $versionMax):void{ $min = max(1, min(40, $versionMin)); @@ -292,10 +242,6 @@ trait QROptionsTrait{ /** * sets the minimum version number - * - * @param int $version - * - * @return void */ protected function set_versionMin(int $version):void{ $this->setMinMaxVersion($version, $this->versionMax); @@ -303,10 +249,6 @@ trait QROptionsTrait{ /** * sets the maximum version number - * - * @param int $version - * - * @return void */ protected function set_versionMax(int $version):void{ $this->setMinMaxVersion($this->versionMin, $version); @@ -315,9 +257,6 @@ trait QROptionsTrait{ /** * sets the error correction level * - * @param int $eccLevel - * - * @return void * @throws \chillerlan\QRCode\QRCodeException */ protected function set_eccLevel(int $eccLevel):void{ @@ -331,10 +270,6 @@ trait QROptionsTrait{ /** * sets/clamps the mask pattern - * - * @param int $maskPattern - * - * @return void */ protected function set_maskPattern(int $maskPattern):void{ @@ -347,15 +282,12 @@ trait QROptionsTrait{ /** * sets the transparency background color * - * @param mixed $imageTransparencyBG - * - * @return void * @throws \chillerlan\QRCode\QRCodeException */ - protected function set_imageTransparencyBG($imageTransparencyBG):void{ + protected function set_imageTransparencyBG(array $imageTransparencyBG):void{ // invalid value - set to white as default - if(!is_array($imageTransparencyBG) || count($imageTransparencyBG) < 3){ + if(count($imageTransparencyBG) < 3){ $this->imageTransparencyBG = [255, 255, 255]; return; @@ -363,6 +295,11 @@ trait QROptionsTrait{ foreach($imageTransparencyBG as $k => $v){ + // cut off exceeding items + if($k > 2){ + break; + } + if(!is_numeric($v)){ throw new QRCodeException('Invalid RGB value.'); } @@ -377,10 +314,6 @@ trait QROptionsTrait{ /** * sets/clamps the version number - * - * @param int $version - * - * @return void */ protected function set_version(int $version):void{ |