MDL-75475 lib: Upgraded PHP CSS Parser to 8.4.0

This commit is contained in:
David Woloszyn
2022-10-20 09:32:47 +11:00
parent f8d28e4ca6
commit c8ee3c9051
40 changed files with 5244 additions and 3086 deletions
+121 -53
View File
@@ -2,68 +2,136 @@
namespace Sabberworm\CSS\Property;
use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Value\URL;
/**
* Class representing an @import rule.
*/
class Import implements AtRule {
private $oLocation;
private $sMediaQuery;
protected $iLineNo;
protected $aComments;
public function __construct(URL $oLocation, $sMediaQuery, $iLineNo = 0) {
$this->oLocation = $oLocation;
$this->sMediaQuery = $sMediaQuery;
$this->iLineNo = $iLineNo;
$this->aComments = array();
}
* Class representing an `@import` rule.
*/
class Import implements AtRule
{
/**
* @var URL
*/
private $oLocation;
/**
* @return int
*/
public function getLineNo() {
return $this->iLineNo;
}
/**
* @var string
*/
private $sMediaQuery;
public function setLocation($oLocation) {
$this->oLocation = $oLocation;
}
/**
* @var int
*/
protected $iLineNo;
public function getLocation() {
return $this->oLocation;
}
public function __toString() {
return $this->render(new \Sabberworm\CSS\OutputFormat());
}
/**
* @var array<array-key, Comment>
*/
protected $aComments;
public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
return "@import ".$this->oLocation->render($oOutputFormat).($this->sMediaQuery === null ? '' : ' '.$this->sMediaQuery).';';
}
/**
* @param URL $oLocation
* @param string $sMediaQuery
* @param int $iLineNo
*/
public function __construct(URL $oLocation, $sMediaQuery, $iLineNo = 0)
{
$this->oLocation = $oLocation;
$this->sMediaQuery = $sMediaQuery;
$this->iLineNo = $iLineNo;
$this->aComments = [];
}
public function atRuleName() {
return 'import';
}
/**
* @return int
*/
public function getLineNo()
{
return $this->iLineNo;
}
public function atRuleArgs() {
$aResult = array($this->oLocation);
if($this->sMediaQuery) {
array_push($aResult, $this->sMediaQuery);
}
return $aResult;
}
/**
* @param URL $oLocation
*
* @return void
*/
public function setLocation($oLocation)
{
$this->oLocation = $oLocation;
}
public function addComments(array $aComments) {
$this->aComments = array_merge($this->aComments, $aComments);
}
/**
* @return URL
*/
public function getLocation()
{
return $this->oLocation;
}
public function getComments() {
return $this->aComments;
}
/**
* @return string
*/
public function __toString()
{
return $this->render(new OutputFormat());
}
public function setComments(array $aComments) {
$this->aComments = $aComments;
}
}
/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
{
return "@import " . $this->oLocation->render($oOutputFormat)
. ($this->sMediaQuery === null ? '' : ' ' . $this->sMediaQuery) . ';';
}
/**
* @return string
*/
public function atRuleName()
{
return 'import';
}
/**
* @return array<int, URL|string>
*/
public function atRuleArgs()
{
$aResult = [$this->oLocation];
if ($this->sMediaQuery) {
array_push($aResult, $this->sMediaQuery);
}
return $aResult;
}
/**
* @param array<array-key, Comment> $aComments
*
* @return void
*/
public function addComments(array $aComments)
{
$this->aComments = array_merge($this->aComments, $aComments);
}
/**
* @return array<array-key, Comment>
*/
public function getComments()
{
return $this->aComments;
}
/**
* @param array<array-key, Comment> $aComments
*
* @return void
*/
public function setComments(array $aComments)
{
$this->aComments = $aComments;
}
}