From 3abdce0fea6b0a8b6b6f9da28efd7eaf099bf333 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:32:12 +0000 Subject: [PATCH] chore(deps): Bump scssphp/scssphp from 1.11.0 to 1.12.1 Bumps [scssphp/scssphp](https://github.com/scssphp/scssphp) from 1.11.0 to 1.12.1. - [Release notes](https://github.com/scssphp/scssphp/releases) - [Commits](https://github.com/scssphp/scssphp/compare/v1.11.0...v1.12.1) --- updated-dependencies: - dependency-name: scssphp/scssphp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 16 +-- composer/installed.json | 16 +-- composer/installed.php | 10 +- scssphp/scssphp/src/Block/CallableBlock.php | 3 +- scssphp/scssphp/src/Compiler.php | 102 ++++++++++++++------ scssphp/scssphp/src/Node/Number.php | 18 +++- scssphp/scssphp/src/OutputStyle.php | 53 ++++++++++ scssphp/scssphp/src/Parser.php | 19 +++- scssphp/scssphp/src/Version.php | 2 +- 10 files changed, 181 insertions(+), 60 deletions(-) diff --git a/composer.json b/composer.json index 99ece1c49..25e55e40c 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "psr/event-dispatcher": "^1.0", "punic/punic": "^3.8", "sabre/dav": "^4.4.0", - "scssphp/scssphp": "^1.11", + "scssphp/scssphp": "^1.12", "stecman/symfony-console-completion": "^0.11.0", "symfony/console": "^5.4.24", "symfony/event-dispatcher": "^5.4.26", diff --git a/composer.lock b/composer.lock index 2f5c018b3..a93ffacfb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "60ef2ffd28342e2b5144d1ba74898944", + "content-hash": "e730d0da53fdfd18af59cf5484a8bf59", "packages": [ { "name": "aws/aws-crt-php", @@ -4199,16 +4199,16 @@ }, { "name": "scssphp/scssphp", - "version": "v1.11.0", + "version": "v1.12.1", "source": { "type": "git", "url": "https://github.com/scssphp/scssphp.git", - "reference": "33749d12c2569bb24071f94e9af828662dabb068" + "reference": "394ed1e960138710a60d035c1a85d43d0bf0faeb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/scssphp/scssphp/zipball/33749d12c2569bb24071f94e9af828662dabb068", - "reference": "33749d12c2569bb24071f94e9af828662dabb068", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/394ed1e960138710a60d035c1a85d43d0bf0faeb", + "reference": "394ed1e960138710a60d035c1a85d43d0bf0faeb", "shasum": "" }, "require": { @@ -4225,7 +4225,7 @@ "thoughtbot/bourbon": "^7.0", "twbs/bootstrap": "~5.0", "twbs/bootstrap4": "4.6.1", - "zurb/foundation": "~6.5" + "zurb/foundation": "~6.7.0" }, "suggest": { "ext-iconv": "Can be used as fallback when ext-mbstring is not available", @@ -4273,9 +4273,9 @@ ], "support": { "issues": "https://github.com/scssphp/scssphp/issues", - "source": "https://github.com/scssphp/scssphp/tree/v1.11.0" + "source": "https://github.com/scssphp/scssphp/tree/v1.12.1" }, - "time": "2022-09-02T21:24:55+00:00" + "time": "2024-01-13T12:36:40+00:00" }, { "name": "spomky-labs/base64url", diff --git a/composer/installed.json b/composer/installed.json index 5de1127c8..b2fd12967 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -4382,17 +4382,17 @@ }, { "name": "scssphp/scssphp", - "version": "v1.11.0", - "version_normalized": "1.11.0.0", + "version": "v1.12.1", + "version_normalized": "1.12.1.0", "source": { "type": "git", "url": "https://github.com/scssphp/scssphp.git", - "reference": "33749d12c2569bb24071f94e9af828662dabb068" + "reference": "394ed1e960138710a60d035c1a85d43d0bf0faeb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/scssphp/scssphp/zipball/33749d12c2569bb24071f94e9af828662dabb068", - "reference": "33749d12c2569bb24071f94e9af828662dabb068", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/394ed1e960138710a60d035c1a85d43d0bf0faeb", + "reference": "394ed1e960138710a60d035c1a85d43d0bf0faeb", "shasum": "" }, "require": { @@ -4409,13 +4409,13 @@ "thoughtbot/bourbon": "^7.0", "twbs/bootstrap": "~5.0", "twbs/bootstrap4": "4.6.1", - "zurb/foundation": "~6.5" + "zurb/foundation": "~6.7.0" }, "suggest": { "ext-iconv": "Can be used as fallback when ext-mbstring is not available", "ext-mbstring": "For best performance, mbstring should be installed as it is faster than ext-iconv" }, - "time": "2022-09-02T21:24:55+00:00", + "time": "2024-01-13T12:36:40+00:00", "bin": [ "bin/pscss" ], @@ -4459,7 +4459,7 @@ ], "support": { "issues": "https://github.com/scssphp/scssphp/issues", - "source": "https://github.com/scssphp/scssphp/tree/v1.11.0" + "source": "https://github.com/scssphp/scssphp/tree/v1.12.1" }, "install-path": "../scssphp/scssphp" }, diff --git a/composer/installed.php b/composer/installed.php index e6d5859c0..09f4302ab 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'nextcloud/3rdparty', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '2676f41402c0f649112085f58aab7b66b047a44c', + 'reference' => '4563c55bf7abac69a9e16d43400fcddff2a98c4f', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -319,7 +319,7 @@ 'nextcloud/3rdparty' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '2676f41402c0f649112085f58aab7b66b047a44c', + 'reference' => '4563c55bf7abac69a9e16d43400fcddff2a98c4f', 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), @@ -653,9 +653,9 @@ 'dev_requirement' => false, ), 'scssphp/scssphp' => array( - 'pretty_version' => 'v1.11.0', - 'version' => '1.11.0.0', - 'reference' => '33749d12c2569bb24071f94e9af828662dabb068', + 'pretty_version' => 'v1.12.1', + 'version' => '1.12.1.0', + 'reference' => '394ed1e960138710a60d035c1a85d43d0bf0faeb', 'type' => 'library', 'install_path' => __DIR__ . '/../scssphp/scssphp', 'aliases' => array(), diff --git a/scssphp/scssphp/src/Block/CallableBlock.php b/scssphp/scssphp/src/Block/CallableBlock.php index a18a87c2a..9b32d8ce7 100644 --- a/scssphp/scssphp/src/Block/CallableBlock.php +++ b/scssphp/scssphp/src/Block/CallableBlock.php @@ -14,6 +14,7 @@ use ScssPhp\ScssPhp\Block; use ScssPhp\ScssPhp\Compiler\Environment; +use ScssPhp\ScssPhp\Node\Number; /** * @internal @@ -26,7 +27,7 @@ class CallableBlock extends Block public $name; /** - * @var array|null + * @var list|null */ public $args; diff --git a/scssphp/scssphp/src/Compiler.php b/scssphp/scssphp/src/Compiler.php index ecafc8cb9..d4e7c6896 100644 --- a/scssphp/scssphp/src/Compiler.php +++ b/scssphp/scssphp/src/Compiler.php @@ -458,10 +458,33 @@ public function compile($code, $path = null) } /** - * Compile scss + * Compiles the provided scss file into CSS. + * + * @param string $path + * + * @return CompilationResult + * + * @throws SassException when the source fails to compile + */ + public function compileFile($path) + { + $source = file_get_contents($path); + + if ($source === false) { + throw new \RuntimeException('Could not read the file content'); + } + + return $this->compileString($source, $path); + } + + /** + * Compiles the provided scss source code into CSS. + * + * If provided, the path is considered to be the path from which the source code comes + * from, which will be used to resolve relative imports. * * @param string $source - * @param string|null $path + * @param string|null $path The path for the source, used to resolve relative imports * * @return CompilationResult * @@ -548,7 +571,7 @@ public function compileString($source, $path = null) $sourceMap = null; - if (! empty($out) && $this->sourceMap && $this->sourceMap !== self::SOURCE_MAP_NONE) { + if (! empty($out) && $this->sourceMap !== self::SOURCE_MAP_NONE && $this->sourceMap) { assert($sourceMapGenerator !== null); $sourceMap = $sourceMapGenerator->generateJson($prefix); $sourceMapUrl = null; @@ -1508,6 +1531,7 @@ protected function filterScopeWithWithout($scope, $with, $without) // start from the root while ($scope->parent && $scope->parent->type !== Type::T_ROOT) { array_unshift($childStash, $scope); + \assert($scope->parent !== null); $scope = $scope->parent; } @@ -2090,6 +2114,11 @@ protected function collapseSelectors($selectors) foreach ($selector as $node) { $compound = ''; + if (!is_array($node)) { + $output[] = $node; + continue; + } + array_walk_recursive( $node, function ($value, $key) use (&$compound) { @@ -2124,12 +2153,16 @@ private function collapseSelectorsAsList($selectors) foreach ($selector as $node) { $compound = ''; - array_walk_recursive( - $node, - function ($value, $key) use (&$compound) { - $compound .= $value; - } - ); + if (!is_array($node)) { + $compound .= $node; + } else { + array_walk_recursive( + $node, + function ($value, $key) use (&$compound) { + $compound .= $value; + } + ); + } if ($this->isImmediateRelationshipCombinator($compound)) { if (\count($output)) { @@ -2885,7 +2918,7 @@ protected function compileChild($child, OutputBlock $out) { if (isset($child[Parser::SOURCE_LINE])) { $this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null; - $this->sourceLine = isset($child[Parser::SOURCE_LINE]) ? $child[Parser::SOURCE_LINE] : -1; + $this->sourceLine = $child[Parser::SOURCE_LINE]; $this->sourceColumn = isset($child[Parser::SOURCE_COLUMN]) ? $child[Parser::SOURCE_COLUMN] : -1; } elseif (\is_array($child) && isset($child[1]->sourceLine) && $child[1] instanceof Block) { $this->sourceIndex = $child[1]->sourceIndex; @@ -4529,8 +4562,10 @@ public function compileValue($value, $quote = true) return $colorName; } - if (is_numeric($alpha)) { + if (\is_int($alpha) || \is_float($alpha)) { $a = new Number($alpha, ''); + } elseif (is_numeric($alpha)) { + $a = new Number((float) $alpha, ''); } else { $a = $alpha; } @@ -5806,13 +5841,13 @@ public function findImport($url, $currentDir = null) if (! \is_null($file)) { if (\is_array($dir)) { - $callableDescription = (\is_object($dir[0]) ? \get_class($dir[0]) : $dir[0]).'::'.$dir[1]; + $callableDescription = (\is_object($dir[0]) ? \get_class($dir[0]) : $dir[0]) . '::' . $dir[1]; } elseif ($dir instanceof \Closure) { $r = new \ReflectionFunction($dir); if (false !== strpos($r->name, '{closure}')) { $callableDescription = sprintf('closure{%s:%s}', $r->getFileName(), $r->getStartLine()); } elseif ($class = $r->getClosureScopeClass()) { - $callableDescription = $class->name.'::'.$r->name; + $callableDescription = $class->name . '::' . $r->name; } else { $callableDescription = $r->name; } @@ -5925,15 +5960,15 @@ private function checkImportPathConflicts(array $paths) private function tryImportPathWithExtensions($path) { $result = array_merge( - $this->tryImportPath($path.'.sass'), - $this->tryImportPath($path.'.scss') + $this->tryImportPath($path . '.sass'), + $this->tryImportPath($path . '.scss') ); if ($result) { return $result; } - return $this->tryImportPath($path.'.css'); + return $this->tryImportPath($path . '.css'); } /** @@ -5943,7 +5978,7 @@ private function tryImportPathWithExtensions($path) */ private function tryImportPath($path) { - $partial = dirname($path).'/_'.basename($path); + $partial = dirname($path) . '/_' . basename($path); $candidates = []; @@ -5969,7 +6004,7 @@ private function tryImportPathAsDirectory($path) return null; } - return $this->checkImportPathConflicts($this->tryImportPathWithExtensions($path.'/index')); + return $this->checkImportPathConflicts($this->tryImportPathWithExtensions($path . '/index')); } /** @@ -5984,7 +6019,7 @@ private function getPrettyPath($path) } $normalizedPath = $path; - $normalizedRootDirectory = $this->rootDirectory.'/'; + $normalizedRootDirectory = $this->rootDirectory . '/'; if (\DIRECTORY_SEPARATOR === '\\') { $normalizedRootDirectory = str_replace('\\', '/', $normalizedRootDirectory); @@ -6371,8 +6406,6 @@ public static function isNativeFunction($name) */ protected function sortNativeFunctionArgs($functionName, $prototypes, $args) { - static $parser = null; - if (! isset($prototypes)) { $keyArgs = []; $posArgs = []; @@ -6526,7 +6559,7 @@ private function parseFunctionPrototype(array $prototype) * * @return array * - * @phpstan-param non-empty-list, rest_argument: string|null}> $prototypes + * @phpstan-param non-empty-array, rest_argument: string|null}> $prototypes * @phpstan-return array{arguments: list, rest_argument: string|null} */ private function selectFunctionPrototype(array $prototypes, $positional, array $names) @@ -6984,10 +7017,14 @@ protected function coerceValue($value) return static::$null; } - if (is_numeric($value)) { + if (\is_int($value) || \is_float($value)) { return new Number($value, ''); } + if (is_numeric($value)) { + return new Number((float) $value, ''); + } + if ($value === '') { return static::$emptyString; } @@ -7675,9 +7712,9 @@ private function HWBtoRGB($hue, $whiteness, $blackness) $b = min(1.0 - $w, $b); $rgb = $this->toRGB($hue, 100, 50); - for($i = 1; $i < 4; $i++) { - $rgb[$i] *= (1.0 - $w - $b); - $rgb[$i] = round($rgb[$i] + 255 * $w + 0.0001); + for ($i = 1; $i < 4; $i++) { + $rgb[$i] *= (1.0 - $w - $b); + $rgb[$i] = round($rgb[$i] + 255 * $w + 0.0001); } return $rgb; @@ -7704,7 +7741,6 @@ private function RGBtoHWB($red, $green, $blue) if ((int) $d === 0) { $h = 0; } else { - if ($red == $max) { $h = 60 * ($green - $blue) / $d; } elseif ($green == $max) { @@ -7714,7 +7750,7 @@ private function RGBtoHWB($red, $green, $blue) } } - return [Type::T_HWB, fmod($h, 360), $min / 255 * 100, 100 - $max / 255 *100]; + return [Type::T_HWB, fmod($h, 360), $min / 255 * 100, 100 - $max / 255 * 100]; } @@ -7923,7 +7959,13 @@ protected function alterColor(array $args, $operation, $fn) $scale = $operation === 'scale'; $change = $operation === 'change'; - /** @phpstan-var callable(string, float|int, bool=, bool=): (float|int|null) $getParam */ + /** + * @param string $name + * @param float|int $max + * @param bool $checkPercent + * @param bool $assertPercent + * @return float|int|null + */ $getParam = function ($name, $max, $checkPercent = false, $assertPercent = false) use (&$kwargs, $scale, $change) { if (!isset($kwargs[$name])) { return null; @@ -8065,7 +8107,7 @@ protected function libAdjustColor($args) protected static $libChangeColor = ['color', 'kwargs...']; protected function libChangeColor($args) { - return $this->alterColor($args,'change', function ($base, $alter, $max) { + return $this->alterColor($args, 'change', function ($base, $alter, $max) { if ($alter === null) { return $base; } diff --git a/scssphp/scssphp/src/Node/Number.php b/scssphp/scssphp/src/Node/Number.php index 48e711f08..6c0445876 100644 --- a/scssphp/scssphp/src/Node/Number.php +++ b/scssphp/scssphp/src/Node/Number.php @@ -33,7 +33,7 @@ * * @template-implements \ArrayAccess */ -class Number extends Node implements \ArrayAccess +class Number extends Node implements \ArrayAccess, \JsonSerializable { const PRECISION = 10; @@ -131,7 +131,7 @@ public function getDimension() } /** - * @return string[] + * @return list */ public function getNumeratorUnits() { @@ -139,13 +139,23 @@ public function getNumeratorUnits() } /** - * @return string[] + * @return list */ public function getDenominatorUnits() { return $this->denominatorUnits; } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + // Passing a compiler instance makes the method output a Sass representation instead of a CSS one, supporting full units. + return $this->output(new Compiler()); + } + /** * @return bool */ @@ -554,7 +564,7 @@ public function equals(Number $other) try { return $this->coerceUnits($other, function ($num1, $num2) { - return round($num1,self::PRECISION) == round($num2, self::PRECISION); + return round($num1, self::PRECISION) == round($num2, self::PRECISION); }); } catch (SassScriptException $e) { return false; diff --git a/scssphp/scssphp/src/OutputStyle.php b/scssphp/scssphp/src/OutputStyle.php index c284639c1..a1d8b4255 100644 --- a/scssphp/scssphp/src/OutputStyle.php +++ b/scssphp/scssphp/src/OutputStyle.php @@ -1,9 +1,62 @@ saveEncoding(); $this->extractLineNumbers($buffer); + if ($this->utf8 && !preg_match('//u', $buffer)) { + $message = $this->sourceName ? 'Invalid UTF-8 file: ' . $this->sourceName : 'Invalid UTF-8 file'; + throw new ParserException($message); + } + $this->pushBlock(null); // root block $this->whitespace(); $this->pushBlock(null); @@ -323,6 +328,13 @@ public function parseValue($buffer, &$out) $list = $this->valueList($out); + if ($this->count !== \strlen($this->buffer)) { + $error = $this->parseError('Expected end of value'); + $message = 'Passing trailing content after the expression when parsing a value is deprecated since Scssphp 1.12.0 and will be an error in 2.0. ' . $error->getMessage(); + + @trigger_error($message, E_USER_DEPRECATED); + } + $this->restoreEncoding(); return $list; @@ -383,10 +395,13 @@ public function parseMediaQueryList($buffer, &$out) $this->inParens = false; $this->eatWhiteDefault = true; $this->buffer = (string) $buffer; + $this->discardComments = true; $this->saveEncoding(); $this->extractLineNumbers($this->buffer); + $this->whitespace(); + $isMediaQuery = $this->mediaQueryList($out); $this->restoreEncoding(); @@ -1678,9 +1693,9 @@ protected function whitespace() */ protected function appendComment($comment) { - assert($this->env !== null); - if (! $this->discardComments) { + assert($this->env !== null); + $this->env->comments[] = $comment; } } diff --git a/scssphp/scssphp/src/Version.php b/scssphp/scssphp/src/Version.php index d604a5057..89bd59526 100644 --- a/scssphp/scssphp/src/Version.php +++ b/scssphp/scssphp/src/Version.php @@ -19,5 +19,5 @@ */ class Version { - const VERSION = '1.11.0'; + const VERSION = '1.12.1'; }