Compare commits

...

8 commits
2.0.0 ... main

Author SHA1 Message Date
Miraty
3c6fbcde2f Release 2.0.1 2023-07-08 18:48:26 +02:00
Miraty
e013ef7abe Update composer dependencies 2023-07-07 22:33:10 +02:00
Miraty
b4ef98673f locales/en.php: "software" is uncountable 2023-07-07 19:15:11 +02:00
dfe393384c Add Basque localization to CHANGELOG.md 2023-05-09 00:26:27 +02:00
020c3274e1 Merge pull request 'Add Basque localisation' (#17) from xabi/libreqr:main into main
Reviewed-on: #17
2023-05-09 00:23:13 +02:00
1503b0dfc8 Add Basque localisation
LibreQR now also available in Basque 😉
2023-05-08 19:24:27 +02:00
Miraty
d45ebbea70 Add Indonesian translation
Someone sent me this translation
2022-10-19 20:48:47 +02:00
f205f36b80 Set minimum QR code size at 21 2022-06-27 16:40:38 +02:00
143 changed files with 3315 additions and 2787 deletions

View file

@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 2.0.1 - 2023-07-08
### Added
* Indonesian localization
* Basque localization
### Changed
* Update dependencies
## 2.0.0 - 2022-06-07
### Added
@ -17,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
@ -32,8 +32,7 @@ There is [a package](https://code.antopie.org/miraty/qr_ynh/) for [YunoHost](htt
For historical reasons, LibreQR is technically named `qr` in YunoHost.
You can install it from the WebAdmin or with this command :
You can install it from the WebAdmin or with this command:
```
sudo yunohost app install qr
```

View file

@ -10,7 +10,7 @@ use Endroid\QrCode\Color\Color;
require "config.inc.php";
require "vendor/autoload.php";
define("LIBREQR_VERSION", "2.0.0");
define("LIBREQR_VERSION", "2.0.1");
// Defines the locale to be used
$locale = DEFAULT_LOCALE;
@ -74,7 +74,7 @@ if (
exit("Wrong value for margin");
}
if (is_numeric($_POST['size']) AND $_POST['size'] >= 1 AND $_POST['size'] <= 4096) {
if (is_numeric($_POST['size']) AND $_POST['size'] >= 21 AND $_POST['size'] <= 4096) {
$params['size'] = $_POST['size'];
} else if (empty($_POST['size'])) {
$params['size'] = NULL;
@ -225,7 +225,7 @@ foreach($themeDimensionsIcons as $dimFav) // Set all icons dimensions
<?= $loc['help_size'] ?>
</p>
</details>
<input type="number" id="size" placeholder="<?= DEFAULT_SIZE ?>" name="size" required="" min="1" max="4096" value="<?= htmlspecialchars($params['size']) ?>">
<input type="number" id="size" placeholder="<?= DEFAULT_SIZE ?>" name="size" required="" min="21" max="4096" value="<?= htmlspecialchars($params['size']) ?>">
</div>
</div>

View file

@ -14,7 +14,7 @@ $loc = array(
'help_content' => "
<p>You can encode whatever text you want.</p>
<p>Software which decodes these QR codes could suggest to open them with dedicated software, depending on their <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>URI scheme</a>.</p>
<p>Software decoding these QR codes could suggest to open them with dedicated software, depending on their <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>URI scheme</a>.</p>
<p>For instance, to open a webpage: <code>https://www.example/</code></p>
<p>To send an email: <code>mailto:contact@email.example</code></p>
<p>To share geographic coordinates: <code>geo:48.867564,2.364057</code></p>
@ -33,10 +33,10 @@ $loc = array(
'metaText_qr' => "
<h3>What's a QR code?</h3>
A QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and an adequate software.
A QR code is a 2 dimensional barcode in which text is written in binary. It can be decoded with a device equipped with a photo sensor and adequate software.
<a href='https://en.wikipedia.org/wiki/QR_code' hreflang='en' rel='help external noreferrer'>QR code on Wikipedia</a>.
",
'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " is a free software whose <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>source code</a> is available under the terms of the <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " is free software whose <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>source code</a> is available under the terms of the <abbr title='GNU Affero General Public License version 3 or any later version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'error_generation' => "An error occurred while generating the QR code. Try with different parameters.",
);

42
locales/eu.php Normal file
View file

@ -0,0 +1,42 @@
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
$loc = array(
'subtitle' => "QR kode sortzailea",
'description' => "Sortu QR kodeak nahieran. Aukeratu edukia, neurria, kolorea…",
'label_content' => "Kodetzeko testua",
'label_redundancy' => "Erredundantzia-tasa",
'label_margin' => "Marjinaren tamaina",
'label_size' => "Irudiaren neurria",
'label_bgColor' => "Hondoaren kolorea",
'label_fgColor' => "Kolore nagusia",
'placeholder' => "Sartu QR kodean kodetzeko testua",
'help_content' => "
<p>Nahi duzun testua kodetu dezakezu.</p>
<p>QR kode horiek deskodetzen dituen softwareak software dedikatuarekin irekitzea iradoki lezake, <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>URI eskema</a>ren arabera.</p>
<p>Adibidez, webgune bat irekitzeko: <code>https://www.adibidea.eus/</code></p>
<p>ePosta bidaltzeko: <code>mailto:lur_axpe@adibidea.eus</code></p>
<p>Koordenatu geografikoak partekatzeko: <code>geo:42.895367,-2.167805</code></p>",
'help_redundancy' => "Erredundantzia QR kodearen informazioa bikoiztean datza, deskodetzean akatsak zuzentzeko. Tasa altuagoak QR kode handiagoa sortuko du, baina behar bezala deskodetzeko aukera handiagoa izango du.
",
'help_margin' => "QR kodearen inguruko banda zuriaren pixel kopurua.",
'help_size' => "Irudiaren zabalera eta altuera pixeletan, marjinarik gabe.",
'button_create' => "Sortu",
'button_download' => "Gorde QR kodea",
'title_showOnlyQR' => "Erakutsi QR kode hau bakarrik",
'alt_QR_before' => 'QR kodearen esanahia "',
'alt_QR_after' => '"',
'metaText_qr' => "
<h3>Zer da QR kode bat?</h3>
QR kodea bi dimentsioko barra-kodea da, testua bitarrean idatzita duena. Argazki-sentsore bat eta software egokia dituen gailu batekin deskodetzen da.
<a href='https://eu.wikipedia.org/wiki/QR_kode' hreflang='eu' rel='help external noreferrer'>QR kodea Wikipedian</a>.
",
'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " software librea da, eta <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>iturburu-kodea</a> <abbr title='GNU Affero Lizentzia Publiko Orokorraren 3. bertsioaren edo ondorengo edozein bertsio'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>ren arabera dago eskuragarri.",
'error_generation' => "Errorea gertatu da QR kodea sortzerakoan. Saiatu berriro parametro desberdinak erabiliz.",
);

42
locales/id.php Normal file
View file

@ -0,0 +1,42 @@
<?php // This file is part of LibreQR, which is distributed under the GNU AGPLv3+ license
$loc = array(
'subtitle' => "Pembuat kode QR",
'description' => "Membuat kode QR dengan bebas. Pilih konten, ukuran warna, ...",
'label_content' => "Teks untuk dienkode",
'label_redundancy' => "Tingkat redundansi",
'label_margin' => "Ukuran tepi",
'label_size' => "Ukuran gambar",
'label_bgColor' => "Warna latar belakang",
'label_fgColor' => "Warna latar depan",
'placeholder' => "Masukkan teks untuk dienkode di kode QR",
'help_content' => "
<p>Anda bisa mengenkode teks apa pun.</p>
<p>Perangkat lunak yang mendekodekan kode QR tersebut bisa memberikan pilihan untuk membuka dengan perangkat lunak tertentu, tergantung pada <a href='https://en.wikipedia.org/wiki/List_of_URI_schemes' hreflang='en' rel='help external noreferrer'>Skema URI</a> mereka.</p>
<p>Contohnya, untuk membuka halaman situs: <code>https://www.contoh.id/</code></p>
<p>Untuk mengirim surel: <code>mailto:contact@email.example</code></p>
<p>Untuk membagikan koordinat geografik: <code>geo:48.867564,2.364057</code></p>
",
'help_redundancy' => "Redundansi adalah duplikasi informasi di kode QR untuk memperbaiki galat saat pendekodean. Tingkat lebih besar akan menghasilkan kode QR yang lebih besar, tetapi akan dapat hasil lebih baik untuk didekodekan dengan benar.",
'help_margin' => "Jumlah piksel di tepi putih di sekitar kode QR.",
'help_size' => "Tinggi dan lebar gambar dalam piksel, tanpa tepian.",
'button_create' => "Buat",
'button_download' => "Simpan kode QR ini",
'title_showOnlyQR' => "Tampilkan kode QR ini saja",
'alt_QR_before' => 'Arti kode QR "',
'alt_QR_after' => '"',
'metaText_qr' => "
<h3>Apa itu Kode QR?</h3>
Kode QR adalah kode batang 2 dimensi yang mana teks ditulis dalam biner. Bisa didekodekan dengan perangkat yang memiliki sensor foto dan perangkat lunak yang memadai.
<a href='https://id.wikipedia.org/wiki/Kode_QR' hreflang='id' rel='help external noreferrer'>Kode QR di Wikipedia</a>.
",
'metaText_legal' => "LibreQR " . LIBREQR_VERSION . " adalah perangkat lunak bebas yang <a href='https://code.antopie.org/miraty/libreqr/' rel='external noreferrer'>kode sumber</a> tersedia di bawah ketentuan <abbr title='GNU Affero General Public License versi 3 atau selanjutnya version'><a href='LICENSE.html' hreflang='en' rel='license'>AGPLv3</a>+</abbr>.",
'error_generation' => "Galat terjadi ketika membuat kode QR. Coba dengan parameter yang berbeda.",
);

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.';
}