update libraries

This commit is contained in:
Andy Miller
2020-11-10 09:46:27 -07:00
parent c6bde87cf6
commit f851335ca9
43 changed files with 3782 additions and 1668 deletions

674
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,8 +37,8 @@ namespace Composer\Autoload;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
@@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();

268
vendor/composer/InstalledVersions.php vendored Normal file
View File

@@ -0,0 +1,268 @@
<?php
namespace Composer;
use Composer\Semver\VersionParser;
class InstalledVersions
{
private static $installed = array (
'root' =>
array (
'pretty_version' => '1.10.x-dev',
'version' => '1.10.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'a8bd391b7886f2330ce1f9906e46522125c69e47',
'name' => 'getgrav/grav-plugin-admin',
),
'versions' =>
array (
'composer/semver' =>
array (
'pretty_version' => '1.7.1',
'version' => '1.7.1.0',
'aliases' =>
array (
),
'reference' => '38276325bd896f90dfcfe30029aa5db40df387a7',
),
'getgrav/grav-plugin-admin' =>
array (
'pretty_version' => '1.10.x-dev',
'version' => '1.10.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'a8bd391b7886f2330ce1f9906e46522125c69e47',
),
'laminas/laminas-xml' =>
array (
'pretty_version' => '1.2.0',
'version' => '1.2.0.0',
'aliases' =>
array (
),
'reference' => '879cc66d1bba6a37705e98074f52a6960c220020',
),
'laminas/laminas-zendframework-bridge' =>
array (
'pretty_version' => '1.1.1',
'version' => '1.1.1.0',
'aliases' =>
array (
),
'reference' => '6ede70583e101030bcace4dcddd648f760ddf642',
),
'miniflux/picofeed' =>
array (
'replaced' =>
array (
0 => '0.1.35',
),
),
'p3k/picofeed' =>
array (
'pretty_version' => 'v0.1.40',
'version' => '0.1.40.0',
'aliases' =>
array (
),
'reference' => '356fd66d48779193b10ac28532cb4a4e11bb801c',
),
'scssphp/scssphp' =>
array (
'pretty_version' => 'v1.4.0',
'version' => '1.4.0.0',
'aliases' =>
array (
),
'reference' => 'f7c9088320e218ca42e4ef0074259a1ba24ec93a',
),
'zendframework/zendxml' =>
array (
'replaced' =>
array (
0 => '1.2.0',
),
),
),
);
public static function getInstalledPackages()
{
return array_keys(self::$installed['versions']);
}
public static function isInstalled($packageName)
{
return isset(self::$installed['versions'][$packageName]);
}
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
public static function getVersionRanges($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
$ranges = array();
if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
public static function getVersion($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['version'])) {
return null;
}
return self::$installed['versions'][$packageName]['version'];
}
public static function getPrettyVersion($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return self::$installed['versions'][$packageName]['pretty_version'];
}
public static function getReference($packageName)
{
if (!isset(self::$installed['versions'][$packageName])) {
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
if (!isset(self::$installed['versions'][$packageName]['reference'])) {
return null;
}
return self::$installed['versions'][$packageName]['reference'];
}
public static function getRootPackage()
{
return self::$installed['root'];
}
public static function getRawData()
{
return self::$installed;
}
public static function reload($data)
{
self::$installed = $data;
}
}

View File

@@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'Grav\\Plugin\\AdminPlugin' => $baseDir . '/admin.php',
);

View File

@@ -22,13 +22,15 @@ class ComposerAutoloaderInitb286bbda7f18d999afbef65014afb574
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitb286bbda7f18d999afbef65014afb574', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitb286bbda7f18d999afbef65014afb574', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb286bbda7f18d999afbef65014afb574::getInitializer($loader));
} else {

View File

@@ -64,6 +64,7 @@ class ComposerStaticInitb286bbda7f18d999afbef65014afb574
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'Grav\\Plugin\\AdminPlugin' => __DIR__ . '/../..' . '/admin.php',
);

View File

@@ -1,299 +1,333 @@
[
{
"name": "composer/semver",
"version": "1.5.1",
"version_normalized": "1.5.1.0",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/c6bea70230ef4dd483e6bbcab6005f682ed3a8de",
"reference": "c6bea70230ef4dd483e6bbcab6005f682ed3a8de",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5 || ^5.0.5"
},
"time": "2020-01-13T12:06:48+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
{
"packages": [
{
"name": "composer/semver",
"version": "1.7.1",
"version_normalized": "1.7.1.0",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "38276325bd896f90dfcfe30029aa5db40df387a7"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/38276325bd896f90dfcfe30029aa5db40df387a7",
"reference": "38276325bd896f90dfcfe30029aa5db40df387a7",
"shasum": ""
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
]
},
{
"name": "laminas/laminas-xml",
"version": "1.2.0",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-xml.git",
"reference": "879cc66d1bba6a37705e98074f52a6960c220020"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-xml/zipball/879cc66d1bba6a37705e98074f52a6960c220020",
"reference": "879cc66d1bba6a37705e98074f52a6960c220020",
"shasum": ""
},
"require": {
"laminas/laminas-zendframework-bridge": "^1.0",
"php": "^5.6 || ^7.0"
},
"replace": {
"zendframework/zendxml": "self.version"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4"
},
"time": "2019-12-31T18:05:42+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev",
"dev-develop": "1.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Laminas\\Xml\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Utility library for XML usage, best practices, and security in PHP",
"homepage": "https://laminas.dev",
"keywords": [
"laminas",
"security",
"xml"
]
},
{
"name": "laminas/laminas-zendframework-bridge",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
"reference": "4939c81f63a8a4968c108c440275c94955753b19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/4939c81f63a8a4968c108c440275c94955753b19",
"reference": "4939c81f63a8a4968c108c440275c94955753b19",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
"squizlabs/php_codesniffer": "^3.5"
},
"time": "2020-08-18T16:34:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev",
"dev-develop": "1.1.x-dev"
"require": {
"php": "^5.3.2 || ^7.0"
},
"laminas": {
"module": "Laminas\\ZendFrameworkBridge"
}
},
"installation-source": "dist",
"autoload": {
"files": [
"src/autoload.php"
"require-dev": {
"phpunit/phpunit": "^4.5 || ^5.0.5"
},
"time": "2020-09-27T13:13:07+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"psr-4": {
"Laminas\\ZendFrameworkBridge\\": "src//"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Alias legacy ZF class names to Laminas Project equivalents.",
"keywords": [
"ZendFramework",
"autoloading",
"laminas",
"zf"
],
"funding": [
{
"url": "https://funding.communitybridge.org/projects/laminas-project",
"type": "community_bridge"
}
]
},
{
"name": "p3k/picofeed",
"version": "v0.1.40",
"version_normalized": "0.1.40.0",
"source": {
"type": "git",
"url": "https://github.com/aaronpk/picofeed.git",
"reference": "356fd66d48779193b10ac28532cb4a4e11bb801c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aaronpk/picofeed/zipball/356fd66d48779193b10ac28532cb4a4e11bb801c",
"reference": "356fd66d48779193b10ac28532cb4a4e11bb801c",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"laminas/laminas-xml": "^1.2",
"php": ">=5.3.0"
},
"replace": {
"miniflux/picofeed": "0.1.35"
},
"require-dev": {
"phpdocumentor/reflection-docblock": "2.0.4",
"phpunit/phpunit": "4.8.26",
"symfony/yaml": "2.8.7"
},
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2020-04-25T17:48:36+00:00",
"bin": [
"picofeed"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoFeed": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot"
}
],
"description": "Modern library to handle RSS/Atom feeds",
"homepage": "https://github.com/aaronpk/picoFeed"
},
{
"name": "scssphp/scssphp",
"version": "1.2",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/scssphp/scssphp.git",
"reference": "ce970268a912dabbfaa0eff65dbc5e4a2a6cb757"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/ce970268a912dabbfaa0eff65dbc5e4a2a6cb757",
"reference": "ce970268a912dabbfaa0eff65dbc5e4a2a6cb757",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3",
"sass/sass-spec": "2020.08.10",
"squizlabs/php_codesniffer": "~3.5",
"twbs/bootstrap": "~4.3",
"zurb/foundation": "~6.5"
},
"time": "2020-08-26T20:47:29+00:00",
"bin": [
"bin/pscss"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"ScssPhp\\ScssPhp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthon Pang",
"email": "apang@softwaredevelopment.ca",
"homepage": "https://github.com/robocoder"
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/1.7.1"
},
{
"name": "Cédric Morin",
"email": "cedric@yterium.com",
"homepage": "https://github.com/Cerdic"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://scssphp.github.io/scssphp/",
"keywords": [
"css",
"less",
"sass",
"scss",
"stylesheet"
]
}
]
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"install-path": "./semver"
},
{
"name": "laminas/laminas-xml",
"version": "1.2.0",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-xml.git",
"reference": "879cc66d1bba6a37705e98074f52a6960c220020"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-xml/zipball/879cc66d1bba6a37705e98074f52a6960c220020",
"reference": "879cc66d1bba6a37705e98074f52a6960c220020",
"shasum": ""
},
"require": {
"laminas/laminas-zendframework-bridge": "^1.0",
"php": "^5.6 || ^7.0"
},
"replace": {
"zendframework/zendxml": "self.version"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4"
},
"time": "2019-12-31T18:05:42+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev",
"dev-develop": "1.3.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Laminas\\Xml\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Utility library for XML usage, best practices, and security in PHP",
"homepage": "https://laminas.dev",
"keywords": [
"laminas",
"security",
"xml"
],
"install-path": "../laminas/laminas-xml"
},
{
"name": "laminas/laminas-zendframework-bridge",
"version": "1.1.1",
"version_normalized": "1.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-zendframework-bridge.git",
"reference": "6ede70583e101030bcace4dcddd648f760ddf642"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6ede70583e101030bcace4dcddd648f760ddf642",
"reference": "6ede70583e101030bcace4dcddd648f760ddf642",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3",
"squizlabs/php_codesniffer": "^3.5"
},
"time": "2020-09-14T14:23:00+00:00",
"type": "library",
"extra": {
"laminas": {
"module": "Laminas\\ZendFrameworkBridge"
}
},
"installation-source": "dist",
"autoload": {
"files": [
"src/autoload.php"
],
"psr-4": {
"Laminas\\ZendFrameworkBridge\\": "src//"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Alias legacy ZF class names to Laminas Project equivalents.",
"keywords": [
"ZendFramework",
"autoloading",
"laminas",
"zf"
],
"support": {
"forum": "https://discourse.laminas.dev/",
"issues": "https://github.com/laminas/laminas-zendframework-bridge/issues",
"rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom",
"source": "https://github.com/laminas/laminas-zendframework-bridge"
},
"funding": [
{
"url": "https://funding.communitybridge.org/projects/laminas-project",
"type": "community_bridge"
}
],
"install-path": "../laminas/laminas-zendframework-bridge"
},
{
"name": "p3k/picofeed",
"version": "v0.1.40",
"version_normalized": "0.1.40.0",
"source": {
"type": "git",
"url": "https://github.com/aaronpk/picofeed.git",
"reference": "356fd66d48779193b10ac28532cb4a4e11bb801c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aaronpk/picofeed/zipball/356fd66d48779193b10ac28532cb4a4e11bb801c",
"reference": "356fd66d48779193b10ac28532cb4a4e11bb801c",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"laminas/laminas-xml": "^1.2",
"php": ">=5.3.0"
},
"replace": {
"miniflux/picofeed": "0.1.35"
},
"require-dev": {
"phpdocumentor/reflection-docblock": "2.0.4",
"phpunit/phpunit": "4.8.26",
"symfony/yaml": "2.8.7"
},
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2020-04-25T17:48:36+00:00",
"bin": [
"picofeed"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoFeed": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot"
}
],
"description": "Modern library to handle RSS/Atom feeds",
"homepage": "https://github.com/aaronpk/picoFeed",
"install-path": "../p3k/picofeed"
},
{
"name": "scssphp/scssphp",
"version": "v1.4.0",
"version_normalized": "1.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/scssphp/scssphp.git",
"reference": "f7c9088320e218ca42e4ef0074259a1ba24ec93a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/scssphp/scssphp/zipball/f7c9088320e218ca42e4ef0074259a1ba24ec93a",
"reference": "f7c9088320e218ca42e4ef0074259a1ba24ec93a",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3 || ^9.4",
"sass/sass-spec": "2020.10.29",
"squizlabs/php_codesniffer": "~3.5",
"symfony/phpunit-bridge": "^5.1",
"twbs/bootstrap": "~4.3",
"zurb/foundation": "~6.5"
},
"time": "2020-11-07T20:53:41+00:00",
"bin": [
"bin/pscss"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"ScssPhp\\ScssPhp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthon Pang",
"email": "apang@softwaredevelopment.ca",
"homepage": "https://github.com/robocoder"
},
{
"name": "Cédric Morin",
"email": "cedric@yterium.com",
"homepage": "https://github.com/Cerdic"
}
],
"description": "scssphp is a compiler for SCSS written in PHP.",
"homepage": "http://scssphp.github.io/scssphp/",
"keywords": [
"css",
"less",
"sass",
"scss",
"stylesheet"
],
"support": {
"issues": "https://github.com/scssphp/scssphp/issues",
"source": "https://github.com/scssphp/scssphp/tree/v1.4.0"
},
"install-path": "../scssphp/scssphp"
}
],
"dev": false
}

83
vendor/composer/installed.php vendored Normal file
View File

@@ -0,0 +1,83 @@
<?php return array (
'root' =>
array (
'pretty_version' => '1.10.x-dev',
'version' => '1.10.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'a8bd391b7886f2330ce1f9906e46522125c69e47',
'name' => 'getgrav/grav-plugin-admin',
),
'versions' =>
array (
'composer/semver' =>
array (
'pretty_version' => '1.7.1',
'version' => '1.7.1.0',
'aliases' =>
array (
),
'reference' => '38276325bd896f90dfcfe30029aa5db40df387a7',
),
'getgrav/grav-plugin-admin' =>
array (
'pretty_version' => '1.10.x-dev',
'version' => '1.10.9999999.9999999-dev',
'aliases' =>
array (
),
'reference' => 'a8bd391b7886f2330ce1f9906e46522125c69e47',
),
'laminas/laminas-xml' =>
array (
'pretty_version' => '1.2.0',
'version' => '1.2.0.0',
'aliases' =>
array (
),
'reference' => '879cc66d1bba6a37705e98074f52a6960c220020',
),
'laminas/laminas-zendframework-bridge' =>
array (
'pretty_version' => '1.1.1',
'version' => '1.1.1.0',
'aliases' =>
array (
),
'reference' => '6ede70583e101030bcace4dcddd648f760ddf642',
),
'miniflux/picofeed' =>
array (
'replaced' =>
array (
0 => '0.1.35',
),
),
'p3k/picofeed' =>
array (
'pretty_version' => 'v0.1.40',
'version' => '0.1.40.0',
'aliases' =>
array (
),
'reference' => '356fd66d48779193b10ac28532cb4a4e11bb801c',
),
'scssphp/scssphp' =>
array (
'pretty_version' => 'v1.4.0',
'version' => '1.4.0.0',
'aliases' =>
array (
),
'reference' => 'f7c9088320e218ca42e4ef0074259a1ba24ec93a',
),
'zendframework/zendxml' =>
array (
'replaced' =>
array (
0 => '1.2.0',
),
),
),
);

27
vendor/composer/platform_check.php vendored Normal file
View File

@@ -0,0 +1,27 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 70103)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.3". You are running ' . PHP_VERSION . '.';
}
$missingExtensions = array();
extension_loaded('ctype') || $missingExtensions[] = 'ctype';
extension_loaded('dom') || $missingExtensions[] = 'dom';
extension_loaded('iconv') || $missingExtensions[] = 'iconv';
extension_loaded('json') || $missingExtensions[] = 'json';
extension_loaded('libxml') || $missingExtensions[] = 'libxml';
extension_loaded('simplexml') || $missingExtensions[] = 'simplexml';
extension_loaded('xml') || $missingExtensions[] = 'xml';
if ($missingExtensions) {
$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', $missingExtensions);
}
if ($issues) {
echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues);
exit(104);
}

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### [1.7.1] 2020-09-27
* Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases
* Fixed: normalization of beta0 and such which was dropping the 0
### [1.7.0] 2020-09-09
* Added: support for `x || @dev`, not very useful but seen in the wild and failed to validate with 1.5.2/1.6.0
* Added: support for `foobar-dev` being equal to `dev-foobar`, dev-foobar is the official way to write it but we need to support the other for BC and convenience
### [1.6.0] 2020-09-08
* Added: support for constraints like `^2.x-dev` and `~2.x-dev`, not very useful but seen in the wild and failed to validate with 1.5.2
* Fixed: invalid aliases will no longer throw, unless explicitly validated by Composer in the root package
### [1.5.2] 2020-09-08
* Fixed: handling of some invalid -dev versions which were seen as valid
* Fixed: some doctypes
### [1.5.1] 2020-01-13
* Fixed: Parsing of aliased version was not validating the alias to be a valid version
@@ -66,6 +86,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint`
* Changed: code style using php-cs-fixer.
[1.7.1]: https://github.com/composer/semver/compare/1.7.0...1.7.1
[1.7.0]: https://github.com/composer/semver/compare/1.6.0...1.7.0
[1.6.0]: https://github.com/composer/semver/compare/1.5.2...1.6.0
[1.5.2]: https://github.com/composer/semver/compare/1.5.1...1.5.2
[1.5.1]: https://github.com/composer/semver/compare/1.5.0...1.5.1
[1.5.0]: https://github.com/composer/semver/compare/1.4.2...1.5.0
[1.4.2]: https://github.com/composer/semver/compare/1.4.1...1.4.2

View File

@@ -46,7 +46,7 @@ The `Composer\Semver\Comparator` class provides the following methods for compar
* equalTo($v1, $v2)
* notEqualTo($v1, $v2)
Each function takes two version strings as arguments. For example:
Each function takes two version strings as arguments and returns a boolean. For example:
```php
use Composer\Semver\Comparator;

View File

@@ -54,7 +54,7 @@ class Constraint implements ConstraintInterface
self::OP_NE => '!=',
);
/** @var string */
/** @var int */
protected $operator;
/** @var string */
@@ -134,7 +134,7 @@ class Constraint implements ConstraintInterface
* @param string $a
* @param string $b
* @param string $operator
* @param bool $compareBranches
* @param bool $compareBranches
*
* @throws \InvalidArgumentException if invalid operator is given.
*
@@ -167,7 +167,7 @@ class Constraint implements ConstraintInterface
/**
* @param Constraint $provider
* @param bool $compareBranches
* @param bool $compareBranches
*
* @return bool
*/

View File

@@ -30,7 +30,7 @@ class EmptyConstraint implements ConstraintInterface
}
/**
* @param $prettyString
* @param string $prettyString
*/
public function setPrettyString($prettyString)
{

View File

@@ -19,7 +19,7 @@ class MultiConstraint implements ConstraintInterface
/** @var ConstraintInterface[] */
protected $constraints;
/** @var string */
/** @var string|null */
protected $prettyString;
/** @var bool */
@@ -27,7 +27,7 @@ class MultiConstraint implements ConstraintInterface
/**
* @param ConstraintInterface[] $constraints A set of constraints
* @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
* @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
*/
public function __construct(array $constraints, $conjunctive = true)
{
@@ -86,7 +86,7 @@ class MultiConstraint implements ConstraintInterface
}
/**
* @param string $prettyString
* @param string|null $prettyString
*/
public function setPrettyString($prettyString)
{

View File

@@ -45,7 +45,7 @@ class Semver
/**
* Return all versions that satisfy given constraints.
*
* @param array $versions
* @param array $versions
* @param string $constraints
*
* @return array
@@ -85,7 +85,7 @@ class Semver
/**
* @param array $versions
* @param int $direction
* @param int $direction
*
* @return array
*/

View File

@@ -38,8 +38,8 @@ class VersionParser
*/
private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
/** @var array */
private static $stabilities = array('stable', 'RC', 'beta', 'alpha', 'dev');
/** @var string */
private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
/**
* Returns the stability of a version.
@@ -102,18 +102,21 @@ class VersionParser
public function normalize($version, $fullVersion = null)
{
$version = trim($version);
$origVersion = $version;
if (null === $fullVersion) {
$fullVersion = $version;
}
// strip off aliasing
if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
// verify that the alias is a version without constraint
$this->normalize($match[2]);
$version = $match[1];
}
// strip off stability flag
if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
$version = substr($version, 0, strlen($version) - strlen($match[0]));
}
// match master-like branches
if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) {
return '9999999-dev';
@@ -148,7 +151,7 @@ class VersionParser
if ('stable' === $matches[$index]) {
return $version;
}
$version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? ltrim($matches[$index + 1], '.-') : '');
$version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
}
if (!empty($matches[$index + 2])) {
@@ -161,19 +164,25 @@ class VersionParser
// match dev branches
if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
try {
return $this->normalizeBranch($match[1]);
$normalized = $this->normalizeBranch($match[1]);
// a branch ending with -dev is only valid if it is numeric
// if it gets prefixed with dev- it means the branch name should
// have had a dev- prefix already when passed to normalize
if (strpos($normalized, 'dev-') === false) {
return $normalized;
}
} catch (\Exception $e) {
}
}
$extraMessage = '';
if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) {
if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
$extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
} elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) {
} elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
$extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
}
throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage);
throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
}
/**
@@ -230,14 +239,6 @@ class VersionParser
{
$prettyConstraint = $constraints;
if (preg_match('{^([^,\s]*?)@(' . implode('|', self::$stabilities) . ')$}i', $constraints, $match)) {
$constraints = empty($match[1]) ? '*' : $match[1];
}
if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraints, $match)) {
$constraints = $match[1];
}
$orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
$orGroups = array();
@@ -300,18 +301,29 @@ class VersionParser
*/
private function parseConstraint($constraint)
{
if (preg_match('{^([^,\s]+?)@(' . implode('|', self::$stabilities) . ')$}i', $constraint, $match)) {
// strip off aliasing
if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
$constraint = $match[1];
}
// strip @stability flags, and keep it for later use
if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
$constraint = '' !== $match[1] ? $match[1] : '*';
if ($match[2] !== 'stable') {
$stabilityModifier = $match[2];
}
}
// get rid of #refs as those are used by composer only
if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
$constraint = $match[1];
}
if (preg_match('{^v?[xX*](\.[xX*])*$}i', $constraint)) {
return array(new EmptyConstraint());
}
$versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?' . self::$modifierRegex . '(?:\+[^\s]+)?';
$versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
// Tilde Range
//
@@ -337,9 +349,14 @@ class VersionParser
$position = 1;
}
// when matching 2.x-dev or 3.0.x-dev we have to shift the second or third number, despite no second/third number matching above
if (!empty($matches[8])) {
$position++;
}
// Calculate the stability suffix
$stabilitySuffix = '';
if (empty($matches[5]) && empty($matches[7])) {
if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
$stabilitySuffix .= '-dev';
}
@@ -375,7 +392,7 @@ class VersionParser
// Calculate the stability suffix
$stabilitySuffix = '';
if (empty($matches[5]) && empty($matches[7])) {
if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
$stabilitySuffix .= '-dev';
}
@@ -428,7 +445,7 @@ class VersionParser
if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
// Calculate the stability suffix
$lowStabilitySuffix = '';
if (empty($matches[6]) && empty($matches[8])) {
if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
$lowStabilitySuffix = '-dev';
}
@@ -439,12 +456,16 @@ class VersionParser
return ($x === 0 || $x === '0') ? false : empty($x);
};
if ((!$empty($matches[11]) && !$empty($matches[12])) || !empty($matches[14]) || !empty($matches[16])) {
if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
$highVersion = $this->normalize($matches['to']);
$upperBound = new Constraint('<=', $highVersion);
} else {
$highMatch = array('', $matches[10], $matches[11], $matches[12], $matches[13]);
$highVersion = $this->manipulateVersionString($highMatch, $empty($matches[11]) ? 1 : 2, 1) . '-dev';
$highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
// validate to version
$this->normalize($matches['to']);
$highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
$upperBound = new Constraint('<', $highVersion);
}
@@ -457,11 +478,23 @@ class VersionParser
// Basic Comparators
if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
try {
$version = $this->normalize($matches[2]);
try {
$version = $this->normalize($matches[2]);
} catch (\UnexpectedValueException $e) {
// recover from an invalid constraint like foobar-dev which should be dev-foobar
// except if the constraint uses a known operator, in which case it must be a parse error
if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
$version = $this->normalize('dev-'.substr($matches[2], 0, -4));
} else {
throw $e;
}
}
if (!empty($stabilityModifier) && self::parseStability($version) === 'stable') {
$op = $matches[1] ?: '=';
if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
$version .= '-' . $stabilityModifier;
} elseif ('<' === $matches[1] || '>=' === $matches[1]) {
} elseif ('<' === $op || '>=' === $op) {
if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
if (strpos($matches[2], 'dev-') !== 0) {
$version .= '-dev';
@@ -487,12 +520,12 @@ class VersionParser
*
* Support function for {@link parseConstraint()}
*
* @param array $matches Array with version parts in array indexes 1,2,3,4
* @param int $position 1,2,3,4 - which segment of the version to increment/decrement
* @param int $increment
* @param string $pad The string to pad version parts after $position
* @param array $matches Array with version parts in array indexes 1,2,3,4
* @param int $position 1,2,3,4 - which segment of the version to increment/decrement
* @param int $increment
* @param string $pad The string to pad version parts after $position
*
* @return string The new version
* @return string|null The new version
*/
private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
{

View File

@@ -1,4 +1,8 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
# Alternate workflow example.
# This one is identical to the one in release-on-milestone.yml, with one change:
# the Release step uses the ORGANIZATION_ADMIN_TOKEN instead, to allow it to
# trigger a release workflow event. This is useful if you have other actions
# that intercept that event.
name: "Automatic Releases"
@@ -21,7 +25,7 @@ jobs:
with:
command-name: "laminas:automatic-releases:release"
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
"GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
@@ -55,3 +59,13 @@ jobs:
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
- name: "Create new milestones"
uses: "laminas/automatic-releases@v1"
with:
command-name: "laminas:automatic-releases:create-milestones"
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
"SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }}
"GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }}
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}

View File

@@ -2,6 +2,29 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 1.1.1 - 2020-09-14
### Fixed
- [#71](https://github.com/laminas/laminas-zendframework-bridge/pull/71) fixes detection of the vendor directory when the `COMPOSER_VENDOR_DIR` env variable is missing or empty. Previously, this could lead to scenarios where a non-existent path was used for finding the bridge autoloader.
-----
### Release Notes for [1.1.1](https://github.com/laminas/laminas-zendframework-bridge/milestone/5)
### 1.1.1
- Total issues resolved: **0**
- Total pull requests resolved: **1**
- Total contributors: **1**
#### Bug
- [71: Verify `COMPOSER&#95;VENDOR&#95;DIR` in conditional](https://github.com/laminas/laminas-zendframework-bridge/pull/71) thanks to @aaronbushnell
## 1.1.0 - 2020-08-18
### Added

View File

@@ -42,10 +42,6 @@
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev",
"dev-develop": "1.1.x-dev"
},
"laminas": {
"module": "Laminas\\ZendFrameworkBridge"
}

View File

@@ -66,7 +66,7 @@ class Autoloader
*/
private static function getClassLoader()
{
if (file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) {
if (getenv('COMPOSER_VENDOR_DIR') && file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) {
return include getenv('COMPOSER_VENDOR_DIR') . '/autoload.php';
}

View File

@@ -1,7 +1,7 @@
# scssphp
### <https://scssphp.github.io/scssphp>
[![Build](https://travis-ci.org/scssphp/scssphp.svg?branch=master)](https://travis-ci.org/scssphp/scssphp)
![Build](https://github.com/scssphp/scssphp/workflows/CI/badge.svg)
[![License](https://poser.pugx.org/scssphp/scssphp/license)](https://packagist.org/packages/scssphp/scssphp)
`scssphp` is a compiler for SCSS written in PHP.
@@ -23,7 +23,7 @@ There are several tests in the `tests/` directory:
* `FailingTest.php` contains tests reported in Github issues that demonstrate compatibility bugs.
* `InputTest.php` compiles every `.scss` file in the `tests/inputs` directory
then compares to the respective `.css` file in the `tests/outputs` directory.
* `ScssTest.php` extracts (ruby) `scss` tests from the `tests/scss_test.rb` file.
* `SassSpecTest.php` extracts tests from the `sass/sass-spec` repository.
When changing any of the tests in `tests/inputs`, the tests will most likely
fail because the output has changed. Once you verify that the output is correct
@@ -31,11 +31,12 @@ you can run the following command to rebuild all the tests:
BUILD=1 vendor/bin/phpunit tests
This will compile all the tests, and save results into `tests/outputs`.
This will compile all the tests, and save results into `tests/outputs`. It also
updates the list of excluded specs from sass-spec.
To enable the `scss` compatibility tests:
To enable the full `sass-spec` compatibility tests:
TEST_SCSS_COMPAT=1 vendor/bin/phpunit tests
TEST_SASS_SPEC=1 vendor/bin/phpunit tests
## Coding Standard

View File

@@ -20,6 +20,8 @@ if (version_compare(PHP_VERSION, '5.6') < 0) {
include __DIR__ . '/../scss.inc.php';
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\ScssPhp\Exception\SassException;
use ScssPhp\ScssPhp\OutputStyle;
use ScssPhp\ScssPhp\Parser;
use ScssPhp\ScssPhp\Version;
@@ -28,8 +30,6 @@ $loadPaths = null;
$dumpTree = false;
$inputFile = null;
$changeDir = false;
$debugInfo = false;
$lineNumbers = false;
$encoding = false;
$sourceMap = false;
@@ -71,14 +71,14 @@ Options include:
--help Show this message [-h, -?]
--continue-on-error [deprecated] Ignored
--debug-info Annotate selectors with CSS referring to the source file and line number [-g]
--debug-info [deprecated] Ignored [-g]
--dump-tree Dump formatted parse tree [-T]
--iso8859-1 Use iso8859-1 encoding instead of default utf-8
--line-numbers Annotate selectors with comments referring to the source file and line number [--line-comments]
--line-numbers [deprecated] Ignored [--line-comments]
--load-path=PATH Set import path [-I]
--precision=N [deprecated] Ignored. (default 10) [-p]
--sourcemap Create source map file
--style=FORMAT Set the output format (compact, compressed, crunched, expanded, or nested) [-s, -t]
--style=FORMAT Set the output style (compressed or expanded) [-s, -t]
--version Print the version [-v]
EOT;
@@ -95,8 +95,9 @@ EOT;
continue;
}
// Keep parsing it to avoid BC breaks for scripts using it
if ($argv[$i] === '-g' || $argv[$i] === '--debug-info') {
$debugInfo = true;
// TODO report it as a warning ?
continue;
}
@@ -105,8 +106,9 @@ EOT;
continue;
}
// Keep parsing it to avoid BC breaks for scripts using it
if ($argv[$i] === '--line-numbers' || $argv[$i] === '--line-comments') {
$lineNumbers = true;
// TODO report it as a warning ?
continue;
}
@@ -151,14 +153,6 @@ EOT;
if ($inputFile) {
$data = file_get_contents($inputFile);
$newWorkingDir = dirname(realpath($inputFile));
$oldWorkingDir = getcwd();
if ($oldWorkingDir !== $newWorkingDir) {
$changeDir = chdir($newWorkingDir);
$inputFile = basename($inputFile);
}
} else {
$data = '';
@@ -177,20 +171,17 @@ if ($dumpTree) {
$scss = new Compiler();
if ($debugInfo) {
$scss->setLineNumberStyle(Compiler::DEBUG_INFO);
}
if ($lineNumbers) {
$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
}
if ($loadPaths) {
$scss->setImportPaths(explode(PATH_SEPARATOR, $loadPaths));
}
if ($style) {
$scss->setFormatter('ScssPhp\\ScssPhp\\Formatter\\' . ucfirst($style));
if ($style === OutputStyle::COMPRESSED || $style === OutputStyle::EXPANDED) {
$scss->setOutputStyle($style);
} else {
fwrite(STDERR, "WARNING: the $style style is deprecated.\n");
$scss->setFormatter('ScssPhp\\ScssPhp\\Formatter\\' . ucfirst($style));
}
}
if ($sourceMap) {
@@ -201,8 +192,9 @@ if ($encoding) {
$scss->setEncoding($encoding);
}
echo $scss->compile($data, $inputFile);
if ($changeDir) {
chdir($oldWorkingDir);
try {
echo $scss->compile($data, $inputFile);
} catch (SassException $e) {
fwrite(STDERR, $e->getMessage()."\n");
exit(1);
}

View File

@@ -31,9 +31,10 @@
"ext-ctype": "*"
},
"require-dev": {
"sass/sass-spec": "2020.08.10",
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3 || ^9.4",
"sass/sass-spec": "2020.10.29",
"squizlabs/php_codesniffer": "~3.5",
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.3",
"symfony/phpunit-bridge": "^5.1",
"twbs/bootstrap": "~4.3",
"zurb/foundation": "~6.5"
},
@@ -42,31 +43,23 @@
"type": "package",
"package": {
"name": "sass/sass-spec",
"version": "2020.08.10",
"version": "2020.10.29",
"source": {
"type": "git",
"url": "https://github.com/sass/sass-spec.git",
"reference": "73222792c42a516d62e2e25c3f5d9e35f5567030"
"reference": "07094dab93a598795e8b04caec6ceae67a43f504"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sass/sass-spec/zipball/73222792c42a516d62e2e25c3f5d9e35f5567030",
"reference": "73222792c42a516d62e2e25c3f5d9e35f5567030",
"url": "https://api.github.com/repos/sass/sass-spec/zipball/07094dab93a598795e8b04caec6ceae67a43f504",
"reference": "07094dab93a598795e8b04caec6ceae67a43f504",
"shasum": ""
}
}
}
],
"minimum-stability": "dev",
"bin": ["bin/pscss"],
"archive": {
"exclude": [
"/Makefile",
"/.gitattributes",
"/.gitignore",
"/.travis.yml",
"/phpunit.xml.dist",
"/tests"
]
"config": {
"sort-packages": true
}
}

View File

@@ -6,12 +6,14 @@ if (version_compare(PHP_VERSION, '5.6') < 0) {
if (! class_exists('ScssPhp\ScssPhp\Version', false)) {
include_once __DIR__ . '/src/Base/Range.php';
include_once __DIR__ . '/src/OutputStyle.php';
include_once __DIR__ . '/src/Block.php';
include_once __DIR__ . '/src/Cache.php';
include_once __DIR__ . '/src/Colors.php';
include_once __DIR__ . '/src/Compiler.php';
include_once __DIR__ . '/src/Compiler/Environment.php';
include_once __DIR__ . '/src/Exception/SassException.php';
include_once __DIR__ . '/src/Exception/SassScriptException.php';
include_once __DIR__ . '/src/Exception/CompilerException.php';
include_once __DIR__ . '/src/Exception/ParserException.php';
include_once __DIR__ . '/src/Exception/RangeException.php';

View File

@@ -50,7 +50,7 @@ class Block
public $sourceColumn;
/**
* @var array
* @var array|null
*/
public $selectors;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
<?php
namespace ScssPhp\ScssPhp\Exception;
/**
* An exception thrown by SassScript.
*
* This class does not implement SassException on purpose, as it should
* never be returned to the outside code. The compilation will catch it
* and replace it with a SassException reporting the location of the
* error.
*/
class SassScriptException extends \Exception
{
/**
* Creates a SassScriptException with support for an argument name.
*
* This helper ensures a consistent handling of argument names in the
* error message, without duplicating it.
*
* @param string $message
* @param string|null $name The argument name, without $
*
* @return SassScriptException
*/
public static function forArgument($message, $name = null)
{
$varDisplay = !\is_null($name) ? "\${$name}: " : '';
return new self($varDisplay . $message);
}
}

View File

@@ -310,22 +310,39 @@ abstract class Formatter
}
if ($this->sourceMapGenerator) {
$this->sourceMapGenerator->addMapping(
$this->currentLine,
$this->currentColumn,
$this->currentBlock->sourceLine,
//columns from parser are off by one
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0,
$this->currentBlock->sourceName
);
$lines = explode("\n", $str);
$lineCount = \count($lines);
$this->currentLine += $lineCount - 1;
$lastLine = array_pop($lines);
$this->currentColumn = ($lineCount === 1 ? $this->currentColumn : 0) + \strlen($lastLine);
foreach ($lines as $line) {
// If the written line starts is empty, adding a mapping would add it for
// a non-existent column as we are at the end of the line
if ($line !== '') {
$this->sourceMapGenerator->addMapping(
$this->currentLine,
$this->currentColumn,
$this->currentBlock->sourceLine,
//columns from parser are off by one
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0,
$this->currentBlock->sourceName
);
}
$this->currentLine++;
$this->currentColumn = 0;
}
if ($lastLine !== '') {
$this->sourceMapGenerator->addMapping(
$this->currentLine,
$this->currentColumn,
$this->currentBlock->sourceLine,
//columns from parser are off by one
$this->currentBlock->sourceColumn > 0 ? $this->currentBlock->sourceColumn - 1 : 0,
$this->currentBlock->sourceName
);
}
$this->currentColumn = \strlen($lastLine);
}
echo $str;

View File

@@ -18,6 +18,8 @@ use ScssPhp\ScssPhp\Formatter;
* Compact formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*
* @deprecated since 1.4.0. Use the Compressed formatter instead.
*/
class Compact extends Formatter
{
@@ -26,6 +28,8 @@ class Compact extends Formatter
*/
public function __construct()
{
@trigger_error('The Compact formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', E_USER_DEPRECATED);
$this->indentLevel = 0;
$this->indentChar = '';
$this->break = '';

View File

@@ -13,7 +13,6 @@
namespace ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter\OutputBlock;
/**
* Compressed formatter

View File

@@ -13,12 +13,13 @@
namespace ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter\OutputBlock;
/**
* Crunched formatter
*
* @author Anthon Pang <anthon.pang@gmail.com>
*
* @deprecated since 1.4.0. Use the Compressed formatter instead.
*/
class Crunched extends Formatter
{
@@ -27,6 +28,8 @@ class Crunched extends Formatter
*/
public function __construct()
{
@trigger_error('The Crunched formatter is deprecated since 1.4.0. Use the Compressed formatter instead.', E_USER_DEPRECATED);
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = '';

View File

@@ -13,12 +13,13 @@
namespace ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter\OutputBlock;
/**
* Debug formatter
*
* @author Anthon Pang <anthon.pang@gmail.com>
*
* @deprecated since 1.4.0.
*/
class Debug extends Formatter
{
@@ -27,6 +28,8 @@ class Debug extends Formatter
*/
public function __construct()
{
@trigger_error('The Debug formatter is deprecated since 1.4.0.', E_USER_DEPRECATED);
$this->indentLevel = 0;
$this->indentChar = '';
$this->break = "\n";

View File

@@ -13,7 +13,6 @@
namespace ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter\OutputBlock;
/**
* Expanded formatter

View File

@@ -13,13 +13,14 @@
namespace ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter;
use ScssPhp\ScssPhp\Formatter\OutputBlock;
use ScssPhp\ScssPhp\Type;
/**
* Nested formatter
*
* @author Leaf Corcoran <leafot@gmail.com>
*
* @deprecated since 1.4.0. Use the Expanded formatter instead.
*/
class Nested extends Formatter
{
@@ -33,6 +34,8 @@ class Nested extends Formatter
*/
public function __construct()
{
@trigger_error('The Nested formatter is deprecated since 1.4.0. Use the Expanded formatter instead.', E_USER_DEPRECATED);
$this->indentLevel = 0;
$this->indentChar = ' ';
$this->break = "\n";

View File

@@ -45,7 +45,7 @@ class OutputBlock
public $children;
/**
* @var \ScssPhp\ScssPhp\Formatter\OutputBlock
* @var OutputBlock|null
*/
public $parent;

View File

@@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Node;
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\ScssPhp\Exception\SassScriptException;
use ScssPhp\ScssPhp\Node;
use ScssPhp\ScssPhp\Type;
@@ -76,74 +77,67 @@ class Number extends Node implements \ArrayAccess
/**
* @var integer|float
*/
public $dimension;
private $dimension;
/**
* @var array
* @var string[]
* @phpstan-var list<string>
*/
public $units;
private $numeratorUnits;
/**
* @var string[]
* @phpstan-var list<string>
*/
private $denominatorUnits;
/**
* Initialize number
*
* @param mixed $dimension
* @param mixed $initialUnit
* @param integer|float $dimension
* @param string[]|string $numeratorUnits
* @param string[] $denominatorUnits
*
* @phpstan-param list<string>|string $numeratorUnits
* @phpstan-param list<string> $denominatorUnits
*/
public function __construct($dimension, $initialUnit)
public function __construct($dimension, $numeratorUnits, array $denominatorUnits = [])
{
$this->type = Type::T_NUMBER;
if (is_string($numeratorUnits)) {
$numeratorUnits = $numeratorUnits ? [$numeratorUnits] : [];
} elseif (isset($numeratorUnits['numerator_units'], $numeratorUnits['denominator_units'])) {
// TODO get rid of this once `$number[2]` is not used anymore
$denominatorUnits = $numeratorUnits['denominator_units'];
$numeratorUnits = $numeratorUnits['numerator_units'];
}
$this->dimension = $dimension;
$this->units = \is_array($initialUnit)
? $initialUnit
: ($initialUnit ? [$initialUnit => 1]
: []);
$this->numeratorUnits = $numeratorUnits;
$this->denominatorUnits = $denominatorUnits;
}
/**
* Coerce number to target units
*
* @param array $units
*
* @return \ScssPhp\ScssPhp\Node\Number
* @return float|int
*/
public function coerce($units)
public function getDimension()
{
if ($this->unitless()) {
return new Number($this->dimension, $units);
}
$dimension = $this->dimension;
if (\count($units)) {
$baseUnit = array_keys($units);
$baseUnit = reset($baseUnit);
$baseUnit = $this->findBaseUnit($baseUnit);
if ($baseUnit && isset(static::$unitTable[$baseUnit])) {
foreach (static::$unitTable[$baseUnit] as $unit => $conv) {
$from = isset($this->units[$unit]) ? $this->units[$unit] : 0;
$to = isset($units[$unit]) ? $units[$unit] : 0;
$factor = pow($conv, $from - $to);
$dimension /= $factor;
}
}
}
return new Number($dimension, $units);
return $this->dimension;
}
/**
* Normalize number
*
* @return \ScssPhp\ScssPhp\Node\Number
* @return string[]
*/
public function normalize()
public function getNumeratorUnits()
{
$dimension = $this->dimension;
$units = [];
return $this->numeratorUnits;
}
$this->normalizeUnits($dimension, $units);
return new Number($dimension, $units);
/**
* @return string[]
*/
public function getDenominatorUnits()
{
return $this->denominatorUnits;
}
/**
@@ -187,13 +181,13 @@ class Number extends Node implements \ArrayAccess
return $this->sourceIndex;
case 0:
return $this->type;
return Type::T_NUMBER;
case 1:
return $this->dimension;
case 2:
return $this->units;
return array('numerator_units' => $this->numeratorUnits, 'denominator_units' => $this->denominatorUnits);
}
}
@@ -202,17 +196,7 @@ class Number extends Node implements \ArrayAccess
*/
public function offsetSet($offset, $value)
{
if ($offset === 1) {
$this->dimension = $value;
} elseif ($offset === 2) {
$this->units = $value;
} elseif ($offset == -1) {
$this->sourceIndex = $value;
} elseif ($offset == -2) {
$this->sourceLine = $value;
} elseif ($offset == -3) {
$this->sourceColumn = $value;
}
throw new \BadMethodCallException('Number is immutable');
}
/**
@@ -220,17 +204,7 @@ class Number extends Node implements \ArrayAccess
*/
public function offsetUnset($offset)
{
if ($offset === 1) {
$this->dimension = null;
} elseif ($offset === 2) {
$this->units = null;
} elseif ($offset === -1) {
$this->sourceIndex = null;
} elseif ($offset === -2) {
$this->sourceLine = null;
} elseif ($offset === -3) {
$this->sourceColumn = null;
}
throw new \BadMethodCallException('Number is immutable');
}
/**
@@ -240,36 +214,19 @@ class Number extends Node implements \ArrayAccess
*/
public function unitless()
{
return ! array_sum($this->units);
return \count($this->numeratorUnits) === 0 && \count($this->denominatorUnits) === 0;
}
/**
* Test if a number can be normalized in a base unit
* ie if its units are homogeneous
* Checks whether the number has exactly this unit
*
* @return boolean
* @param string $unit
*
* @return bool
*/
public function isNormalizable()
public function hasUnit($unit)
{
if ($this->unitless()) {
return false;
}
$baseUnit = null;
foreach ($this->units as $unit => $exp) {
$b = $this->findBaseUnit($unit);
if (\is_null($baseUnit)) {
$baseUnit = $b;
}
if (\is_null($b) or $b !== $baseUnit) {
return false;
}
}
return $baseUnit;
return \count($this->numeratorUnits) === 1 && \count($this->denominatorUnits) === 0 && $this->numeratorUnits[0] === $unit;
}
/**
@@ -279,22 +236,234 @@ class Number extends Node implements \ArrayAccess
*/
public function unitStr()
{
$numerators = [];
$denominators = [];
foreach ($this->units as $unit => $unitSize) {
if ($unitSize > 0) {
$numerators = array_pad($numerators, \count($numerators) + $unitSize, $unit);
continue;
}
if ($unitSize < 0) {
$denominators = array_pad($denominators, \count($denominators) - $unitSize, $unit);
continue;
}
if ($this->unitless()) {
return '';
}
return implode('*', $numerators) . (\count($denominators) ? '/' . implode('*', $denominators) : '');
return self::getUnitString($this->numeratorUnits, $this->denominatorUnits);
}
/**
* @param string|null $varName
*
* @return void
*/
public function assertNoUnits($varName = null)
{
if ($this->unitless()) {
return;
}
throw SassScriptException::forArgument(sprintf('Expected %s to have no units', $this), $varName);
}
/**
* @param Number $other
*
* @return void
*/
public function assertSameUnitOrUnitless(Number $other)
{
if ($other->unitless()) {
return;
}
if ($this->numeratorUnits === $other->numeratorUnits && $this->denominatorUnits === $other->denominatorUnits) {
return;
}
throw new SassScriptException(sprintf(
'Incompatible units %s and %s.',
self::getUnitString($this->numeratorUnits, $this->denominatorUnits),
self::getUnitString($other->numeratorUnits, $other->denominatorUnits)
));
}
/**
* @param Number $other
*
* @return bool
*/
public function isComparableTo(Number $other)
{
if ($this->unitless() || $other->unitless()) {
return true;
}
try {
$this->greaterThan($other);
return true;
} catch (SassScriptException $e) {
return false;
}
}
/**
* @param Number $other
*
* @return bool
*/
public function lessThan(Number $other)
{
return $this->coerceUnits($other, function ($num1, $num2) {
return $num1 < $num2;
});
}
/**
* @param Number $other
*
* @return bool
*/
public function lessThanOrEqual(Number $other)
{
return $this->coerceUnits($other, function ($num1, $num2) {
return $num1 <= $num2;
});
}
/**
* @param Number $other
*
* @return bool
*/
public function greaterThan(Number $other)
{
return $this->coerceUnits($other, function ($num1, $num2) {
return $num1 > $num2;
});
}
/**
* @param Number $other
*
* @return bool
*/
public function greaterThanOrEqual(Number $other)
{
return $this->coerceUnits($other, function ($num1, $num2) {
return $num1 >= $num2;
});
}
/**
* @param Number $other
*
* @return Number
*/
public function plus(Number $other)
{
return $this->coerceNumber($other, function ($num1, $num2) {
return $num1 + $num2;
});
}
/**
* @param Number $other
*
* @return Number
*/
public function minus(Number $other)
{
return $this->coerceNumber($other, function ($num1, $num2) {
return $num1 - $num2;
});
}
/**
* @return Number
*/
public function unaryMinus()
{
return new Number(-$this->dimension, $this->numeratorUnits, $this->denominatorUnits);
}
/**
* @param Number $other
*
* @return Number
*/
public function modulo(Number $other)
{
return $this->coerceNumber($other, function ($num1, $num2) {
if ($num2 == 0) {
return NAN;
}
$result = fmod($num1, $num2);
if ($result == 0) {
return 0;
}
if ($num2 < 0 xor $num1 < 0) {
$result += $num2;
}
return $result;
});
}
/**
* @param Number $other
*
* @return Number
*/
public function times(Number $other)
{
return $this->multiplyUnits($this->dimension * $other->dimension, $this->numeratorUnits, $this->denominatorUnits, $other->numeratorUnits, $other->denominatorUnits);
}
/**
* @param Number $other
*
* @return Number
*/
public function dividedBy(Number $other)
{
if ($other->dimension == 0) {
if ($this->dimension == 0) {
$value = NAN;
} elseif ($this->dimension > 0) {
$value = INF;
} else {
$value = -INF;
}
} else {
$value = $this->dimension / $other->dimension;
}
return $this->multiplyUnits($value, $this->numeratorUnits, $this->denominatorUnits, $other->denominatorUnits, $other->numeratorUnits);
}
/**
* @param Number $other
*
* @return bool
*/
public function equals(Number $other)
{
// Unitless numbers are convertable to unit numbers, but not equal, so we special-case unitless here.
if ($this->unitless() !== $other->unitless()) {
return false;
}
// In Sass, neither NaN nor Infinity are equal to themselves, while PHP defines INF==INF
if (is_nan($this->dimension) || is_nan($other->dimension) || !is_finite($this->dimension) || !is_finite($other->dimension)) {
return false;
}
if ($this->unitless()) {
return round($this->dimension, self::PRECISION) == round($other->dimension, self::PRECISION);
}
try {
return $this->coerceUnits($other, function ($num1, $num2) {
return round($num1,self::PRECISION) == round($num2, self::PRECISION);
});
} catch (SassScriptException $e) {
return false;
}
}
/**
@@ -308,35 +477,29 @@ class Number extends Node implements \ArrayAccess
{
$dimension = round($this->dimension, self::PRECISION);
$units = array_filter($this->units, function ($unitSize) {
return $unitSize;
});
if (\count($units) > 1 && array_sum($units) === 0) {
$dimension = $this->dimension;
$units = [];
$this->normalizeUnits($dimension, $units);
$dimension = round($dimension, self::PRECISION);
$units = array_filter($units, function ($unitSize) {
return $unitSize;
});
if (is_nan($dimension)) {
return 'NaN';
}
$unitSize = array_sum($units);
if ($dimension === INF) {
return 'Infinity';
}
if ($compiler && ($unitSize > 1 || $unitSize < 0 || \count($units) > 1)) {
$this->units = $units;
if ($dimension === -INF) {
return '-Infinity';
}
if ($compiler) {
$unit = $this->unitStr();
} elseif (isset($this->numeratorUnits[0])) {
$unit = $this->numeratorUnits[0];
} else {
reset($units);
$unit = key($units);
$unit = '';
}
$dimension = number_format($dimension, self::PRECISION, '.', '');
return (self::PRECISION ? rtrim(rtrim($dimension, '0'), '.') : $dimension) . $unit;
return rtrim(rtrim($dimension, '0'), '.') . $unit;
}
/**
@@ -348,48 +511,227 @@ class Number extends Node implements \ArrayAccess
}
/**
* Normalize units
* @param Number $other
* @param callable $operation
*
* @param integer|float $dimension
* @param array $units
* @param string $baseUnit
* @return Number
*
* @phpstan-param callable(int|float, int|float): (int|float) $operation
*/
private function normalizeUnits(&$dimension, &$units, $baseUnit = null)
private function coerceNumber(Number $other, $operation)
{
$dimension = $this->dimension;
$units = [];
$result = $this->coerceUnits($other, $operation);
foreach ($this->units as $unit => $exp) {
if (! $baseUnit) {
$baseUnit = $this->findBaseUnit($unit);
}
if ($baseUnit && isset(static::$unitTable[$baseUnit][$unit])) {
$factor = pow(static::$unitTable[$baseUnit][$unit], $exp);
$unit = $baseUnit;
$dimension /= $factor;
}
$units[$unit] = $exp + (isset($units[$unit]) ? $units[$unit] : 0);
if (!$this->unitless()) {
return new Number($result, $this->numeratorUnits, $this->denominatorUnits);
}
return new Number($result, $other->numeratorUnits, $other->denominatorUnits);
}
/**
* Find the base unit family for a given unit
* @param Number $other
* @param callable $operation
*
* @param string $unit
* @return mixed
*
* @return string|null
* @phpstan-template T
* @phpstan-param callable(int|float, int|float): T $operation
* @phpstan-return T
*/
private function findBaseUnit($unit)
private function coerceUnits(Number $other, $operation)
{
foreach (static::$unitTable as $baseUnit => $unitVariants) {
if (isset($unitVariants[$unit])) {
return $baseUnit;
if (!$this->unitless()) {
$num1 = $this->dimension;
$num2 = $other->valueInUnits($this->numeratorUnits, $this->denominatorUnits);
} else {
$num1 = $this->valueInUnits($other->numeratorUnits, $other->denominatorUnits);
$num2 = $other->dimension;
}
return \call_user_func($operation, $num1, $num2);
}
/**
* @param string[] $numeratorUnits
* @param string[] $denominatorUnits
*
* @return int|float
*
* @phpstan-param list<string> $numeratorUnits
* @phpstan-param list<string> $denominatorUnits
*/
private function valueInUnits(array $numeratorUnits, array $denominatorUnits)
{
if (
$this->unitless()
|| (\count($numeratorUnits) === 0 && \count($denominatorUnits) === 0)
|| ($this->numeratorUnits === $numeratorUnits && $this->denominatorUnits === $denominatorUnits)
) {
return $this->dimension;
}
$value = $this->dimension;
$oldNumerators = $this->numeratorUnits;
foreach ($numeratorUnits as $newNumerator) {
foreach ($oldNumerators as $key => $oldNumerator) {
$conversionFactor = self::getConversionFactor($newNumerator, $oldNumerator);
if (\is_null($conversionFactor)) {
continue;
}
$value *= $conversionFactor;
unset($oldNumerators[$key]);
continue 2;
}
throw new SassScriptException(sprintf(
'Incompatible units %s and %s.',
self::getUnitString($this->numeratorUnits, $this->denominatorUnits),
self::getUnitString($numeratorUnits, $denominatorUnits)
));
}
$oldDenominators = $this->denominatorUnits;
foreach ($denominatorUnits as $newDenominator) {
foreach ($oldDenominators as $key => $oldDenominator) {
$conversionFactor = self::getConversionFactor($newDenominator, $oldDenominator);
if (\is_null($conversionFactor)) {
continue;
}
$value /= $conversionFactor;
unset($oldDenominators[$key]);
continue 2;
}
throw new SassScriptException(sprintf(
'Incompatible units %s and %s.',
self::getUnitString($this->numeratorUnits, $this->denominatorUnits),
self::getUnitString($numeratorUnits, $denominatorUnits)
));
}
if (\count($oldNumerators) || \count($oldDenominators)) {
throw new SassScriptException(sprintf(
'Incompatible units %s and %s.',
self::getUnitString($this->numeratorUnits, $this->denominatorUnits),
self::getUnitString($numeratorUnits, $denominatorUnits)
));
}
return $value;
}
/**
* @param int|float $value
* @param string[] $numerators1
* @param string[] $denominators1
* @param string[] $numerators2
* @param string[] $denominators2
*
* @return Number
*
* @phpstan-param list<string> $numerators1
* @phpstan-param list<string> $denominators1
* @phpstan-param list<string> $numerators2
* @phpstan-param list<string> $denominators2
*/
private function multiplyUnits($value, array $numerators1, array $denominators1, array $numerators2, array $denominators2)
{
$newNumerators = array();
foreach ($numerators1 as $numerator) {
foreach ($denominators2 as $key => $denominator) {
$conversionFactor = self::getConversionFactor($numerator, $denominator);
if (\is_null($conversionFactor)) {
continue;
}
$value /= $conversionFactor;
unset($denominators2[$key]);
continue 2;
}
$newNumerators[] = $numerator;
}
foreach ($numerators2 as $numerator) {
foreach ($denominators1 as $key => $denominator) {
$conversionFactor = self::getConversionFactor($numerator, $denominator);
if (\is_null($conversionFactor)) {
continue;
}
$value /= $conversionFactor;
unset($denominators1[$key]);
continue 2;
}
$newNumerators[] = $numerator;
}
$newDenominators = array_values(array_merge($denominators1, $denominators2));
return new Number($value, $newNumerators, $newDenominators);
}
/**
* Returns the number of [unit1]s per [unit2].
*
* Equivalently, `1unit1 * conversionFactor(unit1, unit2) = 1unit2`.
*
* @param string $unit1
* @param string $unit2
*
* @return float|int|null
*/
private static function getConversionFactor($unit1, $unit2)
{
if ($unit1 === $unit2) {
return 1;
}
foreach (static::$unitTable as $unitVariants) {
if (isset($unitVariants[$unit1]) && isset($unitVariants[$unit2])) {
return $unitVariants[$unit1] / $unitVariants[$unit2];
}
}
return null;
}
/**
* Returns unit(s) as the product of numerator units divided by the product of denominator units
*
* @param string[] $numerators
* @param string[] $denominators
*
* @phpstan-param list<string> $numerators
* @phpstan-param list<string> $denominators
*
* @return string
*/
private static function getUnitString(array $numerators, array $denominators)
{
if (!\count($numerators)) {
if (\count($denominators) === 0) {
return 'no units';
}
if (\count($denominators) === 1) {
return $denominators[0] . '^-1';
}
return '(' . implode('*', $denominators) . ')^-1';
}
return implode('*', $numerators) . (\count($denominators) ? '/' . implode('*', $denominators) : '');
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace ScssPhp\ScssPhp;
final class OutputStyle
{
const EXPANDED = 'expanded';
const COMPRESSED = 'compressed';
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,8 +12,6 @@
namespace ScssPhp\ScssPhp\SourceMap;
use ScssPhp\ScssPhp\SourceMap\Base64;
/**
* Base 64 VLQ
*

View File

@@ -154,14 +154,16 @@ class SourceMapGenerator
/**
* Generates the JSON source map
*
* @param string $prefix A prefix added in the output file, which needs to shift mappings
*
* @return string
*
* @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#
*/
public function generateJson()
public function generateJson($prefix = '')
{
$sourceMap = [];
$mappings = $this->generateMappings();
$mappings = $this->generateMappings($prefix);
// File version (always the first entry in the object) and must be a positive integer.
$sourceMap['version'] = self::VERSION;
@@ -232,14 +234,21 @@ class SourceMapGenerator
/**
* Generates the mappings string
*
* @param string $prefix A prefix added in the output file, which needs to shift mappings
*
* @return string
*/
public function generateMappings()
public function generateMappings($prefix = '')
{
if (! \count($this->mappings)) {
return '';
}
$prefixLines = substr_count($prefix, "\n");
$lastPrefixNewLine = strrpos($prefix, "\n");
$lastPrefixLineStart = false === $lastPrefixNewLine ? 0 : $lastPrefixNewLine + 1;
$prefixColumn = strlen($prefix) - $lastPrefixLineStart;
$this->sourceKeys = array_flip(array_keys($this->sources));
// group mappings by generated line number.
@@ -254,6 +263,12 @@ class SourceMapGenerator
$lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0;
foreach ($groupedMap as $lineNumber => $lineMap) {
if ($lineNumber > 1) {
// The prefix only impacts the column for the first line of the original output
$prefixColumn = 0;
}
$lineNumber += $prefixLines;
while (++$lastGeneratedLine < $lineNumber) {
$groupedMapEncoded[] = ';';
}
@@ -262,8 +277,10 @@ class SourceMapGenerator
$lastGeneratedColumn = 0;
foreach ($lineMap as $m) {
$mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn);
$lastGeneratedColumn = $m['generated_column'];
$generatedColumn = $m['generated_column'] + $prefixColumn;
$mapEncoded = $this->encoder->encode($generatedColumn - $lastGeneratedColumn);
$lastGeneratedColumn = $generatedColumn;
// find the index
if ($m['source_file']) {

View File

@@ -22,11 +22,14 @@ class Type
const T_ASSIGN = 'assign';
const T_AT_ROOT = 'at-root';
const T_BLOCK = 'block';
/** @deprecated */
const T_BREAK = 'break';
const T_CHARSET = 'charset';
const T_COLOR = 'color';
const T_COMMENT = 'comment';
/** @deprecated */
const T_CONTINUE = 'continue';
/** @deprecated */
const T_CONTROL = 'control';
const T_CUSTOM_PROPERTY = 'custom';
const T_DEBUG = 'debug';

View File

@@ -82,8 +82,8 @@ class Util
*/
public static function mbChr($code)
{
// Use the native implementation if available.
if (\function_exists('mb_chr')) {
// Use the native implementation if available, but not on PHP 7.2 as mb_chr(0) is buggy there
if (\PHP_VERSION_ID > 70300 && \function_exists('mb_chr')) {
return mb_chr($code, 'UTF-8');
}
@@ -100,4 +100,82 @@ class Util
return $s;
}
/**
* mb_strlen() wrapper
*
* @param string $string
* @return int
*/
public static function mbStrlen($string)
{
// Use the native implementation if available.
if (\function_exists('mb_strlen')) {
return mb_strlen($string, 'UTF-8');
}
if (\function_exists('iconv_strlen')) {
return @iconv_strlen($string, 'UTF-8');
}
return strlen($string);
}
/**
* mb_substr() wrapper
* @param string $string
* @param int $start
* @param null|int $length
* @return string
*/
public static function mbSubstr($string, $start, $length = null)
{
// Use the native implementation if available.
if (\function_exists('mb_substr')) {
return mb_substr($string, $start, $length, 'UTF-8');
}
if (\function_exists('iconv_substr')) {
if ($start < 0) {
$start = static::mbStrlen($string) + $start;
if ($start < 0) {
$start = 0;
}
}
if (null === $length) {
$length = 2147483647;
} elseif ($length < 0) {
$length = static::mbStrlen($string) + $length - $start;
if ($length < 0) {
return '';
}
}
return (string)iconv_substr($string, $start, $length, 'UTF-8');
}
return substr($string, $start, $length);
}
/**
* mb_strpos wrapper
* @param string $haystack
* @param string $needle
* @param int $offset
*
* @return int|false
*/
public static function mbStrpos($haystack, $needle, $offset = 0)
{
if (\function_exists('mb_strpos')) {
return mb_strpos($haystack, $needle, $offset, 'UTF-8');
}
if (\function_exists('iconv_strpos')) {
return iconv_strpos($haystack, $needle, $offset, 'UTF-8');
}
return strpos($haystack, $needle, $offset);
}
}

View File

@@ -19,5 +19,5 @@ namespace ScssPhp\ScssPhp;
*/
class Version
{
const VERSION = '1.2';
const VERSION = '1.3';
}