Update php8.4 and Scssphp 1.13

This commit is contained in:
gtbu 2025-02-22 14:07:52 +01:00
parent 3687faa0fd
commit f74a060798
20 changed files with 172 additions and 178 deletions

View file

@ -18,7 +18,6 @@ class Errors extends \gp\special\Base{
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Strict Notice',
E_RECOVERABLE_ERROR => 'Recoverable Error',
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',

View file

@ -177,7 +177,6 @@ function showError($errno, $errmsg, $filename, $linenum, $vars=null, $backtrace=
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Strict Notice',
E_RECOVERABLE_ERROR => 'Recoverable Error',
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',
@ -189,11 +188,6 @@ function showError($errno, $errmsg, $filename, $linenum, $vars=null, $backtrace=
return false;
}
// since we supported older versions of php, there may be a lot of strict errors
if( $errno === E_STRICT ){
return true;
}
//get the backtrace and function where the error was thrown
if( !$backtrace ){
$backtrace = debug_backtrace();

View file

@ -14,6 +14,7 @@ namespace ScssPhp\ScssPhp\Block;
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<array{string, array|Number|null, bool}>|null
*/
public $args;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -26,7 +27,7 @@ class DirectiveBlock extends Block
public $name;
/**
* @var string|array|null
* @var array|Number|null
*/
public $value;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -26,7 +27,7 @@ class EachBlock extends Block
public $vars = [];
/**
* @var array
* @var array|Number
*/
public $list;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -21,7 +22,7 @@ use ScssPhp\ScssPhp\Type;
class ElseifBlock extends Block
{
/**
* @var array
* @var array|Number
*/
public $cond;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -26,12 +27,12 @@ class ForBlock extends Block
public $var;
/**
* @var array
* @var array|Number
*/
public $start;
/**
* @var array
* @var array|Number
*/
public $end;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -21,7 +22,7 @@ use ScssPhp\ScssPhp\Type;
class IfBlock extends Block
{
/**
* @var array
* @var array|Number
*/
public $cond;

View file

@ -13,6 +13,7 @@
namespace ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Block;
use ScssPhp\ScssPhp\Node\Number;
use ScssPhp\ScssPhp\Type;
/**
@ -21,7 +22,7 @@ use ScssPhp\ScssPhp\Type;
class MediaBlock extends Block
{
/**
* @var string|array|null
* @var string|array|Number|null
*/
public $value;

View file

@ -140,13 +140,28 @@ class Compiler
/** @deprecated */
public static $Infinity = [Type::T_KEYWORD, 'Infinity'];
public static $null = [Type::T_NULL];
/**
* @internal
*/
public static $nullString = [Type::T_STRING, '', []];
/**
* @internal
*/
public static $defaultValue = [Type::T_KEYWORD, ''];
/**
* @internal
*/
public static $selfSelector = [Type::T_SELF];
public static $emptyList = [Type::T_LIST, '', []];
public static $emptyMap = [Type::T_MAP, [], []];
public static $emptyString = [Type::T_STRING, '"', []];
/**
* @internal
*/
public static $with = [Type::T_KEYWORD, 'with'];
/**
* @internal
*/
public static $without = [Type::T_KEYWORD, 'without'];
private static $emptyArgumentList = [Type::T_LIST, '', [], []];
@ -571,7 +586,7 @@ class Compiler
$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;
@ -1656,6 +1671,7 @@ class Compiler
$parser = $this->parserFactory(__METHOD__);
if ($parser->parseValue($buffer, $reParsedWith)) {
\assert(\is_array($reParsedWith));
$withCondition = $reParsedWith;
}
}
@ -5036,7 +5052,7 @@ EOL;
*
* @return array
*/
protected function multiplyMedia(Environment $env = null, $childQueries = null)
protected function multiplyMedia(?Environment $env = null, ?array $childQueries = null)
{
if (
! isset($env) ||
@ -5128,7 +5144,7 @@ EOL;
*
* @return \ScssPhp\ScssPhp\Compiler\Environment
*/
protected function pushEnv(Block $block = null)
protected function pushEnv(?Block $block = null)
{
$env = new Environment();
$env->parent = $this->env;
@ -5192,7 +5208,7 @@ EOL;
*
* @return void
*/
protected function set($name, $value, $shadow = false, Environment $env = null, $valueUnreduced = null)
protected function set($name, $value, $shadow = false, ?Environment $env = null, $valueUnreduced = null)
{
$name = $this->normalizeName($name);
@ -5298,7 +5314,7 @@ EOL;
*
* @return mixed|null
*/
public function get($name, $shouldThrow = true, Environment $env = null, $unreduced = false)
public function get($name, $shouldThrow = true, ?Environment $env = null, $unreduced = false)
{
$normalizedName = $this->normalizeName($name);
$specialContentKey = static::$namespaces['special'] . 'content';
@ -5363,7 +5379,7 @@ EOL;
*
* @return bool
*/
protected function has($name, Environment $env = null)
protected function has($name, ?Environment $env = null)
{
return ! \is_null($this->get($name, false, $env));
}
@ -5702,9 +5718,35 @@ EOL;
@trigger_error('Omitting the argument declaration when registering custom function is deprecated and won\'t be supported in ScssPhp 2.0 anymore.', E_USER_DEPRECATED);
}
if ($this->reflectCallable($callback)->getNumberOfRequiredParameters() > 1) {
@trigger_error('The second argument passed to the callback of custom functions is deprecated and won\'t be supported in ScssPhp 2.0 anymore. Register a callback accepting only 1 parameter instead.', E_USER_DEPRECATED);
}
$this->userFunctions[$this->normalizeName($name)] = [$callback, $argumentDeclaration];
}
/**
* @return \ReflectionFunctionAbstract
*/
private function reflectCallable(callable $c)
{
if (\is_object($c) && !$c instanceof \Closure) {
$c = [$c, '__invoke'];
}
if (\is_string($c) && false !== strpos($c, '::')) {
$c = explode('::', $c, 2);
}
if (\is_array($c)) {
return new \ReflectionMethod($c[0], $c[1]);
}
\assert(\is_string($c) || $c instanceof \Closure);
return new \ReflectionFunction($c);
}
/**
* Unregister function
*
@ -5841,13 +5883,13 @@ EOL;
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;
}
@ -5960,15 +6002,15 @@ EOL;
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');
}
/**
@ -5978,7 +6020,7 @@ EOL;
*/
private function tryImportPath($path)
{
$partial = dirname($path).'/_'.basename($path);
$partial = dirname($path) . '/_' . basename($path);
$candidates = [];
@ -6004,7 +6046,7 @@ EOL;
return null;
}
return $this->checkImportPathConflicts($this->tryImportPathWithExtensions($path.'/index'));
return $this->checkImportPathConflicts($this->tryImportPathWithExtensions($path . '/index'));
}
/**
@ -6019,7 +6061,7 @@ EOL;
}
$normalizedPath = $path;
$normalizedRootDirectory = $this->rootDirectory.'/';
$normalizedRootDirectory = $this->rootDirectory . '/';
if (\DIRECTORY_SEPARATOR === '\\') {
$normalizedRootDirectory = str_replace('\\', '/', $normalizedRootDirectory);
@ -6406,8 +6448,6 @@ EOL;
*/
protected function sortNativeFunctionArgs($functionName, $prototypes, $args)
{
static $parser = null;
if (! isset($prototypes)) {
$keyArgs = [];
$posArgs = [];
@ -6561,7 +6601,7 @@ EOL;
*
* @return array
*
* @phpstan-param non-empty-list<array{arguments: list<array{0: string, 1: string, 2: array|Number|null}>, rest_argument: string|null}> $prototypes
* @phpstan-param non-empty-array<array{arguments: list<array{0: string, 1: string, 2: array|Number|null}>, rest_argument: string|null}> $prototypes
* @phpstan-return array{arguments: list<array{0: string, 1: string, 2: array|Number|null}>, rest_argument: string|null}
*/
private function selectFunctionPrototype(array $prototypes, $positional, array $names)
@ -7714,9 +7754,9 @@ EOL;
$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;
@ -7743,7 +7783,6 @@ EOL;
if ((int) $d === 0) {
$h = 0;
} else {
if ($red == $max) {
$h = 60 * ($green - $blue) / $d;
} elseif ($green == $max) {
@ -7753,7 +7792,7 @@ EOL;
}
}
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];
}
@ -7962,7 +8001,13 @@ EOL;
$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;
@ -8104,7 +8149,7 @@ EOL;
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;
}

View file

@ -272,7 +272,7 @@ abstract class Formatter
*
* @return string
*/
public function format(OutputBlock $block, SourceMapGenerator $sourceMapGenerator = null)
public function format(OutputBlock $block, ?SourceMapGenerator $sourceMapGenerator = null)
{
$this->sourceMapGenerator = null;

View file

@ -33,7 +33,7 @@ use ScssPhp\ScssPhp\Util;
*
* @template-implements \ArrayAccess<int, mixed>
*/
class Number extends Node implements \ArrayAccess
class Number extends Node implements \ArrayAccess, \JsonSerializable
{
const PRECISION = 10;
@ -131,7 +131,7 @@ class Number extends Node implements \ArrayAccess
}
/**
* @return string[]
* @return list<string>
*/
public function getNumeratorUnits()
{
@ -139,13 +139,23 @@ class Number extends Node implements \ArrayAccess
}
/**
* @return string[]
* @return list<string>
*/
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 @@ class Number extends Node implements \ArrayAccess
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;
@ -568,7 +578,7 @@ class Number extends Node implements \ArrayAccess
*
* @return string
*/
public function output(Compiler $compiler = null)
public function output(?Compiler $compiler = null)
{
$dimension = round($this->dimension, self::PRECISION);

View file

@ -140,7 +140,7 @@ class Parser
* @param bool $cssOnly
* @param LoggerInterface|null $logger
*/
public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8', Cache $cache = null, $cssOnly = false, LoggerInterface $logger = null)
public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8', ?Cache $cache = null, $cssOnly = false, ?LoggerInterface $logger = null)
{
$this->sourceName = $sourceName ?: '(stdin)';
$this->sourceIndex = $sourceIndex;
@ -310,8 +310,9 @@ class Parser
*
* @api
*
* @param string $buffer
* @param string|array $out
* @param string $buffer
* @param mixed $out
* @param-out array|Number $out
*
* @return bool
*/
@ -345,9 +346,9 @@ class Parser
*
* @api
*
* @param string $buffer
* @param string|array $out
* @param bool $shouldValidate
* @param string $buffer
* @param array $out
* @param bool $shouldValidate
*
* @return bool
*/
@ -395,10 +396,13 @@ class Parser
$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();
@ -1252,10 +1256,10 @@ class Parser
/**
* Assert a parsed part is plain CSS Valid
*
* @param array|false $parsed
* @param array|Number|false $parsed
* @param int $startPos
*
* @return array
* @return array|Number
*
* @throws ParserException
*/
@ -1285,10 +1289,10 @@ class Parser
/**
* Check a parsed element is plain CSS Valid
*
* @param array $parsed
* @param array|Number|string $parsed
* @param bool $allowExpression
*
* @return array|false
* @return ($parsed is string ? string : ($parsed is Number ? Number : array|false))
*/
protected function isPlainCssValidElement($parsed, $allowExpression = false)
{
@ -1297,6 +1301,10 @@ class Parser
return $parsed;
}
if ($parsed instanceof Number) {
return $parsed;
}
if (
\in_array($parsed[0], [Type::T_FUNCTION, Type::T_FUNCTION_CALL]) &&
!\in_array($parsed[1], [
@ -2091,8 +2099,9 @@ class Parser
/**
* Parse directive value list that considers $vars as keyword
*
* @param array $out
* @param mixed $out
* @param string|false $endChar
* @param-out array|Number $out
*
* @return bool
*
@ -2155,7 +2164,8 @@ class Parser
/**
* Parse comma separated value list
*
* @param array $out
* @param mixed $out
* @param-out array|Number $out
*
* @return bool
*/
@ -2173,10 +2183,11 @@ class Parser
* Parse a function call, where externals () are part of the call
* and not of the value list
*
* @param array $out
* @param mixed $out
* @param bool $mandatoryEnclos
* @param null|string $charAfter
* @param null|bool $eatWhiteSp
* @param-out array|Number $out
*
* @return bool
*/
@ -2212,7 +2223,8 @@ class Parser
/**
* Parse space separated value list
*
* @param array $out
* @param mixed $out
* @param-out array|Number $out
*
* @return bool
*/
@ -2224,10 +2236,11 @@ class Parser
/**
* Parse generic list
*
* @param array $out
* @param mixed $out
* @param string $parseItem The name of the method used to parse items
* @param string $delim
* @param bool $flatten
* @param-out ($flatten is false ? array : array|Number) $out
*
* @return bool
*/
@ -2331,9 +2344,10 @@ class Parser
/**
* Parse expression
*
* @param array $out
* @param mixed $out
* @param bool $listOnly
* @param bool $lookForExp
* @param-out array|Number $out
*
* @return bool
*
@ -2398,10 +2412,11 @@ class Parser
/**
* Parse expression specifically checking for lists in parenthesis or brackets
*
* @param array $out
* @param mixed $out
* @param int $s
* @param string $closingParen
* @param string[] $allowedTypes
* @param-out array|Number $out
*
* @return bool
*
@ -2460,10 +2475,10 @@ class Parser
/**
* Parse left-hand side of subexpression
*
* @param array $lhs
* @param int $minP
* @param array|Number $lhs
* @param int $minP
*
* @return array
* @return array|Number
*/
protected function expHelper($lhs, $minP)
{
@ -2514,7 +2529,8 @@ class Parser
/**
* Parse value
*
* @param array $out
* @param mixed $out
* @param-out array|Number $out
*
* @return bool
*/
@ -2722,7 +2738,8 @@ class Parser
/**
* Parse parenthesized value
*
* @param array $out
* @param mixed $out
* @param-out array|Number $out
*
* @return bool
*/
@ -2794,7 +2811,8 @@ class Parser
* Parse function call
*
* @param string $name
* @param array $func
* @param mixed $func
* @param-out array $func
*
* @return bool
*/
@ -2897,7 +2915,8 @@ class Parser
/**
* Parse mixin/function definition argument list
*
* @param array $out
* @param mixed $out
* @param-out list<array{string, array|Number|null, bool}> $out
*
* @return bool
*/
@ -2959,7 +2978,8 @@ class Parser
/**
* Parse map
*
* @param array $out
* @param mixed $out
* @param-out array $out
*
* @return bool
*/
@ -3001,7 +3021,8 @@ class Parser
/**
* Parse color
*
* @param array $out
* @param mixed $out
* @param-out array $out
*
* @return bool
*/
@ -3027,7 +3048,8 @@ class Parser
/**
* Parse number with unit
*
* @param array $unit
* @param mixed $unit
* @param-out Number $unit
*
* @return bool
*/
@ -3233,11 +3255,12 @@ class Parser
* Parse an unbounded string stopped by $end
*
* @param string $end
* @param array $out
* @param mixed $out
* @param string $nestOpen
* @param string $nestClose
* @param bool $rtrim
* @param string $disallow
* @param-out array $out
*
* @return bool
*/
@ -3314,8 +3337,9 @@ class Parser
/**
* Parser interpolation
*
* @param string|array $out
* @param bool $lookWhite save information about whitespace before and after
* @param mixed $out
* @param bool $lookWhite save information about whitespace before and after
* @param-out array $out
*
* @return bool
*/
@ -3849,7 +3873,8 @@ class Parser
/**
* Parse a variable
*
* @param array $out
* @param mixed $out
* @param-out array{Type::*, string} $out
*
* @return bool
*/
@ -3878,9 +3903,10 @@ class Parser
/**
* Parse a keyword
*
* @param string $word
* @param bool $eatWhitespace
* @param bool $inSelector
* @param mixed $word
* @param bool $eatWhitespace
* @param bool $inSelector
* @param-out string $word
*
* @return bool
*/
@ -3996,7 +4022,8 @@ class Parser
/**
* Parse a url
*
* @param array $out
* @param mixed $out
* @param-out array $out
*
* @return bool
*/
@ -4006,10 +4033,10 @@ class Parser
$s = $this->count;
if (
($this->string($out) || $this->spaceList($out)) &&
($this->string($inner) || $this->spaceList($inner)) &&
$this->matchChar(')')
) {
$out = [Type::T_STRING, '', ['url(', $out, ')']];
$out = [Type::T_STRING, '', ['url(', $inner, ')']];
return true;
}
@ -4052,7 +4079,7 @@ class Parser
/**
* Strip assignment flag from the list
*
* @param array $value
* @param array|Number $value
*
* @return string[]
*/

View file

@ -95,6 +95,9 @@ class Type
* @internal
*/
const T_FOR = 'for';
/**
* @internal
*/
const T_FUNCTION = 'function';
/**
* @internal

View file

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

View file

@ -59,7 +59,7 @@ final class Warn
*
* @internal
*/
public static function setCallback(callable $callback = null)
public static function setCallback(?callable $callback = null)
{
$previousCallback = self::$callback;
self::$callback = $callback;

View file

@ -1,20 +0,0 @@
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.

View file

@ -1,71 +0,0 @@
# 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.

View file

@ -43,7 +43,7 @@
"thoughtbot/bourbon": "^7.0",
"twbs/bootstrap": "~5.0",
"twbs/bootstrap4": "4.6.1",
"zurb/foundation": "~6.5"
"zurb/foundation": "~6.7.0"
},
"repositories": [
{

View file

@ -606,7 +606,7 @@ class elFinder
$this->version = (string)self::$ApiVersion;
// set error handler of WARNING, NOTICE
$errLevel = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR;
$errLevel = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_RECOVERABLE_ERROR;
if (defined('E_DEPRECATED')) {
$errLevel |= E_DEPRECATED | E_USER_DEPRECATED;
}