Initial commit

This commit is contained in:
root
2026-05-26 08:07:45 +00:00
commit a234e55e64
4263 changed files with 855927 additions and 0 deletions
@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace Sabberworm\CSS\Position;
/**
* Provides a standard reusable implementation of `Positionable`.
*
* @internal
*
* @phpstan-require-implements Positionable
*/
trait Position
{
/**
* @var int<1, max>|null
*/
protected $lineNumber;
/**
* @var int<0, max>|null
*/
protected $columnNumber;
/**
* @return int<1, max>|null
*/
public function getLineNumber()
{
return $this->lineNumber;
}
/**
* @return int<0, max>
*/
public function getLineNo()
{
$lineNumber = $this->getLineNumber();
return $lineNumber !== null ? $lineNumber : 0;
}
/**
* @return int<0, max>|null
*/
public function getColumnNumber()
{
return $this->columnNumber;
}
/**
* @return int<0, max>
*/
public function getColNo()
{
$columnNumber = $this->getColumnNumber();
return $columnNumber !== null ? $columnNumber : 0;
}
/**
* @param int<0, max>|null $lineNumber
* @param int<0, max>|null $columnNumber
*/
public function setPosition($lineNumber, $columnNumber = null)
{
// The conditional is for backwards compatibility (backcompat); `0` will not be allowed in future.
$this->lineNumber = $lineNumber !== 0 ? $lineNumber : null;
$this->columnNumber = $columnNumber;
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Sabberworm\CSS\Position;
/**
* Represents a CSS item that may have a position in the source CSS document (line number and possibly column number).
*
* A standard implementation of this interface is available in the `Position` trait.
*/
interface Positionable
{
/**
* @return int<1, max>|null
*/
public function getLineNumber();
/**
* @return int<0, max>
*
* @deprecated in version 8.9.0, will be removed in v9.0. Use `getLineNumber()` instead.
*/
public function getLineNo();
/**
* @return int<0, max>|null
*/
public function getColumnNumber();
/**
* @return int<0, max>
*
* @deprecated in version 8.9.0, will be removed in v9.0. Use `getColumnNumber()` instead.
*/
public function getColNo();
/**
* @param int<0, max>|null $lineNumber
* Providing zero for this parameter is deprecated in version 8.9.0, and will not be supported from v9.0.
* Use `null` instead when no line number is available.
* @param int<0, max>|null $columnNumber
*/
public function setPosition($lineNumber, $columnNumber = null);
}