Skip to content

Commit 39e3dfe

Browse files
committed
🔥 v6.0 first pass: PHP 8.2, remove deprecated elements, add type hints
1 parent a301af5 commit 39e3dfe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+332
-1029
lines changed

.phan/config.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// Note that the **only** effect of choosing `'5.6'` is to infer
1515
// that functions removed in php 7.0 exist.
1616
// (See `backward_compatibility_checks` for additional options)
17-
'target_php_version' => null,
18-
'minimum_target_php_version' => '7.4',
17+
'target_php_version' => null,
18+
'minimum_target_php_version' => '8.2',
1919

2020
// A list of directories that should be parsed for class and
2121
// method information. After excluding the directories
@@ -24,19 +24,19 @@
2424
//
2525
// Thus, both first-party and third-party code being used by
2626
// your application should be included in this list.
27-
'directory_list' => [
27+
'directory_list' => [
2828
'examples',
2929
'src',
3030
'tests',
3131
'vendor',
32-
'.phan/stubs'
32+
'.phan/stubs',
3333
],
3434

3535
// A regex used to match every file name that you want to
3636
// exclude from parsing. Actual value will exclude every
3737
// "test", "tests", "Test" and "Tests" folders found in
3838
// "vendor/" directory.
39-
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
39+
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
4040

4141
// A directory list that defines files that will be excluded
4242
// from static analysis, but whose class and method
@@ -51,12 +51,9 @@
5151
// and `exclude_analysis_directory_list` arrays.
5252
'exclude_analysis_directory_list' => [
5353
'vendor/',
54-
'.phan/stubs'
54+
'.phan/stubs',
5555
],
56-
'suppress_issue_types' => [
56+
'suppress_issue_types' => [
5757
'PhanAccessMethodInternal',
58-
'PhanAccessOverridesFinalConstant',
59-
'PhanDeprecatedClass',
60-
'PhanDeprecatedClassConstant',
6158
],
6259
];

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chillerlan/php-qrcode",
3-
"description": "A QR code generator and reader with a user friendly API. PHP 7.4+",
3+
"description": "A QR code generator and reader with a user friendly API. PHP 8.2+",
44
"homepage": "https://github.com/chillerlan/php-qrcode",
55
"license": [
66
"MIT", "Apache-2.0"
@@ -40,15 +40,15 @@
4040
"minimum-stability": "stable",
4141
"prefer-stable": true,
4242
"require": {
43-
"php": "^7.4 || ^8.0",
43+
"php": "^8.2",
4444
"ext-mbstring": "*",
45-
"chillerlan/php-settings-container": "^2.1.4 || ^3.1"
45+
"chillerlan/php-settings-container": "^3.1"
4646
},
4747
"require-dev": {
48-
"chillerlan/php-authenticator": "^4.0 || ^5.0",
48+
"chillerlan/php-authenticator": "^5.0",
4949
"phan/phan": "^5.4",
5050
"phpunit/phpunit": "^9.6",
51-
"phpmd/phpmd": "^2.13",
51+
"phpmd/phpmd": "^2.14",
5252
"setasign/fpdf": "^1.8.2",
5353
"squizlabs/php_codesniffer": "^3.7"
5454
},

examples/custom_output.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
*/
1212

1313
use chillerlan\QRCode\{QRCode, QROptions};
14-
use chillerlan\QRCode\Common\EccLevel;
15-
use chillerlan\QRCode\Output\{QROutputAbstract, QROutputInterface};
14+
use chillerlan\QRCode\Output\QROutputAbstract;
1615

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

@@ -25,15 +24,15 @@ class MyCustomOutput extends QROutputAbstract{
2524
/**
2625
* @inheritDoc
2726
*/
28-
public static function moduleValueIsValid($value):bool{
27+
public static function moduleValueIsValid(mixed $value):bool{
2928
// TODO: Implement moduleValueIsValid() method. (interface)
3029
return false;
3130
}
3231

3332
/**
3433
* @inheritDoc
3534
*/
36-
protected function prepareModuleValue($value){
35+
protected function prepareModuleValue(mixed $value):mixed{
3736
// TODO: Implement prepareModuleValue() method. (abstract)
3837
return null;
3938
}
@@ -73,7 +72,7 @@ public function dump(string $file = null):string{
7372
$options = new QROptions;
7473

7574
$options->version = 5;
76-
$options->eccLevel = EccLevel::L;
75+
$options->eccLevel = 'L';
7776

7877
$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
7978

@@ -89,7 +88,6 @@ public function dump(string $file = null):string{
8988
var_dump($qrOutputInterface->dump());
9089

9190
// or just via the options
92-
$options->outputType = QROutputInterface::CUSTOM;
9391
$options->outputInterface = MyCustomOutput::class;
9492

9593
var_dump((new QRCode($options))->render($data));

examples/eps.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
use chillerlan\QRCode\{QRCode, QROptions};
1212
use chillerlan\QRCode\Data\QRMatrix;
13-
use chillerlan\QRCode\Output\QROutputInterface;
13+
use chillerlan\QRCode\Output\QREps;
1414

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

1717
$options = new QROptions;
1818

1919
$options->version = 7;
20-
$options->outputType = QROutputInterface::EPS;
20+
$options->outputInterface = QREps::class;
2121
$options->scale = 5;
2222
$options->drawLightModules = false;
2323
// colors can be specified either as [R, G, B] or [C, M, Y, K] (0-255)

examples/fpdf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
use chillerlan\QRCode\{QRCode, QROptions};
1111
use chillerlan\QRCode\Data\QRMatrix;
12-
use chillerlan\QRCode\Output\QROutputInterface;
12+
use chillerlan\QRCode\Output\QRFpdf;
1313

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

1616
$options = new QROptions;
1717

1818
$options->version = 7;
19-
$options->outputType = QROutputInterface::FPDF;
19+
$options->outputInterface = QRFpdf::class;
2020
$options->scale = 5;
2121
$options->fpdfMeasureUnit = 'mm';
2222
$options->bgColor = [222, 222, 222];

examples/html.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
use chillerlan\QRCode\{QRCode, QROptions};
1212
use chillerlan\QRCode\Data\QRMatrix;
13-
use chillerlan\QRCode\Output\QROutputInterface;
13+
use chillerlan\QRCode\Output\QRMarkupHTML;
1414

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

1717
$options = new QROptions;
1818

19-
$options->version = 5;
20-
$options->outputType = QROutputInterface::MARKUP_HTML;
21-
$options->cssClass = 'qrcode';
22-
$options->moduleValues = [
19+
$options->version = 5;
20+
$options->outputInterface = QRMarkupHTML::class;
21+
$options->cssClass = 'qrcode';
22+
$options->moduleValues = [
2323
// finder
2424
QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
2525
QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)

examples/image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
use chillerlan\QRCode\{QRCode, QROptions};
1212
use chillerlan\QRCode\Data\QRMatrix;
13-
use chillerlan\QRCode\Output\QROutputInterface;
13+
use chillerlan\QRCode\Output\QRGdImagePNG;
1414

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

1717
$options = new QROptions;
1818

1919
$options->version = 7;
20-
$options->outputType = QROutputInterface::GDIMAGE_PNG;
20+
$options->outputInterface = QRGdImagePNG::class;
2121
$options->scale = 20;
2222
$options->outputBase64 = false;
2323
$options->bgColor = [200, 150, 200];

examples/imageWithRoundedShapes.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use chillerlan\QRCode\Common\EccLevel;
1717
use chillerlan\QRCode\Data\QRMatrix;
1818
use chillerlan\QRCode\Output\QRGdImagePNG;
19-
use chillerlan\QRCode\Output\QROutputInterface;
2019
use chillerlan\QRCode\QRCode;
2120
use chillerlan\QRCode\QROptions;
2221
use chillerlan\Settings\SettingsContainerInterface;
@@ -30,7 +29,7 @@
3029
class QRGdRounded extends QRGdImagePNG{
3130

3231
/** @inheritDoc */
33-
public function __construct(SettingsContainerInterface $options, QRMatrix $matrix){
32+
public function __construct(SettingsContainerInterface|QROptions $options, QRMatrix $matrix){
3433
// enable the internal scaling for better rounding results at scale < 20
3534
$options->drawCircularModules = true;
3635

@@ -137,7 +136,6 @@ protected function module(int $x, int $y, int $M_TYPE):void{
137136
$options = new QROptions([
138137
'version' => 7,
139138
'eccLevel' => EccLevel::H,
140-
'outputType' => QROutputInterface::CUSTOM,
141139
'outputInterface' => QRGdRounded::class,
142140
'outputBase64' => false,
143141
'scale' => 30,

examples/imageWithText.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
use chillerlan\QRCode\{QRCode, QROptions};
16-
use chillerlan\QRCode\Output\{QROutputInterface, QRGdImagePNG};
16+
use chillerlan\QRCode\Output\QRGdImagePNG;
1717

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

@@ -66,7 +66,7 @@ protected function addText(string $text):void{
6666
$background = imagecolorallocate($this->image, ...$textBG);
6767

6868
// allow transparency
69-
if($this->options->imageTransparent && $this->options->outputType !== QROutputInterface::GDIMAGE_JPG){
69+
if($this->options->imageTransparent){
7070
imagecolortransparent($this->image, $background);
7171
}
7272

examples/imagick.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
use chillerlan\QRCode\{QRCode, QROptions};
1212
use chillerlan\QRCode\Data\QRMatrix;
13-
use chillerlan\QRCode\Output\QROutputInterface;
13+
use chillerlan\QRCode\Output\QRImagick;
1414

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

1717
$options = new QROptions;
1818

1919
$options->version = 7;
20-
$options->outputType = QROutputInterface::IMAGICK;
20+
$options->outputInterface = QRImagick::class;
2121
$options->imagickFormat = 'webp';
2222
$options->quality = 90;
2323
$options->scale = 20;

0 commit comments

Comments
 (0)