Update composer dependencies

This commit is contained in:
Miraty 2023-07-07 22:33:10 +02:00
parent b4ef98673f
commit e013ef7abe
139 changed files with 3217 additions and 2779 deletions

View File

@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Indonesian localization
* Basque localization
### Changed
* Update dependencies
## 2.0.0 - 2022-06-07
### Added
@ -24,7 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Output generated QR code with `data:` URI
* Change the QR code generation library
* Use less.php instead of lesserphp
* Use the prefers-color-scheme CSS feature to let the client choose its prefered theme (dark/light)
* Use the prefers-color-scheme CSS feature to let the client choose its preferred theme (dark/light)
### Removed

View File

@ -10,7 +10,7 @@ A LibreQR instance is available at <https://qr.antopie.org>.
### Generic
Just place this source code in a Web server with PHP7.4+, extensions `gd`, `mbstring` and `iconv`, and writing rights on the `css/` directory.
Just place this source code in a Web server with PHP8.0+, extensions `gd`, `mbstring` and `iconv`, and writing rights on the `css/` directory.
#### Security hardening

19
vendor/autoload.php vendored
View File

@ -3,10 +3,23 @@
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202::getLoader();
return ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a::getLoader();

View File

@ -34,5 +34,11 @@
"allow-plugins": {
"ocramius/package-versions": true
}
},
"archive": {
"exclude": [
"/test",
"/phpunit.xml.dist"
]
}
}

View File

@ -0,0 +1,13 @@
<?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>
<testsuites>
<testsuite name="BaconQrCode Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -89,6 +89,9 @@ final class CharacterSetEci extends AbstractEnum
*/
private static $nameToEci;
/**
* @param int[] $values
*/
public function __construct(array $values, string ...$otherEncodingNames)
{
$this->values = $values;

View File

@ -62,7 +62,7 @@ class FormatInformation
/**
* Offset i holds the number of 1 bits in the binary representation of i.
*
* @var array
* @var int[]
*/
private const BITS_SET_IN_HALF_BYTE = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4];

View File

@ -42,6 +42,9 @@ final class Mode extends AbstractEnum
*/
private $bits;
/**
* @param int[] $characterCountBitsForVersions
*/
protected function __construct(array $characterCountBitsForVersions, int $bits)
{
$this->characterCountBitsForVersions = $characterCountBitsForVersions;

View File

@ -37,7 +37,7 @@ final class Encoder
/**
* Codec cache.
*
* @var array
* @var array<string,ReedSolomonCodec>
*/
private static $codecs = [];

View File

@ -334,7 +334,7 @@ final class SvgImageBackEnd implements ImageBackEndInterface
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($startColor));
if ($startColor instanceof Alpha) {
$this->xmlWriter->writeAttribute('stop-opacity', $startColor->getAlpha());
$this->xmlWriter->writeAttribute('stop-opacity', (string) $startColor->getAlpha());
}
$this->xmlWriter->endElement();
@ -344,7 +344,7 @@ final class SvgImageBackEnd implements ImageBackEndInterface
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($endColor));
if ($endColor instanceof Alpha) {
$this->xmlWriter->writeAttribute('stop-opacity', $endColor->getAlpha());
$this->xmlWriter->writeAttribute('stop-opacity', (string) $endColor->getAlpha());
}
$this->xmlWriter->endElement();

View File

@ -41,7 +41,7 @@ final class EdgeIterator implements IteratorAggregate
}
/**
* @return Edge[]
* @return Traversable<Edge>
*/
public function getIterator() : Traversable
{

View File

@ -136,7 +136,7 @@ final class EllipticArc implements OperationInterface
/**
* @return Curve[]
*/
private function createCurves(float $fromX, $fromY) : array
private function createCurves(float $fromX, float $fromY) : array
{
$xAngle = deg2rad($this->xAxisAngle);
list($centerX, $centerY, $radiusX, $radiusY, $startAngle, $deltaAngle) =

View File

@ -17,10 +17,16 @@ use BaconQrCode\Writer;
use PHPUnit\Framework\TestCase;
use Spatie\Snapshots\MatchesSnapshots;
/**
* @group integration
*/
final class ImagickRenderingTest extends TestCase
{
use MatchesSnapshots;
/**
* @requires extension imagick
*/
public function testGenericQrCode() : void
{
$renderer = new ImageRenderer(
@ -35,6 +41,9 @@ final class ImagickRenderingTest extends TestCase
unlink($tempName);
}
/**
* @requires extension imagick
*/
public function testIssue79() : void
{
$eye = SquareEye::instance();

10
vendor/bin/lessc vendored
View File

@ -108,10 +108,12 @@ if (PHP_VERSION_ID < 80000) {
}
}
if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
include("phpvfscomposer://" . __DIR__ . '/..'.'/wikimedia/less.php/bin/lessc');
exit(0);
if (
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
) {
return include("phpvfscomposer://" . __DIR__ . '/..'.'/wikimedia/less.php/bin/lessc');
}
}
include __DIR__ . '/..'.'/wikimedia/less.php/bin/lessc';
return include __DIR__ . '/..'.'/wikimedia/less.php/bin/lessc';

View File

@ -42,35 +42,37 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var ?string */
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
@ -78,8 +80,7 @@ class ClassLoader
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
* @var array<string, string>
*/
private $classMap = array();
@ -87,29 +88,29 @@ class ClassLoader
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
/** @var string|null */
private $apcuPrefix;
/**
* @var self[]
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return string[]
* @return array<string, list<string>>
*/
public function getPrefixes()
{
@ -121,8 +122,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
@ -130,8 +130,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, string>
* @return list<string>
*/
public function getFallbackDirs()
{
@ -139,8 +138,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, string>
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
@ -148,8 +146,7 @@ class ClassLoader
}
/**
* @return string[] Array of classname => path
* @psalm-return array<string, string>
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
@ -157,8 +154,7 @@ class ClassLoader
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
@ -175,24 +171,25 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
$paths
);
}
@ -201,19 +198,19 @@ class ClassLoader
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
$paths
);
}
}
@ -222,9 +219,9 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
@ -232,17 +229,18 @@ class ClassLoader
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@ -252,18 +250,18 @@ class ClassLoader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
$paths
);
}
}
@ -272,8 +270,8 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
@ -290,8 +288,8 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
@ -425,7 +423,8 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
@ -476,9 +475,9 @@ class ClassLoader
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return self[]
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
@ -555,18 +554,26 @@ class ClassLoader
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
include $file;
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@ -98,7 +98,7 @@ class InstalledVersions
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
@ -119,7 +119,7 @@ class InstalledVersions
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
@ -328,7 +328,9 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
@ -340,12 +342,17 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
$installed[] = self::$installed;
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202
class ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a
{
private static $loader;
@ -24,12 +24,12 @@ class ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::getInitializer($loader));
$loader->register(true);

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202
class ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a
{
public static $prefixLengthsPsr4 = array (
'E' =>
@ -54,10 +54,10 @@ class ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixesPsr0;
$loader->classMap = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixesPsr0;
$loader->classMap = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$classMap;
}, null, ClassLoader::class);
}

View File

@ -2,17 +2,17 @@
"packages": [
{
"name": "bacon/bacon-qr-code",
"version": "2.0.7",
"version_normalized": "2.0.7.0",
"version": "2.0.8",
"version_normalized": "2.0.8.0",
"source": {
"type": "git",
"url": "https://github.com/Bacon/BaconQrCode.git",
"reference": "d70c840f68657ce49094b8d91f9ee0cc07fbf66c"
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/d70c840f68657ce49094b8d91f9ee0cc07fbf66c",
"reference": "d70c840f68657ce49094b8d91f9ee0cc07fbf66c",
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22",
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22",
"shasum": ""
},
"require": {
@ -29,7 +29,7 @@
"suggest": {
"ext-imagick": "to generate QR code images"
},
"time": "2022-03-14T02:02:36+00:00",
"time": "2022-12-07T17:46:57+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -53,30 +53,33 @@
"homepage": "https://github.com/Bacon/BaconQrCode",
"support": {
"issues": "https://github.com/Bacon/BaconQrCode/issues",
"source": "https://github.com/Bacon/BaconQrCode/tree/2.0.7"
"source": "https://github.com/Bacon/BaconQrCode/tree/2.0.8"
},
"install-path": "../bacon/bacon-qr-code"
},
{
"name": "dasprid/enum",
"version": "1.0.3",
"version_normalized": "1.0.3.0",
"version": "1.0.4",
"version_normalized": "1.0.4.0",
"source": {
"type": "git",
"url": "https://github.com/DASPRiD/Enum.git",
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2"
"reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/5abf82f213618696dda8e3bf6f64dd042d8542b2",
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2",
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8e6b6ea76eabbf19ea2bf5b67b98e1860474012f",
"reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f",
"shasum": ""
},
"require": {
"php": ">=7.1 <9.0"
},
"require-dev": {
"phpunit/phpunit": "^7 | ^8 | ^9",
"squizlabs/php_codesniffer": "^3.4"
"squizlabs/php_codesniffer": "*"
},
"time": "2020-10-02T16:03:48+00:00",
"time": "2023-03-01T18:44:03+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -103,33 +106,36 @@
],
"support": {
"issues": "https://github.com/DASPRiD/Enum/issues",
"source": "https://github.com/DASPRiD/Enum/tree/1.0.3"
"source": "https://github.com/DASPRiD/Enum/tree/1.0.4"
},
"install-path": "../dasprid/enum"
},
{
"name": "endroid/qr-code",
"version": "4.4.9",
"version_normalized": "4.4.9.0",
"version": "4.8.2",
"version_normalized": "4.8.2.0",
"source": {
"type": "git",
"url": "https://github.com/endroid/qr-code.git",
"reference": "bf087fa1e93a1b7310e2d94d187e26ae51db199d"
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/bf087fa1e93a1b7310e2d94d187e26ae51db199d",
"reference": "bf087fa1e93a1b7310e2d94d187e26ae51db199d",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/2436c2333a3931c95e2b96eb82f16f53143d6bba",
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba",
"shasum": ""
},
"require": {
"bacon/bacon-qr-code": "^2.0.5",
"php": "^7.4||^8.0"
"php": "^8.0"
},
"conflict": {
"khanamiryan/qrcode-detector-decoder": "^1.0.6"
},
"require-dev": {
"endroid/quality": "dev-master",
"ext-gd": "*",
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
"setasign/fpdf": "^1.8.2"
},
"suggest": {
@ -138,7 +144,7 @@
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
"setasign/fpdf": "Enables you to use the PDF writer"
},
"time": "2022-05-10T07:25:08+00:00",
"time": "2023-03-30T18:46:02+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -172,7 +178,7 @@
],
"support": {
"issues": "https://github.com/endroid/qr-code/issues",
"source": "https://github.com/endroid/qr-code/tree/4.4.9"
"source": "https://github.com/endroid/qr-code/tree/4.8.2"
},
"funding": [
{
@ -184,30 +190,31 @@
},
{
"name": "wikimedia/less.php",
"version": "v3.1.0",
"version_normalized": "3.1.0.0",
"version": "v3.2.1",
"version_normalized": "3.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/wikimedia/less.php.git",
"reference": "a486d78b9bd16b72f237fc6093aa56d69ce8bd13"
"reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wikimedia/less.php/zipball/a486d78b9bd16b72f237fc6093aa56d69ce8bd13",
"reference": "a486d78b9bd16b72f237fc6093aa56d69ce8bd13",
"url": "https://api.github.com/repos/wikimedia/less.php/zipball/0d5b30ba792bdbf8991a646fc9c30561b38a5559",
"reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559",
"shasum": ""
},
"require": {
"php": ">=7.2.9"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "34.0.0",
"mediawiki/minus-x": "1.0.0",
"php-parallel-lint/php-console-highlighter": "0.5.0",
"php-parallel-lint/php-parallel-lint": "1.2.0",
"mediawiki/mediawiki-codesniffer": "40.0.1",
"mediawiki/mediawiki-phan-config": "0.12.0",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.3.2",
"phpunit/phpunit": "^8.5"
},
"time": "2020-12-11T19:33:31+00:00",
"time": "2023-02-03T06:43:41+00:00",
"bin": [
"bin/lessc"
],
@ -226,6 +233,10 @@
"Apache-2.0"
],
"authors": [
{
"name": "Timo Tijhof",
"homepage": "https://timotijhof.net"
},
{
"name": "Josh Schmidt",
"homepage": "https://github.com/oyejorge"
@ -239,7 +250,8 @@
"homepage": "https://github.com/Mordred"
}
],
"description": "PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt)",
"description": "PHP port of the LESS processor",
"homepage": "https://gerrit.wikimedia.org/g/mediawiki/libs/less.php",
"keywords": [
"css",
"less",
@ -250,7 +262,7 @@
],
"support": {
"issues": "https://github.com/wikimedia/less.php/issues",
"source": "https://github.com/wikimedia/less.php/tree/v3.1.0"
"source": "https://github.com/wikimedia/less.php/tree/v3.2.1"
},
"install-path": "../wikimedia/less.php"
}

View File

@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '5e455c1499d4fba2d9bb825e4db8b58a3a6a595e',
'reference' => 'b4ef98673f4ec96aac0c1ff7bda444f72101c479',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -13,43 +13,43 @@
'__root__' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '5e455c1499d4fba2d9bb825e4db8b58a3a6a595e',
'reference' => 'b4ef98673f4ec96aac0c1ff7bda444f72101c479',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'bacon/bacon-qr-code' => array(
'pretty_version' => '2.0.7',
'version' => '2.0.7.0',
'reference' => 'd70c840f68657ce49094b8d91f9ee0cc07fbf66c',
'pretty_version' => '2.0.8',
'version' => '2.0.8.0',
'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22',
'type' => 'library',
'install_path' => __DIR__ . '/../bacon/bacon-qr-code',
'aliases' => array(),
'dev_requirement' => false,
),
'dasprid/enum' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'reference' => '5abf82f213618696dda8e3bf6f64dd042d8542b2',
'pretty_version' => '1.0.4',
'version' => '1.0.4.0',
'reference' => '8e6b6ea76eabbf19ea2bf5b67b98e1860474012f',
'type' => 'library',
'install_path' => __DIR__ . '/../dasprid/enum',
'aliases' => array(),
'dev_requirement' => false,
),
'endroid/qr-code' => array(
'pretty_version' => '4.4.9',
'version' => '4.4.9.0',
'reference' => 'bf087fa1e93a1b7310e2d94d187e26ae51db199d',
'pretty_version' => '4.8.2',
'version' => '4.8.2.0',
'reference' => '2436c2333a3931c95e2b96eb82f16f53143d6bba',
'type' => 'library',
'install_path' => __DIR__ . '/../endroid/qr-code',
'aliases' => array(),
'dev_requirement' => false,
),
'wikimedia/less.php' => array(
'pretty_version' => 'v3.1.0',
'version' => '3.1.0.0',
'reference' => 'a486d78b9bd16b72f237fc6093aa56d69ce8bd13',
'pretty_version' => 'v3.2.1',
'version' => '3.2.1.0',
'reference' => '0d5b30ba792bdbf8991a646fc9c30561b38a5559',
'type' => 'library',
'install_path' => __DIR__ . '/../wikimedia/less.php',
'aliases' => array(),

View File

@ -4,8 +4,8 @@
$issues = array();
if (!(PHP_VERSION_ID >= 70400)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
if (!(PHP_VERSION_ID >= 80000)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {

View File

@ -0,0 +1,47 @@
name: Tests
on: [push, pull_request]
jobs:
php-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1]
dependency-version: [prefer-stable]
os: [ubuntu-latest, windows-latest]
name: ${{ matrix.os }} - PHP${{ matrix.php }} - ${{ matrix.dependency-version }}
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
- name: Code Sniffer
run: vendor/bin/phpcs

View File

@ -1,6 +1,6 @@
# PHP 7.1 enums
[![Build Status](https://travis-ci.org/DASPRiD/Enum.svg?branch=master)](https://travis-ci.org/DASPRiD/Enum)
[![Build Status](https://github.com/DASPRiD/Enum/actions/workflows/tests.yml/badge.svg)](https://github.com/DASPRiD/Enum/actions?query=workflow%3Atests)
[![Coverage Status](https://coveralls.io/repos/github/DASPRiD/Enum/badge.svg?branch=master)](https://coveralls.io/github/DASPRiD/Enum?branch=master)
[![Latest Stable Version](https://poser.pugx.org/dasprid/enum/v/stable)](https://packagist.org/packages/dasprid/enum)
[![Total Downloads](https://poser.pugx.org/dasprid/enum/downloads)](https://packagist.org/packages/dasprid/enum)
@ -41,7 +41,7 @@ final class WeekDay extends AbstractEnum
protected const SATURDAY = null;
protected const SUNDAY = null;
}
```
```
If you need to provide constants for either internal use or public use, you can mark them as either private or public,
in which case they will be ignored by the enum, which only considers protected constants as valid values. As you can
@ -56,16 +56,16 @@ function tellItLikeItIs(WeekDay $weekDay)
case WeekDay::MONDAY():
echo 'Mondays are bad.';
break;
case WeekDay::FRIDAY():
echo 'Fridays are better.';
break;
case WeekDay::SATURDAY():
case WeekDay::SUNDAY():
echo 'Weekends are best.';
break;
default:
echo 'Midweek days are so-so.';
}
@ -107,14 +107,14 @@ final class Planet extends AbstractEnum
protected const SATURN = [5.688e+26, 6.0268e7];
protected const URANUS = [8.686e+25, 2.5559e7];
protected const NEPTUNE = [1.024e+26, 2.4746e7];
/**
* Universal gravitational constant.
*
* @var float
*/
private const G = 6.67300E-11;
/**
* Mass in kilograms.
*
@ -124,32 +124,32 @@ final class Planet extends AbstractEnum
/**
* Radius in meters.
*
*
* @var float
*/
*/
private $radius;
protected function __construct(float $mass, float $radius)
{
$this->mass = $mass;
$this->radius = $radius;
}
public function mass() : float
{
return $this->mass;
}
public function radius() : float
{
return $this->radius;
return $this->radius;
}
public function surfaceGravity() : float
{
return self::G * $this->mass / ($this->radius * $this->radius);
}
public function surfaceWeight(float $otherMass) : float
{
return $otherMass * $this->surfaceGravity();

View File

@ -14,9 +14,12 @@
"enum",
"map"
],
"require": {
"php": ">=7.1 <9.0"
},
"require-dev": {
"phpunit/phpunit": "^7 | ^8 | ^9",
"squizlabs/php_codesniffer": "^3.4"
"squizlabs/php_codesniffer": "*"
},
"autoload": {
"psr-4": {

View File

@ -88,6 +88,31 @@ final class EnumMap implements Serializable, IteratorAggregate
$this->values = array_fill(0, count($this->keyUniverse), null);
}
public function __serialize(): array
{
$values = [];
foreach ($this->values as $ordinal => $value) {
if (null === $value) {
continue;
}
$values[$ordinal] = $this->unmaskNull($value);
}
return [
'keyType' => $this->keyType,
'valueType' => $this->valueType,
'allowNullValues' => $this->allowNullValues,
'values' => $values,
];
}
public function __unserialize(array $data): void
{
$this->unserialize(serialize($data));
}
/**
* Checks whether the map types match the supplied ones.
*
@ -261,22 +286,7 @@ final class EnumMap implements Serializable, IteratorAggregate
public function serialize() : string
{
$values = [];
foreach ($this->values as $ordinal => $value) {
if (null === $value) {
continue;
}
$values[$ordinal] = $this->unmaskNull($value);
}
return serialize([
'keyType' => $this->keyType,
'valueType' => $this->valueType,
'allowNullValues' => $this->allowNullValues,
'values' => $values,
]);
return serialize($this->__serialize());
}
public function unserialize($serialized) : void

View File

@ -1,4 +1,4 @@
Copyright 2020 (c) Jeroen van den Enden
Copyright 2022 (c) Jeroen van den Enden
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -14,13 +14,17 @@ for validating generated QR codes. Further extended with Twig extensions, genera
Symfony bundle for easy installation and configuration. Different writers are provided to generate the QR code
as PNG, SVG, EPS or in binary format.
## Sponsored by
[![Blackfire.io](assets/blackfire.png)](https://www.blackfire.io)
## Installation
Use [Composer](https://getcomposer.org/) to install the library. Also make sure you have enabled and configured the
[GD extension](https://www.php.net/manual/en/book.image.php) if you want to generate images.
``` bash
$ composer require endroid/qr-code
composer require endroid/qr-code
```
## Usage: using the builder
@ -47,6 +51,7 @@ $result = Builder::create()
->labelText('This is the label')
->labelFont(new NotoSans(20))
->labelAlignment(new LabelAlignmentCenter())
->validateResult(false)
->build();
```
@ -61,11 +66,12 @@ use Endroid\QrCode\Label\Label;
use Endroid\QrCode\Logo\Logo;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Writer\ValidationException;
$writer = new PngWriter();
// Create QR code
$qrCode = QrCode::create('Data')
$qrCode = QrCode::create('Life is too short to be generating QR codes')
->setEncoding(new Encoding('UTF-8'))
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
->setSize(300)
@ -83,6 +89,9 @@ $label = Label::create('Label')
->setTextColor(new Color(255, 0, 0));
$result = $writer->write($qrCode, $logo, $label);
// Validate the result
$writer->validateResult($result, 'Life is too short to be generating QR codes');
```
## Usage: working with results
@ -104,10 +113,32 @@ $dataUri = $result->getDataUri();
### Writer options
Some writers provide writer options. Each available writer option is can be
found as a constant prefixed with WRITER_OPTION_ in the writer class.
* `PdfWriter`
* `unit`: unit of measurement (default: mm)
* `fpdf`: PDF to place the image in (default: new PDF)
* `x`: image offset (default: 0)
* `y`: image offset (default: 0)
* `PngWriter`
* `compression_level`: compression level (0-9, default: -1 = zlib default)
* `SvgWriter`
* `block_id`: id of the block element for external reference (default: block)
* `exclude_xml_declaration`: exclude XML declaration (default: false)
* `exclude_svg_width_and_height`: exclude width and height (default: false)
* `force_xlink_href`: forces xlink namespace in case of compatibility issues (default: false)
* `WebPWriter`
* `quality`: image quality (0-100, default: 80)
You can provide any writer options like this.
```php
use Endroid\QrCode\Writer\SvgWriter;
$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
$builder->setWriterOptions([
SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true
]);
```
### Encoding
@ -145,13 +176,14 @@ size can result in additional padding to compensate for the rounding difference.
And finally the encoding (default UTF-8 to support large character sets) can be
set to `ISO-8859-1` if possible to improve readability.