Update composer dependencies
This commit is contained in:
parent
b4ef98673f
commit
e013ef7abe
@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
* Indonesian localization
|
* Indonesian localization
|
||||||
* Basque localization
|
* Basque localization
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Update dependencies
|
||||||
|
|
||||||
## 2.0.0 - 2022-06-07
|
## 2.0.0 - 2022-06-07
|
||||||
|
|
||||||
### Added
|
### 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
|
* Output generated QR code with `data:` URI
|
||||||
* Change the QR code generation library
|
* Change the QR code generation library
|
||||||
* Use less.php instead of lesserphp
|
* 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
|
### Removed
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ A LibreQR instance is available at <https://qr.antopie.org>.
|
|||||||
|
|
||||||
### Generic
|
### 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
|
#### Security hardening
|
||||||
|
|
||||||
|
19
vendor/autoload.php
vendored
19
vendor/autoload.php
vendored
@ -3,10 +3,23 @@
|
|||||||
// autoload.php @generated by Composer
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50600) {
|
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;
|
if (!headers_sent()) {
|
||||||
exit(1);
|
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';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202::getLoader();
|
return ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a::getLoader();
|
||||||
|
6
vendor/bacon/bacon-qr-code/composer.json
vendored
6
vendor/bacon/bacon-qr-code/composer.json
vendored
@ -34,5 +34,11 @@
|
|||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
"ocramius/package-versions": true
|
"ocramius/package-versions": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"archive": {
|
||||||
|
"exclude": [
|
||||||
|
"/test",
|
||||||
|
"/phpunit.xml.dist"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
vendor/bacon/bacon-qr-code/phpunit.xml.dist
vendored
Normal file
13
vendor/bacon/bacon-qr-code/phpunit.xml.dist
vendored
Normal 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>
|
@ -89,6 +89,9 @@ final class CharacterSetEci extends AbstractEnum
|
|||||||
*/
|
*/
|
||||||
private static $nameToEci;
|
private static $nameToEci;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int[] $values
|
||||||
|
*/
|
||||||
public function __construct(array $values, string ...$otherEncodingNames)
|
public function __construct(array $values, string ...$otherEncodingNames)
|
||||||
{
|
{
|
||||||
$this->values = $values;
|
$this->values = $values;
|
||||||
|
@ -62,7 +62,7 @@ class FormatInformation
|
|||||||
/**
|
/**
|
||||||
* Offset i holds the number of 1 bits in the binary representation of i.
|
* 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];
|
private const BITS_SET_IN_HALF_BYTE = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4];
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ final class Mode extends AbstractEnum
|
|||||||
*/
|
*/
|
||||||
private $bits;
|
private $bits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int[] $characterCountBitsForVersions
|
||||||
|
*/
|
||||||
protected function __construct(array $characterCountBitsForVersions, int $bits)
|
protected function __construct(array $characterCountBitsForVersions, int $bits)
|
||||||
{
|
{
|
||||||
$this->characterCountBitsForVersions = $characterCountBitsForVersions;
|
$this->characterCountBitsForVersions = $characterCountBitsForVersions;
|
||||||
|
@ -37,7 +37,7 @@ final class Encoder
|
|||||||
/**
|
/**
|
||||||
* Codec cache.
|
* Codec cache.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array<string,ReedSolomonCodec>
|
||||||
*/
|
*/
|
||||||
private static $codecs = [];
|
private static $codecs = [];
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ final class SvgImageBackEnd implements ImageBackEndInterface
|
|||||||
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($startColor));
|
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($startColor));
|
||||||
|
|
||||||
if ($startColor instanceof Alpha) {
|
if ($startColor instanceof Alpha) {
|
||||||
$this->xmlWriter->writeAttribute('stop-opacity', $startColor->getAlpha());
|
$this->xmlWriter->writeAttribute('stop-opacity', (string) $startColor->getAlpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->xmlWriter->endElement();
|
$this->xmlWriter->endElement();
|
||||||
@ -344,7 +344,7 @@ final class SvgImageBackEnd implements ImageBackEndInterface
|
|||||||
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($endColor));
|
$this->xmlWriter->writeAttribute('stop-color', $this->getColorString($endColor));
|
||||||
|
|
||||||
if ($endColor instanceof Alpha) {
|
if ($endColor instanceof Alpha) {
|
||||||
$this->xmlWriter->writeAttribute('stop-opacity', $endColor->getAlpha());
|
$this->xmlWriter->writeAttribute('stop-opacity', (string) $endColor->getAlpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->xmlWriter->endElement();
|
$this->xmlWriter->endElement();
|
||||||
|
@ -41,7 +41,7 @@ final class EdgeIterator implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Edge[]
|
* @return Traversable<Edge>
|
||||||
*/
|
*/
|
||||||
public function getIterator() : Traversable
|
public function getIterator() : Traversable
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ final class EllipticArc implements OperationInterface
|
|||||||
/**
|
/**
|
||||||
* @return Curve[]
|
* @return Curve[]
|
||||||
*/
|
*/
|
||||||
private function createCurves(float $fromX, $fromY) : array
|
private function createCurves(float $fromX, float $fromY) : array
|
||||||
{
|
{
|
||||||
$xAngle = deg2rad($this->xAxisAngle);
|
$xAngle = deg2rad($this->xAxisAngle);
|
||||||
list($centerX, $centerY, $radiusX, $radiusY, $startAngle, $deltaAngle) =
|
list($centerX, $centerY, $radiusX, $radiusY, $startAngle, $deltaAngle) =
|
||||||
|
@ -17,10 +17,16 @@ use BaconQrCode\Writer;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Spatie\Snapshots\MatchesSnapshots;
|
use Spatie\Snapshots\MatchesSnapshots;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group integration
|
||||||
|
*/
|
||||||
final class ImagickRenderingTest extends TestCase
|
final class ImagickRenderingTest extends TestCase
|
||||||
{
|
{
|
||||||
use MatchesSnapshots;
|
use MatchesSnapshots;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires extension imagick
|
||||||
|
*/
|
||||||
public function testGenericQrCode() : void
|
public function testGenericQrCode() : void
|
||||||
{
|
{
|
||||||
$renderer = new ImageRenderer(
|
$renderer = new ImageRenderer(
|
||||||
@ -35,6 +41,9 @@ final class ImagickRenderingTest extends TestCase
|
|||||||
unlink($tempName);
|
unlink($tempName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires extension imagick
|
||||||
|
*/
|
||||||
public function testIssue79() : void
|
public function testIssue79() : void
|
||||||
{
|
{
|
||||||
$eye = SquareEye::instance();
|
$eye = SquareEye::instance();
|
||||||
|
10
vendor/bin/lessc
vendored
10
vendor/bin/lessc
vendored
@ -108,10 +108,12 @@ if (PHP_VERSION_ID < 80000) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
|
if (
|
||||||
include("phpvfscomposer://" . __DIR__ . '/..'.'/wikimedia/less.php/bin/lessc');
|
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
|
||||||
exit(0);
|
|| (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';
|
||||||
|
137
vendor/composer/ClassLoader.php
vendored
137
vendor/composer/ClassLoader.php
vendored
@ -42,35 +42,37 @@ namespace Composer\Autoload;
|
|||||||
*/
|
*/
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
/** @var ?string */
|
/** @var \Closure(string):void */
|
||||||
|
private static $includeFile;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
private $vendorDir;
|
private $vendorDir;
|
||||||
|
|
||||||
// PSR-4
|
// PSR-4
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* @var array<string, array<string, int>>
|
||||||
* @psalm-var array<string, array<string, int>>
|
|
||||||
*/
|
*/
|
||||||
private $prefixLengthsPsr4 = array();
|
private $prefixLengthsPsr4 = array();
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* @var array<string, list<string>>
|
||||||
* @psalm-var array<string, array<int, string>>
|
|
||||||
*/
|
*/
|
||||||
private $prefixDirsPsr4 = array();
|
private $prefixDirsPsr4 = array();
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* @var list<string>
|
||||||
* @psalm-var array<string, string>
|
|
||||||
*/
|
*/
|
||||||
private $fallbackDirsPsr4 = array();
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
// PSR-0
|
// PSR-0
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* List of PSR-0 prefixes
|
||||||
* @psalm-var array<string, array<string, string[]>>
|
*
|
||||||
|
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||||
|
*
|
||||||
|
* @var array<string, array<string, list<string>>>
|
||||||
*/
|
*/
|
||||||
private $prefixesPsr0 = array();
|
private $prefixesPsr0 = array();
|
||||||
/**
|
/**
|
||||||
* @var array[]
|
* @var list<string>
|
||||||
* @psalm-var array<string, string>
|
|
||||||
*/
|
*/
|
||||||
private $fallbackDirsPsr0 = array();
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
@ -78,8 +80,7 @@ class ClassLoader
|
|||||||
private $useIncludePath = false;
|
private $useIncludePath = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var array<string, string>
|
||||||
* @psalm-var array<string, string>
|
|
||||||
*/
|
*/
|
||||||
private $classMap = array();
|
private $classMap = array();
|
||||||
|
|
||||||
@ -87,29 +88,29 @@ class ClassLoader
|
|||||||
private $classMapAuthoritative = false;
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool[]
|
* @var array<string, bool>
|
||||||
* @psalm-var array<string, bool>
|
|
||||||
*/
|
*/
|
||||||
private $missingClasses = array();
|
private $missingClasses = array();
|
||||||
|
|
||||||
/** @var ?string */
|
/** @var string|null */
|
||||||
private $apcuPrefix;
|
private $apcuPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var self[]
|
* @var array<string, self>
|
||||||
*/
|
*/
|
||||||
private static $registeredLoaders = array();
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ?string $vendorDir
|
* @param string|null $vendorDir
|
||||||
*/
|
*/
|
||||||
public function __construct($vendorDir = null)
|
public function __construct($vendorDir = null)
|
||||||
{
|
{
|
||||||
$this->vendorDir = $vendorDir;
|
$this->vendorDir = $vendorDir;
|
||||||
|
self::initializeIncludeClosure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return array<string, list<string>>
|
||||||
*/
|
*/
|
||||||
public function getPrefixes()
|
public function getPrefixes()
|
||||||
{
|
{
|
||||||
@ -121,8 +122,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return array<string, list<string>>
|
||||||
* @psalm-return array<string, array<int, string>>
|
|
||||||
*/
|
*/
|
||||||
public function getPrefixesPsr4()
|
public function getPrefixesPsr4()
|
||||||
{
|
{
|
||||||
@ -130,8 +130,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return list<string>
|
||||||
* @psalm-return array<string, string>
|
|
||||||
*/
|
*/
|
||||||
public function getFallbackDirs()
|
public function getFallbackDirs()
|
||||||
{
|
{
|
||||||
@ -139,8 +138,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array[]
|
* @return list<string>
|
||||||
* @psalm-return array<string, string>
|
|
||||||
*/
|
*/
|
||||||
public function getFallbackDirsPsr4()
|
public function getFallbackDirsPsr4()
|
||||||
{
|
{
|
||||||
@ -148,8 +146,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[] Array of classname => path
|
* @return array<string, string> Array of classname => path
|
||||||
* @psalm-return array<string, string>
|
|
||||||
*/
|
*/
|
||||||
public function getClassMap()
|
public function getClassMap()
|
||||||
{
|
{
|
||||||
@ -157,8 +154,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $classMap Class to filename map
|
* @param array<string, string> $classMap Class to filename map
|
||||||
* @psalm-param array<string, string> $classMap
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -175,24 +171,25 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param string[]|string $paths The PSR-0 root directories
|
* @param list<string>|string $paths The PSR-0 root directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function add($prefix, $paths, $prepend = false)
|
public function add($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->fallbackDirsPsr0
|
$this->fallbackDirsPsr0
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
$this->fallbackDirsPsr0,
|
$this->fallbackDirsPsr0,
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,19 +198,19 @@ class ClassLoader
|
|||||||
|
|
||||||
$first = $prefix[0];
|
$first = $prefix[0];
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
$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
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param string[]|string $paths The PSR-4 base directories
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
* @param bool $prepend Whether to prepend the directories
|
* @param bool $prepend Whether to prepend the directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*
|
*
|
||||||
@ -232,17 +229,18 @@ class ClassLoader
|
|||||||
*/
|
*/
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
|
$paths = (array) $paths;
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
// Register directories for the root namespace.
|
// Register directories for the root namespace.
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->fallbackDirsPsr4
|
$this->fallbackDirsPsr4
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
$this->fallbackDirsPsr4,
|
$this->fallbackDirsPsr4,
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
} 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.");
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||||
} elseif ($prepend) {
|
} elseif ($prepend) {
|
||||||
// Prepend directories for an already registered namespace.
|
// Prepend directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
(array) $paths,
|
$paths,
|
||||||
$this->prefixDirsPsr4[$prefix]
|
$this->prefixDirsPsr4[$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Append directories for an already registered namespace.
|
// Append directories for an already registered namespace.
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
$this->prefixDirsPsr4[$prefix],
|
$this->prefixDirsPsr4[$prefix],
|
||||||
(array) $paths
|
$paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,8 +270,8 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-0 directories for a given prefix,
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
* replacing any others previously set for this prefix.
|
* replacing any others previously set for this prefix.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix
|
* @param string $prefix The prefix
|
||||||
* @param string[]|string $paths The PSR-0 base directories
|
* @param list<string>|string $paths The PSR-0 base directories
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -290,8 +288,8 @@ class ClassLoader
|
|||||||
* Registers a set of PSR-4 directories for a given namespace,
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
* replacing any others previously set for this namespace.
|
* replacing any others previously set for this namespace.
|
||||||
*
|
*
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
* @param string[]|string $paths The PSR-4 base directories
|
* @param list<string>|string $paths The PSR-4 base directories
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*
|
*
|
||||||
@ -425,7 +423,8 @@ class ClassLoader
|
|||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
if ($file = $this->findFile($class)) {
|
if ($file = $this->findFile($class)) {
|
||||||
includeFile($file);
|
$includeFile = self::$includeFile;
|
||||||
|
$includeFile($file);
|
||||||
|
|
||||||
return true;
|
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()
|
public static function getRegisteredLoaders()
|
||||||
{
|
{
|
||||||
@ -555,18 +554,26 @@ class ClassLoader
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope isolated include.
|
* @return void
|
||||||
*
|
*/
|
||||||
* Prevents access to $this/self from included files.
|
private static function initializeIncludeClosure()
|
||||||
*
|
{
|
||||||
* @param string $file
|
if (self::$includeFile !== null) {
|
||||||
* @return void
|
return;
|
||||||
* @private
|
}
|
||||||
*/
|
|
||||||
function includeFile($file)
|
/**
|
||||||
{
|
* Scope isolated include.
|
||||||
include $file;
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
self::$includeFile = \Closure::bind(static function($file) {
|
||||||
|
include $file;
|
||||||
|
}, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
17
vendor/composer/InstalledVersions.php
vendored
17
vendor/composer/InstalledVersions.php
vendored
@ -98,7 +98,7 @@ class InstalledVersions
|
|||||||
{
|
{
|
||||||
foreach (self::getInstalled() as $installed) {
|
foreach (self::getInstalled() as $installed) {
|
||||||
if (isset($installed['versions'][$packageName])) {
|
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)
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||||
{
|
{
|
||||||
$constraint = $parser->parseConstraints($constraint);
|
$constraint = $parser->parseConstraints((string) $constraint);
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
return $provided->matches($constraint);
|
||||||
@ -328,7 +328,9 @@ class InstalledVersions
|
|||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
$installed[] = self::$installedByVendor[$vendorDir];
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
} 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__, '\\', '/')) {
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||||
self::$installed = $installed[count($installed) - 1];
|
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,
|
// 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
|
// 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') {
|
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 {
|
} else {
|
||||||
self::$installed = array();
|
self::$installed = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$installed[] = self::$installed;
|
|
||||||
|
if (self::$installed !== array()) {
|
||||||
|
$installed[] = self::$installed;
|
||||||
|
}
|
||||||
|
|
||||||
return $installed;
|
return $installed;
|
||||||
}
|
}
|
||||||
|
8
vendor/composer/autoload_real.php
vendored
8
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202
|
class ComposerAutoloaderInitd4957e04ba4dff37d0ecbf0a4b59e14a
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
@ -24,12 +24,12 @@ class ComposerAutoloaderInit6bb82695b2f28e8ee61f74ae2d5c5202
|
|||||||
|
|
||||||
require __DIR__ . '/platform_check.php';
|
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__));
|
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';
|
require __DIR__ . '/autoload_static.php';
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::getInitializer($loader));
|
call_user_func(\Composer\Autoload\ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::getInitializer($loader));
|
||||||
|
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202
|
class ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a
|
||||||
{
|
{
|
||||||
public static $prefixLengthsPsr4 = array (
|
public static $prefixLengthsPsr4 = array (
|
||||||
'E' =>
|
'E' =>
|
||||||
@ -54,10 +54,10 @@ class ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202
|
|||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixDirsPsr4;
|
||||||
$loader->prefixesPsr0 = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$prefixesPsr0;
|
$loader->prefixesPsr0 = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$prefixesPsr0;
|
||||||
$loader->classMap = ComposerStaticInit6bb82695b2f28e8ee61f74ae2d5c5202::$classMap;
|
$loader->classMap = ComposerStaticInitd4957e04ba4dff37d0ecbf0a4b59e14a::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
84
vendor/composer/installed.json
vendored
84
vendor/composer/installed.json
vendored
@ -2,17 +2,17 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bacon/bacon-qr-code",
|
"name": "bacon/bacon-qr-code",
|
||||||
"version": "2.0.7",
|
"version": "2.0.8",
|
||||||
"version_normalized": "2.0.7.0",
|
"version_normalized": "2.0.8.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Bacon/BaconQrCode.git",
|
"url": "https://github.com/Bacon/BaconQrCode.git",
|
||||||
"reference": "d70c840f68657ce49094b8d91f9ee0cc07fbf66c"
|
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/d70c840f68657ce49094b8d91f9ee0cc07fbf66c",
|
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22",
|
||||||
"reference": "d70c840f68657ce49094b8d91f9ee0cc07fbf66c",
|
"reference": "8674e51bb65af933a5ffaf1c308a660387c35c22",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -29,7 +29,7 @@
|
|||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-imagick": "to generate QR code images"
|
"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",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -53,30 +53,33 @@
|
|||||||
"homepage": "https://github.com/Bacon/BaconQrCode",
|
"homepage": "https://github.com/Bacon/BaconQrCode",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/Bacon/BaconQrCode/issues",
|
"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"
|
"install-path": "../bacon/bacon-qr-code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dasprid/enum",
|
"name": "dasprid/enum",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"version_normalized": "1.0.3.0",
|
"version_normalized": "1.0.4.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DASPRiD/Enum.git",
|
"url": "https://github.com/DASPRiD/Enum.git",
|
||||||
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2"
|
"reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/5abf82f213618696dda8e3bf6f64dd042d8542b2",
|
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8e6b6ea76eabbf19ea2bf5b67b98e1860474012f",
|
||||||
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2",
|
"reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1 <9.0"
|
||||||
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7 | ^8 | ^9",
|
"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",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -103,33 +106,36 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/DASPRiD/Enum/issues",
|
"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"
|
"install-path": "../dasprid/enum"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "endroid/qr-code",
|
"name": "endroid/qr-code",
|
||||||
"version": "4.4.9",
|
"version": "4.8.2",
|
||||||
"version_normalized": "4.4.9.0",
|
"version_normalized": "4.8.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/endroid/qr-code.git",
|
"url": "https://github.com/endroid/qr-code.git",
|
||||||
"reference": "bf087fa1e93a1b7310e2d94d187e26ae51db199d"
|
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/endroid/qr-code/zipball/bf087fa1e93a1b7310e2d94d187e26ae51db199d",
|
"url": "https://api.github.com/repos/endroid/qr-code/zipball/2436c2333a3931c95e2b96eb82f16f53143d6bba",
|
||||||
"reference": "bf087fa1e93a1b7310e2d94d187e26ae51db199d",
|
"reference": "2436c2333a3931c95e2b96eb82f16f53143d6bba",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"bacon/bacon-qr-code": "^2.0.5",
|
"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": {
|
"require-dev": {
|
||||||
"endroid/quality": "dev-master",
|
"endroid/quality": "dev-master",
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
|
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
|
||||||
"setasign/fpdf": "^1.8.2"
|
"setasign/fpdf": "^1.8.2"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
@ -138,7 +144,7 @@
|
|||||||
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
|
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
|
||||||
"setasign/fpdf": "Enables you to use the PDF writer"
|
"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",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
@ -172,7 +178,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/endroid/qr-code/issues",
|
"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": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -184,30 +190,31 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "wikimedia/less.php",
|
"name": "wikimedia/less.php",
|
||||||
"version": "v3.1.0",
|
"version": "v3.2.1",
|
||||||
"version_normalized": "3.1.0.0",
|
"version_normalized": "3.2.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/wikimedia/less.php.git",
|
"url": "https://github.com/wikimedia/less.php.git",
|
||||||
"reference": "a486d78b9bd16b72f237fc6093aa56d69ce8bd13"
|
"reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/wikimedia/less.php/zipball/a486d78b9bd16b72f237fc6093aa56d69ce8bd13",
|
"url": "https://api.github.com/repos/wikimedia/less.php/zipball/0d5b30ba792bdbf8991a646fc9c30561b38a5559",
|
||||||
"reference": "a486d78b9bd16b72f237fc6093aa56d69ce8bd13",
|
"reference": "0d5b30ba792bdbf8991a646fc9c30561b38a5559",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.9"
|
"php": ">=7.2.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mediawiki/mediawiki-codesniffer": "34.0.0",
|
"mediawiki/mediawiki-codesniffer": "40.0.1",
|
||||||
"mediawiki/minus-x": "1.0.0",
|
"mediawiki/mediawiki-phan-config": "0.12.0",
|
||||||
"php-parallel-lint/php-console-highlighter": "0.5.0",
|
"mediawiki/minus-x": "1.1.1",
|
||||||
"php-parallel-lint/php-parallel-lint": "1.2.0",
|
"php-parallel-lint/php-console-highlighter": "1.0.0",
|
||||||
|
"php-parallel-lint/php-parallel-lint": "1.3.2",
|
||||||
"phpunit/phpunit": "^8.5"
|
"phpunit/phpunit": "^8.5"
|
||||||
},
|
},
|
||||||
"time": "2020-12-11T19:33:31+00:00",
|
"time": "2023-02-03T06:43:41+00:00",
|
||||||
"bin": [
|
"bin": [
|
||||||
"bin/lessc"
|
"bin/lessc"
|
||||||
],
|
],
|
||||||
@ -226,6 +233,10 @@
|
|||||||
"Apache-2.0"
|
"Apache-2.0"
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Timo Tijhof",
|
||||||
|
"homepage": "https://timotijhof.net"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Josh Schmidt",
|
"name": "Josh Schmidt",
|
||||||
"homepage": "https://github.com/oyejorge"
|
"homepage": "https://github.com/oyejorge"
|
||||||
@ -239,7 +250,8 @@
|
|||||||
"homepage": "https://github.com/Mordred"
|
"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": [
|
"keywords": [
|
||||||
"css",
|
"css",
|
||||||
"less",
|
"less",
|
||||||
@ -250,7 +262,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/wikimedia/less.php/issues",
|
"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"
|
"install-path": "../wikimedia/less.php"
|
||||||
}
|
}
|
||||||
|
28
vendor/composer/installed.php
vendored
28
vendor/composer/installed.php
vendored
@ -3,7 +3,7 @@
|
|||||||
'name' => '__root__',
|
'name' => '__root__',
|
||||||
'pretty_version' => 'dev-main',
|
'pretty_version' => 'dev-main',
|
||||||
'version' => 'dev-main',
|
'version' => 'dev-main',
|
||||||
'reference' => '5e455c1499d4fba2d9bb825e4db8b58a3a6a595e',
|
'reference' => 'b4ef98673f4ec96aac0c1ff7bda444f72101c479',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
@ -13,43 +13,43 @@
|
|||||||
'__root__' => array(
|
'__root__' => array(
|
||||||
'pretty_version' => 'dev-main',
|
'pretty_version' => 'dev-main',
|
||||||
'version' => 'dev-main',
|
'version' => 'dev-main',
|
||||||
'reference' => '5e455c1499d4fba2d9bb825e4db8b58a3a6a595e',
|
'reference' => 'b4ef98673f4ec96aac0c1ff7bda444f72101c479',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../../',
|
'install_path' => __DIR__ . '/../../',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'bacon/bacon-qr-code' => array(
|
'bacon/bacon-qr-code' => array(
|
||||||
'pretty_version' => '2.0.7',
|
'pretty_version' => '2.0.8',
|
||||||
'version' => '2.0.7.0',
|
'version' => '2.0.8.0',
|
||||||
'reference' => 'd70c840f68657ce49094b8d91f9ee0cc07fbf66c',
|
'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../bacon/bacon-qr-code',
|
'install_path' => __DIR__ . '/../bacon/bacon-qr-code',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'dasprid/enum' => array(
|
'dasprid/enum' => array(
|
||||||
'pretty_version' => '1.0.3',
|
'pretty_version' => '1.0.4',
|
||||||
'version' => '1.0.3.0',
|
'version' => '1.0.4.0',
|
||||||
'reference' => '5abf82f213618696dda8e3bf6f64dd042d8542b2',
|
'reference' => '8e6b6ea76eabbf19ea2bf5b67b98e1860474012f',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../dasprid/enum',
|
'install_path' => __DIR__ . '/../dasprid/enum',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'endroid/qr-code' => array(
|
'endroid/qr-code' => array(
|
||||||
'pretty_version' => '4.4.9',
|
'pretty_version' => '4.8.2',
|
||||||
'version' => '4.4.9.0',
|
'version' => '4.8.2.0',
|
||||||
'reference' => 'bf087fa1e93a1b7310e2d94d187e26ae51db199d',
|
'reference' => '2436c2333a3931c95e2b96eb82f16f53143d6bba',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../endroid/qr-code',
|
'install_path' => __DIR__ . '/../endroid/qr-code',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
'dev_requirement' => false,
|
'dev_requirement' => false,
|
||||||
),
|
),
|
||||||
'wikimedia/less.php' => array(
|
'wikimedia/less.php' => array(
|
||||||
'pretty_version' => 'v3.1.0',
|
'pretty_version' => 'v3.2.1',
|
||||||
'version' => '3.1.0.0',
|
'version' => '3.2.1.0',
|
||||||
'reference' => 'a486d78b9bd16b72f237fc6093aa56d69ce8bd13',
|
'reference' => '0d5b30ba792bdbf8991a646fc9c30561b38a5559',
|
||||||
'type' => 'library',
|
'type' => 'library',
|
||||||
'install_path' => __DIR__ . '/../wikimedia/less.php',
|
'install_path' => __DIR__ . '/../wikimedia/less.php',
|
||||||
'aliases' => array(),
|
'aliases' => array(),
|
||||||
|
4
vendor/composer/platform_check.php
vendored
4
vendor/composer/platform_check.php
vendored
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
$issues = array();
|
$issues = array();
|
||||||
|
|
||||||
if (!(PHP_VERSION_ID >= 70400)) {
|
if (!(PHP_VERSION_ID >= 80000)) {
|
||||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
|
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($issues) {
|
if ($issues) {
|
||||||
|
47
vendor/dasprid/enum/.github/workflows/tests.yml
vendored
Normal file
47
vendor/dasprid/enum/.github/workflows/tests.yml
vendored
Normal 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
|
||||||
|
|
30
vendor/dasprid/enum/README.md
vendored
30
vendor/dasprid/enum/README.md
vendored
@ -1,6 +1,6 @@
|
|||||||
# PHP 7.1 enums
|
# 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)
|
[![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)
|
[![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)
|
[![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 SATURDAY = null;
|
||||||
protected const SUNDAY = 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,
|
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
|
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():
|
case WeekDay::MONDAY():
|
||||||
echo 'Mondays are bad.';
|
echo 'Mondays are bad.';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WeekDay::FRIDAY():
|
case WeekDay::FRIDAY():
|
||||||
echo 'Fridays are better.';
|
echo 'Fridays are better.';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WeekDay::SATURDAY():
|
case WeekDay::SATURDAY():
|
||||||
case WeekDay::SUNDAY():
|
case WeekDay::SUNDAY():
|
||||||
echo 'Weekends are best.';
|
echo 'Weekends are best.';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
echo 'Midweek days are so-so.';
|
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 SATURN = [5.688e+26, 6.0268e7];
|
||||||
protected const URANUS = [8.686e+25, 2.5559e7];
|
protected const URANUS = [8.686e+25, 2.5559e7];
|
||||||
protected const NEPTUNE = [1.024e+26, 2.4746e7];
|
protected const NEPTUNE = [1.024e+26, 2.4746e7];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Universal gravitational constant.
|
* Universal gravitational constant.
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private const G = 6.67300E-11;
|
private const G = 6.67300E-11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mass in kilograms.
|
* Mass in kilograms.
|
||||||
*
|
*
|
||||||
@ -124,32 +124,32 @@ final class Planet extends AbstractEnum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Radius in meters.
|
* Radius in meters.
|
||||||
*
|
*
|
||||||
* @var float
|
* @var float
|
||||||
*/
|
*/
|
||||||
private $radius;
|
private $radius;
|
||||||
|
|
||||||
protected function __construct(float $mass, float $radius)
|
protected function __construct(float $mass, float $radius)
|
||||||
{
|
{
|
||||||
$this->mass = $mass;
|
$this->mass = $mass;
|
||||||
$this->radius = $radius;
|
$this->radius = $radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mass() : float
|
public function mass() : float
|
||||||
{
|
{
|
||||||
return $this->mass;
|
return $this->mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function radius() : float
|
public function radius() : float
|
||||||
{
|
{
|
||||||
return $this->radius;
|
return $this->radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function surfaceGravity() : float
|
public function surfaceGravity() : float
|
||||||
{
|
{
|
||||||
return self::G * $this->mass / ($this->radius * $this->radius);
|
return self::G * $this->mass / ($this->radius * $this->radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function surfaceWeight(float $otherMass) : float
|
public function surfaceWeight(float $otherMass) : float
|
||||||
{
|
{
|
||||||
return $otherMass * $this->surfaceGravity();
|
return $otherMass * $this->surfaceGravity();
|
||||||
|
5
vendor/dasprid/enum/composer.json
vendored
5
vendor/dasprid/enum/composer.json
vendored
@ -14,9 +14,12 @@
|
|||||||
"enum",
|
"enum",
|
||||||
"map"
|
"map"
|
||||||
],
|
],
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1 <9.0"
|
||||||
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7 | ^8 | ^9",
|
"phpunit/phpunit": "^7 | ^8 | ^9",
|
||||||
"squizlabs/php_codesniffer": "^3.4"
|
"squizlabs/php_codesniffer": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
42
vendor/dasprid/enum/src/EnumMap.php
vendored
42
vendor/dasprid/enum/src/EnumMap.php
vendored
@ -88,6 +88,31 @@ final class EnumMap implements Serializable, IteratorAggregate
|
|||||||
$this->values = array_fill(0, count($this->keyUniverse), null);
|
$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.
|
* Checks whether the map types match the supplied ones.
|
||||||
*
|
*
|
||||||
@ -261,22 +286,7 @@ final class EnumMap implements Serializable, IteratorAggregate
|
|||||||
|
|
||||||
public function serialize() : string
|
public function serialize() : string
|
||||||
{
|
{
|
||||||
$values = [];
|
return serialize($this->__serialize());
|
||||||
|
|
||||||
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,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unserialize($serialized) : void
|
public function unserialize($serialized) : void
|
||||||
|
2
vendor/endroid/qr-code/LICENSE
vendored
2
vendor/endroid/qr-code/LICENSE
vendored
@ -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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
50
vendor/endroid/qr-code/README.md
vendored
50
vendor/endroid/qr-code/README.md
vendored
@ -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
|
Symfony bundle for easy installation and configuration. Different writers are provided to generate the QR code
|
||||||
as PNG, SVG, EPS or in binary format.
|
as PNG, SVG, EPS or in binary format.
|
||||||
|
|
||||||
|
## Sponsored by
|
||||||
|
|
||||||
|
[![Blackfire.io](assets/blackfire.png)](https://www.blackfire.io)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Use [Composer](https://getcomposer.org/) to install the library. Also make sure you have enabled and configured the
|
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.
|
[GD extension](https://www.php.net/manual/en/book.image.php) if you want to generate images.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
$ composer require endroid/qr-code
|
composer require endroid/qr-code
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage: using the builder
|
## Usage: using the builder
|
||||||
@ -47,6 +51,7 @@ $result = Builder::create()
|
|||||||
->labelText('This is the label')
|
->labelText('This is the label')
|
||||||
->labelFont(new NotoSans(20))
|
->labelFont(new NotoSans(20))
|
||||||
->labelAlignment(new LabelAlignmentCenter())
|
->labelAlignment(new LabelAlignmentCenter())
|
||||||
|
->validateResult(false)
|
||||||
->build();
|
->build();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -61,11 +66,12 @@ use Endroid\QrCode\Label\Label;
|
|||||||
use Endroid\QrCode\Logo\Logo;
|
use Endroid\QrCode\Logo\Logo;
|
||||||
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
|
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
|
||||||
use Endroid\QrCode\Writer\PngWriter;
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
|
use Endroid\QrCode\Writer\ValidationException;
|
||||||
|
|
||||||
$writer = new PngWriter();
|
$writer = new PngWriter();
|
||||||
|
|
||||||
// Create QR code
|
// Create QR code
|
||||||
$qrCode = QrCode::create('Data')
|
$qrCode = QrCode::create('Life is too short to be generating QR codes')
|
||||||
->setEncoding(new Encoding('UTF-8'))
|
->setEncoding(new Encoding('UTF-8'))
|
||||||
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
|
->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
|
||||||
->setSize(300)
|
->setSize(300)
|
||||||
@ -83,6 +89,9 @@ $label = Label::create('Label')
|
|||||||
->setTextColor(new Color(255, 0, 0));
|
->setTextColor(new Color(255, 0, 0));
|
||||||
|
|
||||||
$result = $writer->write($qrCode, $logo, $label);
|
$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
|
## Usage: working with results
|
||||||
@ -104,10 +113,32 @@ $dataUri = $result->getDataUri();
|
|||||||
|
|
||||||
### Writer options
|
### 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
|
```php
|
||||||
use Endroid\QrCode\Writer\SvgWriter;
|
use Endroid\QrCode\Writer\SvgWriter;
|
||||||
|
|
||||||
$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
|
$builder->setWriterOptions([
|
||||||
|
SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true
|
||||||
|
]);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Encoding
|
### 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
|
And finally the encoding (default UTF-8 to support large character sets) can be
|
||||||
set to `ISO-8859-1` if possible to improve readability.
|
set to `ISO-8859-1` if possible to improve readability.
|
||||||
|
|
||||||
## Built-in validation reader
|
## Validating the generated QR code
|
||||||
|
|
||||||
You can enable the built-in validation reader (disabled by default) by calling
|
If you need to be extra sure the QR code you generated is readable and contains
|
||||||
setValidateResult(true). This validation reader does not guarantee that the QR
|
the exact data you requested you can enable the validation reader, which is
|
||||||
code will be readable by all readers but it helps you provide a minimum level
|
disabled by default. You can do this either via the builder or directly on any
|
||||||
of quality. Take note that the validator can consume quite amount of additional
|
writer that supports validation. See the examples above.
|
||||||
resources and it should be installed separately only if you use it.
|
|
||||||
|
Please note that validation affects performance so only use it in case of problems.
|
||||||
|
|
||||||
## Symfony integration
|
## Symfony integration
|
||||||
|
|
||||||
|
BIN
vendor/endroid/qr-code/assets/blackfire.png
vendored
Normal file
BIN
vendor/endroid/qr-code/assets/blackfire.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
10
vendor/endroid/qr-code/composer.json
vendored
10
vendor/endroid/qr-code/composer.json
vendored
@ -12,15 +12,18 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.4||^8.0",
|
"php": "^8.0",
|
||||||
"bacon/bacon-qr-code": "^2.0.5"
|
"bacon/bacon-qr-code": "^2.0.5"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"endroid/quality": "dev-master",
|
"endroid/quality": "dev-master",
|
||||||
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
|
"khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2",
|
||||||
"setasign/fpdf": "^1.8.2"
|
"setasign/fpdf": "^1.8.2"
|
||||||
},
|
},
|
||||||
|
"conflict": {
|
||||||
|
"khanamiryan/qrcode-detector-decoder": "^1.0.6"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-gd": "Enables you to write PNG images",
|
"ext-gd": "Enables you to write PNG images",
|
||||||
"khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator",
|
"khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator",
|
||||||
@ -41,6 +44,9 @@
|
|||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"preferred-install": {
|
"preferred-install": {
|
||||||
"endroid/*": "source"
|
"endroid/*": "source"
|
||||||
|
},
|
||||||
|
"allow-plugins": {
|
||||||
|
"endroid/installer": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -7,6 +7,7 @@ namespace Endroid\QrCode\Builder;
|
|||||||
use Endroid\QrCode\Color\ColorInterface;
|
use Endroid\QrCode\Color\ColorInterface;
|
||||||
use Endroid\QrCode\Encoding\EncodingInterface;
|
use Endroid\QrCode\Encoding\EncodingInterface;
|
||||||
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface;
|
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface;
|
||||||
|
use Endroid\QrCode\Exception\ValidationException;
|
||||||
use Endroid\QrCode\Label\Alignment\LabelAlignmentInterface;
|
use Endroid\QrCode\Label\Alignment\LabelAlignmentInterface;
|
||||||
use Endroid\QrCode\Label\Font\FontInterface;
|
use Endroid\QrCode\Label\Font\FontInterface;
|
||||||
use Endroid\QrCode\Label\Label;
|
use Endroid\QrCode\Label\Label;
|
||||||
@ -24,7 +25,7 @@ use Endroid\QrCode\Writer\WriterInterface;
|
|||||||
class Builder implements BuilderInterface
|
class Builder implements BuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array<mixed>{
|
* @var array<string, mixed>{
|
||||||
* data: string,
|
* data: string,
|
||||||
* writer: WriterInterface,
|
* writer: WriterInterface,
|
||||||
* writerOptions: array,
|
* writerOptions: array,
|
||||||
@ -77,7 +78,7 @@ class Builder implements BuilderInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param array<mixed> $writerOptions */
|
/** @param array<string, mixed> $writerOptions */
|
||||||
public function writerOptions(array $writerOptions): BuilderInterface
|
public function writerOptions(array $writerOptions): BuilderInterface
|
||||||
{
|
{
|
||||||
$this->options['writerOptions'] = $writerOptions;
|
$this->options['writerOptions'] = $writerOptions;
|
||||||
@ -216,7 +217,7 @@ class Builder implements BuilderInterface
|
|||||||
$writer = $this->options['writer'];
|
$writer = $this->options['writer'];
|
||||||
|
|
||||||
if ($this->options['validateResult'] && !$writer instanceof ValidatingWriterInterface) {
|
if ($this->options['validateResult'] && !$writer instanceof ValidatingWriterInterface) {
|
||||||
throw new \Exception('Unable to validate result with '.get_class($writer));
|
throw ValidationException::createForUnsupportedWriter(strval(get_class($writer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var QrCode $qrCode */
|
/** @var QrCode $qrCode */
|
||||||
@ -242,7 +243,7 @@ class Builder implements BuilderInterface
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function buildObject(string $class, string $optionsPrefix = null)
|
private function buildObject(string $class, string|null $optionsPrefix = null)
|
||||||
{
|
{
|
||||||
/** @var \ReflectionClass<object> $reflectionClass */
|
/** @var \ReflectionClass<object> $reflectionClass */
|
||||||
$reflectionClass = new \ReflectionClass($class);
|
$reflectionClass = new \ReflectionClass($class);
|
||||||
|
@ -20,7 +20,7 @@ interface BuilderInterface
|
|||||||
|
|
||||||
public function writer(WriterInterface $writer): BuilderInterface;
|
public function writer(WriterInterface $writer): BuilderInterface;
|
||||||
|
|
||||||
/** @param array<mixed> $writerOptions */
|
/** @param array<string, mixed> $writerOptions */
|
||||||
public function writerOptions(array $writerOptions): BuilderInterface;
|
public function writerOptions(array $writerOptions): BuilderInterface;
|
||||||
|
|
||||||
public function data(string $data): BuilderInterface;
|
public function data(string $data): BuilderInterface;
|
||||||
|
22
vendor/endroid/qr-code/src/Color/Color.php
vendored
22
vendor/endroid/qr-code/src/Color/Color.php
vendored
@ -6,17 +6,12 @@ namespace Endroid\QrCode\Color;
|
|||||||
|
|
||||||
final class Color implements ColorInterface
|
final class Color implements ColorInterface
|
||||||
{
|
{
|
||||||
private int $red;
|
public function __construct(
|
||||||
private int $green;
|
private int $red,
|
||||||
private int $blue;
|
private int $green,
|
||||||
private int $alpha;
|
private int $blue,
|
||||||
|
private int $alpha = 0
|
||||||
public function __construct(int $red, int $green, int $blue, int $alpha = 0)
|
) {
|
||||||
{
|
|
||||||
$this->red = $red;
|
|
||||||
$this->green = $green;
|
|
||||||
$this->blue = $blue;
|
|
||||||
$this->alpha = $alpha;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRed(): int
|
public function getRed(): int
|
||||||
@ -44,6 +39,11 @@ final class Color implements ColorInterface
|
|||||||
return 1 - $this->alpha / 127;
|
return 1 - $this->alpha / 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHex(): string
|
||||||
|
{
|
||||||
|
return sprintf('#%02x%02x%02x', $this->red, $this->green, $this->blue);
|
||||||
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -16,6 +16,8 @@ interface ColorInterface
|
|||||||
|
|
||||||
public function getOpacity(): float;
|
public function getOpacity(): float;
|
||||||
|
|
||||||
|
public function getHex(): string;
|
||||||
|
|
||||||
/** @return array<string, int> */
|
/** @return array<string, int> */
|
||||||
public function toArray(): array;
|
public function toArray(): array;
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,12 @@ namespace Endroid\QrCode\Encoding;
|
|||||||
|
|
||||||
final class Encoding implements EncodingInterface
|
final class Encoding implements EncodingInterface
|
||||||
{
|
{
|
||||||
private string $value;
|
public function __construct(
|
||||||
|
private string $value
|
||||||
public function __construct(string $value)
|
) {
|
||||||
{
|
|
||||||
if (!in_array($value, mb_list_encodings())) {
|
if (!in_array($value, mb_list_encodings())) {
|
||||||
throw new \Exception(sprintf('Invalid encoding "%s"', $value));
|
throw new \Exception(sprintf('Invalid encoding "%s"', $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->value = $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
|
23
vendor/endroid/qr-code/src/Exception/ValidationException.php
vendored
Normal file
23
vendor/endroid/qr-code/src/Exception/ValidationException.php
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Exception;
|
||||||
|
|
||||||
|
final class ValidationException extends \Exception
|
||||||
|
{
|
||||||
|
public static function createForUnsupportedWriter(string $writerClass): self
|
||||||
|
{
|
||||||
|
return new self(sprintf('Unable to validate the result: "%s" does not support validation', $writerClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createForMissingPackage(string $packageName): self
|
||||||
|
{
|
||||||
|
return new self(sprintf('Please install "%s" or disable image validation', $packageName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createForInvalidData(string $expectedData, string $actualData): self
|
||||||
|
{
|
||||||
|
return new self('The validation reader read "'.$actualData.'" instead of "'.$expectedData.'". Adjust your parameters to increase readability or disable validation.');
|
||||||
|
}
|
||||||
|
}
|
@ -8,13 +8,10 @@ use Endroid\QrCode\Label\LabelInterface;
|
|||||||
|
|
||||||
class LabelImageData
|
class LabelImageData
|
||||||
{
|
{
|
||||||
private int $width;
|
private function __construct(
|
||||||
private int $height;
|
private int $width,
|
||||||
|
private int $height
|
||||||
private function __construct(int $width, int $height)
|
) {
|
||||||
{
|
|
||||||
$this->width = $width;
|
|
||||||
$this->height = $height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createForLabel(LabelInterface $label): self
|
public static function createForLabel(LabelInterface $label): self
|
||||||
|
@ -8,31 +8,14 @@ use Endroid\QrCode\Logo\LogoInterface;
|
|||||||
|
|
||||||
class LogoImageData
|
class LogoImageData
|
||||||
{
|
{
|
||||||
private string $data;
|
|
||||||
|
|
||||||
/** @var mixed */
|
|
||||||
private $image;
|
|
||||||
|
|
||||||
private string $mimeType;
|
|
||||||
private int $width;
|
|
||||||
private int $height;
|
|
||||||
private bool $punchoutBackground;
|
|
||||||
|
|
||||||
/** @param mixed $image */
|
|
||||||
private function __construct(
|
private function __construct(
|
||||||
string $data,
|
private string $data,
|
||||||
$image,
|
private \GdImage|null $image,
|
||||||
string $mimeType,
|
private string $mimeType,
|
||||||
int $width,
|
private int $width,
|
||||||
int $height,
|
private int $height,
|
||||||
bool $punchoutBackground
|
private bool $punchoutBackground
|
||||||
) {
|
) {
|
||||||
$this->data = $data;
|
|
||||||
$this->image = $image;
|
|
||||||
$this->mimeType = $mimeType;
|
|
||||||
$this->width = $width;
|
|
||||||
$this->height = $height;
|
|
||||||
$this->punchoutBackground = $punchoutBackground;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createForLogo(LogoInterface $logo): self
|
public static function createForLogo(LogoInterface $logo): self
|
||||||
@ -89,10 +72,9 @@ class LogoImageData
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return mixed */
|
public function getImage(): \GdImage
|
||||||
public function getImage()
|
|
||||||
{
|
{
|
||||||
if (null === $this->image) {
|
if (!$this->image instanceof \GdImage) {
|
||||||
throw new \Exception('SVG Images have no image resource');
|
throw new \Exception('SVG Images have no image resource');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +108,7 @@ class LogoImageData
|
|||||||
|
|
||||||
private static function detectMimeTypeFromUrl(string $url): string
|
private static function detectMimeTypeFromUrl(string $url): string
|
||||||
{
|
{
|
||||||
/** @var mixed $format */
|
$headers = get_headers($url, true);
|
||||||
$format = PHP_VERSION_ID >= 80000 ? true : 1;
|
|
||||||
|
|
||||||
$headers = get_headers($url, $format);
|
|
||||||
|
|
||||||
if (!is_array($headers) || !isset($headers['Content-Type'])) {
|
if (!is_array($headers) || !isset($headers['Content-Type'])) {
|
||||||
throw new \Exception(sprintf('Content type could not be determined for logo URL "%s"', $url));
|
throw new \Exception(sprintf('Content type could not be determined for logo URL "%s"', $url));
|
||||||
|
16
vendor/endroid/qr-code/src/Label/Font/Font.php
vendored
16
vendor/endroid/qr-code/src/Label/Font/Font.php
vendored
@ -6,18 +6,14 @@ namespace Endroid\QrCode\Label\Font;
|
|||||||
|
|
||||||
final class Font implements FontInterface
|
final class Font implements FontInterface
|
||||||
{
|
{
|
||||||
private string $path;
|
public function __construct(
|
||||||
private int $size;
|
private string $path,
|
||||||
|
private int $size = 16
|
||||||
public function __construct(string $path, int $size = 16)
|
) {
|
||||||
{
|
$this->assertValidPath($path);
|
||||||
$this->validatePath($path);
|
|
||||||
|
|
||||||
$this->path = $path;
|
|
||||||
$this->size = $size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validatePath(string $path): void
|
private function assertValidPath(string $path): void
|
||||||
{
|
{
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
throw new \Exception(sprintf('Invalid font path "%s"', $path));
|
throw new \Exception(sprintf('Invalid font path "%s"', $path));
|
||||||
|
@ -6,11 +6,9 @@ namespace Endroid\QrCode\Label\Font;
|
|||||||
|
|
||||||
final class NotoSans implements FontInterface
|
final class NotoSans implements FontInterface
|
||||||
{
|
{
|
||||||
private int $size;
|
public function __construct(
|
||||||
|
private int $size = 16
|
||||||
public function __construct(int $size = 16)
|
) {
|
||||||
{
|
|
||||||
$this->size = $size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPath(): string
|
public function getPath(): string
|
||||||
|
@ -6,11 +6,9 @@ namespace Endroid\QrCode\Label\Font;
|
|||||||
|
|
||||||
final class OpenSans implements FontInterface
|
final class OpenSans implements FontInterface
|
||||||
{
|
{
|
||||||
private int $size;
|
public function __construct(
|
||||||
|
private int $size = 16
|
||||||
public function __construct(int $size = 16)
|
) {
|
||||||
{
|
|
||||||
$this->size = $size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPath(): string
|
public function getPath(): string
|
||||||
|
20
vendor/endroid/qr-code/src/Label/Label.php
vendored
20
vendor/endroid/qr-code/src/Label/Label.php
vendored
@ -15,24 +15,22 @@ use Endroid\QrCode\Label\Margin\MarginInterface;
|
|||||||
|
|
||||||
final class Label implements LabelInterface
|
final class Label implements LabelInterface
|
||||||
{
|
{
|
||||||
private string $text;
|
|
||||||
private FontInterface $font;
|
private FontInterface $font;
|
||||||
private LabelAlignmentInterface $alignment;
|
private LabelAlignmentInterface $alignment;
|
||||||
private MarginInterface $margin;
|
private MarginInterface $margin;
|
||||||
private ColorInterface $textColor;
|
private ColorInterface $textColor;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $text,
|
private string $text,
|
||||||
FontInterface $font = null,
|
FontInterface|null $font = null,
|
||||||
LabelAlignmentInterface $alignment = null,
|
LabelAlignmentInterface|null $alignment = null,
|
||||||
MarginInterface $margin = null,
|
MarginInterface|null $margin = null,
|
||||||
ColorInterface $textColor = null
|
ColorInterface|null $textColor = null
|
||||||
) {
|
) {
|
||||||
$this->text = $text;
|
$this->font = $font ?? new Font(__DIR__.'/../../assets/noto_sans.otf', 16);
|
||||||
$this->font = isset($font) ? $font : new Font(__DIR__.'/../../assets/noto_sans.otf', 16);
|
$this->alignment = $alignment ?? new LabelAlignmentCenter();
|
||||||
$this->alignment = isset($alignment) ? $alignment : new LabelAlignmentCenter();
|
$this->margin = $margin ?? new Margin(0, 10, 10, 10);
|
||||||
$this->margin = isset($margin) ? $margin : new Margin(0, 10, 10, 10);
|
$this->textColor = $textColor ?? new Color(0, 0, 0);
|
||||||
$this->textColor = isset($textColor) ? $textColor : new Color(0, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(string $text): self
|
public static function create(string $text): self
|
||||||
|
@ -6,17 +6,12 @@ namespace Endroid\QrCode\Label\Margin;
|
|||||||
|
|
||||||
final class Margin implements MarginInterface
|
final class Margin implements MarginInterface
|
||||||
{
|
{
|
||||||
private int $top;
|
public function __construct(
|
||||||
private int $right;
|
private int $top,
|
||||||
private int $bottom;
|
private int $right,
|
||||||
private int $left;
|
private int $bottom,
|
||||||
|
private int $left
|
||||||
public function __construct(int $top, int $right, int $bottom, int $left)
|
) {
|
||||||
{
|
|
||||||
$this->top = $top;
|
|
||||||
$this->right = $right;
|
|
||||||
$this->bottom = $bottom;
|
|
||||||
$this->left = $left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTop(): int
|
public function getTop(): int
|
||||||
|
25
vendor/endroid/qr-code/src/Logo/Logo.php
vendored
25
vendor/endroid/qr-code/src/Logo/Logo.php
vendored
@ -6,17 +6,12 @@ namespace Endroid\QrCode\Logo;
|
|||||||
|
|
||||||
final class Logo implements LogoInterface
|
final class Logo implements LogoInterface
|
||||||
{
|
{
|
||||||
private string $path;
|
public function __construct(
|
||||||
private ?int $resizeToWidth;
|
private string $path,
|
||||||
private ?int $resizeToHeight;
|
private int|null $resizeToWidth = null,
|
||||||
private bool $punchoutBackground;
|
private int|null $resizeToHeight = null,
|
||||||
|
private bool $punchoutBackground = false
|
||||||
public function __construct(string $path, ?int $resizeToWidth = null, ?int $resizeToHeight = null, bool $punchoutBackground = false)
|
) {
|
||||||
{
|
|
||||||
$this->path = $path;
|
|
||||||
$this->resizeToWidth = $resizeToWidth;
|
|
||||||
$this->resizeToHeight = $resizeToHeight;
|
|
||||||
$this->punchoutBackground = $punchoutBackground;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create(string $path): self
|
public static function create(string $path): self
|
||||||
@ -36,24 +31,24 @@ final class Logo implements LogoInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResizeToWidth(): ?int
|
public function getResizeToWidth(): int|null
|
||||||
{
|
{
|
||||||
return $this->resizeToWidth;
|
return $this->resizeToWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResizeToWidth(?int $resizeToWidth): self
|
public function setResizeToWidth(int|null $resizeToWidth): self
|
||||||
{
|
{
|
||||||
$this->resizeToWidth = $resizeToWidth;
|
$this->resizeToWidth = $resizeToWidth;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResizeToHeight(): ?int
|
public function getResizeToHeight(): int|null
|
||||||
{
|
{
|
||||||
return $this->resizeToHeight;
|
return $this->resizeToHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResizeToHeight(?int $resizeToHeight): self
|
public function setResizeToHeight(int|null $resizeToHeight): self
|
||||||
{
|
{
|
||||||
$this->resizeToHeight = $resizeToHeight;
|
$this->resizeToHeight = $resizeToHeight;
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ interface LogoInterface
|
|||||||
{
|
{
|
||||||
public function getPath(): string;
|
public function getPath(): string;
|
||||||
|
|
||||||
public function getResizeToWidth(): ?int;
|
public function getResizeToWidth(): int|null;
|
||||||
|
|
||||||
public function getResizeToHeight(): ?int;
|
public function getResizeToHeight(): int|null;
|
||||||
|
|
||||||
public function getPunchoutBackground(): bool;
|
public function getPunchoutBackground(): bool;
|
||||||
}
|
}
|
||||||
|
13
vendor/endroid/qr-code/src/Matrix/Matrix.php
vendored
13
vendor/endroid/qr-code/src/Matrix/Matrix.php
vendored
@ -11,9 +11,6 @@ use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeShrink;
|
|||||||
|
|
||||||
final class Matrix implements MatrixInterface
|
final class Matrix implements MatrixInterface
|
||||||
{
|
{
|
||||||
/** @var array<int, array<int, int>> */
|
|
||||||
private array $blockValues = [];
|
|
||||||
|
|
||||||
private float $blockSize;
|
private float $blockSize;
|
||||||
private int $innerSize;
|
private int $innerSize;
|
||||||
private int $outerSize;
|
private int $outerSize;
|
||||||
@ -21,10 +18,12 @@ final class Matrix implements MatrixInterface
|
|||||||
private int $marginRight;
|
private int $marginRight;
|
||||||
|
|
||||||
/** @param array<array<int>> $blockValues */
|
/** @param array<array<int>> $blockValues */
|
||||||
public function __construct(array $blockValues, int $size, int $margin, RoundBlockSizeModeInterface $roundBlockSizeMode)
|
public function __construct(
|
||||||
{
|
private array $blockValues,
|
||||||
$this->blockValues = $blockValues;
|
int $size,
|
||||||
|
int $margin,
|
||||||
|
RoundBlockSizeModeInterface $roundBlockSizeMode
|
||||||
|
) {
|
||||||
$this->blockSize = $size / $this->getBlockCount();
|
$this->blockSize = $size / $this->getBlockCount();
|
||||||
$this->innerSize = $size;
|
$this->innerSize = $size;
|
||||||
$this->outerSize = $size + 2 * $margin;
|
$this->outerSize = $size + 2 * $margin;
|
||||||
|
22
vendor/endroid/qr-code/src/QrCode.php
vendored
22
vendor/endroid/qr-code/src/QrCode.php
vendored
@ -15,30 +15,24 @@ use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
|
|||||||
|
|
||||||
final class QrCode implements QrCodeInterface
|
final class QrCode implements QrCodeInterface
|
||||||
{
|
{
|
||||||
private string $data;
|
|
||||||
private EncodingInterface $encoding;
|
private EncodingInterface $encoding;
|
||||||
private ErrorCorrectionLevelInterface $errorCorrectionLevel;
|
private ErrorCorrectionLevelInterface $errorCorrectionLevel;
|
||||||
private int $size;
|
|
||||||
private int $margin;
|
|
||||||
private RoundBlockSizeModeInterface $roundBlockSizeMode;
|
private RoundBlockSizeModeInterface $roundBlockSizeMode;
|
||||||
private ColorInterface $foregroundColor;
|
private ColorInterface $foregroundColor;
|
||||||
private ColorInterface $backgroundColor;
|
private ColorInterface $backgroundColor;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $data,
|
private string $data,
|
||||||
EncodingInterface $encoding = null,
|
EncodingInterface|null $encoding = null,
|
||||||
ErrorCorrectionLevelInterface $errorCorrectionLevel = null,
|
ErrorCorrectionLevelInterface|null $errorCorrectionLevel = null,
|
||||||
int $size = 300,
|
private int $size = 300,
|
||||||
int $margin = 10,
|
private int $margin = 10,
|
||||||
RoundBlockSizeModeInterface $roundBlockSizeMode = null,
|
RoundBlockSizeModeInterface|null $roundBlockSizeMode = null,
|
||||||
ColorInterface $foregroundColor = null,
|
ColorInterface|null $foregroundColor = null,
|
||||||
ColorInterface $backgroundColor = null
|
ColorInterface|null $backgroundColor = null
|
||||||
) {
|
) {
|
||||||
$this->data = $data;
|
|
||||||
$this->encoding = $encoding ?? new Encoding('UTF-8');
|
$this->encoding = $encoding ?? new Encoding('UTF-8');
|
||||||
$this->errorCorrectionLevel = $errorCorrectionLevel ?? new ErrorCorrectionLevelLow();
|
$this->errorCorrectionLevel = $errorCorrectionLevel ?? new ErrorCorrectionLevelLow();
|
||||||
$this->size = $size;
|
|
||||||
$this->margin = $margin;
|
|
||||||
$this->roundBlockSizeMode = $roundBlockSizeMode ?? new RoundBlockSizeModeMargin();
|
$this->roundBlockSizeMode = $roundBlockSizeMode ?? new RoundBlockSizeModeMargin();
|
||||||
$this->foregroundColor = $foregroundColor ?? new Color(0, 0, 0);
|
$this->foregroundColor = $foregroundColor ?? new Color(0, 0, 0);
|
||||||
$this->backgroundColor = $backgroundColor ?? new Color(255, 255, 255);
|
$this->backgroundColor = $backgroundColor ?? new Color(255, 255, 255);
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
interface WritableInterface
|
|
||||||
{
|
|
||||||
}
|
|
205
vendor/endroid/qr-code/src/Writer/AbstractGdWriter.php
vendored
Normal file
205
vendor/endroid/qr-code/src/Writer/AbstractGdWriter.php
vendored
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Bacon\MatrixFactory;
|
||||||
|
use Endroid\QrCode\Exception\ValidationException;
|
||||||
|
use Endroid\QrCode\ImageData\LabelImageData;
|
||||||
|
use Endroid\QrCode\ImageData\LogoImageData;
|
||||||
|
use Endroid\QrCode\Label\Alignment\LabelAlignmentLeft;
|
||||||
|
use Endroid\QrCode\Label\Alignment\LabelAlignmentRight;
|
||||||
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
|
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeNone;
|
||||||
|
use Endroid\QrCode\Writer\Result\GdResult;
|
||||||
|
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||||
|
use Zxing\QrReader;
|
||||||
|
|
||||||
|
abstract class AbstractGdWriter implements WriterInterface, ValidatingWriterInterface
|
||||||
|
{
|
||||||
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
|
{
|
||||||
|
if (!extension_loaded('gd')) {
|
||||||
|
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
||||||
|
}
|
||||||
|
|
||||||
|
$matrixFactory = new MatrixFactory();
|
||||||
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
|
|
||||||
|
$baseBlockSize = $qrCode->getRoundBlockSizeMode() instanceof RoundBlockSizeModeNone ? 10 : intval($matrix->getBlockSize());
|
||||||
|
$baseImage = imagecreatetruecolor($matrix->getBlockCount() * $baseBlockSize, $matrix->getBlockCount() * $baseBlockSize);
|
||||||
|
|
||||||
|
if (!$baseImage) {
|
||||||
|
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var int $foregroundColor */
|
||||||
|
$foregroundColor = imagecolorallocatealpha(
|
||||||
|
$baseImage,
|
||||||
|
$qrCode->getForegroundColor()->getRed(),
|
||||||
|
$qrCode->getForegroundColor()->getGreen(),
|
||||||
|
$qrCode->getForegroundColor()->getBlue(),
|
||||||
|
$qrCode->getForegroundColor()->getAlpha()
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @var int $transparentColor */
|
||||||
|
$transparentColor = imagecolorallocatealpha($baseImage, 255, 255, 255, 127);
|
||||||
|
|
||||||
|
imagefill($baseImage, 0, 0, $transparentColor);
|
||||||
|
|
||||||
|
for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) {
|
||||||
|
for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) {
|
||||||
|
if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) {
|
||||||
|
imagefilledrectangle(
|
||||||
|
$baseImage,
|
||||||
|
$columnIndex * $baseBlockSize,
|
||||||
|
$rowIndex * $baseBlockSize,
|
||||||
|
($columnIndex + 1) * $baseBlockSize - 1,
|
||||||
|
($rowIndex + 1) * $baseBlockSize - 1,
|
||||||
|
$foregroundColor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetWidth = $matrix->getOuterSize();
|
||||||
|
$targetHeight = $matrix->getOuterSize();
|
||||||
|
|
||||||
|
if ($label instanceof LabelInterface) {
|
||||||
|
$labelImageData = LabelImageData::createForLabel($label);
|
||||||
|
$targetHeight += $labelImageData->getHeight() + $label->getMargin()->getTop() + $label->getMargin()->getBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||||
|
|
||||||
|
if (!$targetImage) {
|
||||||
|
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var int $backgroundColor */
|
||||||
|
$backgroundColor = imagecolorallocatealpha(
|
||||||
|
$targetImage,
|
||||||
|
$qrCode->getBackgroundColor()->getRed(),
|
||||||
|
$qrCode->getBackgroundColor()->getGreen(),
|
||||||
|
$qrCode->getBackgroundColor()->getBlue(),
|
||||||
|
$qrCode->getBackgroundColor()->getAlpha()
|
||||||
|
);
|
||||||
|
|
||||||
|
imagefill($targetImage, 0, 0, $backgroundColor);
|
||||||
|
|
||||||
|
imagecopyresampled(
|
||||||
|
$targetImage,
|
||||||
|
$baseImage,
|
||||||
|
$matrix->getMarginLeft(),
|
||||||
|
$matrix->getMarginLeft(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$matrix->getInnerSize(),
|
||||||
|
$matrix->getInnerSize(),
|
||||||
|
imagesx($baseImage),
|
||||||
|
imagesy($baseImage)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($qrCode->getBackgroundColor()->getAlpha() > 0) {
|
||||||
|
imagesavealpha($targetImage, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = new GdResult($matrix, $targetImage);
|
||||||
|
|
||||||
|
if ($logo instanceof LogoInterface) {
|
||||||
|
$result = $this->addLogo($logo, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($label instanceof LabelInterface) {
|
||||||
|
$result = $this->addLabel($label, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addLogo(LogoInterface $logo, GdResult $result): GdResult
|
||||||
|
{
|
||||||
|
$logoImageData = LogoImageData::createForLogo($logo);
|
||||||
|
|
||||||
|
if ('image/svg+xml' === $logoImageData->getMimeType()) {
|
||||||
|
throw new \Exception('PNG Writer does not support SVG logo');
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetImage = $result->getImage();
|
||||||
|
$matrix = $result->getMatrix();
|
||||||
|
|
||||||
|
if ($logoImageData->getPunchoutBackground()) {
|
||||||
|
/** @var int $transparent */
|
||||||
|
$transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127);
|
||||||
|
imagealphablending($targetImage, false);
|
||||||
|
$xOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2);
|
||||||
|
$yOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2);
|
||||||
|
for ($xOffset = $xOffsetStart; $xOffset < $xOffsetStart + $logoImageData->getWidth(); ++$xOffset) {
|
||||||
|
for ($yOffset = $yOffsetStart; $yOffset < $yOffsetStart + $logoImageData->getHeight(); ++$yOffset) {
|
||||||
|
imagesetpixel($targetImage, $xOffset, $yOffset, $transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagecopyresampled(
|
||||||
|
$targetImage,
|
||||||
|
$logoImageData->getImage(),
|
||||||
|
intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2),
|
||||||
|
intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$logoImageData->getWidth(),
|
||||||
|
$logoImageData->getHeight(),
|
||||||
|
imagesx($logoImageData->getImage()),
|
||||||
|
imagesy($logoImageData->getImage())
|
||||||
|
);
|
||||||
|
|
||||||
|
return new GdResult($matrix, $targetImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addLabel(LabelInterface $label, GdResult $result): GdResult
|
||||||
|
{
|
||||||
|
$targetImage = $result->getImage();
|
||||||
|
|
||||||
|
$labelImageData = LabelImageData::createForLabel($label);
|
||||||
|
|
||||||
|
/** @var int $textColor */
|
||||||
|
$textColor = imagecolorallocatealpha(
|
||||||
|
$targetImage,
|
||||||
|
$label->getTextColor()->getRed(),
|
||||||
|
$label->getTextColor()->getGreen(),
|
||||||
|
$label->getTextColor()->getBlue(),
|
||||||
|
$label->getTextColor()->getAlpha()
|
||||||
|
);
|
||||||
|
|
||||||
|
$x = intval(imagesx($targetImage) / 2 - $labelImageData->getWidth() / 2);
|
||||||
|
$y = imagesy($targetImage) - $label->getMargin()->getBottom();
|
||||||
|
|
||||||
|
if ($label->getAlignment() instanceof LabelAlignmentLeft) {
|
||||||
|
$x = $label->getMargin()->getLeft();
|
||||||
|
} elseif ($label->getAlignment() instanceof LabelAlignmentRight) {
|
||||||
|
$x = imagesx($targetImage) - $labelImageData->getWidth() - $label->getMargin()->getRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
imagettftext($targetImage, $label->getFont()->getSize(), 0, $x, $y, $textColor, $label->getFont()->getPath(), $label->getText());
|
||||||
|
|
||||||
|
return new GdResult($result->getMatrix(), $targetImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateResult(ResultInterface $result, string $expectedData): void
|
||||||
|
{
|
||||||
|
$string = $result->getString();
|
||||||
|
|
||||||
|
if (!class_exists(QrReader::class)) {
|
||||||
|
throw ValidationException::createForMissingPackage('khanamiryan/qrcode-detector-decoder');
|
||||||
|
}
|
||||||
|
|
||||||
|
$reader = new QrReader($string, QrReader::SOURCE_TYPE_BLOB);
|
||||||
|
if ($reader->text() !== $expectedData) {
|
||||||
|
throw ValidationException::createForInvalidData($expectedData, strval($reader->text()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
|
|||||||
|
|
||||||
final class BinaryWriter implements WriterInterface
|
final class BinaryWriter implements WriterInterface
|
||||||
{
|
{
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
$matrixFactory = new MatrixFactory();
|
$matrixFactory = new MatrixFactory();
|
||||||
$matrix = $matrixFactory->create($qrCode);
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
|
23
vendor/endroid/qr-code/src/Writer/ConsoleWriter.php
vendored
Normal file
23
vendor/endroid/qr-code/src/Writer/ConsoleWriter.php
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Bacon\MatrixFactory;
|
||||||
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
|
use Endroid\QrCode\Writer\Result\ConsoleResult;
|
||||||
|
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||||
|
|
||||||
|
final class ConsoleWriter implements WriterInterface
|
||||||
|
{
|
||||||
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, $options = []): ResultInterface
|
||||||
|
{
|
||||||
|
$matrixFactory = new MatrixFactory();
|
||||||
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
|
|
||||||
|
return new ConsoleResult($matrix, $qrCode->getForegroundColor(), $qrCode->getBackgroundColor());
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer;
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Bacon\MatrixFactory;
|
||||||
use Endroid\QrCode\Label\LabelInterface;
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
use Endroid\QrCode\Logo\LogoInterface;
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
use Endroid\QrCode\QrCodeInterface;
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
@ -12,9 +13,12 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
|
|||||||
|
|
||||||
final class DebugWriter implements WriterInterface, ValidatingWriterInterface
|
final class DebugWriter implements WriterInterface, ValidatingWriterInterface
|
||||||
{
|
{
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
return new DebugResult($qrCode, $logo, $label, $options);
|
$matrixFactory = new MatrixFactory();
|
||||||
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
|
|
||||||
|
return new DebugResult($matrix, $qrCode, $logo, $label, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateResult(ResultInterface $result, string $expectedData): void
|
public function validateResult(ResultInterface $result, string $expectedData): void
|
||||||
|
@ -15,7 +15,7 @@ final class EpsWriter implements WriterInterface
|
|||||||
{
|
{
|
||||||
public const DECIMAL_PRECISION = 10;
|
public const DECIMAL_PRECISION = 10;
|
||||||
|
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
$matrixFactory = new MatrixFactory();
|
$matrixFactory = new MatrixFactory();
|
||||||
$matrix = $matrixFactory->create($qrCode);
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
@ -39,6 +39,6 @@ final class EpsWriter implements WriterInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EpsResult($lines);
|
return new EpsResult($matrix, $lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
vendor/endroid/qr-code/src/Writer/GifWriter.php
vendored
Normal file
23
vendor/endroid/qr-code/src/Writer/GifWriter.php
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
|
use Endroid\QrCode\Writer\Result\GdResult;
|
||||||
|
use Endroid\QrCode\Writer\Result\GifResult;
|
||||||
|
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||||
|
|
||||||
|
final class GifWriter extends AbstractGdWriter
|
||||||
|
{
|
||||||
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
|
{
|
||||||
|
/** @var GdResult $gdResult */
|
||||||
|
$gdResult = parent::write($qrCode, $logo, $label, $options);
|
||||||
|
|
||||||
|
return new GifResult($gdResult->getMatrix(), $gdResult->getImage());
|
||||||
|
}
|
||||||
|
}
|
10
vendor/endroid/qr-code/src/Writer/PdfWriter.php
vendored
10
vendor/endroid/qr-code/src/Writer/PdfWriter.php
vendored
@ -17,8 +17,9 @@ final class PdfWriter implements WriterInterface
|
|||||||
public const WRITER_OPTION_PDF = 'fpdf';
|
public const WRITER_OPTION_PDF = 'fpdf';
|
||||||
public const WRITER_OPTION_X = 'x';
|
public const WRITER_OPTION_X = 'x';
|
||||||
public const WRITER_OPTION_Y = 'y';
|
public const WRITER_OPTION_Y = 'y';
|
||||||
|
public const WRITER_OPTION_LINK = 'link';
|
||||||
|
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
$matrixFactory = new MatrixFactory();
|
$matrixFactory = new MatrixFactory();
|
||||||
$matrix = $matrixFactory->create($qrCode);
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
@ -99,7 +100,12 @@ final class PdfWriter implements WriterInterface
|
|||||||
$fpdf->Cell($matrix->getOuterSize(), 0, $label->getText(), 0, 0, 'C');
|
$fpdf->Cell($matrix->getOuterSize(), 0, $label->getText(), 0, 0, 'C');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PdfResult($fpdf);
|
if (isset($options[self::WRITER_OPTION_LINK])) {
|
||||||
|
$link = $options[self::WRITER_OPTION_LINK];
|
||||||
|
$fpdf->Link($x, $y, $x + $matrix->getOuterSize(), $y + $matrix->getOuterSize(), $link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PdfResult($matrix, $fpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addLogo(LogoInterface $logo, \FPDF $fpdf, float $x, float $y, float $size): void
|
private function addLogo(LogoInterface $logo, \FPDF $fpdf, float $x, float $y, float $size): void
|
||||||
|
218
vendor/endroid/qr-code/src/Writer/PngWriter.php
vendored
218
vendor/endroid/qr-code/src/Writer/PngWriter.php
vendored
@ -4,224 +4,26 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer;
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
use Endroid\QrCode\Bacon\MatrixFactory;
|
|
||||||
use Endroid\QrCode\ImageData\LabelImageData;
|
|
||||||
use Endroid\QrCode\ImageData\LogoImageData;
|
|
||||||
use Endroid\QrCode\Label\Alignment\LabelAlignmentLeft;
|
|
||||||
use Endroid\QrCode\Label\Alignment\LabelAlignmentRight;
|
|
||||||
use Endroid\QrCode\Label\LabelInterface;
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
use Endroid\QrCode\Logo\LogoInterface;
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
use Endroid\QrCode\QrCodeInterface;
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeNone;
|
use Endroid\QrCode\Writer\Result\GdResult;
|
||||||
use Endroid\QrCode\Writer\Result\PngResult;
|
use Endroid\QrCode\Writer\Result\PngResult;
|
||||||
use Endroid\QrCode\Writer\Result\ResultInterface;
|
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||||
use Zxing\QrReader;
|
|
||||||
|
|
||||||
final class PngWriter implements WriterInterface, ValidatingWriterInterface
|
final class PngWriter extends AbstractGdWriter
|
||||||
{
|
{
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public const WRITER_OPTION_COMPRESSION_LEVEL = 'compression_level';
|
||||||
|
|
||||||
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
if (!extension_loaded('gd')) {
|
if (!isset($options[self::WRITER_OPTION_COMPRESSION_LEVEL])) {
|
||||||
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
$options[self::WRITER_OPTION_COMPRESSION_LEVEL] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$matrixFactory = new MatrixFactory();
|
/** @var GdResult $gdResult */
|
||||||
$matrix = $matrixFactory->create($qrCode);
|
$gdResult = parent::write($qrCode, $logo, $label, $options);
|
||||||
|
|
||||||
$baseBlockSize = $qrCode->getRoundBlockSizeMode() instanceof RoundBlockSizeModeNone ? 10 : intval($matrix->getBlockSize());
|
return new PngResult($gdResult->getMatrix(), $gdResult->getImage(), $options[self::WRITER_OPTION_COMPRESSION_LEVEL]);
|
||||||
$baseImage = imagecreatetruecolor($matrix->getBlockCount() * $baseBlockSize, $matrix->getBlockCount() * $baseBlockSize);
|
|
||||||
|
|
||||||
if (!$baseImage) {
|
|
||||||
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var int $foregroundColor */
|
|
||||||
$foregroundColor = imagecolorallocatealpha(
|
|
||||||
$baseImage,
|
|
||||||
$qrCode->getForegroundColor()->getRed(),
|
|
||||||
$qrCode->getForegroundColor()->getGreen(),
|
|
||||||
$qrCode->getForegroundColor()->getBlue(),
|
|
||||||
$qrCode->getForegroundColor()->getAlpha()
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @var int $transparentColor */
|
|
||||||
$transparentColor = imagecolorallocatealpha($baseImage, 255, 255, 255, 127);
|
|
||||||
|
|
||||||
imagefill($baseImage, 0, 0, $transparentColor);
|
|
||||||
|
|
||||||
for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) {
|
|
||||||
for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) {
|
|
||||||
if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) {
|
|
||||||
imagefilledrectangle(
|
|
||||||
$baseImage,
|
|
||||||
$columnIndex * $baseBlockSize,
|
|
||||||
$rowIndex * $baseBlockSize,
|
|
||||||
($columnIndex + 1) * $baseBlockSize - 1,
|
|
||||||
($rowIndex + 1) * $baseBlockSize - 1,
|
|
||||||
$foregroundColor
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$targetWidth = $matrix->getOuterSize();
|
|
||||||
$targetHeight = $matrix->getOuterSize();
|
|
||||||
|
|
||||||
if ($label instanceof LabelInterface) {
|
|
||||||
$labelImageData = LabelImageData::createForLabel($label);
|
|
||||||
$targetHeight += $labelImageData->getHeight() + $label->getMargin()->getTop() + $label->getMargin()->getBottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
|
|
||||||
|
|
||||||
if (!$targetImage) {
|
|
||||||
throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var int $backgroundColor */
|
|
||||||
$backgroundColor = imagecolorallocatealpha(
|
|
||||||
$targetImage,
|
|
||||||
$qrCode->getBackgroundColor()->getRed(),
|
|
||||||
$qrCode->getBackgroundColor()->getGreen(),
|
|
||||||
$qrCode->getBackgroundColor()->getBlue(),
|
|
||||||
$qrCode->getBackgroundColor()->getAlpha()
|
|
||||||
);
|
|
||||||
|
|
||||||
imagefill($targetImage, 0, 0, $backgroundColor);
|
|
||||||
|
|
||||||
imagecopyresampled(
|
|
||||||
$targetImage,
|
|
||||||
$baseImage,
|
|
||||||
$matrix->getMarginLeft(),
|
|
||||||
$matrix->getMarginLeft(),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
$matrix->getInnerSize(),
|
|
||||||
$matrix->getInnerSize(),
|
|
||||||
imagesx($baseImage),
|
|
||||||
imagesy($baseImage)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 80000) {
|
|
||||||
imagedestroy($baseImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($qrCode->getBackgroundColor()->getAlpha() > 0) {
|
|
||||||
imagesavealpha($targetImage, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = new PngResult($targetImage);
|
|
||||||
|
|
||||||
if ($logo instanceof LogoInterface) {
|
|
||||||
$result = $this->addLogo($logo, $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($label instanceof LabelInterface) {
|
|
||||||
$result = $this->addLabel($label, $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addLogo(LogoInterface $logo, PngResult $result): PngResult
|
|
||||||
{
|
|
||||||
$logoImageData = LogoImageData::createForLogo($logo);
|
|
||||||
|
|
||||||
if ('image/svg+xml' === $logoImageData->getMimeType()) {
|
|
||||||
throw new \Exception('PNG Writer does not support SVG logo');
|
|
||||||
}
|
|
||||||
|
|
||||||
$targetImage = $result->getImage();
|
|
||||||
|
|
||||||
if ($logoImageData->getPunchoutBackground()) {
|
|
||||||
/** @var int $transparent */
|
|
||||||
$transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127);
|
|
||||||
imagealphablending($targetImage, false);
|
|
||||||
for (
|
|
||||||
$x_offset = intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2);
|
|
||||||
$x_offset < intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2) + $logoImageData->getWidth();
|
|
||||||
++$x_offset
|
|
||||||
) {
|
|
||||||
for (
|
|
||||||
$y_offset = intval(imagesy($targetImage) / 2 - $logoImageData->getHeight() / 2);
|
|
||||||
$y_offset < intval(imagesy($targetImage) / 2 - $logoImageData->getHeight() / 2) + $logoImageData->getHeight();
|
|
||||||
++$y_offset
|
|
||||||
) {
|
|
||||||
imagesetpixel(
|
|
||||||
$targetImage,
|
|
||||||
$x_offset,
|
|
||||||
$y_offset,
|
|
||||||
$transparent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
imagecopyresampled(
|
|
||||||
$targetImage,
|
|
||||||
$logoImageData->getImage(),
|
|
||||||
intval(imagesx($targetImage) / 2 - $logoImageData->getWidth() / 2),
|
|
||||||
intval(imagesx($targetImage) / 2 - $logoImageData->getHeight() / 2),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
$logoImageData->getWidth(),
|
|
||||||
$logoImageData->getHeight(),
|
|
||||||
imagesx($logoImageData->getImage()),
|
|
||||||
imagesy($logoImageData->getImage())
|
|
||||||
);
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 80000) {
|
|
||||||
imagedestroy($logoImageData->getImage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return new PngResult($targetImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addLabel(LabelInterface $label, PngResult $result): PngResult
|
|
||||||
{
|
|
||||||
$targetImage = $result->getImage();
|
|
||||||
|
|
||||||
$labelImageData = LabelImageData::createForLabel($label);
|
|
||||||
|
|
||||||
/** @var int $textColor */
|
|
||||||
$textColor = imagecolorallocatealpha(
|
|
||||||
$targetImage,
|
|
||||||
$label->getTextColor()->getRed(),
|
|
||||||
$label->getTextColor()->getGreen(),
|
|
||||||
$label->getTextColor()->getBlue(),
|
|
||||||
$label->getTextColor()->getAlpha()
|
|
||||||
);
|
|
||||||
|
|
||||||
$x = intval(imagesx($targetImage) / 2 - $labelImageData->getWidth() / 2);
|
|
||||||
$y = imagesy($targetImage) - $label->getMargin()->getBottom();
|
|
||||||
|
|
||||||
if ($label->getAlignment() instanceof LabelAlignmentLeft) {
|
|
||||||
$x = $label->getMargin()->getLeft();
|
|
||||||
} elseif ($label->getAlignment() instanceof LabelAlignmentRight) {
|
|
||||||
$x = imagesx($targetImage) - $labelImageData->getWidth() - $label->getMargin()->getRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
imagettftext($targetImage, $label->getFont()->getSize(), 0, $x, $y, $textColor, $label->getFont()->getPath(), $label->getText());
|
|
||||||
|
|
||||||
return new PngResult($targetImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateResult(ResultInterface $result, string $expectedData): void
|
|
||||||
{
|
|
||||||
$string = $result->getString();
|
|
||||||
|
|
||||||
if (!class_exists(QrReader::class)) {
|
|
||||||
throw new \Exception('Please install khanamiryan/qrcode-detector-decoder or disable image validation');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
|
||||||
throw new \Exception('The validator is not compatible with PHP 8 yet, see https://github.com/khanamiryan/php-qrcode-detector-decoder/pull/103');
|
|
||||||
}
|
|
||||||
|
|
||||||
$reader = new QrReader($string, QrReader::SOURCE_TYPE_BLOB);
|
|
||||||
if ($reader->text() !== $expectedData) {
|
|
||||||
throw new \Exception('Built-in validation reader read "'.$reader->text().'" instead of "'.$expectedData.'".
|
|
||||||
Adjust your parameters to increase readability or disable built-in validation.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
abstract class AbstractResult implements ResultInterface
|
abstract class AbstractResult implements ResultInterface
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
private MatrixInterface $matrix
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMatrix(): MatrixInterface
|
||||||
|
{
|
||||||
|
return $this->matrix;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDataUri(): string
|
public function getDataUri(): string
|
||||||
{
|
{
|
||||||
return 'data:'.$this->getMimeType().';base64,'.base64_encode($this->getString());
|
return 'data:'.$this->getMimeType().';base64,'.base64_encode($this->getString());
|
||||||
|
@ -8,19 +8,19 @@ use Endroid\QrCode\Matrix\MatrixInterface;
|
|||||||
|
|
||||||
final class BinaryResult extends AbstractResult
|
final class BinaryResult extends AbstractResult
|
||||||
{
|
{
|
||||||
private MatrixInterface $matrix;
|
|
||||||
|
|
||||||
public function __construct(MatrixInterface $matrix)
|
public function __construct(MatrixInterface $matrix)
|
||||||
{
|
{
|
||||||
$this->matrix = $matrix;
|
parent::__construct($matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getString(): string
|
public function getString(): string
|
||||||
{
|
{
|
||||||
|
$matrix = $this->getMatrix();
|
||||||
|
|
||||||
$binaryString = '';
|
$binaryString = '';
|
||||||
for ($rowIndex = 0; $rowIndex < $this->matrix->getBlockCount(); ++$rowIndex) {
|
for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) {
|
||||||
for ($columnIndex = 0; $columnIndex < $this->matrix->getBlockCount(); ++$columnIndex) {
|
for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) {
|
||||||
$binaryString .= $this->matrix->getBlockValue($rowIndex, $columnIndex);
|
$binaryString .= $matrix->getBlockValue($rowIndex, $columnIndex);
|
||||||
}
|
}
|
||||||
$binaryString .= "\n";
|
$binaryString .= "\n";
|
||||||
}
|
}
|
||||||
|
69
vendor/endroid/qr-code/src/Writer/Result/ConsoleResult.php
vendored
Normal file
69
vendor/endroid/qr-code/src/Writer/Result/ConsoleResult.php
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Color\ColorInterface;
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
|
class ConsoleResult extends AbstractResult
|
||||||
|
{
|
||||||
|
private const TWO_BLOCKS = [
|
||||||
|
0 => ' ',
|
||||||
|
1 => "\xe2\x96\x80",
|
||||||
|
2 => "\xe2\x96\x84",
|
||||||
|
3 => "\xe2\x96\x88",
|
||||||
|
];
|
||||||
|
|
||||||
|
private string $colorEscapeCode;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
MatrixInterface $matrix,
|
||||||
|
ColorInterface $foreground,
|
||||||
|
ColorInterface $background
|
||||||
|
) {
|
||||||
|
parent::__construct($matrix);
|
||||||
|
|
||||||
|
$this->colorEscapeCode = sprintf(
|
||||||
|
"\e[38;2;%d;%d;%dm\e[48;2;%d;%d;%dm",
|
||||||
|
$foreground->getRed(),
|
||||||
|
$foreground->getGreen(),
|
||||||
|
$foreground->getBlue(),
|
||||||
|
$background->getRed(),
|
||||||
|
$background->getGreen(),
|
||||||
|
$background->getBlue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMimeType(): string
|
||||||
|
{
|
||||||
|
return 'text/plain';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getString(): string
|
||||||
|
{
|
||||||
|
$matrix = $this->getMatrix();
|
||||||
|
|
||||||
|
$side = $matrix->getBlockCount();
|
||||||
|
$marginLeft = $this->colorEscapeCode.self::TWO_BLOCKS[0].self::TWO_BLOCKS[0];
|
||||||
|
$marginRight = self::TWO_BLOCKS[0].self::TWO_BLOCKS[0]."\e[0m".PHP_EOL;
|
||||||
|
$marginVertical = $marginLeft.str_repeat(self::TWO_BLOCKS[0], $side).$marginRight;
|
||||||
|
|
||||||
|
$qrCodeString = $marginVertical;
|
||||||
|
for ($rowIndex = 0; $rowIndex < $side; $rowIndex += 2) {
|
||||||
|
$qrCodeString .= $marginLeft;
|
||||||
|
for ($columnIndex = 0; $columnIndex < $side; ++$columnIndex) {
|
||||||
|
$combined = $matrix->getBlockValue($rowIndex, $columnIndex);
|
||||||
|
if ($rowIndex + 1 < $side) {
|
||||||
|
$combined |= $matrix->getBlockValue($rowIndex + 1, $columnIndex) << 1;
|
||||||
|
}
|
||||||
|
$qrCodeString .= self::TWO_BLOCKS[$combined];
|
||||||
|
}
|
||||||
|
$qrCodeString .= $marginRight;
|
||||||
|
}
|
||||||
|
$qrCodeString .= $marginVertical;
|
||||||
|
|
||||||
|
return $qrCodeString;
|
||||||
|
}
|
||||||
|
}
|
@ -6,26 +6,22 @@ namespace Endroid\QrCode\Writer\Result;
|
|||||||
|
|
||||||
use Endroid\QrCode\Label\LabelInterface;
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
use Endroid\QrCode\Logo\LogoInterface;
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
use Endroid\QrCode\QrCodeInterface;
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
|
|
||||||
final class DebugResult extends AbstractResult
|
final class DebugResult extends AbstractResult
|
||||||
{
|
{
|
||||||
private QrCodeInterface $qrCode;
|
|
||||||
private ?LogoInterface $logo;
|
|
||||||
private ?LabelInterface $label;
|
|
||||||
|
|
||||||
/** @var array<mixed> */
|
|
||||||
private array $options;
|
|
||||||
|
|
||||||
private bool $validateResult = false;
|
private bool $validateResult = false;
|
||||||
|
|
||||||
/** @param array<mixed> $options */
|
public function __construct(
|
||||||
public function __construct(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = [])
|
MatrixInterface $matrix,
|
||||||
{
|
private QrCodeInterface $qrCode,
|
||||||
$this->qrCode = $qrCode;
|
private LogoInterface|null $logo = null,
|
||||||
$this->logo = $logo;
|
private LabelInterface|null $label = null,
|
||||||
$this->label = $label;
|
/** @var array<string, mixed> $options */
|
||||||
$this->options = $options;
|
private array $options = []
|
||||||
|
) {
|
||||||
|
parent::__construct($matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValidateResult(bool $validateResult): void
|
public function setValidateResult(bool $validateResult): void
|
||||||
|
@ -4,15 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
final class EpsResult extends AbstractResult
|
final class EpsResult extends AbstractResult
|
||||||
{
|
{
|
||||||
/** @var array<string> */
|
public function __construct(
|
||||||
private array $lines;
|
MatrixInterface $matrix,
|
||||||
|
/** @var array<string> $lines */
|
||||||
/** @param array<string> $lines */
|
private array $lines
|
||||||
public function __construct(array $lines)
|
) {
|
||||||
{
|
parent::__construct($matrix);
|
||||||
$this->lines = $lines;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getString(): string
|
public function getString(): string
|
||||||
|
32
vendor/endroid/qr-code/src/Writer/Result/GdResult.php
vendored
Normal file
32
vendor/endroid/qr-code/src/Writer/Result/GdResult.php
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
|
class GdResult extends AbstractResult
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
MatrixInterface $matrix,
|
||||||
|
protected \GdImage $image
|
||||||
|
) {
|
||||||
|
parent::__construct($matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getImage(): \GdImage
|
||||||
|
{
|
||||||
|
return $this->image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getString(): string
|
||||||
|
{
|
||||||
|
throw new \Exception('You can only use this method in a concrete implementation');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMimeType(): string
|
||||||
|
{
|
||||||
|
throw new \Exception('You can only use this method in a concrete implementation');
|
||||||
|
}
|
||||||
|
}
|
21
vendor/endroid/qr-code/src/Writer/Result/GifResult.php
vendored
Normal file
21
vendor/endroid/qr-code/src/Writer/Result/GifResult.php
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
final class GifResult extends GdResult
|
||||||
|
{
|
||||||
|
public function getString(): string
|
||||||
|
{
|
||||||
|
ob_start();
|
||||||
|
imagegif($this->image);
|
||||||
|
|
||||||
|
return strval(ob_get_clean());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMimeType(): string
|
||||||
|
{
|
||||||
|
return 'image/gif';
|
||||||
|
}
|
||||||
|
}
|
@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
final class PdfResult extends AbstractResult
|
final class PdfResult extends AbstractResult
|
||||||
{
|
{
|
||||||
private \FPDF $fpdf;
|
public function __construct(
|
||||||
|
MatrixInterface $matrix,
|
||||||
public function __construct(\FPDF $fpdf)
|
private \FPDF $fpdf
|
||||||
{
|
) {
|
||||||
$this->fpdf = $fpdf;
|
parent::__construct($matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPdf(): \FPDF
|
public function getPdf(): \FPDF
|
||||||
|
@ -4,27 +4,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
final class PngResult extends AbstractResult
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
|
final class PngResult extends GdResult
|
||||||
{
|
{
|
||||||
/** @var mixed */
|
private int $quality;
|
||||||
private $image;
|
|
||||||
|
|
||||||
/** @param mixed $image */
|
public function __construct(MatrixInterface $matrix, \GdImage $image, int $quality = -1)
|
||||||
public function __construct($image)
|
|
||||||
{
|
{
|
||||||
$this->image = $image;
|
parent::__construct($matrix, $image);
|
||||||
}
|
$this->quality = $quality;
|
||||||
|
|
||||||
/** @return mixed */
|
|
||||||
public function getImage()
|
|
||||||
{
|
|
||||||
return $this->image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getString(): string
|
public function getString(): string
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
imagepng($this->image);
|
imagepng($this->image, quality: $this->quality);
|
||||||
|
|
||||||
return strval(ob_get_clean());
|
return strval(ob_get_clean());
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
interface ResultInterface
|
interface ResultInterface
|
||||||
{
|
{
|
||||||
|
public function getMatrix(): MatrixInterface;
|
||||||
|
|
||||||
public function getString(): string;
|
public function getString(): string;
|
||||||
|
|
||||||
public function getDataUri(): string;
|
public function getDataUri(): string;
|
||||||
|
@ -4,15 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Endroid\QrCode\Writer\Result;
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
final class SvgResult extends AbstractResult
|
final class SvgResult extends AbstractResult
|
||||||
{
|
{
|
||||||
private \SimpleXMLElement $xml;
|
public function __construct(
|
||||||
private bool $excludeXmlDeclaration;
|
MatrixInterface $matrix,
|
||||||
|
private \SimpleXMLElement $xml,
|
||||||
public function __construct(\SimpleXMLElement $xml, bool $excludeXmlDeclaration = false)
|
private bool $excludeXmlDeclaration = false
|
||||||
{
|
) {
|
||||||
$this->xml = $xml;
|
parent::__construct($matrix);
|
||||||
$this->excludeXmlDeclaration = $excludeXmlDeclaration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getXml(): \SimpleXMLElement
|
public function getXml(): \SimpleXMLElement
|
||||||
|
35
vendor/endroid/qr-code/src/Writer/Result/WebPResult.php
vendored
Normal file
35
vendor/endroid/qr-code/src/Writer/Result/WebPResult.php
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer\Result;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Matrix\MatrixInterface;
|
||||||
|
|
||||||
|
final class WebPResult extends GdResult
|
||||||
|
{
|
||||||
|
private int $quality;
|
||||||
|
|
||||||
|
public function __construct(MatrixInterface $matrix, \GdImage $image, int $quality = -1)
|
||||||
|
{
|
||||||
|
parent::__construct($matrix, $image);
|
||||||
|
$this->quality = $quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getString(): string
|
||||||
|
{
|
||||||
|
if (!function_exists('imagewebp')) {
|
||||||
|
throw new \Exception('WebP support is not available in your GD installation');
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
imagewebp($this->image, quality: $this->quality);
|
||||||
|
|
||||||
|
return strval(ob_get_clean());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMimeType(): string
|
||||||
|
{
|
||||||
|
return 'image/webp';
|
||||||
|
}
|
||||||
|
}
|
17
vendor/endroid/qr-code/src/Writer/SvgWriter.php
vendored
17
vendor/endroid/qr-code/src/Writer/SvgWriter.php
vendored
@ -17,9 +17,10 @@ final class SvgWriter implements WriterInterface
|
|||||||
public const DECIMAL_PRECISION = 10;
|
public const DECIMAL_PRECISION = 10;
|
||||||
public const WRITER_OPTION_BLOCK_ID = 'block_id';
|
public const WRITER_OPTION_BLOCK_ID = 'block_id';
|
||||||
public const WRITER_OPTION_EXCLUDE_XML_DECLARATION = 'exclude_xml_declaration';
|
public const WRITER_OPTION_EXCLUDE_XML_DECLARATION = 'exclude_xml_declaration';
|
||||||
|
public const WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT = 'exclude_svg_width_and_height';
|
||||||
public const WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';
|
public const WRITER_OPTION_FORCE_XLINK_HREF = 'force_xlink_href';
|
||||||
|
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
{
|
{
|
||||||
if (!isset($options[self::WRITER_OPTION_BLOCK_ID])) {
|
if (!isset($options[self::WRITER_OPTION_BLOCK_ID])) {
|
||||||
$options[self::WRITER_OPTION_BLOCK_ID] = 'block';
|
$options[self::WRITER_OPTION_BLOCK_ID] = 'block';
|
||||||
@ -29,13 +30,19 @@ final class SvgWriter implements WriterInterface
|
|||||||
$options[self::WRITER_OPTION_EXCLUDE_XML_DECLARATION] = false;
|
$options[self::WRITER_OPTION_EXCLUDE_XML_DECLARATION] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($options[self::WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT])) {
|
||||||
|
$options[self::WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT] = false;
|
||||||
|
}
|
||||||
|
|
||||||
$matrixFactory = new MatrixFactory();
|
$matrixFactory = new MatrixFactory();
|
||||||
$matrix = $matrixFactory->create($qrCode);
|
$matrix = $matrixFactory->create($qrCode);
|
||||||
|
|
||||||
$xml = new \SimpleXMLElement('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>');
|
$xml = new \SimpleXMLElement('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>');
|
||||||
$xml->addAttribute('version', '1.1');
|
$xml->addAttribute('version', '1.1');
|
||||||
$xml->addAttribute('width', $matrix->getOuterSize().'px');
|
if (!$options[self::WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT]) {
|
||||||
$xml->addAttribute('height', $matrix->getOuterSize().'px');
|
$xml->addAttribute('width', $matrix->getOuterSize().'px');
|
||||||
|
$xml->addAttribute('height', $matrix->getOuterSize().'px');
|
||||||
|
}
|
||||||
$xml->addAttribute('viewBox', '0 0 '.$matrix->getOuterSize().' '.$matrix->getOuterSize());
|
$xml->addAttribute('viewBox', '0 0 '.$matrix->getOuterSize().' '.$matrix->getOuterSize());
|
||||||
$xml->addChild('defs');
|
$xml->addChild('defs');
|
||||||
|
|
||||||
@ -65,7 +72,7 @@ final class SvgWriter implements WriterInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = new SvgResult($xml, boolval($options[self::WRITER_OPTION_EXCLUDE_XML_DECLARATION]));
|
$result = new SvgResult($matrix, $xml, boolval($options[self::WRITER_OPTION_EXCLUDE_XML_DECLARATION]));
|
||||||
|
|
||||||
if ($logo instanceof LogoInterface) {
|
if ($logo instanceof LogoInterface) {
|
||||||
$this->addLogo($logo, $result, $options);
|
$this->addLogo($logo, $result, $options);
|
||||||
@ -74,7 +81,7 @@ final class SvgWriter implements WriterInterface
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param array<mixed> $options */
|
/** @param array<string, mixed> $options */
|
||||||
private function addLogo(LogoInterface $logo, SvgResult $result, array $options): void
|
private function addLogo(LogoInterface $logo, SvgResult $result, array $options): void
|
||||||
{
|
{
|
||||||
$logoImageData = LogoImageData::createForLogo($logo);
|
$logoImageData = LogoImageData::createForLogo($logo);
|
||||||
|
29
vendor/endroid/qr-code/src/Writer/WebPWriter.php
vendored
Normal file
29
vendor/endroid/qr-code/src/Writer/WebPWriter.php
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Endroid\QrCode\Writer;
|
||||||
|
|
||||||
|
use Endroid\QrCode\Label\LabelInterface;
|
||||||
|
use Endroid\QrCode\Logo\LogoInterface;
|
||||||
|
use Endroid\QrCode\QrCodeInterface;
|
||||||
|
use Endroid\QrCode\Writer\Result\GdResult;
|
||||||
|
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||||
|
use Endroid\QrCode\Writer\Result\WebPResult;
|
||||||
|
|
||||||
|
final class WebPWriter extends AbstractGdWriter
|
||||||
|
{
|
||||||
|
public const WRITER_OPTION_QUALITY = 'quality';
|
||||||
|
|
||||||
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface
|
||||||
|
{
|
||||||
|
if (!isset($options[self::WRITER_OPTION_QUALITY])) {
|
||||||
|
$options[self::WRITER_OPTION_QUALITY] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var GdResult $gdResult */
|
||||||
|
$gdResult = parent::write($qrCode, $logo, $label, $options);
|
||||||
|
|
||||||
|
return new WebPResult($gdResult->getMatrix(), $gdResult->getImage(), $options[self::WRITER_OPTION_QUALITY]);
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,6 @@ use Endroid\QrCode\Writer\Result\ResultInterface;
|
|||||||
|
|
||||||
interface WriterInterface
|
interface WriterInterface
|
||||||
{
|
{
|
||||||
/** @param array<mixed> $options */
|
/** @param array<string, mixed> $options */
|
||||||
public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface;
|
public function write(QrCodeInterface $qrCode, LogoInterface|null $logo = null, LabelInterface|null $label = null, array $options = []): ResultInterface;
|
||||||
}
|
}
|
||||||
|
197
vendor/wikimedia/less.php/API.md
vendored
Normal file
197
vendor/wikimedia/less.php/API.md
vendored
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
Less.php API
|
||||||
|
========
|
||||||
|
|
||||||
|
## Basic use
|
||||||
|
|
||||||
|
#### Parse strings
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parse( '@color: #36c; .link { color: @color; } a { color: @color; }' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parse files
|
||||||
|
|
||||||
|
The `parseFile()` function takes two parameters:
|
||||||
|
|
||||||
|
* The absolute path to a `.less` file.
|
||||||
|
* The base URL for any relative image or CSS references in the `.less` file,
|
||||||
|
typically the same directory that contains the `.less` file or a public equivalent.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'https://example.org/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Handle invalid syntax
|
||||||
|
|
||||||
|
An exception will be thrown if the compiler encounters invalid LESS.
|
||||||
|
|
||||||
|
```php
|
||||||
|
try{
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'https://example.org/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Parse multiple inputs
|
||||||
|
|
||||||
|
Less.php can parse multiple input sources (e.g. files and/or strings) and generate a single CSS output.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$parser->parse( '@color: #36c; .link { color: @color; } a { color: @color; }' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Metadata
|
||||||
|
|
||||||
|
Less.php keeps track of which `.less` files have been parsed, i.e. the input
|
||||||
|
file(s) and any direct and indirect imports.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
$files = $parser->AllParsedFiles();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compress output
|
||||||
|
|
||||||
|
You can tell Less.php to remove comments and whitespace to generate minified CSS.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$options = [ 'compress' => true ];
|
||||||
|
$parser = new Less_Parser( $options );
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get variables
|
||||||
|
|
||||||
|
You can use the `getVariables()` method to get an all variables defined and
|
||||||
|
their value in an associative array. Note that the input must be compiled first
|
||||||
|
by calling `getCss()`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser;
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less');
|
||||||
|
$css = $parser->getCss();
|
||||||
|
$variables = $parser->getVariables();
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Set variables
|
||||||
|
|
||||||
|
Use the `ModifyVars()` method to inject additional variables, i.e. custom values
|
||||||
|
computed or accessed from your PHP code.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$parser->ModifyVars( [ 'font-size-base' => '16px' ] );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Import directories
|
||||||
|
|
||||||
|
By default, Less.php will look for imported files in the directory of the file passed to `parseFile()`.
|
||||||
|
|
||||||
|
If you use `parse()`, or if need to enable additional import directories, you can specify these by
|
||||||
|
calling `SetImportDirs()`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$directories = [ '/var/www/mysite/bootstrap/' => '/mysite/bootstrap/' ];
|
||||||
|
$parser = new Less_Parser();
|
||||||
|
$parser->SetImportDirs( $directories );
|
||||||
|
$parser->parseFile( '/var/www/mysite/theme.less', '/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Caching
|
||||||
|
|
||||||
|
Compiling LESS code into CSS can be a time-consuming process. It is recommended to cache your results.
|
||||||
|
|
||||||
|
#### Basic cache
|
||||||
|
|
||||||
|
Use the `Less_Cache` class to save and reuse the results of compiling LESS files.
|
||||||
|
This class will check the modified time and size of each LESS file (including imported files) and
|
||||||
|
either re-use or re-generate the CSS output accordingly.
|
||||||
|
|
||||||
|
The cache files are determinstically named, based on the full list of referenced LESS files and the metadata (file path, file mtime, file size) of each file. This means that each time a change is made, a different cache filename is used.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$lessFiles = [ '/var/www/mysite/bootstrap.less' => '/mysite/' ];
|
||||||
|
$options = [ 'cache_dir' => '/var/www/writable_folder' ];
|
||||||
|
$cssOutputFile = Less_Cache::Get( $lessFiles, $options );
|
||||||
|
$css = file_get_contents( '/var/www/writable_folder/' . $cssOutputFile );
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Caching with variables
|
||||||
|
|
||||||
|
Passing custom variables to `Less_Cache::Get()`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$lessFiles = [ '/var/www/mysite/bootstrap.less' => '/mysite/' ];
|
||||||
|
$options = [ 'cache_dir' => '/var/www/writable_folder' ];
|
||||||
|
$variables = [ 'width' => '100px' ];
|
||||||
|
$cssOutputFile = Less_Cache::Get( $lessFiles, $options, $variables );
|
||||||
|
$css = file_get_contents( '/var/www/writable_folder/' . $cssOutputFile );
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Incremental caching
|
||||||
|
|
||||||
|
In addition to the whole-output caching described above, Less.php also has the ability to keep an internal cache which allows re-parses to be faster by effectively only re-compiling portions that have changed.
|
||||||
|
|
||||||
|
## Source maps
|
||||||
|
|
||||||
|
Less.php supports v3 sourcemaps.
|
||||||
|
|
||||||
|
#### Inline
|
||||||
|
|
||||||
|
The sourcemap will be appended to the generated CSS file.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$options = [ 'sourceMap' => true ];
|
||||||
|
$parser = new Less_Parser($options);
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Saving to map file
|
||||||
|
|
||||||
|
```php
|
||||||
|
$options = [
|
||||||
|
'sourceMap' => true,
|
||||||
|
'sourceMapWriteTo' => '/var/www/mysite/writable_folder/filename.map',
|
||||||
|
'sourceMapURL' => '/mysite/writable_folder/filename.map',
|
||||||
|
];
|
||||||
|
$parser = new Less_Parser($options);
|
||||||
|
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
||||||
|
$css = $parser->getCss();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Command line
|
||||||
|
|
||||||
|
An additional script has been included to use the Less.php compiler from the command line.
|
||||||
|
In its simplest invocation, you specify an input file and the compiled CSS is written to standard out:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ lessc input.less > output.css
|
||||||
|
```
|
||||||
|
|
||||||
|
By using the `-w` flag you can watch a specified input file and have it compile as needed to the output file:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ lessc -w input.less output.css
|
||||||
|
```
|
||||||
|
|
||||||
|
Errors from watch mode are written to standard out.
|
||||||
|
|
||||||
|
For more information, run `lessc --help`
|
133
vendor/wikimedia/less.php/CHANGES.md
vendored
133
vendor/wikimedia/less.php/CHANGES.md
vendored
@ -1,70 +1,91 @@
|
|||||||
# 3.1.0
|
# Changelog
|
||||||
- [All Changes](https://github.com/wikimedia/less.php/compare/v3.0.0...v3.1.0)
|
|
||||||
* PHP 8.0 support: Drop use of curly braces for sub-string eval (James D. Forrester)
|
## 3.2.1
|
||||||
|
|
||||||
|
* [All changes](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+log/v3.2.1)
|
||||||
|
* Tree_Ruleset: Fix support for nested parent selectors (Timo Tijhof) [T204816](https://phabricator.wikimedia.org/T204816)
|
||||||
|
* Fix ParseError when interpolating variable after colon in selector (Timo Tijhof) [T327163](https://phabricator.wikimedia.org/T327163)
|
||||||
|
* Functions: Fix "Undefined property" warning on bad minmax arg
|
||||||
|
* Tree_Call: Include previous exception when catching functions (Robert Frunzke)
|
||||||
|
|
||||||
|
## 3.2.0
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v3.1.0...v3.2.0)
|
||||||
|
* Fix "Implicit conversion" PHP 8.1 warnings (Ayokunle Odusan)
|
||||||
|
* Fix "Creation of dynamic property" PHP 8.2 warnings (Bas Couwenberg)
|
||||||
|
* Fix "Creation of dynamic property" PHP 8.2 warnings (Rajesh Kumar)
|
||||||
|
* Tree_Url: Add support for "Url" type to `Parser::getVariables()` (ciroarcadio) [#51](https://github.com/wikimedia/less.php/pull/51)
|
||||||
|
* Tree_Import: Add support for importing URLs without file extension (Timo Tijhof) [#27](https://github.com/wikimedia/less.php/issues/27)
|
||||||
|
|
||||||
|
## 3.1.0
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v3.0.0...v3.1.0)
|
||||||
|
* Add PHP 8.0 support: Drop use of curly braces for sub-string eval (James D. Forrester)
|
||||||
* Make `Directive::__construct` $rules arg optional (fix PHP 7.4 warning) (Sam Reed)
|
* Make `Directive::__construct` $rules arg optional (fix PHP 7.4 warning) (Sam Reed)
|
||||||
* ProcessExtends: Improve performance by using a map for selectors and parents (Andrey Legayev)
|
* ProcessExtends: Improve performance by using a map for selectors and parents (Andrey Legayev)
|
||||||
* build: Run CI tests on PHP 8.0 too (James D. Forrester)
|
|
||||||
* code: Fix PSR12.Properties.ConstantVisibility.NotFound (Sam Reed)
|
|
||||||
|
|
||||||
# 3.0.0
|
## 3.0.0
|
||||||
- [All Changes](https://github.com/wikimedia/less.php/compare/v2.0.0...v3.0.0)
|
|
||||||
- Raise PHP requirement from 7.1 to 7.2.9 (James Forrester)
|
|
||||||
- build: Upgrade phpunit to ^8.5 and make pass (James Forrester)
|
|
||||||
- build: Install php-parallel-lint (James Forrester)
|
|
||||||
- build: Install minus-x and make pass (James Forrester)
|
|
||||||
|
|
||||||
# 2.0.0
|
* [All changes](https://github.com/wikimedia/less.php/compare/v2.0.0...v3.0.0)
|
||||||
- [All Changes](https://github.com/wikimedia/less.php/compare/1.8.2...v2.0.0)
|
* Raise PHP requirement from 7.1 to 7.2.9 (James Forrester)
|
||||||
- Relax PHP requirement down to 7.1, from 7.2.9 (Franz Liedke)
|
|
||||||
- Reflect recent breaking changes properly with the semantic versioning (James Forrester)
|
|
||||||
|
|
||||||
# 1.8.2
|
## 2.0.0
|
||||||
- [All Changes](https://github.com/wikimedia/less.php/compare/1.8.1...1.8.2)
|
|
||||||
- Require PHP 7.2.9+, up from 5.3+ (James Forrester)
|
|
||||||
- Release: Update Version.php with the current release ID (COBadger)
|
|
||||||
- Fix access array offset on value of type null (Michele Locati)
|
|
||||||
- Fixed test suite on PHP 7.4 (Sergei Morozov)
|
|
||||||
- docs: Fix 1.8.1 "All changes" link (Timo Tijhof)
|
|
||||||
|
|
||||||
# 1.8.1
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.8.2...v2.0.0)
|
||||||
- [All Changes](https://github.com/wikimedia/less.php/compare/v1.8.0...1.8.1)
|
* Relax PHP requirement down to 7.1, from 7.2.9 (Franz Liedke)
|
||||||
- Another PHP 7.3 compatibility tweak
|
* Reflect recent breaking changes properly with the semantic versioning (James Forrester)
|
||||||
|
|
||||||
# 1.8.0
|
## 1.8.2
|
||||||
- [All Changes](https://github.com/Asenar/less.php/compare/v1.7.0.13...v1.8.0)
|
|
||||||
- Wikimedia fork
|
|
||||||
- Supports up to PHP 7.3
|
|
||||||
- No longer tested against PHP 5, though it's still remains allowed in `composer.json` for HHVM compatibility
|
|
||||||
- Switched to [semantic versioning](https://semver.org/), hence version numbers now use 3 digits
|
|
||||||
|
|
||||||
# 1.7.0.13
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.8.1...v1.8.2)
|
||||||
- [All Changes](https://github.com/Asenar/less.php/compare/v1.7.0.12...v1.7.0.13)
|
* Require PHP 7.2.9+, up from 5.3+ (James Forrester)
|
||||||
- Fix composer.json (PSR-4 was invalid)
|
* release: Update Version.php with the current release ID (COBadger)
|
||||||
|
* Fix access array offset on value of type null (Michele Locati)
|
||||||
|
* Fix test suite on PHP 7.4 (Sergei Morozov)
|
||||||
|
|
||||||
# 1.7.0.12
|
## 1.8.1
|
||||||
- [All Changes](https://github.com/Asenar/less.php/compare/v1.7.0.11...v1.7.0.12)
|
|
||||||
- set bin/lessc bit executable
|
|
||||||
- Add 'gettingVariables' method in Less_Parser
|
|
||||||
|
|
||||||
# 1.7.0.11
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.8.0...v1.8.1)
|
||||||
- [All Changes](https://github.com/Asenar/less.php/compare/v1.7.0.10...v1.7.0.11)
|
* Another PHP 7.3 compatibility tweak
|
||||||
- Fix realpath issue (windows)
|
|
||||||
- Set Less_Tree_Call property back to public ( Fix 258 266 267 issues from oyejorge/less.php)
|
|
||||||
|
|
||||||
# 1.7.0.10
|
## 1.8.0
|
||||||
|
|
||||||
- [All Changes](https://github.com/oyejorge/less.php/compare/v1.7.0.9...v1.7.10)
|
Library forked by Wikimedia, from [oyejorge/less.php](https://github.com/oyejorge/less.php).
|
||||||
- Add indentation option
|
|
||||||
- Add 'optional' modifier for @import
|
|
||||||
- fix $color in Exception messages
|
|
||||||
- don't use set_time_limit when running cli
|
|
||||||
- take relative-url into account when building the cache filename
|
|
||||||
- urlArgs should be string no array()
|
|
||||||
- add bug-report fixtures [#6dc898f](https://github.com/oyejorge/less.php/commit/6dc898f5d75b447464906bdf19d79c2e19d95e33)
|
|
||||||
- fix #269, missing on NameValue type [#a8dac63](https://github.com/oyejorge/less.php/commit/a8dac63d93fb941c54fb78b12588abf635747c1b)
|
|
||||||
|
|
||||||
# 1.7.0.9
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.13...v1.8.0)
|
||||||
|
* Supports up to PHP 7.3
|
||||||
|
* No longer tested against PHP 5, though it's still remains allowed in `composer.json` for HHVM compatibility
|
||||||
|
* Switched to [semantic versioning](https://semver.org/), hence version numbers now use 3 digits
|
||||||
|
|
||||||
- [All Changes](https://github.com/oyejorge/less.php/compare/v1.7.0.8...v1.7.0.9)
|
## 1.7.0.13
|
||||||
- Remove space at beginning of Version.php
|
|
||||||
- Revert require() paths in test interface
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.12...v1.7.0.13)
|
||||||
|
* Fix composer.json (PSR-4 was invalid)
|
||||||
|
|
||||||
|
## 1.7.0.12
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.11...v1.7.0.12)
|
||||||
|
* set bin/lessc bit executable
|
||||||
|
* Add `gettingVariables` method to `Less_Parser`
|
||||||
|
|
||||||
|
## 1.7.0.11
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.10...v1.7.0.11)
|
||||||
|
* Fix realpath issue (windows)
|
||||||
|
* Set Less_Tree_Call property back to public ( Fix 258 266 267 issues from oyejorge/less.php)
|
||||||
|
|
||||||
|
## 1.7.0.10
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.9...v1.7.10)
|
||||||
|
* Add indentation option
|
||||||
|
* Add `optional` modifier for `@import`
|
||||||
|
* Fix $color in Exception messages
|
||||||
|
* take relative-url into account when building the cache filename
|
||||||
|
* urlArgs should be string no array()
|
||||||
|
* fix missing on NameValue type [#269](https://github.com/oyejorge/less.php/issues/269)
|
||||||
|
|
||||||
|
## 1.7.0.9
|
||||||
|
|
||||||
|
* [All changes](https://github.com/wikimedia/less.php/compare/v1.7.0.8...v1.7.0.9)
|
||||||
|
* Remove space at beginning of Version.php
|
||||||
|
* Revert require() paths in test interface
|
||||||
|
1
vendor/wikimedia/less.php/CODE_OF_CONDUCT.md
vendored
Normal file
1
vendor/wikimedia/less.php/CODE_OF_CONDUCT.md
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
The development of this software is covered by a [Code of Conduct](https://www.mediawiki.org/wiki/Special:MyLanguage/Code_of_Conduct).
|
324
vendor/wikimedia/less.php/LICENSE
vendored
324
vendor/wikimedia/less.php/LICENSE
vendored
@ -1,178 +1,202 @@
|
|||||||
|
|
||||||
Apache License
|
Apache License
|
||||||
Version 2.0, January 2004
|
Version 2.0, January 2004
|
||||||
http://www.apache.org/licenses/
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
1. Definitions.
|
1. Definitions.
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
the copyright owner that is granting the License.
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
other entities that control, are controlled by, or are under common
|
other entities that control, are controlled by, or are under common
|
||||||
control with that entity. For the purposes of this definition,
|
control with that entity. For the purposes of this definition,
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
direction or management of such entity, whether by contract or
|
direction or management of such entity, whether by contract or
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
exercising permissions granted by this License.
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
including but not limited to software source code, documentation
|
including but not limited to software source code, documentation
|
||||||
source, and configuration files.
|
source, and configuration files.
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
"Object" form shall mean any form resulting from mechanical
|
||||||
transformation or translation of a Source form, including but
|
transformation or translation of a Source form, including but
|
||||||
not limited to compiled object code, generated documentation,
|
not limited to compiled object code, generated documentation,
|
||||||
and conversions to other media types.
|
and conversions to other media types.
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
Object form, made available under the License, as indicated by a
|
Object form, made available under the License, as indicated by a
|
||||||
copyright notice that is included in or attached to the work
|
copyright notice that is included in or attached to the work
|
||||||
(an example is provided in the Appendix below).
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
form, that is based on (or derived from) the Work and for which the
|
form, that is based on (or derived from) the Work and for which the
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
of this License, Derivative Works shall not include works that remain
|
of this License, Derivative Works shall not include works that remain
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
the Work and Derivative Works thereof.
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
"Contribution" shall mean any work of authorship, including
|
||||||
the original version of the Work and any modifications or additions
|
the original version of the Work and any modifications or additions
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
means any form of electronic, verbal, or written communication sent
|
means any form of electronic, verbal, or written communication sent
|
||||||
to the Licensor or its representatives, including but not limited to
|
to the Licensor or its representatives, including but not limited to
|
||||||
communication on electronic mailing lists, source code control systems,
|
communication on electronic mailing lists, source code control systems,
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
excluding communication that is conspicuously marked or otherwise
|
excluding communication that is conspicuously marked or otherwise
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
subsequently incorporated within the Work.
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
Work and such Derivative Works in Source or Object form.
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
(except as stated in this section) patent license to make, have made,
|
(except as stated in this section) patent license to make, have made,
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
where such license applies only to those patent claims licensable
|
where such license applies only to those patent claims licensable
|
||||||
by such Contributor that are necessarily infringed by their
|
by such Contributor that are necessarily infringed by their
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
institute patent litigation against any entity (including a
|
institute patent litigation against any entity (including a
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
or contributory patent infringement, then any patent licenses
|
or contributory patent infringement, then any patent licenses
|
||||||
granted to You under this License for that Work shall terminate
|
granted to You under this License for that Work shall terminate
|
||||||
as of the date such litigation is filed.
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
modifications, and in Source or Object form, provided that You
|
modifications, and in Source or Object form, provided that You
|
||||||
meet the following conditions:
|
meet the following conditions:
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
(a) You must give any other recipients of the Work or
|
||||||
Derivative Works a copy of this License; and
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
(b) You must cause any modified files to carry prominent notices
|
||||||
stating that You changed the files; and
|
stating that You changed the files; and
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
that You distribute, all copyright, patent, trademark, and
|
that You distribute, all copyright, patent, trademark, and
|
||||||
attribution notices from the Source form of the Work,
|
attribution notices from the Source form of the Work,
|
||||||
excluding those notices that do not pertain to any part of
|
excluding those notices that do not pertain to any part of
|
||||||
the Derivative Works; and
|
the Derivative Works; and
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
distribution, then any Derivative Works that You distribute must
|
distribution, then any Derivative Works that You distribute must
|
||||||
include a readable copy of the attribution notices contained
|
include a readable copy of the attribution notices contained
|
||||||
within such NOTICE file, excluding those notices that do not
|
within such NOTICE file, excluding those notices that do not
|
||||||
pertain to any part of the Derivative Works, in at least one
|
pertain to any part of the Derivative Works, in at least one
|
||||||
of the following places: within a NOTICE text file distributed
|
of the following places: within a NOTICE text file distributed
|
||||||
as part of the Derivative Works; within the Source form or
|
as part of the Derivative Works; within the Source form or
|
||||||
documentation, if provided along with the Derivative Works; or,
|
documentation, if provided along with the Derivative Works; or,
|
||||||
within a display generated by the Derivative Works, if and
|
within a display generated by the Derivative Works, if and
|
||||||
wherever such third-party notices normally appear. The contents
|
wherever such third-party notices normally appear. The contents
|
||||||
of the NOTICE file are for informational purposes only and
|
of the NOTICE file are for informational purposes only and
|
||||||
do not modify the License. You may add Your own attribution
|
do not modify the License. You may add Your own attribution
|
||||||
notices within Derivative Works that You distribute, alongside
|
notices within Derivative Works that You distribute, alongside
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
that such additional attribution notices cannot be construed
|
that such additional attribution notices cannot be construed
|
||||||
as modifying the License.
|
as modifying the License.
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
You may add Your own copyright statement to Your modifications and
|
||||||
may provide additional or different license terms and conditions
|
may provide additional or different license terms and conditions
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
the conditions stated in this License.
|
the conditions stated in this License.
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
this License, without any additional terms or conditions.
|
this License, without any additional terms or conditions.
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
the terms of any separate license agreement you may have executed
|
the terms of any separate license agreement you may have executed
|
||||||
with Licensor regarding such Contributions.
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
except as required for reasonable and customary use in describing the
|
except as required for reasonable and customary use in describing the
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
implied, including, without limitation, any warranties or conditions
|
implied, including, without limitation, any warranties or conditions
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
appropriateness of using or redistributing the Work and assume any
|
appropriateness of using or redistributing the Work and assume any
|
||||||
risks associated with Your exercise of permissions under this License.
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
unless required by applicable law (such as deliberate and grossly
|
unless required by applicable law (such as deliberate and grossly
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
liable to You for damages, including any direct, indirect, special,
|
liable to You for damages, including any direct, indirect, special,
|
||||||
incidental, or consequential damages of any character arising as a
|
incidental, or consequential damages of any character arising as a
|
||||||
result of this License or out of the use or inability to use the
|
result of this License or out of the use or inability to use the
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
other commercial damages or losses), even if such Contributor
|
other commercial damages or losses), even if such Contributor
|
||||||
has been advised of the possibility of such damages.
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
or other liability obligations and/or rights consistent with this
|
or other liability obligations and/or rights consistent with this
|
||||||
License. However, in accepting such obligations, You may act only
|
License. However, in accepting such obligations, You may act only
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
defend, and hold each Contributor harmless for any liability
|
defend, and hold each Contributor harmless for any liability
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
of your accepting any such warranty or additional liability.
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
18
vendor/wikimedia/less.php/NOTICE.txt
vendored
Normal file
18
vendor/wikimedia/less.php/NOTICE.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
wikimedia/less.php. https://gerrit.wikimedia.org/g/mediawiki/libs/less.php
|
||||||
|
|
||||||
|
Copyright Matt Agar <https://github.com/agar>
|
||||||
|
Copyright Martin Jantošovič <https://github.com/Mordred>
|
||||||
|
Copyright Josh Schmidt <https://github.com/oyejorge>
|
||||||
|
Copyright Timo Tijhof <https://timotijhof.net>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
328
vendor/wikimedia/less.php/README.md
vendored
328
vendor/wikimedia/less.php/README.md
vendored
@ -1,315 +1,77 @@
|
|||||||
[![Continuous Integration](https://github.com/wikimedia/less.php/workflows/PHP%20Test/badge.svg)](https://github.com/wikimedia/less.php/actions)
|
[![Packagist](https://img.shields.io/packagist/v/wikimedia/less.php.svg?style=flat)](https://packagist.org/packages/wikimedia/less.php)
|
||||||
|
|
||||||
[Less.php](http://lessphp.typesettercms.com)
|
Less.php
|
||||||
========
|
========
|
||||||
|
|
||||||
This is the Wikimedia fork of a PHP port of the official LESS processor <http://lesscss.org>.
|
This is a PHP port of the [official LESS processor](https://lesscss.org).
|
||||||
|
|
||||||
* [About](#about)
|
## About
|
||||||
* [Installation](#installation)
|
|
||||||
* [Basic Use](#basic-use)
|
|
||||||
* [Caching](#caching)
|
|
||||||
* [Source Maps](#source-maps)
|
|
||||||
* [Command Line](#command-line)
|
|
||||||
* [Integration with other projects](#integration-with-other-projects)
|
|
||||||
* [Transitioning from Leafo/lessphp](#transitioning-from-leafolessphp)
|
|
||||||
* [Credits](#credits)
|
|
||||||
|
|
||||||
|
The code structure of Less.php mirrors that of upstream Less.js to ensure compatibility and help reduce maintenance. The port is currently compatible with Less.js 2.5.3. Please note that "inline JavaScript expressions" (via eval or backticks) are not supported.
|
||||||
|
|
||||||
|
* [API § Caching](./API.md#caching), Less.php includes a file-based cache.
|
||||||
|
* [API § Source maps](./API.md#source-maps), Less.php supports v3 sourcemaps.
|
||||||
|
* [API § Command line](./API.md#command-line), the `lessc` command includes a watch mode.
|
||||||
|
|
||||||
About
|
## Installation
|
||||||
---
|
|
||||||
The code structure of less.php mirrors that of the official processor which helps us ensure compatibility and allows for easy maintenance.
|
|
||||||
|
|
||||||
Please note, there are a few unsupported LESS features:
|
You can install the library with Composer or standalone.
|
||||||
|
|
||||||
- Evaluation of JavaScript expressions within back-ticks (for obvious reasons).
|
If you have [Composer](https://getcomposer.org/download/) installed:
|
||||||
- Definition of custom functions.
|
|
||||||
|
|
||||||
|
1. Run `composer require wikimedia/less.php`
|
||||||
|
2. Use `Less_Parser` in your code.
|
||||||
|
|
||||||
Installation
|
Or standalone:
|
||||||
---
|
|
||||||
|
|
||||||
You can install the library with Composer or manually.
|
1. [Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz) and upload the PHP files to your server.
|
||||||
|
2. Include the library:
|
||||||
|
```php
|
||||||
|
require_once '[path to]/less.php/lib/Less/Autoloader.php';
|
||||||
|
Less_Autoloader::register();
|
||||||
|
```
|
||||||
|
3. Use `Less_Parser` in your code.
|
||||||
|
|
||||||
#### Composer
|
## Security
|
||||||
|
|
||||||
1. [Install Composer](https://getcomposer.org/download/)
|
The LESS processor language is powerful and includes features that may read or embed arbitrary files that the web server has access to, and features that may be computationally exensive if misused.
|
||||||
2. Run `composer require wikimedia/less.php`
|
|
||||||
|
|
||||||
#### Manually From Release
|
In general you should treat LESS files as being in the same trust domain as other server-side executables, such as PHP code. In particular, it is not recommended to allow people that use your web service to provide arbitrary LESS code for server-side processing.
|
||||||
|
|
||||||
Step 1. [Download a release](https://github.com/wikimedia/less.php/releases) and upload the PHP files to your server.
|
_See also [SECURITY](./SECURITY.md)._
|
||||||
|
|
||||||
Step 2. Include the library:
|
## Who uses Less.php?
|
||||||
|
|
||||||
```php
|
* **[Wikipedia](https://en.wikipedia.org/wiki/MediaWiki)** and the MediaWiki platform ([docs](https://www.mediawiki.org/wiki/ResourceLoader/Architecture#Resource:_Styles)).
|
||||||
require_once '[path to less.php]/lib/Less/Autoloader.php';
|
* **[Matomo](https://en.wikipedia.org/wiki/Matomo_(software))** ([docs](https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/css-topics/custom_preprocess.html)).
|
||||||
Less_Autoloader::register();
|
* **[Magento](https://en.wikipedia.org/wiki/Magento)** as part of Adobe Commerce ([docs](https://developer.matomo.org/guides/asset-pipeline#vanilla-javascript-css-and-less-files)).
|
||||||
```
|
* **[Icinga](https://en.wikipedia.org/wiki/Icinga)** in Icinga Web ([docs](https://github.com/Icinga/icingaweb2)).
|
||||||
|
* **[Shopware](https://de.wikipedia.org/wiki/Shopware)** ([docs](https://developers.shopware.com/designers-guide/less/)).
|
||||||
|
|
||||||
Basic Use
|
## Integrations
|
||||||
---
|
|
||||||
|
|
||||||
#### Parsing Strings
|
Less.php has been integrated with various other projects.
|
||||||
|
|
||||||
```php
|
#### Transitioning from Leafo/lessphp
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parse( '@color: #4D926F; #header { color: @color; } h2 { color: @color; }' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
If you're looking to transition from the [Leafo/lessphp](https://github.com/leafo/lessphp) library, use the `lessc.inc.php` adapter file that comes with Less.php.
|
||||||
|
|
||||||
#### Parsing LESS Files
|
This allows Less.php to be a drop-in replacement for Leafo/lessphp.
|
||||||
The parseFile() function takes two arguments:
|
|
||||||
|
|
||||||
1. The absolute path of the .less file to be parsed
|
[Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz), unzip the files into your project, and include its `lessc.inc.php` instead.
|
||||||
2. The url root to prepend to any relative image or @import urls in the .less file.
|
|
||||||
|
|
||||||
```php
|
Note: The `setPreserveComments` option is ignored. Less.php already preserves CSS block comments by default, and removes LESS inline comments.
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'http://example.com/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
#### Drupal
|
||||||
|
|
||||||
#### Handling Invalid LESS
|
Less.php can be used with [Drupal's less module](https://drupal.org/project/less) via the `lessc.inc.php` adapter. [Download Less.php](https://gerrit.wikimedia.org/g/mediawiki/libs/less.php/+archive/HEAD.tar.gz) and unzip it so that `lessc.inc.php` is located at `sites/all/libraries/lessphp/lessc.inc.php`, then install the Drupal less module as usual.
|
||||||
An exception will be thrown if the compiler encounters invalid LESS.
|
|
||||||
|
|
||||||
```php
|
|
||||||
try{
|
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', 'http://example.com/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
}catch(Exception $e){
|
|
||||||
$error_message = $e->getMessage();
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Parsing Multiple Sources
|
|
||||||
less.php can parse multiple sources to generate a single CSS file.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$parser->parse( '@color: #4D926F; #header { color: @color; } h2 { color: @color; }' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Getting Info About The Parsed Files
|
|
||||||
less.php can tell you which .less files were imported and parsed.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
$imported_files = $parser->allParsedFiles();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Compressing Output
|
|
||||||
You can tell less.php to remove comments and whitespace to generate minimized CSS files.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$options = array( 'compress'=>true );
|
|
||||||
$parser = new Less_Parser( $options );
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Getting Variables
|
|
||||||
You can use the getVariables() method to get an all variables defined and
|
|
||||||
their value in a php associative array. Note that LESS has to be previously
|
|
||||||
compiled.
|
|
||||||
```php
|
|
||||||
$parser = new Less_Parser;
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less');
|
|
||||||
$css = $parser->getCss();
|
|
||||||
$variables = $parser->getVariables();
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### Setting Variables
|
|
||||||
You can use the ModifyVars() method to customize your CSS if you have variables stored in PHP associative arrays.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$parser->ModifyVars( array('font-size-base'=>'16px') );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Import Directories
|
|
||||||
By default, less.php will look for @imports in the directory of the file passed to parseFile().
|
|
||||||
If you're using parse() or if @imports reside in different directories, you can tell less.php where to look.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$directories = array( '/var/www/mysite/bootstrap/' => '/mysite/bootstrap/' );
|
|
||||||
$parser = new Less_Parser();
|
|
||||||
$parser->SetImportDirs( $directories );
|
|
||||||
$parser->parseFile( '/var/www/mysite/theme.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Caching
|
|
||||||
---
|
|
||||||
Compiling LESS code into CSS is a time consuming process, caching your results is highly recommended.
|
|
||||||
|
|
||||||
|
|
||||||
#### Caching CSS
|
|
||||||
Use the Less_Cache class to save and reuse the results of compiled LESS files.
|
|
||||||
This method will check the modified time and size of each LESS file (including imported files) and regenerate a new CSS file when changes are found.
|
|
||||||
Note: When changes are found, this method will return a different file name for the new cached content.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$less_files = array( '/var/www/mysite/bootstrap.less' => '/mysite/' );
|
|
||||||
$options = array( 'cache_dir' => '/var/www/writable_folder' );
|
|
||||||
$css_file_name = Less_Cache::Get( $less_files, $options );
|
|
||||||
$compiled = file_get_contents( '/var/www/writable_folder/'.$css_file_name );
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Caching CSS With Variables
|
|
||||||
Passing options to Less_Cache::Get()
|
|
||||||
|
|
||||||
```php
|
|
||||||
$less_files = array( '/var/www/mysite/bootstrap.less' => '/mysite/' );
|
|
||||||
$options = array( 'cache_dir' => '/var/www/writable_folder' );
|
|
||||||
$variables = array( 'width' => '100px' );
|
|
||||||
$css_file_name = Less_Cache::Get( $less_files, $options, $variables );
|
|
||||||
$compiled = file_get_contents( '/var/www/writable_folder/'.$css_file_name );
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Parser Caching
|
|
||||||
less.php will save serialized parser data for each .less file if a writable folder is passed to the SetCacheDir() method.
|
|
||||||
Note: This feature only caches intermediate parsing results to improve the performance of repeated CSS generation.
|
|
||||||
Your application should cache any CSS generated by less.php.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$options = array('cache_dir'=>'/var/www/writable_folder');
|
|
||||||
$parser = new Less_Parser( $options );
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
You can specify the caching technique used by changing the ```cache_method``` option. Supported methods are:
|
|
||||||
* ```php```: Creates valid PHP files which can be included without any changes (default method).
|
|
||||||
* ```var_export```: Like "php", but using PHP's ```var_export()``` function without any optimizations.
|
|
||||||
It's recommended to use "php" instead.
|
|
||||||
* ```serialize```: Faster, but pretty memory-intense.
|
|
||||||
* ```callback```: Use custom callback functions to implement your own caching method. Give the "cache_callback_get" and
|
|
||||||
"cache_callback_set" options with callables (see PHP's ```call_user_func()``` and ```is_callable()``` functions). less.php
|
|
||||||
will pass the parser object (class ```Less_Parser```), the path to the parsed .less file ("/some/path/to/file.less") and
|
|
||||||
an identifier that will change every time the .less file is modified. The ```get``` callback must return the ruleset
|
|
||||||
(an array with ```Less_Tree``` objects) provided as fourth parameter of the ```set``` callback. If something goes wrong,
|
|
||||||
return ```NULL``` (cache doesn't exist) or ```FALSE```.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Source Maps
|
|
||||||
---
|
|
||||||
Less.php supports v3 sourcemaps
|
|
||||||
|
|
||||||
#### Inline
|
|
||||||
The sourcemap will be appended to the generated CSS file.
|
|
||||||
|
|
||||||
```php
|
|
||||||
$options = array( 'sourceMap' => true );
|
|
||||||
$parser = new Less_Parser($options);
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Saving to Map File
|
|
||||||
|
|
||||||
```php
|
|
||||||
$options = array(
|
|
||||||
'sourceMap' => true,
|
|
||||||
'sourceMapWriteTo' => '/var/www/mysite/writable_folder/filename.map',
|
|
||||||
'sourceMapURL' => '/mysite/writable_folder/filename.map',
|
|
||||||
);
|
|
||||||
$parser = new Less_Parser($options);
|
|
||||||
$parser->parseFile( '/var/www/mysite/bootstrap.less', '/mysite/' );
|
|
||||||
$css = $parser->getCss();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Command line
|
|
||||||
---
|
|
||||||
An additional script has been included to use the compiler from the command line.
|
|
||||||
In the simplest invocation, you specify an input file and the compiled CSS is written to standard out:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ lessc input.less > output.css
|
|
||||||
```
|
|
||||||
|
|
||||||
By using the -w flag you can watch a specified input file and have it compile as needed to the output file:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ lessc -w input.less output.css
|
|
||||||
```
|
|
||||||
|
|
||||||
Errors from watch mode are written to standard out.
|
|
||||||
|
|
||||||
For more help, run `lessc --help`
|
|
||||||
|
|
||||||
|
|
||||||
Integration with other projects
|
|
||||||
---
|
|
||||||
|
|
||||||
#### Drupal 7
|
|
||||||
|
|
||||||
This library can be used as drop-in replacement of lessphp to work with [Drupal 7 less module](https://drupal.org/project/less).
|
|
||||||
|
|
||||||
How to install:
|
|
||||||
|
|
||||||
1. [Download the less.php source code](https://github.com/wikimedia/less.php/archive/master.zip) and unzip it so that 'lessc.inc.php' is located at 'sites/all/libraries/lessphp/lessc.inc.php'.
|
|
||||||
2. Download and install [Drupal 7 less module](https://drupal.org/project/less) as usual.
|
|
||||||
3. That's it :)
|
|
||||||
|
|
||||||
#### JBST WordPress theme
|
|
||||||
|
|
||||||
JBST has a built-in LESS compiler based on lessphp. Customize your WordPress theme with LESS.
|
|
||||||
|
|
||||||
How to use / install:
|
|
||||||
|
|
||||||
1. [Download the latest release](https://github.com/bassjobsen/jamedo-bootstrap-start-theme) copy the files to your {wordpress/}wp-content/themes folder and activate it.
|
|
||||||
2. Find the compiler under Appearance > LESS Compiler in your WordPress dashboard
|
|
||||||
3. Enter your LESS code in the text area and press (re)compile
|
|
||||||
|
|
||||||
Use the built-in compiler to:
|
|
||||||
- set any [Bootstrap](http://getbootstrap.com/customize/) variable or use Bootstrap's mixins:
|
|
||||||
-`@navbar-default-color: blue;`
|
|
||||||
- create a custom button: `.btn-custom {
|
|
||||||
.button-variant(white; red; blue);
|
|
||||||
}`
|
|
||||||
- set any built-in LESS variable: for example `@footer_bg_color: black;` sets the background color of the footer to black
|
|
||||||
- use built-in mixins: - add a custom font: `.include-custom-font(@family: arial,@font-path, @path: @custom-font-dir, @weight: normal, @style: normal);`
|
|
||||||
|
|
||||||
The compiler can also be downloaded as [plugin](http://wordpress.org/plugins/wp-less-to-css/)
|
|
||||||
|
|
||||||
#### WordPress
|
#### WordPress
|
||||||
|
|
||||||
This simple plugin will simply make the library available to other plugins and themes and can be used as a dependency using the [TGM Library](http://tgmpluginactivation.com/)
|
* [wp_enqueue_less](https://github.com/Ed-ITSolutions/wp_enqueue_less) is a Composer package for use in WordPress themes and plugins. It provides a `wp_enqueue_less()` function to automatically manage caching and compilation on-demand, and loads the compressed CSS on the page.
|
||||||
|
* [JBST framework](https://github.com/bassjobsen/jamedo-bootstrap-start-theme) bundles a copy of Less.php.
|
||||||
|
* The [lessphp plugin](https://wordpress.org/plugins/lessphp/) bundles a copy of Less.php for use in other plugins or themes. This dependency can also be combined with the [TGM Library](http://tgmpluginactivation.com/).
|
||||||
|
|
||||||
How to install:
|
## Credits
|
||||||
|
|
||||||
1. Install the plugin from your WordPress Dashboard: http://wordpress.org/plugins/lessphp/
|
|
||||||
2. That's it :)
|
|
||||||
|
|
||||||
|
|
||||||
Transitioning from Leafo/lessphp
|
|
||||||
---
|
|
||||||
Projects looking for an easy transition from leafo/lessphp can use the lessc.inc.php adapter. To use, [Download the less.php source code](https://github.com/wikimedia/less.php/archive/master.zip) and unzip the files into your project so that the new 'lessc.inc.php' replaces the existing 'lessc.inc.php'.
|
|
||||||
|
|
||||||
Note, the 'setPreserveComments' will no longer have any effect on the compiled LESS.
|
|
||||||
|
|
||||||
Credits
|
|
||||||
---
|
|
||||||
less.php was originally ported to PHP by [Matt Agar](https://github.com/agar) and then updated by [Martin Jantošovič](https://github.com/Mordred). This Wikimedia-maintained fork was split off from [Josh Schmidt's version](https://github.com/oyejorge/less.php).
|
|
||||||
|
|
||||||
|
Less.php was originally ported to PHP in 2011 by [Matt Agar](https://github.com/agar) and then updated by [Martin Jantošovič](https://github.com/Mordred) in 2012. From 2013 to 2017, [Josh Schmidt](https://github.com/oyejorge) lead development of the library. Since 2019, the library is maintained by Wikimedia Foundation.
|
||||||
|
5
vendor/wikimedia/less.php/SECURITY.md
vendored
Normal file
5
vendor/wikimedia/less.php/SECURITY.md
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Security policy
|
||||||
|
|
||||||
|
Wikimedia takes security seriously. If you believe you have found a
|
||||||
|
security issue, see <https://www.mediawiki.org/wiki/Reporting_security_bugs>
|
||||||
|
for information on how to responsibly report it.
|
2
vendor/wikimedia/less.php/bin/lessc
vendored
2
vendor/wikimedia/less.php/bin/lessc
vendored
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../lib/Less/Autoloader.php';
|
require_once __DIR__ . '/../lib/Less/Autoloader.php';
|
||||||
Less_Autoloader::register();
|
Less_Autoloader::register();
|
||||||
|
|
||||||
// Create our environment
|
// Create our environment
|
||||||
|
49
vendor/wikimedia/less.php/composer.json
vendored
49
vendor/wikimedia/less.php/composer.json
vendored
@ -1,49 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "wikimedia/less.php",
|
|
||||||
"description": "PHP port of the Javascript version of LESS http://lesscss.org (Originally maintained by Josh Schmidt)",
|
|
||||||
"keywords": [ "less", "css", "php", "stylesheet", "less.js", "lesscss" ],
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Josh Schmidt",
|
|
||||||
"homepage": "https://github.com/oyejorge"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Matt Agar",
|
|
||||||
"homepage": "https://github.com/agar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Martin Jantošovič",
|
|
||||||
"homepage": "https://github.com/Mordred"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"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",
|
|
||||||
"phpunit/phpunit": "^8.5"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": [
|
|
||||||
"parallel-lint . --exclude vendor",
|
|
||||||
"phpcs -sp",
|
|
||||||
"phpunit",
|
|
||||||
"minus-x check ."
|
|
||||||
],
|
|
||||||
"fix": [
|
|
||||||
"minus-x fix .",
|
|
||||||
"phpcbf"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": { "Less": "lib/" },
|
|
||||||
"classmap": ["lessc.inc.php"]
|
|
||||||
},
|
|
||||||
"bin": [
|
|
||||||
"bin/lessc"
|
|
||||||
]
|
|
||||||
}
|
|
26
vendor/wikimedia/less.php/lessc.inc.php
vendored
26
vendor/wikimedia/less.php/lessc.inc.php
vendored
@ -14,14 +14,14 @@ if ( !class_exists( 'Less_Parser' ) ) {
|
|||||||
|
|
||||||
class lessc {
|
class lessc {
|
||||||
|
|
||||||
static public $VERSION = Less_Version::less_version;
|
public static $VERSION = Less_Version::less_version;
|
||||||
|
|
||||||
public $importDir = '';
|
public $importDir = '';
|
||||||
protected $allParsedFiles = array();
|
protected $allParsedFiles = [];
|
||||||
protected $libFunctions = array();
|
protected $libFunctions = [];
|
||||||
protected $registeredVars = array();
|
protected $registeredVars = [];
|
||||||
private $formatterName;
|
private $formatterName;
|
||||||
private $options = array();
|
private $options = [];
|
||||||
|
|
||||||
public function __construct( $lessc = null, $sourceName = null ) {
|
public function __construct( $lessc = null, $sourceName = null ) {
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ class lessc {
|
|||||||
$this->options[$name] = $value;
|
$this->options[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parse( $buffer, $presets = array() ) {
|
public function parse( $buffer, $presets = [] ) {
|
||||||
$this->setVariables( $presets );
|
$this->setVariables( $presets );
|
||||||
|
|
||||||
$parser = new Less_Parser( $this->getOptions() );
|
$parser = new Less_Parser( $this->getOptions() );
|
||||||
@ -91,7 +91,7 @@ class lessc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getOptions() {
|
protected function getOptions() {
|
||||||
$options = array( 'relativeUrls' => false );
|
$options = [ 'relativeUrls' => false ];
|
||||||
switch ( $this->formatterName ) {
|
switch ( $this->formatterName ) {
|
||||||
case 'compressed':
|
case 'compressed':
|
||||||
$options['compress'] = true;
|
$options['compress'] = true;
|
||||||
@ -105,7 +105,7 @@ class lessc {
|
|||||||
|
|
||||||
protected function getImportDirs() {
|
protected function getImportDirs() {
|
||||||
$dirs_ = (array)$this->importDir;
|
$dirs_ = (array)$this->importDir;
|
||||||
$dirs = array();
|
$dirs = [];
|
||||||
foreach ( $dirs_ as $dir ) {
|
foreach ( $dirs_ as $dir ) {
|
||||||
$dirs[$dir] = '';
|
$dirs[$dir] = '';
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ class lessc {
|
|||||||
$oldImport = $this->importDir;
|
$oldImport = $this->importDir;
|
||||||
$this->importDir = (array)$this->importDir;
|
$this->importDir = (array)$this->importDir;
|
||||||
|
|
||||||
$this->allParsedFiles = array();
|
$this->allParsedFiles = [];
|
||||||
|
|
||||||
$parser = new Less_Parser( $this->getOptions() );
|
$parser = new Less_Parser( $this->getOptions() );
|
||||||
$parser->SetImportDirs( $this->getImportDirs() );
|
$parser->SetImportDirs( $this->getImportDirs() );
|
||||||
@ -141,7 +141,7 @@ class lessc {
|
|||||||
|
|
||||||
public function compileFile( $fname, $outFname = null ) {
|
public function compileFile( $fname, $outFname = null ) {
|
||||||
if ( !is_readable( $fname ) ) {
|
if ( !is_readable( $fname ) ) {
|
||||||
throw new Exception( 'load error: failed to find '.$fname );
|
throw new Exception( 'load error: failed to find ' . $fname );
|
||||||
}
|
}
|
||||||
|
|
||||||
$pi = pathinfo( $fname );
|
$pi = pathinfo( $fname );
|
||||||
@ -149,9 +149,9 @@ class lessc {
|
|||||||
$oldImport = $this->importDir;
|
$oldImport = $this->importDir;
|
||||||
|
|
||||||
$this->importDir = (array)$this->importDir;
|
$this->importDir = (array)$this->importDir;
|
||||||
$this->importDir[] = Less_Parser::AbsPath( $pi['dirname'] ).'/';
|
$this->importDir[] = Less_Parser::AbsPath( $pi['dirname'] ) . '/';
|
||||||
|
|
||||||
$this->allParsedFiles = array();
|
$this->allParsedFiles = [];
|
||||||
$this->addParsedFile( $fname );
|
$this->addParsedFile( $fname );
|
||||||
|
|
||||||
$parser = new Less_Parser( $this->getOptions() );
|
$parser = new Less_Parser( $this->getOptions() );
|
||||||
@ -237,7 +237,7 @@ class lessc {
|
|||||||
|
|
||||||
if ( $root !== null ) {
|
if ( $root !== null ) {
|
||||||
// If we have a root value which means we should rebuild.
|
// If we have a root value which means we should rebuild.
|
||||||
$out = array();
|
$out = [];
|
||||||
$out['root'] = $root;
|
$out['root'] = $root;
|
||||||
$out['compiled'] = $this->compileFile( $root );
|
$out['compiled'] = $this->compileFile( $root );
|
||||||
$out['files'] = $this->allParsedFiles();
|
$out['files'] = $this->allParsedFiles();
|
||||||
|
@ -2,28 +2,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoloader
|
* Autoloader
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage autoload
|
|
||||||
*/
|
*/
|
||||||
class Less_Autoloader {
|
class Less_Autoloader {
|
||||||
|
|
||||||
/**
|
/** @var bool */
|
||||||
* Registered flag
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
protected static $registered = false;
|
protected static $registered = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Library directory
|
* Register the autoloader in the SPL autoloader
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected static $libDir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the autoloader in the spl autoloader
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception If there was an error in registration
|
* @throws Exception If there was an error in registration
|
||||||
@ -33,9 +19,7 @@ class Less_Autoloader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$libDir = dirname( __FILE__ );
|
if ( !spl_autoload_register( [ 'Less_Autoloader', 'loadClass' ] ) ) {
|
||||||
|
|
||||||
if ( false === spl_autoload_register( array( 'Less_Autoloader', 'loadClass' ) ) ) {
|
|
||||||
throw new Exception( 'Unable to register Less_Autoloader::loadClass as an autoloading method.' );
|
throw new Exception( 'Unable to register Less_Autoloader::loadClass as an autoloading method.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,17 +27,17 @@ class Less_Autoloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters the autoloader
|
* Unregister the autoloader
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function unregister() {
|
public static function unregister() {
|
||||||
spl_autoload_unregister( array( 'Less_Autoloader', 'loadClass' ) );
|
spl_autoload_unregister( [ 'Less_Autoloader', 'loadClass' ] );
|
||||||
self::$registered = false;
|
self::$registered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the class
|
* Load the class
|
||||||
*
|
*
|
||||||
* @param string $className The class to load
|
* @param string $className The class to load
|
||||||
*/
|
*/
|
||||||
@ -64,14 +48,10 @@ class Less_Autoloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$className = substr( $className, 5 );
|
$className = substr( $className, 5 );
|
||||||
$fileName = self::$libDir . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $className ) . '.php';
|
$fileName = __DIR__ . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $className ) . '.php';
|
||||||
|
|
||||||
if ( file_exists( $fileName ) ) {
|
require $fileName;
|
||||||
require $fileName;
|
return true;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
throw new Exception( 'file not loadable '.$fileName );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
97
vendor/wikimedia/less.php/lib/Less/Cache.php
vendored
97
vendor/wikimedia/less.php/lib/Less/Cache.php
vendored
@ -1,27 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once dirname( __FILE__ ).'/Version.php';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for handling the generation and caching of css files
|
* Utility for handling the generation and caching of css files
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage cache
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class Less_Cache {
|
class Less_Cache {
|
||||||
|
|
||||||
// directory less.php can use for storing data
|
// directory less.php can use for storing data
|
||||||
public static $cache_dir = false;
|
public static $cache_dir = false;
|
||||||
|
|
||||||
// prefix for the storing data
|
// prefix for the storing data
|
||||||
public static $prefix = 'lessphp_';
|
public static $prefix = 'lessphp_';
|
||||||
|
|
||||||
// prefix for the storing vars
|
// prefix for the storing vars
|
||||||
public static $prefix_vars = 'lessphpvars_';
|
public static $prefix_vars = 'lessphpvars_';
|
||||||
|
|
||||||
// specifies the number of seconds after which data created by less.php will be seen as 'garbage' and potentially cleaned up
|
// specifies the number of seconds after which data created by less.php will be seen as 'garbage' and potentially cleaned up
|
||||||
public static $gc_lifetime = 604800;
|
public static $gc_lifetime = 604800;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save and reuse the results of compiled less files.
|
* Save and reuse the results of compiled less files.
|
||||||
@ -31,31 +25,31 @@ class Less_Cache {
|
|||||||
* @param array $less_files Array of .less files to compile
|
* @param array $less_files Array of .less files to compile
|
||||||
* @param array $parser_options Array of compiler options
|
* @param array $parser_options Array of compiler options
|
||||||
* @param array $modify_vars Array of variables
|
* @param array $modify_vars Array of variables
|
||||||
* @return string Name of the css file
|
* @return string|false Name of the css file
|
||||||
*/
|
*/
|
||||||
public static function Get( $less_files, $parser_options = array(), $modify_vars = array() ) {
|
public static function Get( $less_files, $parser_options = [], $modify_vars = [] ) {
|
||||||
// check $cache_dir
|
// check $cache_dir
|
||||||
if ( isset( $parser_options['cache_dir'] ) ) {
|
if ( isset( $parser_options['cache_dir'] ) ) {
|
||||||
Less_Cache::$cache_dir = $parser_options['cache_dir'];
|
self::$cache_dir = $parser_options['cache_dir'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( Less_Cache::$cache_dir ) ) {
|
if ( empty( self::$cache_dir ) ) {
|
||||||
throw new Exception( 'cache_dir not set' );
|
throw new Exception( 'cache_dir not set' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $parser_options['prefix'] ) ) {
|
if ( isset( $parser_options['prefix'] ) ) {
|
||||||
Less_Cache::$prefix = $parser_options['prefix'];
|
self::$prefix = $parser_options['prefix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( Less_Cache::$prefix ) ) {
|
if ( empty( self::$prefix ) ) {
|
||||||
throw new Exception( 'prefix not set' );
|
throw new Exception( 'prefix not set' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $parser_options['prefix_vars'] ) ) {
|
if ( isset( $parser_options['prefix_vars'] ) ) {
|
||||||
Less_Cache::$prefix_vars = $parser_options['prefix_vars'];
|
self::$prefix_vars = $parser_options['prefix_vars'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( Less_Cache::$prefix_vars ) ) {
|
if ( empty( self::$prefix_vars ) ) {
|
||||||
throw new Exception( 'prefix_vars not set' );
|
throw new Exception( 'prefix_vars not set' );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,18 +59,18 @@ class Less_Cache {
|
|||||||
// create a file for variables
|
// create a file for variables
|
||||||
if ( !empty( $modify_vars ) ) {
|
if ( !empty( $modify_vars ) ) {
|
||||||
$lessvars = Less_Parser::serializeVars( $modify_vars );
|
$lessvars = Less_Parser::serializeVars( $modify_vars );
|
||||||
$vars_file = Less_Cache::$cache_dir . Less_Cache::$prefix_vars . sha1( $lessvars ) . '.less';
|
$vars_file = self::$cache_dir . self::$prefix_vars . sha1( $lessvars ) . '.less';
|
||||||
|
|
||||||
if ( !file_exists( $vars_file ) ) {
|
if ( !file_exists( $vars_file ) ) {
|
||||||
file_put_contents( $vars_file, $lessvars );
|
file_put_contents( $vars_file, $lessvars );
|
||||||
}
|
}
|
||||||
|
|
||||||
$less_files += array( $vars_file => '/' );
|
$less_files += [ $vars_file => '/' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate name for compiled css file
|
// generate name for compiled css file
|
||||||
$hash = md5( json_encode( $less_files ) );
|
$hash = md5( json_encode( $less_files ) );
|
||||||
$list_file = Less_Cache::$cache_dir . Less_Cache::$prefix . $hash . '.list';
|
$list_file = self::$cache_dir . self::$prefix . $hash . '.list';
|
||||||
|
|
||||||
// check cached content
|
// check cached content
|
||||||
if ( !isset( $parser_options['use_cache'] ) || $parser_options['use_cache'] === true ) {
|
if ( !isset( $parser_options['use_cache'] ) || $parser_options['use_cache'] === true ) {
|
||||||
@ -129,19 +123,13 @@ class Less_Cache {
|
|||||||
* @param array $modify_vars Array of variables
|
* @param array $modify_vars Array of variables
|
||||||
* @return string Name of the css file
|
* @return string Name of the css file
|
||||||
*/
|
*/
|
||||||
public static function Regen( $less_files, $parser_options = array(), $modify_vars = array() ) {
|
public static function Regen( $less_files, $parser_options = [], $modify_vars = [] ) {
|
||||||
$parser_options['use_cache'] = false;
|
$parser_options['use_cache'] = false;
|
||||||
return self::Get( $less_files, $parser_options, $modify_vars );
|
return self::Get( $less_files, $parser_options, $modify_vars );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function Cache( &$less_files, $parser_options = array() ) {
|
public static function Cache( &$less_files, $parser_options = [] ) {
|
||||||
// get less.php if it exists
|
$parser_options['cache_dir'] = self::$cache_dir;
|
||||||
$file = dirname( __FILE__ ) . '/Less.php';
|
|
||||||
if ( file_exists( $file ) && !class_exists( 'Less_Parser' ) ) {
|
|
||||||
require_once $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
$parser_options['cache_dir'] = Less_Cache::$cache_dir;
|
|
||||||
$parser = new Less_Parser( $parser_options );
|
$parser = new Less_Parser( $parser_options );
|
||||||
|
|
||||||
// combine files
|
// combine files
|
||||||
@ -172,54 +160,52 @@ class Less_Cache {
|
|||||||
return $parser_options['output'];
|
return $parser_options['output'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Less_Cache::$cache_dir.$parser_options['output'];
|
return self::$cache_dir . $parser_options['output'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Less_Cache::$cache_dir.$compiled_name;
|
return self::$cache_dir . $compiled_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function CompiledName( $files, $extrahash ) {
|
private static function CompiledName( $files, $extrahash ) {
|
||||||
// save the file list
|
// save the file list
|
||||||
$temp = array( Less_Version::cache_version );
|
$temp = [ Less_Version::cache_version ];
|
||||||
foreach ( $files as $file ) {
|
foreach ( $files as $file ) {
|
||||||
$temp[] = filemtime( $file )."\t".filesize( $file )."\t".$file;
|
$temp[] = filemtime( $file ) . "\t" . filesize( $file ) . "\t" . $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Less_Cache::$prefix.sha1( json_encode( $temp ).$extrahash ).'.css';
|
return self::$prefix . sha1( json_encode( $temp ) . $extrahash ) . '.css';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetCacheDir( $dir ) {
|
public static function SetCacheDir( $dir ) {
|
||||||
Less_Cache::$cache_dir = $dir;
|
self::$cache_dir = $dir;
|
||||||
self::CheckCacheDir();
|
self::CheckCacheDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CheckCacheDir() {
|
public static function CheckCacheDir() {
|
||||||
Less_Cache::$cache_dir = str_replace( '\\', '/', Less_Cache::$cache_dir );
|
self::$cache_dir = str_replace( '\\', '/', self::$cache_dir );
|
||||||
Less_Cache::$cache_dir = rtrim( Less_Cache::$cache_dir, '/' ).'/';
|
self::$cache_dir = rtrim( self::$cache_dir, '/' ) . '/';
|
||||||
|
|
||||||
if ( !file_exists( Less_Cache::$cache_dir ) ) {
|
if ( !file_exists( self::$cache_dir ) ) {
|
||||||
if ( !mkdir( Less_Cache::$cache_dir ) ) {
|
if ( !mkdir( self::$cache_dir ) ) {
|
||||||
throw new Less_Exception_Parser( 'Less.php cache directory couldn\'t be created: '.Less_Cache::$cache_dir );
|
throw new Less_Exception_Parser( 'Less.php cache directory couldn\'t be created: ' . self::$cache_dir );
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ( !is_dir( Less_Cache::$cache_dir ) ) {
|
} elseif ( !is_dir( self::$cache_dir ) ) {
|
||||||
throw new Less_Exception_Parser( 'Less.php cache directory doesn\'t exist: '.Less_Cache::$cache_dir );
|
throw new Less_Exception_Parser( 'Less.php cache directory doesn\'t exist: ' . self::$cache_dir );
|
||||||
|
|
||||||
} elseif ( !is_writable( Less_Cache::$cache_dir ) ) {
|
} elseif ( !is_writable( self::$cache_dir ) ) {
|
||||||
throw new Less_Exception_Parser( 'Less.php cache directory isn\'t writable: '.Less_Cache::$cache_dir );
|
throw new Less_Exception_Parser( 'Less.php cache directory isn\'t writable: ' . self::$cache_dir );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete unused less.php files
|
* Delete unused less.php files
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function CleanCache() {
|
public static function CleanCache() {
|
||||||
static $clean = false;
|
static $clean = false;
|
||||||
|
|
||||||
if ( $clean || empty( Less_Cache::$cache_dir ) ) {
|
if ( $clean || empty( self::$cache_dir ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,9 +213,9 @@ class Less_Cache {
|
|||||||
|
|
||||||
// only remove files with extensions created by less.php
|
// only remove files with extensions created by less.php
|
||||||
// css files removed based on the list files
|
// css files removed based on the list files
|
||||||
$remove_types = array( 'lesscache' => 1,'list' => 1,'less' => 1,'map' => 1 );
|
$remove_types = [ 'lesscache' => 1,'list' => 1,'less' => 1,'map' => 1 ];
|
||||||
|
|
||||||
$files = scandir( Less_Cache::$cache_dir );
|
$files = scandir( self::$cache_dir );
|
||||||
if ( !$files ) {
|
if ( !$files ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -238,7 +224,7 @@ class Less_Cache {
|
|||||||
foreach ( $files as $file ) {
|
foreach ( $files as $file ) {
|
||||||
|
|
||||||
// don't delete if the file wasn't created with less.php
|
// don't delete if the file wasn't created with less.php
|
||||||
if ( strpos( $file, Less_Cache::$prefix ) !== 0 ) {
|
if ( strpos( $file, self::$prefix ) !== 0 ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +235,7 @@ class Less_Cache {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$full_path = Less_Cache::$cache_dir . $file;
|
$full_path = self::$cache_dir . $file;
|
||||||
$mtime = filemtime( $full_path );
|
$mtime = filemtime( $full_path );
|
||||||
|
|
||||||
// don't delete if it's a relatively new file
|
// don't delete if it's a relatively new file
|
||||||
@ -261,7 +247,7 @@ class Less_Cache {
|
|||||||
if ( $type === 'list' ) {
|
if ( $type === 'list' ) {
|
||||||
self::ListFiles( $full_path, $list, $css_file_name );
|
self::ListFiles( $full_path, $list, $css_file_name );
|
||||||
if ( $css_file_name ) {
|
if ( $css_file_name ) {
|
||||||
$css_file = Less_Cache::$cache_dir . $css_file_name;
|
$css_file = self::$cache_dir . $css_file_name;
|
||||||
if ( file_exists( $css_file ) ) {
|
if ( file_exists( $css_file ) ) {
|
||||||
unlink( $css_file );
|
unlink( $css_file );
|
||||||
}
|
}
|
||||||
@ -270,12 +256,10 @@ class Less_Cache {
|
|||||||
|
|
||||||
unlink( $full_path );
|
unlink( $full_path );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of less files and generated css file from a list file
|
* Get the list of less files and generated css file from a list file
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static function ListFiles( $list_file, &$list, &$css_file_name ) {
|
static function ListFiles( $list_file, &$list, &$css_file_name ) {
|
||||||
$list = explode( "\n", file_get_contents( $list_file ) );
|
$list = explode( "\n", file_get_contents( $list_file ) );
|
||||||
@ -283,11 +267,10 @@ class Less_Cache {
|
|||||||
// pop the cached name that should match $compiled_name
|
// pop the cached name that should match $compiled_name
|
||||||
$css_file_name = array_pop( $list );
|
$css_file_name = array_pop( $list );
|
||||||
|
|
||||||
if ( !preg_match( '/^' . Less_Cache::$prefix . '[a-f0-9]+\.css$/', $css_file_name ) ) {
|
if ( !preg_match( '/^' . self::$prefix . '[a-f0-9]+\.css$/', $css_file_name ) ) {
|
||||||
$list[] = $css_file_name;
|
$list[] = $css_file_name;
|
||||||
$css_file_name = false;
|
$css_file_name = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
319
vendor/wikimedia/less.php/lib/Less/Colors.php
vendored
319
vendor/wikimedia/less.php/lib/Less/Colors.php
vendored
@ -1,169 +1,176 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for css colors
|
* Utility for css colors
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage color
|
|
||||||
*/
|
*/
|
||||||
class Less_Colors {
|
class Less_Colors {
|
||||||
|
|
||||||
public static $colors = array(
|
private const COLORS = [
|
||||||
'aliceblue' => '#f0f8ff',
|
'aliceblue' => '#f0f8ff',
|
||||||
'antiquewhite' => '#faebd7',
|
'antiquewhite' => '#faebd7',
|
||||||
'aqua' => '#00ffff',
|
'aqua' => '#00ffff',
|
||||||
'aquamarine' => '#7fffd4',
|
'aquamarine' => '#7fffd4',
|
||||||
'azure' => '#f0ffff',
|
'azure' => '#f0ffff',
|
||||||
'beige' => '#f5f5dc',
|
'beige' => '#f5f5dc',
|
||||||
'bisque' => '#ffe4c4',
|
'bisque' => '#ffe4c4',
|
||||||
'black' => '#000000',
|
'black' => '#000000',
|
||||||
'blanchedalmond' => '#ffebcd',
|
'blanchedalmond' => '#ffebcd',
|
||||||
'blue' => '#0000ff',
|
'blue' => '#0000ff',
|
||||||
'blueviolet' => '#8a2be2',
|
'blueviolet' => '#8a2be2',
|
||||||
'brown' => '#a52a2a',
|
'brown' => '#a52a2a',
|
||||||
'burlywood' => '#deb887',
|
'burlywood' => '#deb887',
|
||||||
'cadetblue' => '#5f9ea0',
|
'cadetblue' => '#5f9ea0',
|
||||||
'chartreuse' => '#7fff00',
|
'chartreuse' => '#7fff00',
|
||||||
'chocolate' => '#d2691e',
|
'chocolate' => '#d2691e',
|
||||||
'coral' => '#ff7f50',
|
'coral' => '#ff7f50',
|
||||||
'cornflowerblue' => '#6495ed',
|
'cornflowerblue' => '#6495ed',
|
||||||
'cornsilk' => '#fff8dc',
|
'cornsilk' => '#fff8dc',
|
||||||
'crimson' => '#dc143c',
|
'crimson' => '#dc143c',
|
||||||
'cyan' => '#00ffff',
|
'cyan' => '#00ffff',
|
||||||
'darkblue' => '#00008b',
|
'darkblue' => '#00008b',
|
||||||
'darkcyan' => '#008b8b',
|
'darkcyan' => '#008b8b',
|
||||||
'darkgoldenrod' => '#b8860b',
|
'darkgoldenrod' => '#b8860b',
|
||||||
'darkgray' => '#a9a9a9',
|
'darkgray' => '#a9a9a9',
|
||||||
'darkgrey' => '#a9a9a9',
|
'darkgrey' => '#a9a9a9',
|
||||||
'darkgreen' => '#006400',
|
'darkgreen' => '#006400',
|
||||||
'darkkhaki' => '#bdb76b',
|
'darkkhaki' => '#bdb76b',
|
||||||
'darkmagenta' => '#8b008b',
|
'darkmagenta' => '#8b008b',
|
||||||
'darkolivegreen' => '#556b2f',
|
'darkolivegreen' => '#556b2f',
|
||||||
'darkorange' => '#ff8c00',
|
'darkorange' => '#ff8c00',
|
||||||
'darkorchid' => '#9932cc',
|
'darkorchid' => '#9932cc',
|
||||||
'darkred' => '#8b0000',
|
'darkred' => '#8b0000',
|
||||||
'darksalmon' => '#e9967a',
|
'darksalmon' => '#e9967a',
|
||||||
'darkseagreen' => '#8fbc8f',
|
'darkseagreen' => '#8fbc8f',
|
||||||
'darkslateblue' => '#483d8b',
|
'darkslateblue' => '#483d8b',
|
||||||
'darkslategray' => '#2f4f4f',
|
'darkslategray' => '#2f4f4f',
|
||||||
'darkslategrey' => '#2f4f4f',
|
'darkslategrey' => '#2f4f4f',
|
||||||
'darkturquoise' => '#00ced1',
|
'darkturquoise' => '#00ced1',
|
||||||
'darkviolet' => '#9400d3',
|
'darkviolet' => '#9400d3',
|
||||||
'deeppink' => '#ff1493',
|
'deeppink' => '#ff1493',
|
||||||
'deepskyblue' => '#00bfff',
|
'deepskyblue' => '#00bfff',
|
||||||
'dimgray' => '#696969',
|
'dimgray' => '#696969',
|
||||||
'dimgrey' => '#696969',
|
'dimgrey' => '#696969',
|
||||||
'dodgerblue' => '#1e90ff',
|
'dodgerblue' => '#1e90ff',
|
||||||
'firebrick' => '#b22222',
|
'firebrick' => '#b22222',
|
||||||
'floralwhite' => '#fffaf0',
|
'floralwhite' => '#fffaf0',
|
||||||
'forestgreen' => '#228b22',
|
'forestgreen' => '#228b22',
|
||||||
'fuchsia' => '#ff00ff',
|
'fuchsia' => '#ff00ff',
|
||||||
'gainsboro' => '#dcdcdc',
|
'gainsboro' => '#dcdcdc',
|
||||||
'ghostwhite' => '#f8f8ff',
|
'ghostwhite' => '#f8f8ff',
|
||||||
'gold' => '#ffd700',
|
'gold' => '#ffd700',
|
||||||
'goldenrod' => '#daa520',
|
'goldenrod' => '#daa520',
|
||||||
'gray' => '#808080',
|
'gray' => '#808080',
|
||||||
'grey' => '#808080',
|
'grey' => '#808080',
|
||||||
'green' => '#008000',
|
'green' => '#008000',
|
||||||
'greenyellow' => '#adff2f',
|
'greenyellow' => '#adff2f',
|
||||||
'honeydew' => '#f0fff0',
|
'honeydew' => '#f0fff0',
|
||||||
'hotpink' => '#ff69b4',
|
'hotpink' => '#ff69b4',
|
||||||
'indianred' => '#cd5c5c',
|
'indianred' => '#cd5c5c',
|
||||||
'indigo' => '#4b0082',
|
'indigo' => '#4b0082',
|
||||||
'ivory' => '#fffff0',
|
'ivory' => '#fffff0',
|
||||||
'khaki' => '#f0e68c',
|
'khaki' => '#f0e68c',
|
||||||
'lavender' => '#e6e6fa',
|
'lavender' => '#e6e6fa',
|
||||||
'lavenderblush' => '#fff0f5',
|
'lavenderblush' => '#fff0f5',
|
||||||
'lawngreen' => '#7cfc00',
|
'lawngreen' => '#7cfc00',
|
||||||
'lemonchiffon' => '#fffacd',
|
'lemonchiffon' => '#fffacd',
|
||||||
'lightblue' => '#add8e6',
|
'lightblue' => '#add8e6',
|
||||||
'lightcoral' => '#f08080',
|
'lightcoral' => '#f08080',
|
||||||
'lightcyan' => '#e0ffff',
|
'lightcyan' => '#e0ffff',
|
||||||
'lightgoldenrodyellow' => '#fafad2',
|
'lightgoldenrodyellow' => '#fafad2',
|
||||||
'lightgray' => '#d3d3d3',
|
'lightgray' => '#d3d3d3',
|
||||||
'lightgrey' => '#d3d3d3',
|
'lightgrey' => '#d3d3d3',
|
||||||
'lightgreen' => '#90ee90',
|
'lightgreen' => '#90ee90',
|
||||||
'lightpink' => '#ffb6c1',
|
'lightpink' => '#ffb6c1',
|
||||||
'lightsalmon' => '#ffa07a',
|
'lightsalmon' => '#ffa07a',
|
||||||
'lightseagreen' => '#20b2aa',
|
'lightseagreen' => '#20b2aa',
|
||||||
'lightskyblue' => '#87cefa',
|
'lightskyblue' => '#87cefa',
|
||||||
'lightslategray' => '#778899',
|
'lightslategray' => '#778899',
|
||||||
'lightslategrey' => '#778899',
|
'lightslategrey' => '#778899',
|
||||||
'lightsteelblue' => '#b0c4de',
|
'lightsteelblue' => '#b0c4de',
|
||||||
'lightyellow' => '#ffffe0',
|
'lightyellow' => '#ffffe0',
|
||||||
'lime' => '#00ff00',
|
'lime' => '#00ff00',
|
||||||
'limegreen' => '#32cd32',
|
'limegreen' => '#32cd32',
|
||||||
'linen' => '#faf0e6',
|
'linen' => '#faf0e6',
|
||||||
'magenta' => '#ff00ff',
|
'magenta' => '#ff00ff',
|
||||||
'maroon' => '#800000',
|
'maroon' => '#800000',
|
||||||
'mediumaquamarine' => '#66cdaa',
|
'mediumaquamarine' => '#66cdaa',
|
||||||
'mediumblue' => '#0000cd',
|
'mediumblue' => '#0000cd',
|
||||||
'mediumorchid' => '#ba55d3',
|
'mediumorchid' => '#ba55d3',
|
||||||
'mediumpurple' => '#9370d8',
|
'mediumpurple' => '#9370d8',
|
||||||
'mediumseagreen' => '#3cb371',
|
'mediumseagreen' => '#3cb371',
|
||||||
'mediumslateblue' => '#7b68ee',
|
'mediumslateblue' => '#7b68ee',
|
||||||
'mediumspringgreen' => '#00fa9a',
|
'mediumspringgreen' => '#00fa9a',
|
||||||
'mediumturquoise' => '#48d1cc',
|
'mediumturquoise' => '#48d1cc',
|
||||||
'mediumvioletred' => '#c71585',
|
'mediumvioletred' => '#c71585',
|
||||||
'midnightblue' => '#191970',
|
'midnightblue' => '#191970',
|
||||||
'mintcream' => '#f5fffa',
|
'mintcream' => '#f5fffa',
|
||||||
'mistyrose' => '#ffe4e1',
|
'mistyrose' => '#ffe4e1',
|
||||||
'moccasin' => '#ffe4b5',
|
'moccasin' => '#ffe4b5',
|
||||||
'navajowhite' => '#ffdead',
|
'navajowhite' => '#ffdead',
|
||||||
'navy' => '#000080',
|
'navy' => '#000080',
|
||||||
'oldlace' => '#fdf5e6',
|
'oldlace' => '#fdf5e6',
|
||||||
'olive' => '#808000',
|
'olive' => '#808000',
|
||||||
'olivedrab' => '#6b8e23',
|
'olivedrab' => '#6b8e23',
|
||||||
'orange' => '#ffa500',
|
'orange' => '#ffa500',
|
||||||
'orangered' => '#ff4500',
|
'orangered' => '#ff4500',
|
||||||
'orchid' => '#da70d6',
|
'orchid' => '#da70d6',
|
||||||
'palegoldenrod' => '#eee8aa',
|
'palegoldenrod' => '#eee8aa',
|
||||||
'palegreen' => '#98fb98',
|
'palegreen' => '#98fb98',
|
||||||
'paleturquoise' => '#afeeee',
|
'paleturquoise' => '#afeeee',
|
||||||
'palevioletred' => '#d87093',
|
'palevioletred' => '#d87093',
|
||||||
'papayawhip' => '#ffefd5',
|
'papayawhip' => '#ffefd5',
|
||||||
'peachpuff' => '#ffdab9',
|
'peachpuff' => '#ffdab9',
|
||||||
'peru' => '#cd853f',
|
'peru' => '#cd853f',
|
||||||
'pink' => '#ffc0cb',
|
'pink' => '#ffc0cb',
|
||||||
'plum' => '#dda0dd',
|
'plum' => '#dda0dd',
|
||||||
'powderblue' => '#b0e0e6',
|
'powderblue' => '#b0e0e6',
|
||||||
'purple' => '#800080',
|
'purple' => '#800080',
|
||||||
'red' => '#ff0000',
|
'red' => '#ff0000',
|
||||||
'rosybrown' => '#bc8f8f',
|
'rosybrown' => '#bc8f8f',
|
||||||
'royalblue' => '#4169e1',
|
'royalblue' => '#4169e1',
|
||||||
'saddlebrown' => '#8b4513',
|
'saddlebrown' => '#8b4513',
|
||||||
'salmon' => '#fa8072',
|
'salmon' => '#fa8072',
|
||||||
'sandybrown' => '#f4a460',
|
'sandybrown' => '#f4a460',
|
||||||
'seagreen' => '#2e8b57',
|
'seagreen' => '#2e8b57',
|
||||||
'seashell' => '#fff5ee',
|
'seashell' => '#fff5ee',
|
||||||
'sienna' => '#a0522d',
|
'sienna' => '#a0522d',
|
||||||
'silver' => '#c0c0c0',
|
'silver' => '#c0c0c0',
|
||||||
'skyblue' => '#87ceeb',
|
'skyblue' => '#87ceeb',
|
||||||
'slateblue' => '#6a5acd',
|
'slateblue' => '#6a5acd',
|
||||||
'slategray' => '#708090',
|
'slategray' => '#708090',
|
||||||
'slategrey' => '#708090',
|
'slategrey' => '#708090',
|
||||||
'snow' => '#fffafa',
|
'snow' => '#fffafa',
|
||||||
'springgreen' => '#00ff7f',
|
'springgreen' => '#00ff7f',
|
||||||
'steelblue' => '#4682b4',
|
'steelblue' => '#4682b4',
|
||||||
'tan' => '#d2b48c',
|
'tan' => '#d2b48c',
|
||||||
'teal' => '#008080',
|
'teal' => '#008080',
|
||||||
'thistle' => '#d8bfd8',
|
'thistle' => '#d8bfd8',
|
||||||
'tomato' => '#ff6347',
|
'tomato' => '#ff6347',
|
||||||
'turquoise' => '#40e0d0',
|
'turquoise' => '#40e0d0',
|
||||||
'violet' => '#ee82ee',
|
'violet' => '#ee82ee',
|
||||||
'wheat' => '#f5deb3',
|
'wheat' => '#f5deb3',
|
||||||
'white' => '#ffffff',
|
'white' => '#ffffff',
|
||||||
'whitesmoke' => '#f5f5f5',
|
'whitesmoke' => '#f5f5f5',
|
||||||
'yellow' => '#ffff00',
|
'yellow' => '#ffff00',
|
||||||
'yellowgreen' => '#9acd32'
|
'yellowgreen' => '#9acd32',
|
||||||
);
|
];
|
||||||
|
|
||||||
public static function hasOwnProperty( $color ) {
|
/**
|
||||||
return isset( self::$colors[$color] );
|
* @param string $color
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function hasOwnProperty( string $color ): bool {
|
||||||
|
return isset( self::COLORS[$color] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function color( $color ) {
|
/**
|
||||||
return self::$colors[$color];
|
* @param string $color Should be an existing color name,
|
||||||
|
* checked via hasOwnProperty()
|
||||||
|
* @return string the corresponding hexadecimal representation
|
||||||
|
*/
|
||||||
|
public static function color( string $color ): string {
|
||||||
|
return self::COLORS[$color];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurable
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage Core
|
|
||||||
*/
|
*/
|
||||||
abstract class Less_Configurable {
|
abstract class Less_Configurable {
|
||||||
|
|
||||||
@ -13,14 +9,14 @@ abstract class Less_Configurable {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $options = array();
|
protected $options = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of default options
|
* Array of default options
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $defaultOptions = array();
|
protected $defaultOptions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set options
|
* Set options
|
||||||
@ -28,9 +24,7 @@ abstract class Less_Configurable {
|
|||||||
* If $options is an object it will be converted into an array by called
|
* If $options is an object it will be converted into an array by called
|
||||||
* it's toArray method.
|
* it's toArray method.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
|
||||||
* @param array|object $options
|
* @param array|object $options
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function setOptions( $options ) {
|
public function setOptions( $options ) {
|
||||||
$options = array_intersect_key( $options, $this->defaultOptions );
|
$options = array_intersect_key( $options, $this->defaultOptions );
|
||||||
|
@ -1,39 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage environment
|
|
||||||
*/
|
*/
|
||||||
class Less_Environment {
|
class Less_Environment {
|
||||||
|
|
||||||
// public $paths = array(); // option - unmodified - paths to search for imports on
|
/**
|
||||||
//public static $files = array(); // list of files that have been imported, used for import-once
|
* Information about the current file - for error reporting and importing and making urls relative etc.
|
||||||
//public $rootpath; // option - rootpath to append to URL's
|
*
|
||||||
//public static $strictImports = null; // option -
|
* - rootpath: rootpath to append to URLs
|
||||||
//public $insecure; // option - whether to allow imports from insecure ssl hosts
|
*
|
||||||
//public $processImports; // option - whether to process imports. if false then imports will not be imported
|
* @var array|null $currentFileInfo;
|
||||||
//public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true
|
*/
|
||||||
//public $useFileCache; // browser only - whether to use the per file session cache
|
public $currentFileInfo;
|
||||||
public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc.
|
|
||||||
|
|
||||||
public $importMultiple = false; // whether we are currently importing multiple copies
|
/* Whether we are currently importing multiple copies */
|
||||||
|
public $importMultiple = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $frames = array();
|
public $frames = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $mediaBlocks = array();
|
public $mediaBlocks = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $mediaPath = array();
|
public $mediaPath = [];
|
||||||
|
|
||||||
public static $parensStack = 0;
|
public static $parensStack = 0;
|
||||||
|
|
||||||
@ -48,7 +44,7 @@ class Less_Environment {
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $functions = array();
|
public $functions = [];
|
||||||
|
|
||||||
public function Init() {
|
public function Init() {
|
||||||
self::$parensStack = 0;
|
self::$parensStack = 0;
|
||||||
@ -58,7 +54,7 @@ class Less_Environment {
|
|||||||
|
|
||||||
if ( Less_Parser::$options['compress'] ) {
|
if ( Less_Parser::$options['compress'] ) {
|
||||||
|
|
||||||
Less_Environment::$_outputMap = array(
|
self::$_outputMap = [
|
||||||
',' => ',',
|
',' => ',',
|
||||||
': ' => ':',
|
': ' => ':',
|
||||||
'' => '',
|
'' => '',
|
||||||
@ -70,11 +66,11 @@ class Less_Environment {
|
|||||||
'|' => '|',
|
'|' => '|',
|
||||||
'^' => '^',
|
'^' => '^',
|
||||||
'^^' => '^^'
|
'^^' => '^^'
|
||||||
);
|
];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Less_Environment::$_outputMap = array(
|
self::$_outputMap = [
|
||||||
',' => ', ',
|
',' => ', ',
|
||||||
': ' => ': ',
|
': ' => ': ',
|
||||||
'' => '',
|
'' => '',
|
||||||
@ -86,19 +82,19 @@ class Less_Environment {
|
|||||||
'|' => '|',
|
'|' => '|',
|
||||||
'^' => ' ^ ',
|
'^' => ' ^ ',
|
||||||
'^^' => ' ^^ '
|
'^^' => ' ^^ '
|
||||||
);
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function copyEvalEnv( $frames = array() ) {
|
public function copyEvalEnv( $frames = [] ) {
|
||||||
$new_env = new Less_Environment();
|
$new_env = new Less_Environment();
|
||||||
$new_env->frames = $frames;
|
$new_env->frames = $frames;
|
||||||
return $new_env;
|
return $new_env;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isMathOn() {
|
public static function isMathOn() {
|
||||||
return !Less_Parser::$options['strictMath'] || Less_Environment::$parensStack;
|
return !Less_Parser::$options['strictMath'] || self::$parensStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isPathRelative( $path ) {
|
public static function isPathRelative( $path ) {
|
||||||
@ -108,15 +104,14 @@ class Less_Environment {
|
|||||||
/**
|
/**
|
||||||
* Canonicalize a path by resolving references to '/./', '/../'
|
* Canonicalize a path by resolving references to '/./', '/../'
|
||||||
* Does not remove leading "../"
|
* Does not remove leading "../"
|
||||||
* @param string path or url
|
* @param string $path or url
|
||||||
* @return string Canonicalized path
|
* @return string Canonicalized path
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function normalizePath( $path ) {
|
public static function normalizePath( $path ) {
|
||||||
$segments = explode( '/', $path );
|
$segments = explode( '/', $path );
|
||||||
$segments = array_reverse( $segments );
|
$segments = array_reverse( $segments );
|
||||||
|
|
||||||
$path = array();
|
$path = [];
|
||||||
$path_len = 0;
|
$path_len = 0;
|
||||||
|
|
||||||
while ( $segments ) {
|
while ( $segments ) {
|
||||||
@ -124,9 +119,10 @@ class Less_Environment {
|
|||||||
switch ( $segment ) {
|
switch ( $segment ) {
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '..':
|
case '..':
|
||||||
|
// @phan-suppress-next-line PhanTypeInvalidDimOffset False positive
|
||||||
if ( !$path_len || ( $path[$path_len - 1] === '..' ) ) {
|
if ( !$path_len || ( $path[$path_len - 1] === '..' ) ) {
|
||||||
$path[] = $segment;
|
$path[] = $segment;
|
||||||
$path_len++;
|
$path_len++;
|
||||||
@ -134,12 +130,12 @@ class Less_Environment {
|
|||||||
array_pop( $path );
|
array_pop( $path );
|
||||||
$path_len--;
|
$path_len--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$path[] = $segment;
|
$path[] = $segment;
|
||||||
$path_len++;
|
$path_len++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chunk Exception
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage exception
|
|
||||||
*/
|
*/
|
||||||
class Less_Exception_Chunk extends Less_Exception_Parser {
|
class Less_Exception_Chunk extends Less_Exception_Parser {
|
||||||
|
|
||||||
@ -15,13 +11,11 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
protected $input_len;
|
protected $input_len;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param Exception $previous Previous exception
|
* @param Exception|null $previous Previous exception
|
||||||
* @param integer $index The current parser index
|
* @param int|null $index The current parser index
|
||||||
* @param Less_FileInfo|string $currentFile The file
|
* @param array|null $currentFile The file
|
||||||
* @param integer $code The exception code
|
* @param int $code The exception code
|
||||||
*/
|
*/
|
||||||
public function __construct( $input, Exception $previous = null, $index = null, $currentFile = null, $code = 0 ) {
|
public function __construct( $input, Exception $previous = null, $index = null, $currentFile = null, $code = 0 ) {
|
||||||
$this->message = 'ParseError: Unexpected input'; // default message
|
$this->message = 'ParseError: Unexpected input'; // default message
|
||||||
@ -40,7 +34,6 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
/**
|
/**
|
||||||
* See less.js chunks()
|
* See less.js chunks()
|
||||||
* We don't actually need the chunks
|
* We don't actually need the chunks
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected function Chunks() {
|
protected function Chunks() {
|
||||||
$level = 0;
|
$level = 0;
|
||||||
@ -95,7 +88,9 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
break;
|
break;
|
||||||
// \
|
// \
|
||||||
case 92:
|
case 92:
|
||||||
if ( $this->parserCurrentIndex < $this->input_len - 1 ) { $this->parserCurrentIndex++; break;
|
if ( $this->parserCurrentIndex < $this->input_len - 1 ) {
|
||||||
|
$this->parserCurrentIndex++;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $this->fail( "unescaped `\\`" );
|
return $this->fail( "unescaped `\\`" );
|
||||||
|
|
||||||
@ -105,11 +100,12 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
case 96:
|
case 96:
|
||||||
$matched = 0;
|
$matched = 0;
|
||||||
$currentChunkStartIndex = $this->parserCurrentIndex;
|
$currentChunkStartIndex = $this->parserCurrentIndex;
|
||||||
for ( $this->parserCurrentIndex = $this->parserCurrentIndex + 1; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ) {
|
for ( $this->parserCurrentIndex += 1; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ) {
|
||||||
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
||||||
if ( $cc2 > 96 ) { continue;
|
if ( $cc2 > 96 ) { continue;
|
||||||
}
|
}
|
||||||
if ( $cc2 == $cc ) { $matched = 1; break;
|
if ( $cc2 == $cc ) { $matched = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ( $cc2 == 92 ) { // \
|
if ( $cc2 == 92 ) { // \
|
||||||
if ( $this->parserCurrentIndex == $this->input_len - 1 ) {
|
if ( $this->parserCurrentIndex == $this->input_len - 1 ) {
|
||||||
@ -129,15 +125,15 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
$cc2 = $this->CharCode( $this->parserCurrentIndex + 1 );
|
$cc2 = $this->CharCode( $this->parserCurrentIndex + 1 );
|
||||||
if ( $cc2 == 47 ) {
|
if ( $cc2 == 47 ) {
|
||||||
// //, find lnfeed
|
// //, find lnfeed
|
||||||
for ( $this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ) {
|
for ( $this->parserCurrentIndex += 2; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ) {
|
||||||
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
||||||
if ( ( $cc2 <= 13 ) && ( ( $cc2 == 10 ) || ( $cc2 == 13 ) ) ) { break;
|
if ( ( $cc2 <= 13 ) && ( ( $cc2 == 10 ) || ( $cc2 == 13 ) ) ) { break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( $cc2 == 42 ) {
|
} elseif ( $cc2 == 42 ) {
|
||||||
// /*, find */
|
// /*, find */
|
||||||
$lastMultiComment = $currentChunkStartIndex = $this->parserCurrentIndex;
|
$lastMultiComment = $currentChunkStartIndex = $this->parserCurrentIndex;
|
||||||
for ( $this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len - 1; $this->parserCurrentIndex++ ) {
|
for ( $this->parserCurrentIndex += 2; $this->parserCurrentIndex < $this->input_len - 1; $this->parserCurrentIndex++ ) {
|
||||||
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
$cc2 = $this->CharCode( $this->parserCurrentIndex );
|
||||||
if ( $cc2 == 125 ) { $lastMultiCommentEndBrace = $this->parserCurrentIndex;
|
if ( $cc2 == 125 ) { $lastMultiCommentEndBrace = $this->parserCurrentIndex;
|
||||||
}
|
}
|
||||||
@ -167,7 +163,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
} else {
|
} else {
|
||||||
return $this->fail( "missing closing `}`", $lastOpening );
|
return $this->fail( "missing closing `}`", $lastOpening );
|
||||||
}
|
}
|
||||||
} else if ( $parenLevel !== 0 ) {
|
} elseif ( $parenLevel !== 0 ) {
|
||||||
return $this->fail( "missing closing `)`", $lastParen );
|
return $this->fail( "missing closing `)`", $lastParen );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +182,7 @@ class Less_Exception_Chunk extends Less_Exception_Parser {
|
|||||||
} else {
|
} else {
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
}
|
}
|
||||||
$this->message = 'ParseError: '.$msg;
|
$this->message = 'ParseError: ' . $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiler Exception
|
* Compiler Exception
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage exception
|
|
||||||
*/
|
*/
|
||||||
class Less_Exception_Compiler extends Less_Exception_Parser {
|
class Less_Exception_Compiler extends Less_Exception_Parser {
|
||||||
|
|
||||||
|
@ -2,46 +2,36 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser Exception
|
* Parser Exception
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage exception
|
|
||||||
*/
|
*/
|
||||||
class Less_Exception_Parser extends Exception {
|
class Less_Exception_Parser extends Exception {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current file
|
* The current file
|
||||||
*
|
*
|
||||||
* @var Less_ImportedFile
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $currentFile;
|
public $currentFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current parser index
|
* The current parser index
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $index;
|
public $index;
|
||||||
|
|
||||||
protected $input;
|
protected $input;
|
||||||
|
|
||||||
protected $details = array();
|
protected $details = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* @param string|null $message
|
||||||
*
|
* @param Exception|null $previous Previous exception
|
||||||
* @param string $message
|
* @param int|null $index The current parser index
|
||||||
* @param Exception $previous Previous exception
|
* @param array|null $currentFile The file
|
||||||
* @param integer $index The current parser index
|
* @param int $code The exception code
|
||||||
* @param Less_FileInfo|string $currentFile The file
|
|
||||||
* @param integer $code The exception code
|
|
||||||
*/
|
*/
|
||||||
public function __construct( $message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0 ) {
|
public function __construct( $message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0 ) {
|
||||||
if ( PHP_VERSION_ID < 50300 ) {
|
parent::__construct( $message, $code, $previous );
|
||||||
$this->previous = $previous;
|
|
||||||
parent::__construct( $message, $code );
|
|
||||||
} else {
|
|
||||||
parent::__construct( $message, $code, $previous );
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->currentFile = $currentFile;
|
$this->currentFile = $currentFile;
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
@ -56,20 +46,18 @@ class Less_Exception_Parser extends Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the exception to string
|
* Set a message based on the exception info
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function genMessage() {
|
public function genMessage() {
|
||||||
if ( $this->currentFile && $this->currentFile['filename'] ) {
|
if ( $this->currentFile && $this->currentFile['filename'] ) {
|
||||||
$this->message .= ' in '.basename( $this->currentFile['filename'] );
|
$this->message .= ' in ' . basename( $this->currentFile['filename'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this->index !== null ) {
|
if ( $this->index !== null ) {
|
||||||
$this->getInput();
|
$this->getInput();
|
||||||
if ( $this->input ) {
|
if ( $this->input ) {
|
||||||
$line = self::getLineNumber();
|
$line = self::getLineNumber();
|
||||||
$this->message .= ' on line '.$line.', column '.self::getColumn();
|
$this->message .= ' on line ' . $line . ', column ' . self::getColumn();
|
||||||
|
|
||||||
$lines = explode( "\n", $this->input );
|
$lines = explode( "\n", $this->input );
|
||||||
|
|
||||||
@ -78,17 +66,16 @@ class Less_Exception_Parser extends Exception {
|
|||||||
$last_line = min( $count, $start_line + 6 );
|
$last_line = min( $count, $start_line + 6 );
|
||||||
$num_len = strlen( $last_line );
|
$num_len = strlen( $last_line );
|
||||||
for ( $i = $start_line; $i < $last_line; $i++ ) {
|
for ( $i = $start_line; $i < $last_line; $i++ ) {
|
||||||
$this->message .= "\n".str_pad( $i + 1, $num_len, '0', STR_PAD_LEFT ).'| '.$lines[$i];
|
$this->message .= "\n" . str_pad( (string)( $i + 1 ), $num_len, '0', STR_PAD_LEFT ) . '| ' . $lines[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the line number the error was encountered
|
* Returns the line number the error was encountered
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getLineNumber() {
|
public function getLineNumber() {
|
||||||
if ( $this->index ) {
|
if ( $this->index ) {
|
||||||
@ -105,7 +92,7 @@ class Less_Exception_Parser extends Exception {
|
|||||||
/**
|
/**
|
||||||
* Returns the column the error was encountered
|
* Returns the column the error was encountered
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getColumn() {
|
public function getColumn() {
|
||||||
$part = substr( $this->input, 0, $this->index );
|
$part = substr( $this->input, 0, $this->index );
|
||||||
|
212
vendor/wikimedia/less.php/lib/Less/Functions.php
vendored
212
vendor/wikimedia/less.php/lib/Less/Functions.php
vendored
@ -2,34 +2,33 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Builtin functions
|
* Builtin functions
|
||||||
*
|
* @see https://lesscss.org/functions/
|
||||||
* @package Less
|
|
||||||
* @subpackage function
|
|
||||||
* @see http://lesscss.org/functions/
|
|
||||||
*/
|
*/
|
||||||
class Less_Functions {
|
class Less_Functions {
|
||||||
|
|
||||||
public $env;
|
public $env;
|
||||||
public $currentFileInfo;
|
public $currentFileInfo;
|
||||||
|
|
||||||
function __construct( $env, $currentFileInfo = null ) {
|
function __construct( $env, array $currentFileInfo = null ) {
|
||||||
$this->env = $env;
|
$this->env = $env;
|
||||||
$this->currentFileInfo = $currentFileInfo;
|
$this->currentFileInfo = $currentFileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $op
|
* @param string $op
|
||||||
|
* @param float $a
|
||||||
|
* @param float $b
|
||||||
*/
|
*/
|
||||||
public static function operate( $op, $a, $b ) {
|
public static function operate( $op, $a, $b ) {
|
||||||
switch ( $op ) {
|
switch ( $op ) {
|
||||||
case '+':
|
case '+':
|
||||||
return $a + $b;
|
return $a + $b;
|
||||||
case '-':
|
case '-':
|
||||||
return $a - $b;
|
return $a - $b;
|
||||||
case '*':
|
case '*':
|
||||||
return $a * $b;
|
return $a * $b;
|
||||||
case '/':
|
case '/':
|
||||||
return $a / $b;
|
return $a / $b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +51,7 @@ return $a / $b;
|
|||||||
public static function number( $n ) {
|
public static function number( $n ) {
|
||||||
if ( $n instanceof Less_Tree_Dimension ) {
|
if ( $n instanceof Less_Tree_Dimension ) {
|
||||||
return floatval( $n->unit->is( '%' ) ? $n->value / 100 : $n->value );
|
return floatval( $n->unit->is( '%' ) ? $n->value / 100 : $n->value );
|
||||||
} else if ( is_numeric( $n ) ) {
|
} elseif ( is_numeric( $n ) ) {
|
||||||
return $n;
|
return $n;
|
||||||
} else {
|
} else {
|
||||||
throw new Less_Exception_Compiler( "color functions take numbers as parameters" );
|
throw new Less_Exception_Compiler( "color functions take numbers as parameters" );
|
||||||
@ -63,20 +62,20 @@ return $a / $b;
|
|||||||
if ( $n instanceof Less_Tree_Dimension && $n->unit->is( '%' ) ) {
|
if ( $n instanceof Less_Tree_Dimension && $n->unit->is( '%' ) ) {
|
||||||
return (float)$n->value * $size / 100;
|
return (float)$n->value * $size / 100;
|
||||||
} else {
|
} else {
|
||||||
return Less_Functions::number( $n );
|
return self::number( $n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rgb( $r = null, $g = null, $b = null ) {
|
public function rgb( $r = null, $g = null, $b = null ) {
|
||||||
if ( is_null( $r ) || is_null( $g ) || is_null( $b ) ) {
|
if ( $r === null || $g === null || $b === null ) {
|
||||||
throw new Less_Exception_Compiler( "rgb expects three parameters" );
|
throw new Less_Exception_Compiler( "rgb expects three parameters" );
|
||||||
}
|
}
|
||||||
return $this->rgba( $r, $g, $b, 1.0 );
|
return $this->rgba( $r, $g, $b, 1.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rgba( $r = null, $g = null, $b = null, $a = null ) {
|
public function rgba( $r = null, $g = null, $b = null, $a = null ) {
|
||||||
$rgb = array( $r, $g, $b );
|
$rgb = [ $r, $g, $b ];
|
||||||
$rgb = array_map( array( 'Less_Functions','scaled' ), $rgb );
|
$rgb = array_map( [ 'Less_Functions','scaled' ], $rgb );
|
||||||
|
|
||||||
$a = self::number( $a );
|
$a = self::number( $a );
|
||||||
return new Less_Tree_Color( $rgb, $a );
|
return new Less_Tree_Color( $rgb, $a );
|
||||||
@ -96,18 +95,30 @@ return $a / $b;
|
|||||||
|
|
||||||
$m1 = $l * 2 - $m2;
|
$m1 = $l * 2 - $m2;
|
||||||
|
|
||||||
return $this->rgba( self::hsla_hue( $h + 1 / 3, $m1, $m2 ) * 255,
|
return $this->rgba(
|
||||||
self::hsla_hue( $h, $m1, $m2 ) * 255,
|
self::hsla_hue( $h + 1 / 3, $m1, $m2 ) * 255,
|
||||||
self::hsla_hue( $h - 1 / 3, $m1, $m2 ) * 255,
|
self::hsla_hue( $h, $m1, $m2 ) * 255,
|
||||||
$a );
|
self::hsla_hue( $h - 1 / 3, $m1, $m2 ) * 255,
|
||||||
|
$a
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param double $h
|
* @param float $h
|
||||||
|
* @param float $m1
|
||||||
|
* @param float $m2
|
||||||
*/
|
*/
|
||||||
public function hsla_hue( $h, $m1, $m2 ) {
|
public function hsla_hue( $h, $m1, $m2 ) {
|
||||||
$h = $h < 0 ? $h + 1 : ( $h > 1 ? $h - 1 : $h );
|
$h = $h < 0 ? $h + 1 : ( $h > 1 ? $h - 1 : $h );
|
||||||
if ( $h * 6 < 1 ) return $m1 + ( $m2 - $m1 ) * $h * 6; else if ( $h * 2 < 1 ) return $m2; else if ( $h * 3 < 2 ) return $m1 + ( $m2 - $m1 ) * ( 2 / 3 - $h ) * 6; else return $m1;
|
if ( $h * 6 < 1 ) {
|
||||||
|
return $m1 + ( $m2 - $m1 ) * $h * 6;
|
||||||
|
} elseif ( $h * 2 < 1 ) {
|
||||||
|
return $m2;
|
||||||
|
} elseif ( $h * 3 < 2 ) {
|
||||||
|
return $m1 + ( $m2 - $m1 ) * ( 2 / 3 - $h ) * 6;
|
||||||
|
} else {
|
||||||
|
return $m1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hsv( $h, $s, $v ) {
|
public function hsv( $h, $s, $v ) {
|
||||||
@ -115,33 +126,42 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param double $a
|
* @param Less_Tree|float $h
|
||||||
|
* @param Less_Tree|float $s
|
||||||
|
* @param Less_Tree|float $v
|
||||||
|
* @param float $a
|
||||||
*/
|
*/
|
||||||
public function hsva( $h, $s, $v, $a ) {
|
public function hsva( $h, $s, $v, $a ) {
|
||||||
$h = ( ( Less_Functions::number( $h ) % 360 ) / 360 ) * 360;
|
$h = ( ( self::number( $h ) % 360 ) / 360 ) * 360;
|
||||||
$s = Less_Functions::number( $s );
|
$s = self::number( $s );
|
||||||
$v = Less_Functions::number( $v );
|
$v = self::number( $v );
|
||||||
$a = Less_Functions::number( $a );
|
$a = self::number( $a );
|
||||||
|
|
||||||
$i = floor( ( $h / 60 ) % 6 );
|
$i = floor( (int)( $h / 60 ) % 6 );
|
||||||
$f = ( $h / 60 ) - $i;
|
$f = ( $h / 60 ) - $i;
|
||||||
|
|
||||||
$vs = array( $v,
|
$vs = [
|
||||||
$v * ( 1 - $s ),
|
$v,
|
||||||
$v * ( 1 - $f * $s ),
|
$v * ( 1 - $s ),
|
||||||
$v * ( 1 - ( 1 - $f ) * $s ) );
|
$v * ( 1 - $f * $s ),
|
||||||
|
$v * ( 1 - ( 1 - $f ) * $s )
|
||||||
|
];
|
||||||
|
|
||||||
$perm = array( array( 0, 3, 1 ),
|
$perm = [
|
||||||
array( 2, 0, 1 ),
|
[ 0, 3, 1 ],
|
||||||
array( 1, 0, 3 ),
|
[ 2, 0, 1 ],
|
||||||
array( 1, 2, 0 ),
|
[ 1, 0, 3 ],
|
||||||
array( 3, 1, 0 ),
|
[ 1, 2, 0 ],
|
||||||
array( 0, 1, 2 ) );
|
[ 3, 1, 0 ],
|
||||||
|
[ 0, 1, 2 ]
|
||||||
|
];
|
||||||
|
|
||||||
return $this->rgba( $vs[$perm[$i][0]] * 255,
|
return $this->rgba(
|
||||||
$vs[$perm[$i][1]] * 255,
|
$vs[$perm[$i][0]] * 255,
|
||||||
$vs[$perm[$i][2]] * 255,
|
$vs[$perm[$i][1]] * 255,
|
||||||
$a );
|
$vs[$perm[$i][2]] * 255,
|
||||||
|
$a
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hue( $color = null ) {
|
public function hue( $color = null ) {
|
||||||
@ -275,7 +295,8 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Less_Tree_Dimension $amount
|
* @param Less_Tree_Color|null $color
|
||||||
|
* @param Less_Tree_Dimension|null $amount
|
||||||
*/
|
*/
|
||||||
public function desaturate( $color = null, $amount = null ) {
|
public function desaturate( $color = null, $amount = null ) {
|
||||||
if ( !$color instanceof Less_Tree_Color ) {
|
if ( !$color instanceof Less_Tree_Color ) {
|
||||||
@ -286,7 +307,6 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hsl = $color->toHSL();
|
$hsl = $color->toHSL();
|
||||||
|
|
||||||
$hsl['s'] -= $amount->value / 100;
|
$hsl['s'] -= $amount->value / 100;
|
||||||
$hsl['s'] = self::clamp( $hsl['s'] );
|
$hsl['s'] = self::clamp( $hsl['s'] );
|
||||||
|
|
||||||
@ -385,11 +405,13 @@ return $a / $b;
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
|
// Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
|
||||||
// http://sass-lang.com
|
// https://sass-lang.com/
|
||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Less_Tree_Color $color1
|
* @param Less_Tree|null $color1
|
||||||
|
* @param Less_Tree|null $color2
|
||||||
|
* @param Less_Tree|null $weight
|
||||||
*/
|
*/
|
||||||
public function mix( $color1 = null, $color2 = null, $weight = null ) {
|
public function mix( $color1 = null, $color2 = null, $weight = null ) {
|
||||||
if ( !$color1 instanceof Less_Tree_Color ) {
|
if ( !$color1 instanceof Less_Tree_Color ) {
|
||||||
@ -414,9 +436,11 @@ return $a / $b;
|
|||||||
$w1 = ( ( ( ( $w * $a ) == -1 ) ? $w : ( $w + $a ) / ( 1 + $w * $a ) ) + 1 ) / 2;
|
$w1 = ( ( ( ( $w * $a ) == -1 ) ? $w : ( $w + $a ) / ( 1 + $w * $a ) ) + 1 ) / 2;
|
||||||
$w2 = 1 - $w1;
|
$w2 = 1 - $w1;
|
||||||
|
|
||||||
$rgb = array( $color1->rgb[0] * $w1 + $color2->rgb[0] * $w2,
|
$rgb = [
|
||||||
$color1->rgb[1] * $w1 + $color2->rgb[1] * $w2,
|
$color1->rgb[0] * $w1 + $color2->rgb[0] * $w2,
|
||||||
$color1->rgb[2] * $w1 + $color2->rgb[2] * $w2 );
|
$color1->rgb[1] * $w1 + $color2->rgb[1] * $w2,
|
||||||
|
$color1->rgb[2] * $w1 + $color2->rgb[2] * $w2
|
||||||
|
];
|
||||||
|
|
||||||
$alpha = $color1->alpha * $p + $color2->alpha * ( 1 - $p );
|
$alpha = $color1->alpha * $p + $color2->alpha * ( 1 - $p );
|
||||||
|
|
||||||
@ -456,7 +480,7 @@ return $a / $b;
|
|||||||
if ( !$threshold ) {
|
if ( !$threshold ) {
|
||||||
$threshold = 0.43;
|
$threshold = 0.43;
|
||||||
} else {
|
} else {
|
||||||
$threshold = Less_Functions::number( $threshold );
|
$threshold = self::number( $threshold );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $color->luma() < $threshold ) {
|
if ( $color->luma() < $threshold ) {
|
||||||
@ -474,7 +498,7 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function escape( $str ) {
|
public function escape( $str ) {
|
||||||
$revert = array( '%21' => '!', '%2A' => '*', '%27' => "'",'%3F' => '?','%26' => '&','%2C' => ',','%2F' => '/','%40' => '@','%2B' => '+','%24' => '$' );
|
$revert = [ '%21' => '!', '%2A' => '*', '%27' => "'",'%3F' => '?','%26' => '&','%2C' => ',','%2F' => '/','%40' => '@','%2B' => '+','%24' => '$' ];
|
||||||
|
|
||||||
return new Less_Tree_Anonymous( strtr( rawurlencode( $str->value ), $revert ) );
|
return new Less_Tree_Anonymous( strtr( rawurlencode( $str->value ), $revert ) );
|
||||||
}
|
}
|
||||||
@ -486,7 +510,7 @@ return $a / $b;
|
|||||||
public function replace( $string, $pattern, $replacement, $flags = null ) {
|
public function replace( $string, $pattern, $replacement, $flags = null ) {
|
||||||
$result = $string->value;
|
$result = $string->value;
|
||||||
|
|
||||||
$expr = '/'.str_replace( '/', '\\/', $pattern->value ).'/';
|
$expr = '/' . str_replace( '/', '\\/', $pattern->value ) . '/';
|
||||||
if ( $flags && $flags->value ) {
|
if ( $flags && $flags->value ) {
|
||||||
$expr .= self::replace_flags( $flags->value );
|
$expr .= self::replace_flags( $flags->value );
|
||||||
}
|
}
|
||||||
@ -507,11 +531,11 @@ return $a / $b;
|
|||||||
switch ( $flag ) {
|
switch ( $flag ) {
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'g':
|
case 'g':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$new_flags .= $flag;
|
$new_flags .= $flag;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,7 +666,7 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
$args[0] = (float)$args[0]->value;
|
$args[0] = (float)$args[0]->value;
|
||||||
return new Less_Tree_Dimension( call_user_func_array( $fn, $args ), $unit );
|
return new Less_Tree_Dimension( call_user_func_array( $fn, $args ), $unit );
|
||||||
} else if ( is_numeric( $args[0] ) ) {
|
} elseif ( is_numeric( $args[0] ) ) {
|
||||||
return call_user_func_array( $fn, $args );
|
return call_user_func_array( $fn, $args );
|
||||||
} else {
|
} else {
|
||||||
throw new Less_Exception_Compiler( "math functions take numbers as parameters" );
|
throw new Less_Exception_Compiler( "math functions take numbers as parameters" );
|
||||||
@ -650,7 +674,8 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param boolean $isMin
|
* @param bool $isMin
|
||||||
|
* @param array<Less_Tree> $args
|
||||||
*/
|
*/
|
||||||
private function _minmax( $isMin, $args ) {
|
private function _minmax( $isMin, $args ) {
|
||||||
$arg_count = count( $args );
|
$arg_count = count( $args );
|
||||||
@ -663,18 +688,24 @@ return $a / $b;
|
|||||||
$unitClone = null;
|
$unitClone = null;
|
||||||
$unitStatic = null;
|
$unitStatic = null;
|
||||||
|
|
||||||
$order = array(); // elems only contains original argument values.
|
// elems only contains original argument values.
|
||||||
$values = array(); // key is the unit.toString() for unified tree.Dimension values,
|
$order = [];
|
||||||
// value is the index into the order array.
|
// key is the unit.toString() for unified tree.Dimension values,
|
||||||
|
// value is the index into the order array.
|
||||||
|
$values = [];
|
||||||
|
|
||||||
for ( $i = 0; $i < $arg_count; $i++ ) {
|
for ( $i = 0; $i < $arg_count; $i++ ) {
|
||||||
$current = $args[$i];
|
$current = $args[$i];
|
||||||
if ( !( $current instanceof Less_Tree_Dimension ) ) {
|
if ( !( $current instanceof Less_Tree_Dimension ) ) {
|
||||||
if ( is_array( $args[$i]->value ) ) {
|
// @phan-suppress-next-line PhanUndeclaredProperty Checked Less_Tree->value
|
||||||
|
if ( property_exists( $args[$i], 'value' ) && is_array( $args[$i]->value ) ) {
|
||||||
|
// @phan-suppress-next-line PhanUndeclaredProperty Checked Less_Tree->value
|
||||||
$args[] = $args[$i]->value;
|
$args[] = $args[$i]->value;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// PhanTypeInvalidDimOffset -- False positive, safe after continue or non-first iterations
|
||||||
|
'@phan-var non-empty-list<Less_Tree_Dimension> $order';
|
||||||
|
|
||||||
if ( $current->unit->toString() === '' && !$unitClone ) {
|
if ( $current->unit->toString() === '' && !$unitClone ) {
|
||||||
$temp = new Less_Tree_Dimension( $current->value, $unitClone );
|
$temp = new Less_Tree_Dimension( $current->value, $unitClone );
|
||||||
@ -725,11 +756,11 @@ return $a / $b;
|
|||||||
if ( count( $order ) == 1 ) {
|
if ( count( $order ) == 1 ) {
|
||||||
return $order[0];
|
return $order[0];
|
||||||
}
|
}
|
||||||
$args = array();
|
$args = [];
|
||||||
foreach ( $order as $a ) {
|
foreach ( $order as $a ) {
|
||||||
$args[] = $a->toCSS( $this->env );
|
$args[] = $a->toCSS();
|
||||||
}
|
}
|
||||||
return new Less_Tree_Anonymous( ( $isMin ? 'min(' : 'max(' ) . implode( Less_Environment::$_outputMap[','], $args ).')' );
|
return new Less_Tree_Anonymous( ( $isMin ? 'min(' : 'max(' ) . implode( Less_Environment::$_outputMap[','], $args ) . ')' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function min() {
|
public function min() {
|
||||||
@ -807,10 +838,12 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $unit
|
* @param Less_Tree $n
|
||||||
|
* @param Less_Tree|string $unit
|
||||||
*/
|
*/
|
||||||
public function isunit( $n, $unit ) {
|
public function isunit( $n, $unit ) {
|
||||||
if ( is_object( $unit ) && property_exists( $unit, 'value' ) ) {
|
if ( is_object( $unit ) && property_exists( $unit, 'value' ) ) {
|
||||||
|
// @phan-suppress-next-line PhanUndeclaredProperty Checked Less_Tree->value
|
||||||
$unit = $unit->value;
|
$unit = $unit->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,6 +851,7 @@ return $a / $b;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Less_Tree $n
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*/
|
*/
|
||||||
private function _isa( $n, $type ) {
|
private function _isa( $n, $type ) {
|
||||||
@ -866,15 +900,16 @@ return $a / $b;
|
|||||||
|
|
||||||
$filePath = str_replace( '\\', '/', $filePath );
|
$filePath = str_replace( '\\', '/', $filePath );
|
||||||
if ( Less_Environment::isPathRelative( $filePath ) ) {
|
if ( Less_Environment::isPathRelative( $filePath ) ) {
|
||||||
|
$currentFileInfo = $this->currentFileInfo;
|
||||||
|
'@phan-var array $currentFileInfo';
|
||||||
if ( Less_Parser::$options['relativeUrls'] ) {
|
if ( Less_Parser::$options['relativeUrls'] ) {
|
||||||
$temp = $this->currentFileInfo['currentDirectory'];
|
$temp = $currentFileInfo['currentDirectory'];
|
||||||
} else {
|
} else {
|
||||||
$temp = $this->currentFileInfo['entryPath'];
|
$temp = $currentFileInfo['entryPath'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty( $temp ) ) {
|
if ( !empty( $temp ) ) {
|
||||||
$filePath = Less_Environment::normalizePath( rtrim( $temp, '/' ).'/'.$filePath );
|
$filePath = Less_Environment::normalizePath( rtrim( $temp, '/' ) . '/' . $filePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -895,7 +930,7 @@ return $a / $b;
|
|||||||
$mimetype = Less_Mime::lookup( $filePath );
|
$mimetype = Less_Mime::lookup( $filePath );
|
||||||
|
|
||||||
$charset = Less_Mime::charsets_lookup( $mimetype );
|
$charset = Less_Mime::charsets_lookup( $mimetype );
|
||||||
$useBase64 = !in_array( $charset, array( 'US-ASCII', 'UTF-8' ) );
|
$useBase64 = !in_array( $charset, [ 'US-ASCII', 'UTF-8' ] );
|
||||||
if ( $useBase64 ) { $mimetype .= ';base64';
|
if ( $useBase64 ) { $mimetype .= ';base64';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,8 +949,8 @@ return $a / $b;
|
|||||||
$DATA_URI_MAX_KB = 32;
|
$DATA_URI_MAX_KB = 32;
|
||||||
$fileSizeInKB = round( strlen( $buf ) / 1024 );
|
$fileSizeInKB = round( strlen( $buf ) / 1024 );
|
||||||
if ( $fileSizeInKB >= $DATA_URI_MAX_KB ) {
|
if ( $fileSizeInKB >= $DATA_URI_MAX_KB ) {
|
||||||
$url = new Less_Tree_Url( ( $filePathNode ? $filePathNode : $mimetypeNode ), $this->currentFileInfo );
|
$url = new Less_Tree_Url( ( $filePathNode ?: $mimetypeNode ), $this->currentFileInfo );
|
||||||
return $url->compile( $this );
|
return $url->compile( $this->env );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $buf ) {
|
if ( $buf ) {
|
||||||
@ -994,9 +1029,9 @@ return $a / $b;
|
|||||||
$returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>';
|
$returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>';
|
||||||
|
|
||||||
if ( $useBase64 ) {
|
if ( $useBase64 ) {
|
||||||
$returner = "'data:image/svg+xml;base64,".base64_encode( $returner )."'";
|
$returner = "'data:image/svg+xml;base64," . base64_encode( $returner ) . "'";
|
||||||
} else {
|
} else {
|
||||||
$returner = "'data:image/svg+xml,".$returner."'";
|
$returner = "'data:image/svg+xml," . $returner . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) );
|
return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) );
|
||||||
@ -1009,17 +1044,18 @@ return $a / $b;
|
|||||||
* @return string The encoded string
|
* @return string The encoded string
|
||||||
*/
|
*/
|
||||||
public static function encodeURIComponent( $string ) {
|
public static function encodeURIComponent( $string ) {
|
||||||
$revert = array( '%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')' );
|
$revert = [ '%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')' ];
|
||||||
return strtr( rawurlencode( $string ), $revert );
|
return strtr( rawurlencode( $string ), $revert );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color Blending
|
// Color Blending
|
||||||
// ref: http://www.w3.org/TR/compositing-1
|
// ref: https://www.w3.org/TR/compositing-1/
|
||||||
|
|
||||||
public function colorBlend( $mode, $color1, $color2 ) {
|
public function colorBlend( $mode, $color1, $color2 ) {
|
||||||
$ab = $color1->alpha; // backdrop
|
// backdrop
|
||||||
$as = $color2->alpha; // source
|
$ab = $color1->alpha;
|
||||||
$r = array(); // result
|
// source
|
||||||
|
$as = $color2->alpha;
|
||||||
|
$result = [];
|
||||||
|
|
||||||
$ar = $as + $ab * ( 1 - $as );
|
$ar = $as + $ab * ( 1 - $as );
|
||||||
for ( $i = 0; $i < 3; $i++ ) {
|
for ( $i = 0; $i < 3; $i++ ) {
|
||||||
@ -1029,10 +1065,10 @@ return $a / $b;
|
|||||||
if ( $ar ) {
|
if ( $ar ) {
|
||||||
$cr = ( $as * $cs + $ab * ( $cb - $as * ( $cb + $cs - $cr ) ) ) / $ar;
|
$cr = ( $as * $cs + $ab * ( $cb - $as * ( $cb + $cs - $cr ) ) ) / $ar;
|
||||||
}
|
}
|
||||||
$r[$i] = $cr * 255;
|
$result[$i] = $cr * 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Less_Tree_Color( $r, $ar );
|
return new Less_Tree_Color( $result, $ar );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function multiply( $color1 = null, $color2 = null ) {
|
public function multiply( $color1 = null, $color2 = null ) {
|
||||||
@ -1043,7 +1079,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to multiply must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to multiply must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendMultiply' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendMultiply' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendMultiply( $cb, $cs ) {
|
private function colorBlendMultiply( $cb, $cs ) {
|
||||||
@ -1058,7 +1094,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to screen must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to screen must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendScreen' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendScreen' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendScreen( $cb, $cs ) {
|
private function colorBlendScreen( $cb, $cs ) {
|
||||||
@ -1073,7 +1109,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to overlay must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to overlay must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendOverlay' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendOverlay' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendOverlay( $cb, $cs ) {
|
private function colorBlendOverlay( $cb, $cs ) {
|
||||||
@ -1091,7 +1127,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to softlight must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to softlight must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendSoftlight' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendSoftlight' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendSoftlight( $cb, $cs ) {
|
private function colorBlendSoftlight( $cb, $cs ) {
|
||||||
@ -1113,7 +1149,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to hardlight must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to hardlight must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendHardlight' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendHardlight' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendHardlight( $cb, $cs ) {
|
private function colorBlendHardlight( $cb, $cs ) {
|
||||||
@ -1128,7 +1164,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to difference must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to difference must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendDifference' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendDifference' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendDifference( $cb, $cs ) {
|
private function colorBlendDifference( $cb, $cs ) {
|
||||||
@ -1143,7 +1179,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to exclusion must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to exclusion must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendExclusion' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendExclusion' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colorBlendExclusion( $cb, $cs ) {
|
private function colorBlendExclusion( $cb, $cs ) {
|
||||||
@ -1158,7 +1194,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to average must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to average must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendAverage' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendAverage' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// non-w3c functions:
|
// non-w3c functions:
|
||||||
@ -1174,7 +1210,7 @@ return $a / $b;
|
|||||||
throw new Less_Exception_Compiler( 'The second argument to negation must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
throw new Less_Exception_Compiler( 'The second argument to negation must be a color' . ( $color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->colorBlend( array( $this,'colorBlendNegation' ), $color1, $color2 );
|
return $this->colorBlend( [ $this,'colorBlendNegation' ], $color1, $color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function colorBlendNegation( $cb, $cs ) {
|
public function colorBlendNegation( $cb, $cs ) {
|
||||||
|
37
vendor/wikimedia/less.php/lib/Less/Mime.php
vendored
37
vendor/wikimedia/less.php/lib/Less/Mime.php
vendored
@ -1,37 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mime lookup
|
* Mime lookup
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage node
|
|
||||||
*/
|
*/
|
||||||
class Less_Mime {
|
class Less_Mime {
|
||||||
|
|
||||||
// this map is intentionally incomplete
|
// this map is intentionally incomplete
|
||||||
// if you want more, install 'mime' dep
|
// if you want more, install 'mime' dep
|
||||||
static $_types = array(
|
private static $types = [
|
||||||
'.htm' => 'text/html',
|
'.htm' => 'text/html',
|
||||||
'.html' => 'text/html',
|
'.html' => 'text/html',
|
||||||
'.gif' => 'image/gif',
|
'.gif' => 'image/gif',
|
||||||
'.jpg' => 'image/jpeg',
|
'.jpg' => 'image/jpeg',
|
||||||
'.jpeg' => 'image/jpeg',
|
'.jpeg' => 'image/jpeg',
|
||||||
'.png' => 'image/png',
|
'.png' => 'image/png',
|
||||||
'.ttf' => 'application/x-font-ttf',
|
'.ttf' => 'application/x-font-ttf',
|
||||||
'.otf' => 'application/x-font-otf',
|
'.otf' => 'application/x-font-otf',
|
||||||
'.eot' => 'application/vnd.ms-fontobject',
|
'.eot' => 'application/vnd.ms-fontobject',
|
||||||
'.woff' => 'application/x-font-woff',
|
'.woff' => 'application/x-font-woff',
|
||||||
'.svg' => 'image/svg+xml',
|
'.svg' => 'image/svg+xml',
|
||||||
);
|
];
|
||||||
|
|
||||||
public static function lookup( $filepath ) {
|
public static function lookup( $filepath ) {
|
||||||
$parts = explode( '.', $filepath );
|
$parts = explode( '.', $filepath );
|
||||||
$ext = '.'.strtolower( array_pop( $parts ) );
|
$ext = '.' . strtolower( array_pop( $parts ) );
|
||||||
|
|
||||||
if ( !isset( self::$_types[$ext] ) ) {
|
return self::$types[$ext] ?? null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return self::$_types[$ext];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function charsets_lookup( $type = null ) {
|
public static function charsets_lookup( $type = null ) {
|
||||||
|
14
vendor/wikimedia/less.php/lib/Less/Output.php
vendored
14
vendor/wikimedia/less.php/lib/Less/Output.php
vendored
@ -1,26 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser output
|
* Parser output
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage output
|
|
||||||
*/
|
*/
|
||||||
class Less_Output {
|
class Less_Output {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output holder
|
* Output holder
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $strs = array();
|
protected $strs = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a chunk to the stack
|
* Adds a chunk to the stack
|
||||||
*
|
*
|
||||||
* @param string $chunk The chunk to output
|
* @param string $chunk The chunk to output
|
||||||
* @param Less_FileInfo $fileInfo The file information
|
* @param array|null $fileInfo The file information
|
||||||
* @param integer $index The index
|
* @param int $index The index
|
||||||
* @param mixed $mapLines
|
* @param mixed $mapLines
|
||||||
*/
|
*/
|
||||||
public function add( $chunk, $fileInfo = null, $index = 0, $mapLines = null ) {
|
public function add( $chunk, $fileInfo = null, $index = 0, $mapLines = null ) {
|
||||||
@ -30,7 +28,7 @@ class Less_Output {
|
|||||||
/**
|
/**
|
||||||
* Is the output empty?
|
* Is the output empty?
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isEmpty() {
|
public function isEmpty() {
|
||||||
return count( $this->strs ) === 0;
|
return count( $this->strs ) === 0;
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser output with source map
|
* Parser output with source map
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage Output
|
|
||||||
*/
|
*/
|
||||||
class Less_Output_Mapped extends Less_Output {
|
class Less_Output_Mapped extends Less_Output {
|
||||||
|
|
||||||
@ -18,14 +16,14 @@ class Less_Output_Mapped extends Less_Output {
|
|||||||
/**
|
/**
|
||||||
* Current line
|
* Current line
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $lineNumber = 0;
|
protected $lineNumber = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current column
|
* Current column
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $column = 0;
|
protected $column = 0;
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ class Less_Output_Mapped extends Less_Output {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $contentsMap = array();
|
protected $contentsMap = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -52,8 +50,8 @@ class Less_Output_Mapped extends Less_Output {
|
|||||||
* The $index for less.php may be different from less.js since less.php does not chunkify inputs
|
* The $index for less.php may be different from less.js since less.php does not chunkify inputs
|
||||||
*
|
*
|
||||||
* @param string $chunk
|
* @param string $chunk
|
||||||
* @param string $fileInfo
|
* @param array|null $fileInfo
|
||||||
* @param integer $index
|
* @param int $index
|
||||||
* @param mixed $mapLines
|
* @param mixed $mapLines
|
||||||
*/
|
*/
|
||||||
public function add( $chunk, $fileInfo = null, $index = 0, $mapLines = null ) {
|
public function add( $chunk, $fileInfo = null, $index = 0, $mapLines = null ) {
|
||||||
@ -62,7 +60,7 @@ class Less_Output_Mapped extends Less_Output {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourceLines = array();
|
$sourceLines = [];
|
||||||
$sourceColumns = ' ';
|
$sourceColumns = ' ';
|
||||||
|
|
||||||
if ( $fileInfo ) {
|
if ( $fileInfo ) {
|
||||||
@ -74,7 +72,7 @@ class Less_Output_Mapped extends Less_Output {
|
|||||||
$sourceLines = explode( "\n", $inputSource );
|
$sourceLines = explode( "\n", $inputSource );
|
||||||
$sourceColumns = end( $sourceLines );
|
$sourceColumns = end( $sourceLines );
|
||||||
} else {
|
} else {
|
||||||
throw new Exception( 'Filename '.$url.' not in contentsMap' );
|
throw new Exception( 'Filename ' . $url . ' not in contentsMap' );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1018
vendor/wikimedia/less.php/lib/Less/Parser.php
vendored
1018
vendor/wikimedia/less.php/lib/Less/Parser.php
vendored
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode / Decode Base64 VLQ.
|
* Encode / Decode Base64 VLQ.
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage SourceMap
|
|
||||||
*/
|
*/
|
||||||
class Less_SourceMap_Base64VLQ {
|
class Less_SourceMap_Base64VLQ {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift
|
* Shift
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $shift = 5;
|
private $shift = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mask
|
* Mask
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $mask = 0x1F; // == (1 << shift) == 0b00011111
|
private $mask = 0x1F; // == (1 << shift) == 0b00011111
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Continuation bit
|
* Continuation bit
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $continuationBit = 0x20; // == (mask - 1 ) == 0b00100000
|
private $continuationBit = 0x20; // == (mask - 1 ) == 0b00100000
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $charToIntMap = array(
|
private $charToIntMap = [
|
||||||
'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6,
|
'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6,
|
||||||
'H' => 7,'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13,
|
'H' => 7,'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13,
|
||||||
'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20,
|
'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20,
|
||||||
@ -44,14 +42,14 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48,
|
'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48,
|
||||||
'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56,
|
'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56,
|
||||||
5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63,
|
5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63,
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integer to char map
|
* Integer to char map
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $intToCharMap = array(
|
private $intToCharMap = [
|
||||||
0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G',
|
0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G',
|
||||||
7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N',
|
7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N',
|
||||||
14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U',
|
14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U',
|
||||||
@ -62,7 +60,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3',
|
49 => 'x', 50 => 'y', 51 => 'z', 52 => '0', 53 => '1', 54 => '2', 55 => '3',
|
||||||
56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+',
|
56 => '4', 57 => '5', 58 => '6', 59 => '7', 60 => '8', 61 => '9', 62 => '+',
|
||||||
63 => '/',
|
63 => '/',
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -83,7 +81,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
||||||
* We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297,
|
* We generate the value for 32 bit machines, hence -2147483648 becomes 1, not 4294967297,
|
||||||
* even on a 64 bit machine.
|
* even on a 64 bit machine.
|
||||||
* @param string $aValue
|
* @param int $aValue
|
||||||
*/
|
*/
|
||||||
public function toVLQSigned( $aValue ) {
|
public function toVLQSigned( $aValue ) {
|
||||||
return 0xffffffff & ( $aValue < 0 ? ( ( -$aValue ) << 1 ) + 1 : ( $aValue << 1 ) + 0 );
|
return 0xffffffff & ( $aValue < 0 ? ( ( -$aValue ) << 1 ) + 1 : ( $aValue << 1 ) + 0 );
|
||||||
@ -98,7 +96,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
* Hence
|
* Hence
|
||||||
* 1 becomes -2147483648
|
* 1 becomes -2147483648
|
||||||
* even on a 64 bit machine.
|
* even on a 64 bit machine.
|
||||||
* @param integer $aValue
|
* @param int $aValue
|
||||||
*/
|
*/
|
||||||
public function fromVLQSigned( $aValue ) {
|
public function fromVLQSigned( $aValue ) {
|
||||||
return $aValue & 1 ? $this->zeroFill( ~$aValue + 2, 1 ) | ( -1 - 0x7fffffff ) : $this->zeroFill( $aValue, 1 );
|
return $aValue & 1 ? $this->zeroFill( ~$aValue + 2, 1 ) | ( -1 - 0x7fffffff ) : $this->zeroFill( $aValue, 1 );
|
||||||
@ -107,7 +105,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
/**
|
/**
|
||||||
* Return the base 64 VLQ encoded value.
|
* Return the base 64 VLQ encoded value.
|
||||||
*
|
*
|
||||||
* @param string $aValue The value to encode
|
* @param int $aValue The value to encode
|
||||||
* @return string The encoded value
|
* @return string The encoded value
|
||||||
*/
|
*/
|
||||||
public function encode( $aValue ) {
|
public function encode( $aValue ) {
|
||||||
@ -130,7 +128,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
* Return the value decoded from base 64 VLQ.
|
* Return the value decoded from base 64 VLQ.
|
||||||
*
|
*
|
||||||
* @param string $encoded The encoded value to decode
|
* @param string $encoded The encoded value to decode
|
||||||
* @return integer The decoded value
|
* @return int The decoded value
|
||||||
*/
|
*/
|
||||||
public function decode( $encoded ) {
|
public function decode( $encoded ) {
|
||||||
$vlq = 0;
|
$vlq = 0;
|
||||||
@ -148,9 +146,9 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
/**
|
/**
|
||||||
* Right shift with zero fill.
|
* Right shift with zero fill.
|
||||||
*
|
*
|
||||||
* @param integer $a number to shift
|
* @param int $a number to shift
|
||||||
* @param integer $b number of bits to shift
|
* @param int $b number of bits to shift
|
||||||
* @return integer
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function zeroFill( $a, $b ) {
|
public function zeroFill( $a, $b ) {
|
||||||
return ( $a >= 0 ) ? ( $a >> $b ) : ( $a >> $b ) & ( PHP_INT_MAX >> ( $b - 1 ) );
|
return ( $a >= 0 ) ? ( $a >> $b ) : ( $a >> $b ) & ( PHP_INT_MAX >> ( $b - 1 ) );
|
||||||
@ -159,13 +157,13 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
/**
|
/**
|
||||||
* Encode single 6-bit digit as base64.
|
* Encode single 6-bit digit as base64.
|
||||||
*
|
*
|
||||||
* @param integer $number
|
* @param int $number
|
||||||
* @return string
|
* @return string
|
||||||
* @throws Exception If the number is invalid
|
* @throws Exception If the number is invalid
|
||||||
*/
|
*/
|
||||||
public function base64Encode( $number ) {
|
public function base64Encode( $number ) {
|
||||||
if ( $number < 0 || $number > 63 ) {
|
if ( $number < 0 || $number > 63 ) {
|
||||||
throw new Exception( sprintf( 'Invalid number "%s" given. Must be between 0 and 63.', $number ) );
|
throw new Exception( sprintf( 'Invalid number "%s" given. Must be between 0 and 63.', (string)$number ) );
|
||||||
}
|
}
|
||||||
return $this->intToCharMap[$number];
|
return $this->intToCharMap[$number];
|
||||||
}
|
}
|
||||||
@ -174,7 +172,7 @@ class Less_SourceMap_Base64VLQ {
|
|||||||
* Decode single 6-bit digit from base64
|
* Decode single 6-bit digit from base64
|
||||||
*
|
*
|
||||||
* @param string $char
|
* @param string $char
|
||||||
* @return number
|
* @return int
|
||||||
* @throws Exception If the number is invalid
|
* @throws Exception If the number is invalid
|
||||||
*/
|
*/
|
||||||
public function base64Decode( $char ) {
|
public function base64Decode( $char ) {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Source map generator
|
* Source map generator
|
||||||
*
|
*
|
||||||
* @package Less
|
* @private
|
||||||
* @subpackage Output
|
|
||||||
*/
|
*/
|
||||||
class Less_SourceMap_Generator extends Less_Configurable {
|
class Less_SourceMap_Generator extends Less_Configurable {
|
||||||
|
|
||||||
@ -18,7 +16,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $defaultOptions = array(
|
protected $defaultOptions = [
|
||||||
// an optional source root, useful for relocating source files
|
// an optional source root, useful for relocating source files
|
||||||
// on a server or removing repeated values in the 'sources' entry.
|
// on a server or removing repeated values in the 'sources' entry.
|
||||||
// This value is prepended to the individual entries in the 'source' field.
|
// This value is prepended to the individual entries in the 'source' field.
|
||||||
@ -41,7 +39,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
|
|
||||||
// base path for filename normalization
|
// base path for filename normalization
|
||||||
'sourceMapBasepath' => ''
|
'sourceMapBasepath' => ''
|
||||||
);
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base64 VLQ encoder
|
* The base64 VLQ encoder
|
||||||
@ -55,7 +53,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $mappings = array();
|
protected $mappings = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The root node
|
* The root node
|
||||||
@ -69,23 +67,24 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $contentsMap = array();
|
protected $contentsMap = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File to content map
|
* File to content map
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $sources = array();
|
protected $sources = [];
|
||||||
protected $source_keys = array();
|
protected $source_keys = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param Less_Tree_Ruleset $root The root node
|
* @param Less_Tree_Ruleset $root The root node
|
||||||
|
* @param array $contentsMap
|
||||||
* @param array $options Array of options
|
* @param array $options Array of options
|
||||||
*/
|
*/
|
||||||
public function __construct( Less_Tree_Ruleset $root, $contentsMap, $options = array() ) {
|
public function __construct( Less_Tree_Ruleset $root, $contentsMap, $options = [] ) {
|
||||||
$this->root = $root;
|
$this->root = $root;
|
||||||
$this->contentsMap = $contentsMap;
|
$this->contentsMap = $contentsMap;
|
||||||
$this->encoder = new Less_SourceMap_Base64VLQ();
|
$this->encoder = new Less_SourceMap_Base64VLQ();
|
||||||
@ -182,20 +181,20 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
/**
|
/**
|
||||||
* Adds a mapping
|
* Adds a mapping
|
||||||
*
|
*
|
||||||
* @param integer $generatedLine The line number in generated file
|
* @param int $generatedLine The line number in generated file
|
||||||
* @param integer $generatedColumn The column number in generated file
|
* @param int $generatedColumn The column number in generated file
|
||||||
* @param integer $originalLine The line number in original file
|
* @param int $originalLine The line number in original file
|
||||||
* @param integer $originalColumn The column number in original file
|
* @param int $originalColumn The column number in original file
|
||||||
* @param string $sourceFile The original source file
|
* @param array $fileInfo The original source file
|
||||||
*/
|
*/
|
||||||
public function addMapping( $generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ) {
|
public function addMapping( $generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ) {
|
||||||
$this->mappings[] = array(
|
$this->mappings[] = [
|
||||||
'generated_line' => $generatedLine,
|
'generated_line' => $generatedLine,
|
||||||
'generated_column' => $generatedColumn,
|
'generated_column' => $generatedColumn,
|
||||||
'original_line' => $originalLine,
|
'original_line' => $originalLine,
|
||||||
'original_column' => $originalColumn,
|
'original_column' => $originalColumn,
|
||||||
'source_file' => $fileInfo['currentUri']
|
'source_file' => $fileInfo['currentUri']
|
||||||
);
|
];
|
||||||
|
|
||||||
$this->sources[$fileInfo['currentUri']] = $fileInfo['filename'];
|
$this->sources[$fileInfo['currentUri']] = $fileInfo['filename'];
|
||||||
}
|
}
|
||||||
@ -207,7 +206,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
* @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#
|
* @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#
|
||||||
*/
|
*/
|
||||||
protected function generateJson() {
|
protected function generateJson() {
|
||||||
$sourceMap = array();
|
$sourceMap = [];
|
||||||
$mappings = $this->generateMappings();
|
$mappings = $this->generateMappings();
|
||||||
|
|
||||||
// File version (always the first entry in the object) and must be a positive integer.
|
// File version (always the first entry in the object) and must be a positive integer.
|
||||||
@ -226,13 +225,13 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A list of original sources used by the 'mappings' entry.
|
// A list of original sources used by the 'mappings' entry.
|
||||||
$sourceMap['sources'] = array();
|
$sourceMap['sources'] = [];
|
||||||
foreach ( $this->sources as $source_uri => $source_filename ) {
|
foreach ( $this->sources as $source_uri => $source_filename ) {
|
||||||
$sourceMap['sources'][] = $this->normalizeFilename( $source_filename );
|
$sourceMap['sources'][] = $this->normalizeFilename( $source_filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
// A list of symbol names used by the 'mappings' entry.
|
// A list of symbol names used by the 'mappings' entry.
|
||||||
$sourceMap['names'] = array();
|
$sourceMap['names'] = [];
|
||||||
|
|
||||||
// A string with the encoded mapping data.
|
// A string with the encoded mapping data.
|
||||||
$sourceMap['mappings'] = $mappings;
|
$sourceMap['mappings'] = $mappings;
|
||||||
@ -261,7 +260,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
if ( empty( $this->sources ) ) {
|
if ( empty( $this->sources ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$content = array();
|
$content = [];
|
||||||
foreach ( $this->sources as $sourceFile ) {
|
foreach ( $this->sources as $sourceFile ) {
|
||||||
$content[] = file_get_contents( $sourceFile );
|
$content[] = file_get_contents( $sourceFile );
|
||||||
}
|
}
|
||||||
@ -281,7 +280,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
$this->source_keys = array_flip( array_keys( $this->sources ) );
|
$this->source_keys = array_flip( array_keys( $this->sources ) );
|
||||||
|
|
||||||
// group mappings by generated line number.
|
// group mappings by generated line number.
|
||||||
$groupedMap = $groupedMapEncoded = array();
|
$groupedMap = $groupedMapEncoded = [];
|
||||||
foreach ( $this->mappings as $m ) {
|
foreach ( $this->mappings as $m ) {
|
||||||
$groupedMap[$m['generated_line']][] = $m;
|
$groupedMap[$m['generated_line']][] = $m;
|
||||||
}
|
}
|
||||||
@ -294,7 +293,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
$groupedMapEncoded[] = ';';
|
$groupedMapEncoded[] = ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
$lineMapEncoded = array();
|
$lineMapEncoded = [];
|
||||||
$lastGeneratedColumn = 0;
|
$lastGeneratedColumn = 0;
|
||||||
|
|
||||||
foreach ( $line_map as $m ) {
|
foreach ( $line_map as $m ) {
|
||||||
@ -330,7 +329,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
* Finds the index for the filename
|
* Finds the index for the filename
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return integer|false
|
* @return int|false
|
||||||
*/
|
*/
|
||||||
protected function findFileIndex( $filename ) {
|
protected function findFileIndex( $filename ) {
|
||||||
return $this->source_keys[$filename];
|
return $this->source_keys[$filename];
|
||||||
@ -339,6 +338,7 @@ class Less_SourceMap_Generator extends Less_Configurable {
|
|||||||
/**
|
/**
|
||||||
* fix windows paths
|
* fix windows paths
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
* @param bool $addEndSlash
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function fixWindowsPath( $path, $addEndSlash = false ) {
|
public function fixWindowsPath( $path, $addEndSlash = false ) {
|
||||||
|
23
vendor/wikimedia/less.php/lib/Less/Tree.php
vendored
23
vendor/wikimedia/less.php/lib/Less/Tree.php
vendored
@ -3,12 +3,18 @@
|
|||||||
/**
|
/**
|
||||||
* Tree
|
* Tree
|
||||||
*
|
*
|
||||||
* @package Less
|
* TODO: Callers often use `property_exists(, 'value')` to distinguish
|
||||||
* @subpackage tree
|
* tree nodes that are considerd value-holding. Refactor this to move
|
||||||
|
* the 'value' property that most subclasses implement to there, and use
|
||||||
|
* something else (special value, method, or intermediate class?) to
|
||||||
|
* signal whether a subclass is considered value-holding.
|
||||||
*/
|
*/
|
||||||
class Less_Tree {
|
class Less_Tree {
|
||||||
|
|
||||||
public $cache_string;
|
public $cache_string;
|
||||||
|
public $parensInOp = false;
|
||||||
|
public $extendOnEveryPath;
|
||||||
|
public $allExtends;
|
||||||
|
|
||||||
public function toCSS() {
|
public function toCSS() {
|
||||||
$output = new Less_Output();
|
$output = new Less_Output();
|
||||||
@ -25,7 +31,12 @@ class Less_Tree {
|
|||||||
public function genCSS( $output ) {
|
public function genCSS( $output ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function compile( $env ) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Less_Output $output
|
||||||
* @param Less_Tree_Ruleset[] $rules
|
* @param Less_Tree_Ruleset[] $rules
|
||||||
*/
|
*/
|
||||||
public static function outputRuleset( $output, $rules ) {
|
public static function outputRuleset( $output, $rules ) {
|
||||||
@ -45,8 +56,8 @@ class Less_Tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Non-compressed
|
// Non-compressed
|
||||||
$tabSetStr = "\n".str_repeat( Less_Parser::$options['indentation'], Less_Environment::$tabLevel - 1 );
|
$tabSetStr = "\n" . str_repeat( Less_Parser::$options['indentation'], Less_Environment::$tabLevel - 1 );
|
||||||
$tabRuleStr = $tabSetStr.Less_Parser::$options['indentation'];
|
$tabRuleStr = $tabSetStr . Less_Parser::$options['indentation'];
|
||||||
|
|
||||||
$output->add( " {" );
|
$output->add( " {" );
|
||||||
for ( $i = 0; $i < $ruleCnt; $i++ ) {
|
for ( $i = 0; $i < $ruleCnt; $i++ ) {
|
||||||
@ -54,8 +65,7 @@ class Less_Tree {
|
|||||||
$rules[$i]->genCSS( $output );
|
$rules[$i]->genCSS( $output );
|
||||||
}
|
}
|
||||||
Less_Environment::$tabLevel--;
|
Less_Environment::$tabLevel--;
|
||||||
$output->add( $tabSetStr.'}' );
|
$output->add( $tabSetStr . '}' );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function accept( $visitor ) {
|
public function accept( $visitor ) {
|
||||||
@ -64,6 +74,7 @@ class Less_Tree {
|
|||||||
public static function ReferencedArray( $rules ) {
|
public static function ReferencedArray( $rules ) {
|
||||||
foreach ( $rules as $rule ) {
|
foreach ( $rules as $rule ) {
|
||||||
if ( method_exists( $rule, 'markReferenced' ) ) {
|
if ( method_exists( $rule, 'markReferenced' ) ) {
|
||||||
|
// @phan-suppress-next-line PhanUndeclaredMethod
|
||||||
$rule->markReferenced();
|
$rule->markReferenced();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alpha
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage tree
|
|
||||||
*/
|
*/
|
||||||
class Less_Tree_Alpha extends Less_Tree {
|
class Less_Tree_Alpha extends Less_Tree {
|
||||||
public $value;
|
public $value;
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anonymous
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage tree
|
|
||||||
*/
|
*/
|
||||||
class Less_Tree_Anonymous extends Less_Tree {
|
class Less_Tree_Anonymous extends Less_Tree {
|
||||||
public $value;
|
public $value;
|
||||||
@ -15,8 +11,8 @@ class Less_Tree_Anonymous extends Less_Tree {
|
|||||||
public $type = 'Anonymous';
|
public $type = 'Anonymous';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $index
|
* @param int $index
|
||||||
* @param boolean $mapLines
|
* @param bool|null $mapLines
|
||||||
*/
|
*/
|
||||||
public function __construct( $value, $index = null, $currentFileInfo = null, $mapLines = null ) {
|
public function __construct( $value, $index = null, $currentFileInfo = null, $mapLines = null ) {
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
@ -25,7 +21,7 @@ class Less_Tree_Anonymous extends Less_Tree {
|
|||||||
$this->currentFileInfo = $currentFileInfo;
|
$this->currentFileInfo = $currentFileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function compile() {
|
public function compile( $env ) {
|
||||||
return new Less_Tree_Anonymous( $this->value, $this->index, $this->currentFileInfo, $this->mapLines );
|
return new Less_Tree_Anonymous( $this->value, $this->index, $this->currentFileInfo, $this->mapLines );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assignment
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage tree
|
|
||||||
*/
|
*/
|
||||||
class Less_Tree_Assignment extends Less_Tree {
|
class Less_Tree_Assignment extends Less_Tree {
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute
|
* @private
|
||||||
*
|
|
||||||
* @package Less
|
|
||||||
* @subpackage tree
|
|
||||||
*/
|
*/
|
||||||
class Less_Tree_Attribute extends Less_Tree {
|
class Less_Tree_Attribute extends Less_Tree {
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user