Skip to content

Commit cd57255

Browse files
chore:support laravel 12.x
1 parent 71e0448 commit cd57255

23 files changed

+76
-89
lines changed

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push]
44

55
jobs:
66
php-code-styling:
7-
runs-on: ubuntu-22.04
7+
runs-on: ubuntu-latest
88

99
strategy:
1010
fail-fast: true
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: 8.2
19+
php-version: 8.4
2020
tools: composer:v2
2121
coverage: none
2222

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
phpstan:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-latest
1212

1313
strategy:
1414
fail-fast: true
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup PHP
2323
uses: shivammathur/setup-php@v2
2424
with:
25-
php-version: 8.2
25+
php-version: 8.4
2626
tools: composer:v2
2727
coverage: none
2828

.github/workflows/run-tests.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-latest
1212

1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [ 8.1, 8.2, 8.3 ]
17-
laravel: [ 9, 10, 11 ]
16+
php: [ 8.4, 8.3, 8.2, 8.1 ]
17+
laravel: ["^12.0", "^11.0", "^10.0", "^9.0"]
1818
exclude:
1919
- php: 8.1
20-
laravel: 11
20+
laravel: "^12.0"
21+
- php: 8.1
22+
laravel: "^11.0"
23+
- php: 8.4
24+
laravel: 9
2125
- php: 8.3
2226
laravel: 9
2327

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[![Laravel 9.x](https://img.shields.io/badge/Laravel-9.x-red.svg?style=flat-square)](https://laravel.com/docs/9.x)
55
[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-red.svg?style=flat-square)](http://laravel.com/docs/10.x)
66
[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-red.svg?style=flat-square)](http://laravel.com/docs/11.x)
7+
[![Laravel 12.x](https://img.shields.io/badge/Laravel-12.x-red.svg?style=flat-square)](http://laravel.com/docs/12.x)
78
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/ageekdev/laravel-barcode/run-tests.yml?style=flat-square)](https://github.com/ageekdev/laravel-barcode/actions/workflows/run-tests.yml)
89
[![Total Downloads](https://img.shields.io/packagist/dt/ageekdev/laravel-barcode.svg?style=flat-square&logo=Packagist)](https://packagist.org/packages/ageekdev/laravel-barcode)
910

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
"require": {
1919
"php": "^8.1",
2020
"ext-bcmath": "*",
21-
"illuminate/contracts": "^9.0|^10.0|^11.0",
21+
"illuminate/contracts": "^9.0|^10.0|^11.0|^12.0",
2222
"spatie/color": "^1.5"
2323
},
2424
"require-dev": {
25-
"laravel/pint": "^1.10",
26-
"larastan/larastan": "^2.0",
27-
"orchestra/testbench": "^7.31|^8.11|^9.0",
25+
"laravel/pint": "^1.5",
26+
"larastan/larastan": "^2.0|^3.0",
27+
"orchestra/testbench": "^7.31|^8.11|^9.0|^10.0",
2828
"pestphp/pest": "^1.0|^2.0",
2929
"pestphp/pest-plugin-laravel": "^1.4|^2.0",
30-
"phpstan/extension-installer": "^1.1",
31-
"phpstan/phpstan-deprecation-rules": "^1.0",
32-
"phpstan/phpstan-phpunit": "^1.0",
30+
"phpstan/extension-installer": "^1.1|^2.0",
31+
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
32+
"phpstan/phpstan-phpunit": "^1.0|^2.0",
3333
"roave/security-advisories": "dev-latest"
3434
},
3535
"autoload": {

phpstan-baseline.neon

Whitespace-only changes.

phpstan.neon.dist

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
includes:
2-
- phpstan-baseline.neon
3-
41
parameters:
52
level: 4
63
paths:
74
- src
8-
- config
95
tmpDir: build/phpstan
106
checkOctaneCompatibility: true
11-
checkModelProperties: true
12-
checkMissingIterableValueType: false
137

src/BarcodeManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,39 @@ protected function callCustomCreator(string $driver): ImageType
105105
*/
106106
public function createHtmlDriver(): ImageType
107107
{
108-
return new HTML();
108+
return new HTML;
109109
}
110110

111111
/**
112112
* Create an DynamicHTML instance.
113113
*/
114114
public function createDynamicHtmlDriver(): ImageType
115115
{
116-
return new DynamicHTML();
116+
return new DynamicHTML;
117117
}
118118

119119
/**
120120
* Create an JPG instance.
121121
*/
122122
public function createJpgDriver(): ImageType
123123
{
124-
return new JPG();
124+
return new JPG;
125125
}
126126

127127
/**
128128
* Create an PNG instance.
129129
*/
130130
public function createPngDriver(): ImageType
131131
{
132-
return new PNG();
132+
return new PNG;
133133
}
134134

135135
/**
136136
* Create an SVG instance.
137137
*/
138138
public function createSvgDriver(): ImageType
139139
{
140-
return new SVG();
140+
return new SVG;
141141
}
142142

143143
/**

src/Drivers/JPG.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class JPG extends PNG
88
{
99
protected function createImagickImageObject(int $width, int $height): Imagick
1010
{
11-
$image = new Imagick();
11+
$image = new Imagick;
1212
$image->newImage($width, $height, 'white', 'JPG');
1313

1414
return $image;

src/Drivers/PNG.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function generate(string $text): string
6666
$foregroundColor = $this->getForegroundColor();
6767

6868
if ($this->useImagick) {
69-
$imagickBarsShape = new imagickdraw();
69+
$imagickBarsShape = new imagickdraw;
7070
$imagickBarsShape->setFillColor(new imagickpixel('rgb('.implode(',', $foregroundColor).')'));
7171
} else {
7272
$image = $this->createGdImageObject($width, $this->height);
@@ -127,7 +127,7 @@ protected function createGdImageObject(int $width, int $height)
127127
*/
128128
protected function createImagickImageObject(int $width, int $height): Imagick
129129
{
130-
$image = new Imagick();
130+
$image = new Imagick;
131131
$image->newImage($width, $height, 'none', 'PNG');
132132

133133
return $image;

src/Enums/Type.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,67 +102,67 @@ enum Type: string
102102
public function class(): TypeInterface
103103
{
104104
return match ($this) {
105-
self::TYPE_CODE_32 => new TypeCode32(),
105+
self::TYPE_CODE_32 => new TypeCode32,
106106

107-
self::TYPE_CODE_39 => new TypeCode39(),
107+
self::TYPE_CODE_39 => new TypeCode39,
108108

109-
self::TYPE_CODE_39_CHECKSUM => new TypeCode39Checksum(),
109+
self::TYPE_CODE_39_CHECKSUM => new TypeCode39Checksum,
110110

111-
self::TYPE_CODE_39E => new TypeCode39Extended(),
111+
self::TYPE_CODE_39E => new TypeCode39Extended,
112112

113-
self::TYPE_CODE_39E_CHECKSUM => new TypeCode39ExtendedChecksum(),
113+
self::TYPE_CODE_39E_CHECKSUM => new TypeCode39ExtendedChecksum,
114114

115-
self::TYPE_CODE_93 => new TypeCode93(),
115+
self::TYPE_CODE_93 => new TypeCode93,
116116

117-
self::TYPE_STANDARD_2_5 => new TypeStandard2of5(),
117+
self::TYPE_STANDARD_2_5 => new TypeStandard2of5,
118118

119-
self::TYPE_STANDARD_2_5_CHECKSUM => new TypeStandard2of5Checksum(),
119+
self::TYPE_STANDARD_2_5_CHECKSUM => new TypeStandard2of5Checksum,
120120

121-
self::TYPE_INTERLEAVED_2_5 => new TypeInterleaved25(),
121+
self::TYPE_INTERLEAVED_2_5 => new TypeInterleaved25,
122122

123-
self::TYPE_INTERLEAVED_2_5_CHECKSUM => new TypeInterleaved25Checksum(),
123+
self::TYPE_INTERLEAVED_2_5_CHECKSUM => new TypeInterleaved25Checksum,
124124

125-
self::TYPE_CODE_128 => new TypeCode128(),
125+
self::TYPE_CODE_128 => new TypeCode128,
126126

127-
self::TYPE_CODE_128_A => new TypeCode128A(),
127+
self::TYPE_CODE_128_A => new TypeCode128A,
128128

129-
self::TYPE_CODE_128_B => new TypeCode128B(),
129+
self::TYPE_CODE_128_B => new TypeCode128B,
130130

131-
self::TYPE_CODE_128_C => new TypeCode128C(),
131+
self::TYPE_CODE_128_C => new TypeCode128C,
132132

133-
self::TYPE_EAN_2 => new TypeUpcExtension2(),
133+
self::TYPE_EAN_2 => new TypeUpcExtension2,
134134

135-
self::TYPE_EAN_5 => new TypeUpcExtension5(),
135+
self::TYPE_EAN_5 => new TypeUpcExtension5,
136136

137-
self::TYPE_EAN_8 => new TypeEan8(),
137+
self::TYPE_EAN_8 => new TypeEan8,
138138

139-
self::TYPE_EAN_13 => new TypeEan13(),
139+
self::TYPE_EAN_13 => new TypeEan13,
140140

141-
self::TYPE_UPC_A => new TypeUpcA(),
141+
self::TYPE_UPC_A => new TypeUpcA,
142142

143-
self::TYPE_UPC_E => new TypeUpcE(),
143+
self::TYPE_UPC_E => new TypeUpcE,
144144

145-
self::TYPE_MSI => new TypeMsi(),
145+
self::TYPE_MSI => new TypeMsi,
146146

147-
self::TYPE_MSI_CHECKSUM => new TypeMsiChecksum(),
147+
self::TYPE_MSI_CHECKSUM => new TypeMsiChecksum,
148148

149-
self::TYPE_POSTNET => new TypePostnet(),
149+
self::TYPE_POSTNET => new TypePostnet,
150150

151-
self::TYPE_PLANET => new TypePlanet(),
151+
self::TYPE_PLANET => new TypePlanet,
152152

153-
self::TYPE_RMS4CC => new TypeRms4cc(),
153+
self::TYPE_RMS4CC => new TypeRms4cc,
154154

155-
self::TYPE_KIX => new TypeKix(),
155+
self::TYPE_KIX => new TypeKix,
156156

157-
self::TYPE_IMB => new TypeIntelligentMailBarcode(),
157+
self::TYPE_IMB => new TypeIntelligentMailBarcode,
158158

159-
self::TYPE_CODABAR => new TypeCodabar(),
159+
self::TYPE_CODABAR => new TypeCodabar,
160160

161-
self::TYPE_CODE_11 => new TypeCode11(),
161+
self::TYPE_CODE_11 => new TypeCode11,
162162

163-
self::TYPE_PHARMA_CODE => new TypePharmacode(),
163+
self::TYPE_PHARMA_CODE => new TypePharmacode,
164164

165-
self::TYPE_PHARMA_CODE_TWO_TRACKS => new TypePharmacodeTwoCode(),
165+
self::TYPE_PHARMA_CODE_TWO_TRACKS => new TypePharmacodeTwoCode,
166166
};
167167
}
168168
}

src/Exceptions/BarcodeException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class BarcodeException extends \Exception
6-
{
7-
}
5+
class BarcodeException extends \Exception {}

src/Exceptions/InvalidCharacterException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class InvalidCharacterException extends BarcodeException
6-
{
7-
}
5+
class InvalidCharacterException extends BarcodeException {}

src/Exceptions/InvalidCheckDigitException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class InvalidCheckDigitException extends BarcodeException
6-
{
7-
}
5+
class InvalidCheckDigitException extends BarcodeException {}

src/Exceptions/InvalidFormatException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class InvalidFormatException extends BarcodeException
6-
{
7-
}
5+
class InvalidFormatException extends BarcodeException {}

src/Exceptions/InvalidLengthException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class InvalidLengthException extends BarcodeException
6-
{
7-
}
5+
class InvalidLengthException extends BarcodeException {}

src/Exceptions/UnknownTypeException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace AgeekDev\Barcode\Exceptions;
44

5-
class UnknownTypeException extends BarcodeException
6-
{
7-
}
5+
class UnknownTypeException extends BarcodeException {}

src/Types/TypeCode128.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function getBarcodeData(string $code): Barcode
206206
if (preg_match('/(\d{2})/', $chrnum) > 0) {
207207
$code_data[] = (int) $chrnum;
208208
} else {
209-
throw new InvalidCharacterException();
209+
throw new InvalidCharacterException;
210210
}
211211
}
212212
break;
@@ -218,7 +218,7 @@ public function getBarcodeData(string $code): Barcode
218218
$numseq = [];
219219
preg_match_all('/(\d{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
220220

221-
if (isset($numseq[1]) && ! empty($numseq[1])) {
221+
if (! empty($numseq[1])) {
222222
$end_offset = 0;
223223

224224
foreach ($numseq[1] as $val) {
@@ -385,7 +385,7 @@ protected function get128ABsequence(string $code): array
385385
// get A sequences (if any)
386386
$numseq = [];
387387
preg_match_all('/([\x00-\x1f])/', $code, $numseq, PREG_OFFSET_CAPTURE);
388-
if (isset($numseq[1]) && ! empty($numseq[1])) {
388+
if (! empty($numseq[1])) {
389389
$end_offset = 0;
390390
foreach ($numseq[1] as $val) {
391391
$offset = $val[1];

src/Types/TypeEanUpcBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getBarcodeData(string $code): Barcode
5151
} elseif ($checksumDigit !== (int) $code[$dataLength]) {
5252
// If length of given barcode is same as final length, barcode is including checksum
5353
// Make sure that checksum is the same as we calculated
54-
throw new InvalidCheckDigitException();
54+
throw new InvalidCheckDigitException;
5555
}
5656

5757
if ($this->upca || $this->upce) {

src/Types/TypeIntelligentMailBarcode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public function getBarcodeData(string $code): Barcode
372372
}
373373
if (($fcs & $bitmask) > 0) {
374374
// bitwise invert
375-
$chrcode = ((~$chrcode) & 8191); /** @phpstan-ignore-line */
375+
$chrcode = ((~$chrcode) & 8191);
376376
}
377377
$characters[] = $chrcode;
378378
$bitmask /= 2;

src/Types/TypeInterleaved25Checksum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function getBarcodeData(string $code): Barcode
4848
$char_bar = $code[$i];
4949
$char_space = $code[$i + 1];
5050
if (! isset($chr[$char_bar], $chr[$char_space])) {
51-
throw new InvalidCharacterException();
51+
throw new InvalidCharacterException;
5252
}
5353

5454
// create a bar-space sequence

0 commit comments

Comments
 (0)