Skip to content

Commit

Permalink
Php8 (#80)
Browse files Browse the repository at this point in the history
* Require PHP 8+
  • Loading branch information
nicolaasuni committed Nov 22, 2023
1 parent cd81392 commit 313b243
Show file tree
Hide file tree
Showing 124 changed files with 10,920 additions and 7,978 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/check.yml
Expand Up @@ -23,13 +23,10 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]
php-version: ["8.0", "8.1", "8.2"]
experimental: [false]
os: [ubuntu-latest]
coverage-extension: [pcov]
include:
- { php-version: '5.6', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' }
- { php-version: '7.1', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' }
steps:
- uses: actions/checkout@v4
- name: Use php ${{ matrix.php-version }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -8,11 +8,13 @@
**/auth.json
**/nbproject
**/temp.php
**/test.php
.phpdoc
.phpunit.cache
.phpunit.result.cache
composer.lock
example/test.php
ecs.php
phpunit.xml
rector.php
target
vendor
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -163,7 +163,7 @@ endif
deps: ensuretarget
rm -rf ./vendor/*
($(COMPOSER) install -vvv --no-interaction)
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.38/phpstan.phar \
curl --silent --show-error --fail --location --output ./vendor/phpstan.phar https://github.com/phpstan/phpstan/releases/download/1.10.41/phpstan.phar \
&& chmod +x ./vendor/phpstan.phar

# Generate source code documentation
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -108,7 +108,7 @@ All artifacts are generated in the target directory.

Examples are located in the `example` directory.

Start a development server (requires at least PHP 5.6) using the command:
Start a development server (requires PHP 8.0+) using the command:

```
make server
Expand Down Expand Up @@ -147,15 +147,15 @@ Create a composer.json in your projects root-directory:
```json
{
"require": {
"tecnickcom/tc-lib-barcode": "^1.18"
"tecnickcom/tc-lib-barcode": "^2.0"
}
}
```

Or add to an existing project with:

```bash
composer require tecnickcom/tc-lib-barcode ^1.18
composer require tecnickcom/tc-lib-barcode ^2.0
```

## Packaging
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.18.4
2.0.7
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -53,18 +53,18 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=8.0",
"ext-bcmath": "*",
"ext-date": "*",
"ext-gd": "*",
"ext-pcre": "*",
"tecnickcom/tc-lib-color": "^1.14"
"tecnickcom/tc-lib-color": "^2.0"
},
"require-dev": {
"pdepend/pdepend": "2.13.0",
"phpmd/phpmd": "2.13.0",
"phpunit/phpunit": "10.1.2 || 9.6.7 || 8.5.31 || 7.5.20 || 6.5.14 || 5.7.27 || 4.8.36",
"squizlabs/php_codesniffer": "3.7.2 || 2.9.2"
"phpunit/phpunit": "10.1.2 || 9.6.13",
"squizlabs/php_codesniffer": "3.7.2"
},
"autoload": {
"psr-4": {
Expand Down
120 changes: 60 additions & 60 deletions example/index.php
Expand Up @@ -14,75 +14,75 @@
*/

// autoloader when using Composer
require ('../vendor/autoload.php');
require(__DIR__ . '/../vendor/autoload.php');

// autoloader when using RPM or DEB package installation
//require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php');

// data to generate for each barcode type
$linear = array(
'C128A' => array('0123456789', 'CODE 128 A'),
'C128B' => array('0123456789', 'CODE 128 B'),
'C128C' => array('0123456789', 'CODE 128 C'),
'C128' => array('0123456789', 'CODE 128'),
'C39E+' => array('0123456789', 'CODE 39 EXTENDED + CHECKSUM'),
'C39E' => array('0123456789', 'CODE 39 EXTENDED'),
'C39+' => array('0123456789', 'CODE 39 + CHECKSUM'),
'C39' => array('0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'),
'C93' => array('0123456789', 'CODE 93 - USS-93'),
'CODABAR' => array('0123456789', 'CODABAR'),
'CODE11' => array('0123456789', 'CODE 11'),
'EAN13' => array('0123456789', 'EAN 13'),
'EAN2' => array('12', 'EAN 2-Digits UPC-Based Extension'),
'EAN5' => array('12345', 'EAN 5-Digits UPC-Based Extension'),
'EAN8' => array('1234567', 'EAN 8'),
'I25+' => array('0123456789', 'Interleaved 2 of 5 + CHECKSUM'),
'I25' => array('0123456789', 'Interleaved 2 of 5'),
'IMB' => array('01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'),
'IMBPRE' => array('AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'),
'KIX' => array('0123456789', 'KIX (Klant index - Customer index)'),
'MSI+' => array('0123456789', 'MSI + CHECKSUM (modulo 11)'),
'MSI' => array('0123456789', 'MSI (Variation of Plessey code)'),
'PHARMA2T' => array('0123456789', 'PHARMACODE TWO-TRACKS'),
'PHARMA' => array('0123456789', 'PHARMACODE'),
'PLANET' => array('0123456789', 'PLANET'),
'POSTNET' => array('0123456789', 'POSTNET'),
'RMS4CC' => array('0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'),
'S25+' => array('0123456789', 'Standard 2 of 5 + CHECKSUM'),
'S25' => array('0123456789', 'Standard 2 of 5'),
'UPCA' => array('72527273070', 'UPC-A'),
'UPCE' => array('725277', 'UPC-E'),
);
$linear = [
'C128A' => ['0123456789', 'CODE 128 A'],
'C128B' => ['0123456789', 'CODE 128 B'],
'C128C' => ['0123456789', 'CODE 128 C'],
'C128' => ['0123456789', 'CODE 128'],
'C39E+' => ['0123456789', 'CODE 39 EXTENDED + CHECKSUM'],
'C39E' => ['0123456789', 'CODE 39 EXTENDED'],
'C39+' => ['0123456789', 'CODE 39 + CHECKSUM'],
'C39' => ['0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'],
'C93' => ['0123456789', 'CODE 93 - USS-93'],
'CODABAR' => ['0123456789', 'CODABAR'],
'CODE11' => ['0123456789', 'CODE 11'],
'EAN13' => ['0123456789', 'EAN 13'],
'EAN2' => ['12', 'EAN 2-Digits UPC-Based Extension'],
'EAN5' => ['12345', 'EAN 5-Digits UPC-Based Extension'],
'EAN8' => ['1234567', 'EAN 8'],
'I25+' => ['0123456789', 'Interleaved 2 of 5 + CHECKSUM'],
'I25' => ['0123456789', 'Interleaved 2 of 5'],
'IMB' => ['01234567094987654321-01234567891', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'],
'IMBPRE' => ['AADTFFDFTDADTAADAATFDTDDAAADDTDTTDAFADADDDTFFFDDTTTADFAAADFTDAADA', 'IMB pre-processed'],
'KIX' => ['0123456789', 'KIX (Klant index - Customer index)'],
'MSI+' => ['0123456789', 'MSI + CHECKSUM (modulo 11)'],
'MSI' => ['0123456789', 'MSI (Variation of Plessey code)'],
'PHARMA2T' => ['0123456789', 'PHARMACODE TWO-TRACKS'],
'PHARMA' => ['0123456789', 'PHARMACODE'],
'PLANET' => ['0123456789', 'PLANET'],
'POSTNET' => ['0123456789', 'POSTNET'],
'RMS4CC' => ['0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'],
'S25+' => ['0123456789', 'Standard 2 of 5 + CHECKSUM'],
'S25' => ['0123456789', 'Standard 2 of 5'],
'UPCA' => ['72527273070', 'UPC-A'],
'UPCE' => ['725277', 'UPC-E'],
];

$square = array(
'LRAW' => array('0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'),
'SRAW' => array('0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'),
'AZTEC' => array('ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'),
'AZTEC,50,A,A' => array('ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'),
'PDF417' => array('0123456789', 'PDF417 (ISO/IEC 15438:2006)'),
'QRCODE' => array('0123456789', 'QR-CODE'),
'QRCODE,H,ST,0,0' => array('abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'),
'DATAMATRIX' => array('0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'),
'DATAMATRIX,R' => array('0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'),
'DATAMATRIX,S,GS1' => array(chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'),
'DATAMATRIX,R,GS1' => array(chr(232).'01095011010209171719050810ABCD1234'.chr(232).'2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1'),
);
$square = [
'LRAW' => ['0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'],
'SRAW' => ['0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)'],
'AZTEC' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'],
'AZTEC,50,A,A' => ['ABCDabcd01234', 'AZTEC (ISO/IEC 24778:2008)'],
'PDF417' => ['0123456789', 'PDF417 (ISO/IEC 15438:2006)'],
'QRCODE' => ['0123456789', 'QR-CODE'],
'QRCODE,H,ST,0,0' => ['abcdefghijklmnopqrstuvwxy0123456789', 'QR-CODE WITH PARAMETERS'],
'DATAMATRIX' => ['0123456789', 'DATAMATRIX (ISO/IEC 16022) SQUARE'],
'DATAMATRIX,R' => ['0123456789012345678901234567890123456789', 'DATAMATRIX Rectangular (ISO/IEC 16022) RECTANGULAR'],
'DATAMATRIX,S,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) SQUARE GS1'],
'DATAMATRIX,R,GS1' => [chr(232) . '01095011010209171719050810ABCD1234' . chr(232) . '2110', 'GS1 DATAMATRIX (ISO/IEC 16022) RECTANGULAR GS1'],
];

$barcode = new \Com\Tecnick\Barcode\Barcode();

$examples = '<h3>Linear</h3>'."\n";
$examples = '<h3>Linear</h3>' . "\n";
foreach ($linear as $type => $code) {
$bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', array(0, 0, 0, 0));
$examples .= '<h4>[<span>'.$type.'</span>] '.$code[1].'</h4><p style="font-family:monospace;">'.$bobj->getHtmlDiv().'</p>'."\n";
$bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', [0, 0, 0, 0]);
$examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n";
}

$examples .= '<h3>Square</h3>'."\n";
$examples .= '<h3>Square</h3>' . "\n";
foreach ($square as $type => $code) {
$bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', array(0, 0, 0, 0));
$examples .= '<h4>[<span>'.$type.'</span>] '.$code[1].'</h4><p style="font-family:monospace;">'.$bobj->getHtmlDiv().'</p>'."\n";
$bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', [0, 0, 0, 0]);
$examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n";
}

$bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', array(-2, -2, -2, -2))->setBackgroundColor('#f0f0f0');
$bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', [-2, -2, -2, -2])->setBackgroundColor('#f0f0f0');

echo "
<!DOCTYPE html>
Expand All @@ -105,17 +105,17 @@
<p>This is an usage example of <a href=\"https://github.com/tecnickcom/tc-lib-barcode\" title=\"tc-lib-barcode: PHP library to generate linear and bidimensional barcodes\">tc-lib-barcode</a> library.</p>
<h2>Output Formats</h2>
<h3>PNG Image</h3>
<p><img alt=\"Embedded Image\" src=\"data:image/png;base64,".base64_encode($bobj->getPngData())."\" /></p>
<p><img alt=\"Embedded Image\" src=\"data:image/png;base64," . base64_encode($bobj->getPngData()) . "\" /></p>
<h3>SVG Image</h3>
<p style=\"font-family:monospace;\">".$bobj->getSvgCode()."</p>
<p style=\"font-family:monospace;\">" . $bobj->getSvgCode() . "</p>
<h3>HTML DIV</h3>
<p style=\"font-family:monospace;\">".$bobj->getHtmlDiv()."</p>
<p style=\"font-family:monospace;\">" . $bobj->getHtmlDiv() . "</p>
<h3>Unicode String</h3>
<pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">".$bobj->getGrid(json_decode('"\u00A0"'), json_decode('"\u2584"'))."</pre>
<pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">" . $bobj->getGrid(json_decode('"\u00A0"'), json_decode('"\u2584"')) . "</pre>
<h3>Binary String</h3>
<pre style=\"font-family:monospace;\">".$bobj->getGrid()."</pre>
<pre style=\"font-family:monospace;\">" . $bobj->getGrid() . "</pre>
<h2>Barcode Types</h2>
".$examples."
" . $examples . "
</body>
</html>
";
2 changes: 1 addition & 1 deletion phpstan.neon
@@ -1,5 +1,5 @@
parameters:
level: 5
level: max
paths:
- src
- test
Expand Down
4 changes: 2 additions & 2 deletions resources/debian/control
Expand Up @@ -10,7 +10,7 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git
Package: ~#PKGNAME#~
Provides: php-~#PROJECT#~
Architecture: all
Depends: php (>= 5.6.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 1.14.39), ${misc:Depends}
Depends: php (>= 8.0.0), php-bcmath, php-date, php-gd, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.4), ${misc:Depends}
Description: PHP Barcode library
This library includes PHP classes to generate linear
and bidimensional barcodes:
Expand All @@ -20,4 +20,4 @@ Description: PHP Barcode library
UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code),
CBC (Customer Bar Code), KIX (Klant index - Customer index),
Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11,
PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix ECC200, QR-Code, PDF417.
PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417.
6 changes: 3 additions & 3 deletions resources/rpm/rpm.spec
Expand Up @@ -16,9 +16,9 @@ URL: https://github.com/%{gh_owner}/%{gh_project}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
BuildArch: noarch

Requires: php(language) >= 5.6.0
Requires: php(language) >= 8.0.0
Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.14.39
Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.4
Requires: php-bcmath
Requires: php-date
Requires: php-gd
Expand All @@ -35,7 +35,7 @@ Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C,
UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code),
CBC (Customer Bar Code), KIX (Klant index - Customer index),
Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11,
PHARMACODE, PHARMACODE TWO-TRACKS, Datamatrix ECC200, QR-Code, PDF417.
PHARMACODE, PHARMACODE TWO-TRACKS, AZTEC, Datamatrix ECC200, QR-Code, PDF417.

Optional dependency: php-pecl-imagick

Expand Down

0 comments on commit 313b243

Please sign in to comment.