Initial commit

This commit is contained in:
2026-08-30 22:02:02 +00:00
commit b6bd2277f5
2334 changed files with 646393 additions and 0 deletions
@@ -0,0 +1,67 @@
<?php
/**
* FallbackMath.php
*
* @since 2026-08-06
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
use Com\Tecnick\Barcode\Math;
/**
* Forces the pure-PHP arithmetic used when the bcmath extension is not available.
*/
trait FallbackMath
{
/**
* @param numeric-string $left
* @param numeric-string $right
*
* @return numeric-string
*/
protected function addNumeric(string $left, string $right): string
{
return Math::fallbackAdd($left, $right);
}
/**
* @param numeric-string $left
* @param numeric-string $right
*
* @return numeric-string
*/
protected function mulNumeric(string $left, string $right): string
{
return Math::fallbackMul($left, $right);
}
/**
* @param numeric-string $left
* @param numeric-string $right
*
* @return numeric-string
*/
protected function divNumeric(string $left, string $right): string
{
return Math::fallbackDiv($left, $right);
}
/**
* @param numeric-string $left
* @param numeric-string $right
*/
protected function modNumeric(string $left, string $right): int
{
return (int) Math::fallbackMod($left, $right);
}
}
@@ -0,0 +1,22 @@
<?php
/**
* FallbackMathImb.php
*
* @since 2026-08-06
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
class FallbackMathImb extends \Com\Tecnick\Barcode\Type\Linear\Imb
{
use FallbackMath;
}
@@ -0,0 +1,22 @@
<?php
/**
* FallbackMathPdfFourOneSeven.php
*
* @since 2026-08-06
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
class FallbackMathPdfFourOneSeven extends \Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven
{
use FallbackMath;
}
@@ -0,0 +1,102 @@
<?php
/**
* InternalBarcodeType.php
*
* @since 2026-04-19
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
class InternalBarcodeType extends \Com\Tecnick\Barcode\Type
{
protected const TYPE = 'linear';
protected const FORMAT = 'INTERNAL';
/**
* @var array<int, array{int, int, int, int}>|null
*/
private ?array $rotatedBarsOverride = null;
/**
* @throws \Com\Tecnick\Barcode\Exception
* @throws \Com\Tecnick\Color\Exception
*/
public function __construct(
private bool $useParentHooks = false,
) {
$this->ncols = 2;
$this->nrows = 1;
parent::__construct('12', -2, -3, 'black', [], [-2, -1, 0, 1]);
}
protected function setParameters(): void
{
if ($this->useParentHooks) {
parent::setParameters();
return;
}
$this->params = ['ok'];
}
protected function setBars(): void
{
if ($this->useParentHooks) {
parent::setBars();
return;
}
$this->bars = [[0, 0, 1, 1]];
}
/**
* @param array<int, array{int, int, int, int}> $bars
*/
public function setBarsForTest(array $bars): void
{
$this->bars = $bars;
}
public function setRowsColsForTest(int $nrows, int $ncols): void
{
$this->nrows = $nrows;
$this->ncols = $ncols;
}
public function setRatiosForTest(float $widthRatio, float $heightRatio): void
{
$this->width_ratio = $widthRatio;
$this->height_ratio = $heightRatio;
}
/**
* @param array<int, array{int, int, int, int}>|null $bars
*/
public function setRotatedBarsOverrideForTest(?array $bars): void
{
$this->rotatedBarsOverride = $bars;
}
/**
* @return array<int, array{int, int, int, int}>
*/
protected function getRotatedBarArray(): array
{
if ($this->rotatedBarsOverride !== null) {
return $this->rotatedBarsOverride;
}
return parent::getRotatedBarArray();
}
}
@@ -0,0 +1,110 @@
<?php
/**
* InternalConvert.php
*
* @since 2026-05-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
class InternalConvert extends \Com\Tecnick\Barcode\Type\Convert
{
/**
* @param array<int, string|array<int>> $rows
*
* @throws \Com\Tecnick\Barcode\Exception
*/
public function exposeProcessBinarySequence(array $rows): void
{
$this->processBinarySequence($rows);
}
/**
* @throws \Com\Tecnick\Barcode\Exception
*
* @return array<int, string>
*/
public function exposeGetRawCodeRows(string $data): array
{
return $this->getRawCodeRows($data);
}
public function exposeConvertDecToHex(string $number): string
{
return $this->convertDecToHex($number);
}
public function exposeConvertHexToDec(string $hex): string
{
return $this->convertHexToDec($hex);
}
/**
* @return array<int, array{int, int, int, int}>
*/
public function exposeGetRotatedBarArray(): array
{
return $this->getRotatedBarArray();
}
/**
* @param array<int, array{int, int, int, int}> $bars
*/
public function setBars(array $bars): void
{
$this->bars = $bars;
}
public function setColsRows(int $ncols, int $nrows): void
{
$this->ncols = $ncols;
$this->nrows = $nrows;
}
/**
* @param array{'T': int, 'R': int, 'B': int, 'L': int} $padding
*/
public function setRatiosAndPadding(float $widthRatio, float $heightRatio, array $padding): void
{
$this->width_ratio = $widthRatio;
$this->height_ratio = $heightRatio;
$this->padding = $padding;
}
/**
* @param array{int, int, int, int} $bar
*
* @return array{float, float, float, float}
*/
public function exposeGetBarRectXYXY(array $bar): array
{
return $this->getBarRectXYXY($bar);
}
/**
* @param array{int, int, int, int} $bar
*
* @return array{float, float, float, float}
*/
public function exposeGetBarRectXYWH(array $bar): array
{
return $this->getBarRectXYWH($bar);
}
/**
* @return array<int, array{int, int, int, int}>
*/
public function getBars(): array
{
return \array_values($this->bars);
}
}
@@ -0,0 +1,130 @@
<?php
/**
* InternalQrByteStream.php
*
* @since 2026-04-19
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2026 Nicola Asuni - Tecnick.com LTD
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Test\Fixture;
/**
* @phpstan-import-type Item from \Com\Tecnick\Barcode\Type\Square\QrCode\Estimate
*/
class InternalQrByteStream extends \Com\Tecnick\Barcode\Type\Square\QrCode\ByteStream
{
/**
* @var array<int, array{0: array<int, Item>, 1: int}>
*/
public array $queuedCbs = [];
public ?int $forcedEstVer = null;
public ?int $forcedMinVer = null;
public function exposeLookAnTable(int $chr): int
{
return $this->lookAnTable($chr);
}
/**
* @param array<int, Item> $items
* @param array<int, string> $data
*
* @return array<int, Item>
* @throws \Com\Tecnick\Barcode\Exception
*/
public function exposeAppendNewInputItem(array $items, int $mode, int $size, array $data): array
{
return $this->appendNewInputItem($items, $mode, $size, $data);
}
/**
* @param array<int, string> $data
* @param array<int, int> $bstream
*
* @return Item
* @throws \Com\Tecnick\Barcode\Exception
*/
public function exposeNewInputItem(int $mode, int $size, array $data, array $bstream = []): array
{
return $this->newInputItem($mode, $size, $data, $bstream);
}
/**
* @param array<int, int> $bstream
*
* @return array<int, int>
*/
public function exposeAppendPaddingBit(array $bstream): array
{
return $this->appendPaddingBit($bstream);
}
/**
* @param array<int, int> $bstream
*
* @return array<int, int>
*/
public function exposeBitstreamToByte(array $bstream): array
{
return $this->bitstreamToByte($bstream);
}
/**
* @param array<int, Item> $items
*
* @return array<int, Item>
* @throws \Com\Tecnick\Barcode\Exception
*/
public function exposeConvertData(array $items): array
{
return $this->convertData($items);
}
/**
* @param array<int, Item> $items
*
* @return array{0: array<int, Item>, 1: int}
* @throws \Com\Tecnick\Barcode\Exception
*/
public function exposeCreateBitStream(array $items): array
{
return parent::createBitStream($items);
}
/**
* @param array<int, Item> $items
*/
public function estimateVersion(array $items, int $level): int
{
return $this->forcedEstVer ?? parent::estimateVersion($items, $level);
}
/**
* @param array<int, Item> $items
*
* @return array{0: array<int, Item>, 1: int}
*/
protected function createBitStream(array $items): array
{
if ($this->queuedCbs !== []) {
return \array_shift($this->queuedCbs);
}
return parent::createBitStream($items);
}
protected function getMinimumVersion(int $size, int $level): int
{
return $this->forcedMinVer ?? parent::getMinimumVersion($size, $level);
}
}