mirror of
https://github.com/gtbu/Typesetter-5.3-p8.git
synced 2024-11-21 13:59:11 +01:00
update scsssphp 1.12
This commit is contained in:
parent
946e830125
commit
3c28626217
6 changed files with 209 additions and 14 deletions
61
include/thirdparty/ScssPhp/ScssPhp/Compiler.php
vendored
61
include/thirdparty/ScssPhp/ScssPhp/Compiler.php
vendored
|
@ -458,10 +458,33 @@ class Compiler
|
|||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -1508,6 +1531,7 @@ class Compiler
|
|||
// 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 @@ class Compiler
|
|||
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 @@ class Compiler
|
|||
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 @@ class Compiler
|
|||
{
|
||||
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 @@ EOL;
|
|||
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;
|
||||
}
|
||||
|
@ -6984,10 +7019,14 @@ EOL;
|
|||
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;
|
||||
}
|
||||
|
|
20
include/thirdparty/ScssPhp/ScssPhp/LICENSE.md
vendored
Normal file
20
include/thirdparty/ScssPhp/ScssPhp/LICENSE.md
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2015 Leaf Corcoran, http://scssphp.github.io/scssphp
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,9 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SCSSPHP
|
||||
*
|
||||
* @copyright 2012-2020 Leaf Corcoran
|
||||
*
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*
|
||||
* @link http://scssphp.github.io/scssphp
|
||||
*/
|
||||
|
||||
namespace ScssPhp\ScssPhp;
|
||||
|
||||
final class OutputStyle
|
||||
{
|
||||
const EXPANDED = 'expanded';
|
||||
const COMPRESSED = 'compressed';
|
||||
|
||||
/**
|
||||
* Converts a string to an output style.
|
||||
*
|
||||
* Using this method allows to write code which will support both
|
||||
* versions 1.12+ and 2.0 of Scssphp. In 2.0, OutputStyle will be
|
||||
* an enum instead of using string constants.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return self::*
|
||||
*/
|
||||
public static function fromString($string)
|
||||
{
|
||||
switch ($string) {
|
||||
case 'expanded':
|
||||
return self::EXPANDED;
|
||||
|
||||
case 'compressed':
|
||||
return self::COMPRESSED;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid output style');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an output style to a string supported by {@see OutputStyle::fromString()}.
|
||||
*
|
||||
* Using this method allows to write code which will support both
|
||||
* versions 1.12+ and 2.0 of Scssphp. In 2.0, OutputStyle will be
|
||||
* an enum instead of using string constants.
|
||||
* The returned string representation is guaranteed to be compatible
|
||||
* between 1.12 and 2.0.
|
||||
*
|
||||
* @param self::* $outputStyle
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toString($outputStyle)
|
||||
{
|
||||
return $outputStyle;
|
||||
}
|
||||
}
|
||||
|
|
16
include/thirdparty/ScssPhp/ScssPhp/Parser.php
vendored
16
include/thirdparty/ScssPhp/ScssPhp/Parser.php
vendored
|
@ -273,6 +273,11 @@ class Parser
|
|||
$this->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 @@ class Parser
|
|||
|
||||
$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;
|
||||
|
@ -1678,9 +1690,9 @@ class Parser
|
|||
*/
|
||||
protected function appendComment($comment)
|
||||
{
|
||||
assert($this->env !== null);
|
||||
|
||||
if (! $this->discardComments) {
|
||||
assert($this->env !== null);
|
||||
|
||||
$this->env->comments[] = $comment;
|
||||
}
|
||||
}
|
||||
|
|
71
include/thirdparty/ScssPhp/ScssPhp/README.md
vendored
Normal file
71
include/thirdparty/ScssPhp/ScssPhp/README.md
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
# scssphp
|
||||
### <https://scssphp.github.io/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.
|
||||
|
||||
Checkout the homepage, <https://scssphp.github.io/scssphp>, for directions on how to use.
|
||||
|
||||
## Running Tests
|
||||
|
||||
`scssphp` uses [PHPUnit](https://github.com/sebastianbergmann/phpunit) for testing.
|
||||
|
||||
Run the following command from the root directory to run every test:
|
||||
|
||||
vendor/bin/phpunit tests
|
||||
|
||||
There are several tests in the `tests/` directory:
|
||||
|
||||
* `ApiTest.php` contains various unit tests that test the PHP interface.
|
||||
* `ExceptionTest.php` contains unit tests that test for exceptions thrown by the parser and compiler.
|
||||
* `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.
|
||||
* `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
|
||||
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`. It also
|
||||
updates the list of excluded specs from sass-spec.
|
||||
|
||||
To enable the full `sass-spec` compatibility tests:
|
||||
|
||||
TEST_SASS_SPEC=1 vendor/bin/phpunit tests
|
||||
|
||||
## Coding Standard
|
||||
|
||||
`scssphp` source conforms to [PSR12](https://www.php-fig.org/psr/psr-12/).
|
||||
|
||||
Run the following command from the root directory to check the code for "sniffs".
|
||||
|
||||
vendor/bin/phpcs --standard=PSR12 --extensions=php bin src tests *.php
|
||||
|
||||
## Static Analysis
|
||||
|
||||
`scssphp` uses [phpstan](https://phpstan.org/) for static analysis.
|
||||
|
||||
Run the following command from the root directory to analyse the codebase:
|
||||
|
||||
make phpstan
|
||||
|
||||
As most of the codebase is composed of legacy code which cannot be type-checked
|
||||
fully, the setup contains a baseline file with all errors we want to ignore. In
|
||||
particular, we ignore all errors related to not specifying the types inside arrays
|
||||
when these arrays correspond to the representation of Sass values and Sass AST nodes
|
||||
in the parser and compiler.
|
||||
When contributing, the proper process to deal with static analysis is the following:
|
||||
|
||||
1. Make your change in the codebase
|
||||
2. Run `make phpstan`
|
||||
3. Fix errors reported by phpstan when possible
|
||||
4. Repeat step 2 and 3 until nothing gets fixed anymore at step 3
|
||||
5. Run `make phpstan-baseline` to regenerate the phpstan baseline
|
||||
|
||||
Additions to the baseline will be reviewed to avoid ignoring errors that should have
|
||||
been fixed.
|
|
@ -19,5 +19,5 @@ namespace ScssPhp\ScssPhp;
|
|||
*/
|
||||
class Version
|
||||
{
|
||||
const VERSION = '1.11.0';
|
||||
const VERSION = '1.12.0';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue