Re-dump autoloader and composer.lock

This commit is contained in:
Stephen Abello
2025-09-18 10:26:38 +02:00
parent 7e515e7216
commit edbe4974ac
613 changed files with 5661 additions and 4259 deletions

View File

@@ -4,27 +4,32 @@ namespace Sabberworm\CSS\Rule;
use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\Comment\Commentable;
use Sabberworm\CSS\CSSElement;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Parsing\ParserState;
use Sabberworm\CSS\Parsing\UnexpectedEOFException;
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
use Sabberworm\CSS\Renderable;
use Sabberworm\CSS\Position\Position;
use Sabberworm\CSS\Position\Positionable;
use Sabberworm\CSS\Value\RuleValueList;
use Sabberworm\CSS\Value\Value;
/**
* RuleSets contains Rule objects which always have a key and a value.
* In CSS, Rules are expressed as follows: “key: value[0][0] value[0][1], value[1][0] value[1][1];”
* `Rule`s just have a string key (the rule) and a 'Value'.
*
* In CSS, `Rule`s are expressed as follows: “key: value[0][0] value[0][1], value[1][0] value[1][1];”
*/
class Rule implements Renderable, Commentable
class Rule implements Commentable, CSSElement, Positionable
{
use Position;
/**
* @var string
*/
private $sRule;
/**
* @var RuleValueList|null
* @var RuleValueList|string|null
*/
private $mValue;
@@ -38,18 +43,10 @@ class Rule implements Renderable, Commentable
*/
private $aIeHack;
/**
* @var int
*/
protected $iLineNo;
/**
* @var int
*/
protected $iColNo;
/**
* @var array<array-key, Comment>
*
* @internal since 8.8.0
*/
protected $aComments;
@@ -64,20 +61,23 @@ class Rule implements Renderable, Commentable
$this->mValue = null;
$this->bIsImportant = false;
$this->aIeHack = [];
$this->iLineNo = $iLineNo;
$this->iColNo = $iColNo;
$this->setPosition($iLineNo, $iColNo);
$this->aComments = [];
}
/**
* @param array<int, Comment> $commentsBeforeRule
*
* @return Rule
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*
* @internal since V8.8.0
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState, $commentsBeforeRule = [])
{
$aComments = $oParserState->consumeWhiteSpace();
$aComments = \array_merge($commentsBeforeRule, $oParserState->consumeWhiteSpace());
$oRule = new Rule(
$oParserState->parseIdentifier(!$oParserState->comes("--")),
$oParserState->currentLine(),
@@ -106,50 +106,31 @@ class Rule implements Renderable, Commentable
while ($oParserState->comes(';')) {
$oParserState->consume(';');
}
$oParserState->consumeWhiteSpace();
return $oRule;
}
/**
* Returns a list of delimiters (or separators).
* The first item is the innermost separator (or, put another way, the highest-precedence operator).
* The sequence continues to the outermost separator (or lowest-precedence operator).
*
* @param string $sRule
*
* @return array<int, string>
* @return list<non-empty-string>
*/
private static function listDelimiterForRule($sRule)
{
if (preg_match('/^font($|-)/', $sRule)) {
return [',', '/', ' '];
}
return [',', ' ', '/'];
}
/**
* @return int
*/
public function getLineNo()
{
return $this->iLineNo;
}
/**
* @return int
*/
public function getColNo()
{
return $this->iColNo;
}
/**
* @param int $iLine
* @param int $iColumn
*
* @return void
*/
public function setPosition($iLine, $iColumn)
{
$this->iColNo = $iColumn;
$this->iLineNo = $iLine;
switch ($sRule) {
case 'src':
return [' ', ','];
default:
return [',', ' ', '/'];
}
}
/**
@@ -171,7 +152,7 @@ class Rule implements Renderable, Commentable
}
/**
* @return RuleValueList|null
* @return RuleValueList|string|null
*/
public function getValue()
{
@@ -179,7 +160,7 @@ class Rule implements Renderable, Commentable
}
/**
* @param RuleValueList|null $mValue
* @param RuleValueList|string|null $mValue
*
* @return void
*/
@@ -277,7 +258,7 @@ class Rule implements Renderable, Commentable
}
if (!$this->mValue instanceof RuleValueList || $this->mValue->getListSeparator() !== $sType) {
$mCurrentValue = $this->mValue;
$this->mValue = new RuleValueList($sType, $this->iLineNo);
$this->mValue = new RuleValueList($sType, $this->getLineNumber());
if ($mCurrentValue) {
$this->mValue->addListComponent($mCurrentValue);
}
@@ -291,6 +272,8 @@ class Rule implements Renderable, Commentable
* @param int $iModifier
*
* @return void
*
* @deprecated since V8.8.0, will be removed in V9.0
*/
public function addIeHack($iModifier)
{
@@ -301,6 +284,8 @@ class Rule implements Renderable, Commentable
* @param array<int, int> $aModifiers
*
* @return void
*
* @deprecated since V8.8.0, will be removed in V9.0
*/
public function setIeHack(array $aModifiers)
{
@@ -309,6 +294,8 @@ class Rule implements Renderable, Commentable
/**
* @return array<int, int>
*
* @deprecated since V8.8.0, will be removed in V9.0
*/
public function getIeHack()
{
@@ -335,6 +322,8 @@ class Rule implements Renderable, Commentable
/**
* @return string
*
* @deprecated in V8.8.0, will be removed in V9.0.0. Use `render` instead.
*/
public function __toString()
{
@@ -342,12 +331,14 @@ class Rule implements Renderable, Commentable
}
/**
* @param OutputFormat|null $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
{
$sResult = "{$this->sRule}:{$oOutputFormat->spaceAfterRuleName()}";
if ($this->mValue instanceof Value) { //Can also be a ValueList
$sResult = "{$oOutputFormat->comments($this)}{$this->sRule}:{$oOutputFormat->spaceAfterRuleName()}";
if ($this->mValue instanceof Value) { // Can also be a ValueList
$sResult .= $this->mValue->render($oOutputFormat);
} else {
$sResult .= $this->mValue;