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

feat: drop support for php 8 #157

Merged
merged 1 commit into from
Mar 18, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2']
php-versions: ['8.1', '8.2', '8.3']
runs-on: ${{ matrix.operating-system }}
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/composer.lock
/vendor
/.phpunit.result.cache
/.phpunit.cache
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 3.0.0 - 2022-03-14

### Changed

- Add strong php Types
- Fix spelling of DEFAULT_BYTE_MODE_ENCODING => DEFAULT_BYTE_MODE_ENCODING
- Constructor names of BlockPair
- Drop support for PHP < 8.1

## 2.0.7 - 2022-03-14

### Fixed
Expand Down
18 changes: 12 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license" : "BSD-2-Clause",
"homepage": "https://github.com/Bacon/BaconQrCode",
"require": {
"php": "^7.1 || ^8.0",
"php": "^8.1",
"ext-iconv": "*",
"dasprid/enum": "^1.0.3"
},
Expand All @@ -24,15 +24,21 @@
"BaconQrCode\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"BaconQrCodeTest\\": "test/"
}
},
"require-dev": {
"phpunit/phpunit": "^7 | ^8 | ^9",
"spatie/phpunit-snapshot-assertions": "^4.2.9",
"squizlabs/php_codesniffer": "^3.4",
"phly/keep-a-changelog": "^2.1"
"phpunit/phpunit": "^10.5.11 || 11.0.4",
"spatie/phpunit-snapshot-assertions": "^5.1.5",
"squizlabs/php_codesniffer": "^3.9",
"phly/keep-a-changelog": "^2.12"
},
"config": {
"allow-plugins": {
"ocramius/package-versions": true
"ocramius/package-versions": true,
"php-http/discovery": true
}
},
"archive": {
Expand Down
18 changes: 12 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="BaconQrCode Tests">
<directory>./test</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory>src</directory>
</include>
</source>

</phpunit>
16 changes: 4 additions & 12 deletions src/Common/BitArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@ final class BitArray
*
* @var SplFixedArray<int>
*/
private $bits;

/**
* Size of the bit array in bits.
*
* @var int
*/
private $size;
private SplFixedArray $bits;

/**
* Creates a new bit array with a given size.
*/
public function __construct(int $size = 0)
public function __construct(private int $size = 0)
{
$this->size = $size;
$this->bits = SplFixedArray::fromArray(array_fill(0, ($this->size + 31) >> 3, 0));
}

Expand Down Expand Up @@ -107,7 +99,7 @@ public function getNextSet(int $from) : int
}

$result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits);
return $result > $this->size ? $this->size : $result;
return min($result, $this->size);
}

/**
Expand All @@ -133,7 +125,7 @@ public function getNextUnset(int $from) : int
}

$result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits);
return $result > $this->size ? $this->size : $result;
return min($result, $this->size);
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/Common/BitMatrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,25 @@ class BitMatrix
{
/**
* Width of the bit matrix.
*
* @var int
*/
private $width;
private int $width;

/**
* Height of the bit matrix.
*
* @var int
*/
private $height;
private ?int $height;

/**
* Size in bits of each individual row.
*
* @var int
*/
private $rowSize;
private int $rowSize;

/**
* Bits representation.
*
* @var SplFixedArray<int>
*/
private $bits;
private SplFixedArray $bits;

/**
* @throws InvalidArgumentException if a dimension is smaller than zero
Expand Down
14 changes: 4 additions & 10 deletions src/Common/CharacterSetEci.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,26 @@ final class CharacterSetEci extends AbstractEnum
protected const GB18030 = [[29], 'GB2312', 'EUC_CN', 'GBK'];
protected const EUC_KR = [[30], 'EUC-KR'];

/**
* @var int[]
*/
private $values;

/**
* @var string[]
*/
private $otherEncodingNames;
private array $otherEncodingNames;

/**
* @var array<int, self>|null
*/
private static $valueToEci;
private static ?array $valueToEci;

/**
* @var array<string, self>|null
*/
private static $nameToEci;
private static ?array $nameToEci = null;

/**
* @param int[] $values
*/
public function __construct(array $values, string ...$otherEncodingNames)
public function __construct(private readonly array $values, string ...$otherEncodingNames)
{
$this->values = $values;
$this->otherEncodingNames = $otherEncodingNames;
}

Expand Down
18 changes: 1 addition & 17 deletions src/Common/EcBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@
*/
final class EcBlock
{
/**
* How many times the block is used.
*
* @var int
*/
private $count;

/**
* Number of data codewords.
*
* @var int
*/
private $dataCodewords;

public function __construct(int $count, int $dataCodewords)
public function __construct(private readonly int $count, private readonly int $dataCodewords)
{
$this->count = $count;
$this->dataCodewords = $dataCodewords;
}

/**
Expand Down
12 changes: 2 additions & 10 deletions src/Common/EcBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,15 @@
*/
final class EcBlocks
{
/**
* Number of EC codewords per block.
*
* @var int
*/
private $ecCodewordsPerBlock;

/**
* List of EC blocks.
*
* @var EcBlock[]
*/
private $ecBlocks;
private array $ecBlocks;

public function __construct(int $ecCodewordsPerBlock, EcBlock ...$ecBlocks)
public function __construct(private readonly int $ecCodewordsPerBlock, EcBlock ...$ecBlocks)
{
$this->ecCodewordsPerBlock = $ecCodewordsPerBlock;
$this->ecBlocks = $ecBlocks;
}

Expand Down
8 changes: 1 addition & 7 deletions src/Common/ErrorCorrectionLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ final class ErrorCorrectionLevel extends AbstractEnum
protected const Q = [0x03];
protected const H = [0x02];

/**
* @var int
*/
private $bits;

protected function __construct(int $bits)
protected function __construct(private readonly int $bits)
{
$this->bits = $bits;
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Common/FormatInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,10 @@ class FormatInformation

/**
* Error correction level.
*
* @var ErrorCorrectionLevel
*/
private $ecLevel;
private ErrorCorrectionLevel $ecLevel;

/**
* Data mask.
*
* @var int
*/
private $dataMask;
private int $dataMask;

protected function __construct(int $formatInfo)
{
Expand Down
18 changes: 4 additions & 14 deletions src/Common/Mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,13 @@ final class Mode extends AbstractEnum
protected const FNC1_SECOND_POSITION = [[0, 0, 0], 0x09];
protected const HANZI = [[8, 10, 12], 0x0d];

/**
* @var int[]
*/
private $characterCountBitsForVersions;

/**
* @var int
*/
private $bits;

/**
* @param int[] $characterCountBitsForVersions
*/
protected function __construct(array $characterCountBitsForVersions, int $bits)
{
$this->characterCountBitsForVersions = $characterCountBitsForVersions;
$this->bits = $bits;
protected function __construct(
private readonly array $characterCountBitsForVersions,
private readonly int $bits
) {
}

/**
Expand Down
Loading
Loading