Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for PHP 8.0 | Add support for PHP 8.4 #265

Merged
merged 10 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
php: ['8.1', '8.2', '8.3', '8.4']
stability: ['prefer-lowest', 'prefer-stable']

name: PHP Tests ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
extensions: dom, curl, libxml, mbstring, zip, bcmath, gd
tools: composer
coverage: none
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ The beauty of open source software lies in the fact that everybody can benefit f

In addition, a minor version will always be published if any visible change in the output of the qr code or the payment part takes place, even if it could be considered to be just a bugfix.

### PHP version support

This library supports a PHP version as long as it accounts for at least approximately 10% [of current installations](https://packagist.org/packages/sprain/swiss-qr-bill/php-stats).

### Depdendency support

Older versions of dependencies are supported as long as they do not hinder further development or account for at least
approximately 10% of current installations of the corresponding dependency.

## Support the project

* Do you like this project? [Consider a Github sponsorship.](https://github.com/sponsors/sprain)
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"license": "MIT",
"require": {
"php": "~8.0.0|~8.1.0|~8.2.0|~8.3.0",
"php": "~8.1.0|~8.2.0|~8.3.0|~8.4.0",
"ext-dom": "*",
"ext-bcmath": "*",
"symfony/validator": "^4.4|^5.0|^6.0|^7.0",
Expand All @@ -24,7 +24,8 @@
"phpstan/phpstan": "^1.11-dev",
"setasign/fpdi": "^2.3.5",
"setasign/fpdf": "^1.8.2",
"tecnickcom/tcpdf": "^6.3.2"
"tecnickcom/tcpdf": "^6.3.2",
"rector/rector": "^1.2"
},
"scripts": {
"cs:fix": "vendor/bin/php-cs-fixer fix --verbose",
Expand Down
3 changes: 2 additions & 1 deletion example/FpdfOutput/fpdf-example.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php declare(strict_types=1);

use Fpdf\Fpdf;
use Sprain\SwissQrBill as QrBill;
use Sprain\SwissQrBill\PaymentPart\Output\DisplayOptions;

Expand All @@ -10,7 +11,7 @@

// 2. Create an FPDF instance (or use an existing one from your project)
// – alternatively, an instance of \setasign\Fpdi\Fpdi() is also accepted by FpdfOutput.
$fpdf = new \Fpdf\Fpdf('P', 'mm', 'A4');
$fpdf = new Fpdf('P', 'mm', 'A4');

// In case your server does not support "allow_url_fopen", use this way to create your FPDF instance:
// $fpdf = new class('P', 'mm', 'A4') extends \Fpdf\Fpdf {
Expand Down
2 changes: 1 addition & 1 deletion example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
try {
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.png');
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.svg');
} catch (Exception $e) {
} catch (Exception) {
foreach ($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
Expand Down
2 changes: 1 addition & 1 deletion example/example_minimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
try {
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.png');
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.svg');
} catch (Exception $e) {
} catch (Exception) {
foreach ($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
Expand Down
2 changes: 1 addition & 1 deletion example/example_scor.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
try {
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.png');
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.svg');
} catch (Exception $e) {
} catch (Exception) {
foreach ($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
Expand Down
2 changes: 1 addition & 1 deletion example/example_zero_amount.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
try {
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.png');
$qrBill->getQrCode()->writeFile(__DIR__ . '/qr.svg');
} catch (Exception $e) {
} catch (Exception) {
foreach ($qrBill->getViolations() as $violation) {
print $violation->getMessage()."\n";
}
Expand Down
22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Set\ValueObject\SetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/example',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->importNames(true);
$rectorConfig->importShortClasses(false)

$rectorConfig->sets([SetList::PHP_81]);

$rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class);
};
26 changes: 10 additions & 16 deletions src/DataGroup/Element/AdditionalInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,18 @@ final class AdditionalInformation implements QrCodeableInterface, SelfValidatabl

public const TRAILER_EPD = 'EPD';

/**
* Unstructured information can be used to indicate the payment purpose
* or for additional textual information about payments with a structured reference.
*/
private ?string $message;

/**
* Bill information contains coded information for automated booking of the payment.
* The data is not forwarded with the payment.
*/
private ?string $billInformation;

private function __construct(
?string $message,
?string $billInformation
/**
* Unstructured information can be used to indicate the payment purpose
* or for additional textual information about payments with a structured reference.
*/
private ?string $message,
/**
* Bill information contains coded information for automated booking of the payment.
* The data is not forwarded with the payment.
*/
private ?string $billInformation
) {
$this->message = $message;
$this->billInformation = $billInformation;
}

public static function create(
Expand Down
14 changes: 6 additions & 8 deletions src/DataGroup/Element/AlternativeScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ final class AlternativeScheme implements QrCodeableInterface, SelfValidatableInt
{
use SelfValidatableTrait;

/**
* Parameter character chain of the alternative scheme
*/
private string $parameter;

private function __construct(string $parameter)
{
$this->parameter = $parameter;
private function __construct(
/**
* Parameter character chain of the alternative scheme
*/
private string $parameter
) {
}

public static function create(string $parameter): self
Expand Down
53 changes: 23 additions & 30 deletions src/DataGroup/Element/CombinedAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use Sprain\SwissQrBill\DataGroup\AddressInterface;
use Sprain\SwissQrBill\DataGroup\Element\Abstracts\Address;
use Sprain\SwissQrBill\DataGroup\QrCodeableInterface;
use Sprain\SwissQrBill\String\StringAnalyzer;
use Sprain\SwissQrBill\String\StringModifier;
use Sprain\SwissQrBill\Validator\SelfValidatableInterface;
use Sprain\SwissQrBill\Validator\SelfValidatableTrait;
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -18,35 +16,30 @@ class CombinedAddress extends Address implements AddressInterface, SelfValidatab

public const ADDRESS_TYPE = 'K';

/**
* Name or company
*/
private string $name;

/**
* Address line 1
*
* Street and building number or P.O. Box
*/
private ?string $addressLine1;

/**
* Address line 2
*
* Postal code and town
*/
private string $addressLine2;

/**
* Country (ISO 3166-1 alpha-2)
*/
private string $country;

private function __construct(
string $name,
?string $addressLine1,
string $addressLine2,
string $country
/**
* Name or company
*/
private string $name,

/**
* Address line 1
*
* Street and building number or P.O. Box
*/
private ?string $addressLine1,

/**
* Address line 2
*
* Postal code and town
*/
private string $addressLine2,

/**
* Country (ISO 3166-1 alpha-2)
*/
private string $country
) {
$this->name = self::normalizeString($name);
$this->addressLine1 = self::normalizeString($addressLine1);
Expand Down
13 changes: 6 additions & 7 deletions src/DataGroup/Element/CreditorInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ final class CreditorInformation implements QrCodeableInterface, SelfValidatableI
{
use SelfValidatableTrait;

/**
* IBAN or QR-IBAN of the creditor
*/
private string $iban;

private function __construct(string $iban)
{
private function __construct(
/**
* IBAN or QR-IBAN of the creditor
*/
private string $iban
) {
$this->iban = StringModifier::stripWhitespace($iban);
}

Expand Down
42 changes: 19 additions & 23 deletions src/DataGroup/Element/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,25 @@ final class Header implements QrCodeableInterface, SelfValidatableInterface
public const VERSION_0200 = '0200';
public const CODING_LATIN = 1;

/**
* Unambiguous indicator for the Swiss QR code.
*/
private string $qrType;

/**
* Version of the specifications (Implementation Guidelines) in use on
* the date on which the Swiss QR code was created.
* The first two positions indicate the main version, the following the
* two positions the sub-version ("0200" for version 2.0).
*/
private string $version;

/**
* Character set code
*/
private int $coding;

private function __construct(string $qrType, string $version, int $coding)
{
$this->qrType = $qrType;
$this->version = $version;
$this->coding = $coding;
private function __construct(
/**
* Unambiguous indicator for the Swiss QR code.
*/
private readonly string $qrType,

/**
* Version of the specifications (Implementation Guidelines) in use on
* the date on which the Swiss QR code was created.
* The first two positions indicate the main version, the following the
* two positions the sub-version ("0200" for version 2.0).
*/
private readonly string $version,

/**
* Character set code
*/
private readonly int $coding
) {
}

public static function create(string $qrType, string $version, int $coding): self
Expand Down
24 changes: 11 additions & 13 deletions src/DataGroup/Element/PaymentAmountInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ final class PaymentAmountInformation implements QrCodeableInterface, SelfValidat
public const CURRENCY_CHF = 'CHF';
public const CURRENCY_EUR = 'EUR';

/**
* The payment amount due
*/
private ?float $amount;

/**
* Payment currency code (ISO 4217)
*/
private string $currency;

private function __construct(string $currency, ?float $amount)
{
private function __construct(
/**
* Payment currency code (ISO 4217)
*/
private string $currency,

/**
* The payment amount due
*/
private readonly ?float $amount
) {
$this->currency = strtoupper($currency);
$this->amount = $amount;
}

public static function create(string $currency, ?float $amount = null): self
Expand Down
Loading
Loading