Skip to content

Commit

Permalink
Merge pull request #4 from ageekdev/laravel12-support
Browse files Browse the repository at this point in the history
Laravel 12.x Support
  • Loading branch information
tintnaingwin authored Mar 2, 2025
2 parents 71e0448 + b49c66c commit 00bcd4c
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 92 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
php-code-styling:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
fail-fast: true
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.4
tools: composer:v2
coverage: none

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
phpstan:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
fail-fast: true
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.4
tools: composer:v2
coverage: none

Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ on:

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9, 10, 11 ]
php: [ 8.4, 8.3, 8.2, 8.1 ]
laravel: ["^12.0", "^11.0", "^10.0", "^9.0"]
exclude:
- php: 8.1
laravel: 11
laravel: "^12.0"
- php: 8.1
laravel: "^11.0"
- php: 8.4
laravel: "^9.0"
- php: 8.3
laravel: 9
laravel: "^9.0"

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand All @@ -42,7 +46,7 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:^${{ matrix.laravel }}" --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:>=2.72" --dev --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress
- name: Execute tests
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Laravel 9.x](https://img.shields.io/badge/Laravel-9.x-red.svg?style=flat-square)](https://laravel.com/docs/9.x)
[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-red.svg?style=flat-square)](http://laravel.com/docs/10.x)
[![Laravel 11.x](https://img.shields.io/badge/Laravel-11.x-red.svg?style=flat-square)](http://laravel.com/docs/11.x)
[![Laravel 12.x](https://img.shields.io/badge/Laravel-12.x-red.svg?style=flat-square)](http://laravel.com/docs/12.x)
[![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)
[![Total Downloads](https://img.shields.io/packagist/dt/ageekdev/laravel-barcode.svg?style=flat-square&logo=Packagist)](https://packagist.org/packages/ageekdev/laravel-barcode)

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"require": {
"php": "^8.1",
"ext-bcmath": "*",
"illuminate/contracts": "^9.0|^10.0|^11.0",
"illuminate/contracts": "^9.0|^10.0|^11.0|^12.0",
"spatie/color": "^1.5"
},
"require-dev": {
"laravel/pint": "^1.10",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^7.31|^8.11|^9.0",
"pestphp/pest": "^1.0|^2.0",
"pestphp/pest-plugin-laravel": "^1.4|^2.0",
"laravel/pint": "^1.5",
"larastan/larastan": "^2.0|^3.0",
"orchestra/testbench": "^7.31|^8.11|^9.0|^10.0",
"pestphp/pest": "^1.21|^2.0|^3.0",
"pestphp/pest-plugin-laravel": "^1.4|^2.0|^3.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0|^2.0",
"phpstan/phpstan-phpunit": "^1.0|^2.0",
"roave/security-advisories": "dev-latest"
},
"autoload": {
Expand Down
Empty file removed phpstan-baseline.neon
Empty file.
6 changes: 0 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: 4
paths:
- src
- config
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false

10 changes: 5 additions & 5 deletions src/BarcodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,39 @@ protected function callCustomCreator(string $driver): ImageType
*/
public function createHtmlDriver(): ImageType
{
return new HTML();
return new HTML;
}

/**
* Create an DynamicHTML instance.
*/
public function createDynamicHtmlDriver(): ImageType
{
return new DynamicHTML();
return new DynamicHTML;
}

/**
* Create an JPG instance.
*/
public function createJpgDriver(): ImageType
{
return new JPG();
return new JPG;
}

/**
* Create an PNG instance.
*/
public function createPngDriver(): ImageType
{
return new PNG();
return new PNG;
}

/**
* Create an SVG instance.
*/
public function createSvgDriver(): ImageType
{
return new SVG();
return new SVG;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/JPG.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class JPG extends PNG
{
protected function createImagickImageObject(int $width, int $height): Imagick
{
$image = new Imagick();
$image = new Imagick;
$image->newImage($width, $height, 'white', 'JPG');

return $image;
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/PNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function generate(string $text): string
$foregroundColor = $this->getForegroundColor();

if ($this->useImagick) {
$imagickBarsShape = new imagickdraw();
$imagickBarsShape = new imagickdraw;
$imagickBarsShape->setFillColor(new imagickpixel('rgb('.implode(',', $foregroundColor).')'));
} else {
$image = $this->createGdImageObject($width, $this->height);
Expand Down Expand Up @@ -127,7 +127,7 @@ protected function createGdImageObject(int $width, int $height)
*/
protected function createImagickImageObject(int $width, int $height): Imagick
{
$image = new Imagick();
$image = new Imagick;
$image->newImage($width, $height, 'none', 'PNG');

return $image;
Expand Down
62 changes: 31 additions & 31 deletions src/Enums/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,67 +102,67 @@ enum Type: string
public function class(): TypeInterface
{
return match ($this) {
self::TYPE_CODE_32 => new TypeCode32(),
self::TYPE_CODE_32 => new TypeCode32,

self::TYPE_CODE_39 => new TypeCode39(),
self::TYPE_CODE_39 => new TypeCode39,

self::TYPE_CODE_39_CHECKSUM => new TypeCode39Checksum(),
self::TYPE_CODE_39_CHECKSUM => new TypeCode39Checksum,

self::TYPE_CODE_39E => new TypeCode39Extended(),
self::TYPE_CODE_39E => new TypeCode39Extended,

self::TYPE_CODE_39E_CHECKSUM => new TypeCode39ExtendedChecksum(),
self::TYPE_CODE_39E_CHECKSUM => new TypeCode39ExtendedChecksum,

self::TYPE_CODE_93 => new TypeCode93(),
self::TYPE_CODE_93 => new TypeCode93,

self::TYPE_STANDARD_2_5 => new TypeStandard2of5(),
self::TYPE_STANDARD_2_5 => new TypeStandard2of5,

self::TYPE_STANDARD_2_5_CHECKSUM => new TypeStandard2of5Checksum(),
self::TYPE_STANDARD_2_5_CHECKSUM => new TypeStandard2of5Checksum,

self::TYPE_INTERLEAVED_2_5 => new TypeInterleaved25(),
self::TYPE_INTERLEAVED_2_5 => new TypeInterleaved25,

self::TYPE_INTERLEAVED_2_5_CHECKSUM => new TypeInterleaved25Checksum(),
self::TYPE_INTERLEAVED_2_5_CHECKSUM => new TypeInterleaved25Checksum,

self::TYPE_CODE_128 => new TypeCode128(),
self::TYPE_CODE_128 => new TypeCode128,

self::TYPE_CODE_128_A => new TypeCode128A(),
self::TYPE_CODE_128_A => new TypeCode128A,

self::TYPE_CODE_128_B => new TypeCode128B(),
self::TYPE_CODE_128_B => new TypeCode128B,

self::TYPE_CODE_128_C => new TypeCode128C(),
self::TYPE_CODE_128_C => new TypeCode128C,

self::TYPE_EAN_2 => new TypeUpcExtension2(),
self::TYPE_EAN_2 => new TypeUpcExtension2,

self::TYPE_EAN_5 => new TypeUpcExtension5(),
self::TYPE_EAN_5 => new TypeUpcExtension5,

self::TYPE_EAN_8 => new TypeEan8(),
self::TYPE_EAN_8 => new TypeEan8,

self::TYPE_EAN_13 => new TypeEan13(),
self::TYPE_EAN_13 => new TypeEan13,

self::TYPE_UPC_A => new TypeUpcA(),
self::TYPE_UPC_A => new TypeUpcA,

self::TYPE_UPC_E => new TypeUpcE(),
self::TYPE_UPC_E => new TypeUpcE,

self::TYPE_MSI => new TypeMsi(),
self::TYPE_MSI => new TypeMsi,

self::TYPE_MSI_CHECKSUM => new TypeMsiChecksum(),
self::TYPE_MSI_CHECKSUM => new TypeMsiChecksum,

self::TYPE_POSTNET => new TypePostnet(),
self::TYPE_POSTNET => new TypePostnet,

self::TYPE_PLANET => new TypePlanet(),
self::TYPE_PLANET => new TypePlanet,

self::TYPE_RMS4CC => new TypeRms4cc(),
self::TYPE_RMS4CC => new TypeRms4cc,

self::TYPE_KIX => new TypeKix(),
self::TYPE_KIX => new TypeKix,

self::TYPE_IMB => new TypeIntelligentMailBarcode(),
self::TYPE_IMB => new TypeIntelligentMailBarcode,

self::TYPE_CODABAR => new TypeCodabar(),
self::TYPE_CODABAR => new TypeCodabar,

self::TYPE_CODE_11 => new TypeCode11(),
self::TYPE_CODE_11 => new TypeCode11,

self::TYPE_PHARMA_CODE => new TypePharmacode(),
self::TYPE_PHARMA_CODE => new TypePharmacode,

self::TYPE_PHARMA_CODE_TWO_TRACKS => new TypePharmacodeTwoCode(),
self::TYPE_PHARMA_CODE_TWO_TRACKS => new TypePharmacodeTwoCode,
};
}
}
4 changes: 1 addition & 3 deletions src/Exceptions/BarcodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class BarcodeException extends \Exception
{
}
class BarcodeException extends \Exception {}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidCharacterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class InvalidCharacterException extends BarcodeException
{
}
class InvalidCharacterException extends BarcodeException {}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidCheckDigitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class InvalidCheckDigitException extends BarcodeException
{
}
class InvalidCheckDigitException extends BarcodeException {}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidFormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class InvalidFormatException extends BarcodeException
{
}
class InvalidFormatException extends BarcodeException {}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidLengthException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class InvalidLengthException extends BarcodeException
{
}
class InvalidLengthException extends BarcodeException {}
4 changes: 1 addition & 3 deletions src/Exceptions/UnknownTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace AgeekDev\Barcode\Exceptions;

class UnknownTypeException extends BarcodeException
{
}
class UnknownTypeException extends BarcodeException {}
6 changes: 3 additions & 3 deletions src/Types/TypeCode128.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function getBarcodeData(string $code): Barcode
if (preg_match('/(\d{2})/', $chrnum) > 0) {
$code_data[] = (int) $chrnum;
} else {
throw new InvalidCharacterException();
throw new InvalidCharacterException;
}
}
break;
Expand All @@ -218,7 +218,7 @@ public function getBarcodeData(string $code): Barcode
$numseq = [];
preg_match_all('/(\d{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);

if (isset($numseq[1]) && ! empty($numseq[1])) {
if (! empty($numseq[1])) {
$end_offset = 0;

foreach ($numseq[1] as $val) {
Expand Down Expand Up @@ -385,7 +385,7 @@ protected function get128ABsequence(string $code): array
// get A sequences (if any)
$numseq = [];
preg_match_all('/([\x00-\x1f])/', $code, $numseq, PREG_OFFSET_CAPTURE);
if (isset($numseq[1]) && ! empty($numseq[1])) {
if (! empty($numseq[1])) {
$end_offset = 0;
foreach ($numseq[1] as $val) {
$offset = $val[1];
Expand Down
2 changes: 1 addition & 1 deletion src/Types/TypeEanUpcBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getBarcodeData(string $code): Barcode
} elseif ($checksumDigit !== (int) $code[$dataLength]) {
// If length of given barcode is same as final length, barcode is including checksum
// Make sure that checksum is the same as we calculated
throw new InvalidCheckDigitException();
throw new InvalidCheckDigitException;
}

if ($this->upca || $this->upce) {
Expand Down
2 changes: 1 addition & 1 deletion src/Types/TypeIntelligentMailBarcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getBarcodeData(string $code): Barcode
}
if (($fcs & $bitmask) > 0) {
// bitwise invert
$chrcode = ((~$chrcode) & 8191); /** @phpstan-ignore-line */
$chrcode = ((~$chrcode) & 8191);
}
$characters[] = $chrcode;
$bitmask /= 2;
Expand Down
2 changes: 1 addition & 1 deletion src/Types/TypeInterleaved25Checksum.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getBarcodeData(string $code): Barcode
$char_bar = $code[$i];
$char_space = $code[$i + 1];
if (! isset($chr[$char_bar], $chr[$char_space])) {
throw new InvalidCharacterException();
throw new InvalidCharacterException;
}

// create a bar-space sequence
Expand Down
Loading

0 comments on commit 00bcd4c

Please sign in to comment.