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

@@ -5,10 +5,15 @@ namespace Sabberworm\CSS\Parsing;
use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\Settings;
/**
* @internal since 8.7.0
*/
class ParserState
{
/**
* @var null
*
* @internal since 8.5.2
*/
const EOF = null;
@@ -33,6 +38,8 @@ class ParserState
private $iCurrentPosition;
/**
* will only be used if the CSS does not contain an `@charset` declaration
*
* @var string
*/
private $sCharset;
@@ -48,7 +55,7 @@ class ParserState
private $iLineNo;
/**
* @param string $sText
* @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
* @param int $iLineNo
*/
public function __construct($sText, Settings $oParserSettings, $iLineNo = 1)
@@ -61,6 +68,8 @@ class ParserState
}
/**
* Sets the charset to be used if the CSS does not contain an `@charset` declaration.
*
* @param string $sCharset
*
* @return void
@@ -75,6 +84,8 @@ class ParserState
}
/**
* Returns the charset that is used if the CSS does not contain an `@charset` declaration.
*
* @return string
*/
public function getCharset()
@@ -106,21 +117,44 @@ class ParserState
return $this->oParserSettings;
}
/**
* @return \Sabberworm\CSS\Parsing\Anchor
*/
public function anchor()
{
return new Anchor($this->iCurrentPosition, $this);
}
/**
* @param int $iPosition
*
* @return void
*/
public function setPosition($iPosition)
{
$this->iCurrentPosition = $iPosition;
}
/**
* @param bool $bIgnoreCase
*
* @return string
*
* @throws UnexpectedTokenException
*
* @internal since V8.8.0
*/
public function parseIdentifier($bIgnoreCase = true)
{
if ($this->isEnd()) {
throw new UnexpectedEOFException('', '', 'identifier', $this->iLineNo);
}
$sResult = $this->parseCharacter(true);
if ($sResult === null) {
throw new UnexpectedTokenException($sResult, $this->peek(5), 'identifier', $this->iLineNo);
}
$sCharacter = null;
while (($sCharacter = $this->parseCharacter(true)) !== null) {
while (!$this->isEnd() && ($sCharacter = $this->parseCharacter(true)) !== null) {
if (preg_match('/[a-zA-Z0-9\x{00A0}-\x{FFFF}_-]/Sux', $sCharacter)) {
$sResult .= $sCharacter;
} else {
@@ -140,6 +174,8 @@ class ParserState
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*
* @internal since V8.8.0
*/
public function parseCharacter($bIsForIdentifier)
{
@@ -204,7 +240,7 @@ class ParserState
*/
public function consumeWhiteSpace()
{
$comments = [];
$aComments = [];
do {
while (preg_match('/\\s/isSu', $this->peek()) === 1) {
$this->consume(1);
@@ -214,16 +250,16 @@ class ParserState
$oComment = $this->consumeComment();
} catch (UnexpectedEOFException $e) {
$this->iCurrentPosition = $this->iLength;
return;
return $aComments;
}
} else {
$oComment = $this->consumeComment();
}
if ($oComment !== false) {
$comments[] = $oComment;
$aComments[] = $oComment;
}
} while ($oComment !== false);
return $comments;
return $aComments;
}
/**

View File

@@ -2,12 +2,12 @@
namespace Sabberworm\CSS\Parsing;
class SourceException extends \Exception
use Sabberworm\CSS\Position\Position;
use Sabberworm\CSS\Position\Positionable;
class SourceException extends \Exception implements Positionable
{
/**
* @var int
*/
private $iLineNo;
use Position;
/**
* @param string $sMessage
@@ -15,18 +15,10 @@ class SourceException extends \Exception
*/
public function __construct($sMessage, $iLineNo = 0)
{
$this->iLineNo = $iLineNo;
$this->setPosition($iLineNo);
if (!empty($iLineNo)) {
$sMessage .= " [line no: $iLineNo]";
}
parent::__construct($sMessage);
}
/**
* @return int
*/
public function getLineNo()
{
return $this->iLineNo;
}
}