Skip to content

Commit

Permalink
[TASK] Use native types for all constructor parameters
Browse files Browse the repository at this point in the history
Part of #811
  • Loading branch information
oliverklee committed Feb 14, 2025
1 parent fa5ff8a commit e511f8c
Show file tree
Hide file tree
Showing 28 changed files with 28 additions and 52 deletions.
4 changes: 1 addition & 3 deletions src/CSSList/AtRuleBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ class AtRuleBlockList extends CSSBlockList implements AtRule
private $arguments;

/**
* @param string $type
* @param string $arguments
* @param int<0, max> $lineNumber
*/
public function __construct($type, $arguments = '', $lineNumber = 0)
public function __construct(string $type, string $arguments = '', int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->type = $type;
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/CSSBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class CSSBlockList extends CSSList
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct($lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract class CSSList implements Renderable, Commentable
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
$this->comments = [];
$this->contents = [];
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Document extends CSSBlockList
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct($lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class KeyFrame extends CSSList implements AtRule
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->vendorKeyFrame = null;
Expand Down
3 changes: 1 addition & 2 deletions src/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ class Comment implements Renderable
protected $commentText;

/**
* @param string $commentText
* @param int<0, max> $lineNumber
*/
public function __construct($commentText = '', $lineNumber = 0)
public function __construct(string $commentText = '', int $lineNumber = 0)
{
$this->commentText = $commentText;
$this->lineNumber = $lineNumber;
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Parser
* @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
* @param int<0, max> $lineNumber the line number (starting from 1, not from 0)
*/
public function __construct($sText, ?Settings $oParserSettings = null, $lineNumber = 1)
public function __construct(string $sText, ?Settings $oParserSettings = null, int $lineNumber = 1)
{
if ($oParserSettings === null) {
$oParserSettings = Settings::create();
Expand Down
5 changes: 1 addition & 4 deletions src/Parsing/Anchor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class Anchor
*/
private $parserState;

/**
* @param int $iPosition
*/
public function __construct($iPosition, ParserState $parserState)
public function __construct(int $iPosition, ParserState $parserState)
{
$this->iPosition = $iPosition;
$this->parserState = $parserState;
Expand Down
2 changes: 1 addition & 1 deletion src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ParserState
* @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
* @param int<0, max> $lineNumber
*/
public function __construct($sText, Settings $oParserSettings, $lineNumber = 1)
public function __construct(string $sText, Settings $oParserSettings, int $lineNumber = 1)
{
$this->oParserSettings = $oParserSettings;
$this->sText = $sText;
Expand Down
4 changes: 1 addition & 3 deletions src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ class CSSNamespace implements AtRule
protected $comments;

/**
* @param string $mUrl
* @param string|null $sPrefix
* @param int<0, max> $lineNumber
*/
public function __construct($mUrl, $sPrefix = null, $lineNumber = 0)
public function __construct(string $mUrl, ?string $sPrefix = null, int $lineNumber = 0)
{
$this->mUrl = $mUrl;
$this->sPrefix = $sPrefix;
Expand Down
2 changes: 1 addition & 1 deletion src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Charset implements AtRule
/**
* @param int<0, max> $lineNumber
*/
public function __construct(CSSString $oCharset, $lineNumber = 0)
public function __construct(CSSString $oCharset, int $lineNumber = 0)
{
$this->oCharset = $oCharset;
$this->lineNumber = $lineNumber;
Expand Down
3 changes: 1 addition & 2 deletions src/Property/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ class Import implements AtRule
protected $comments;

/**
* @param string $mediaQuery
* @param int<0, max> $lineNumber
*/
public function __construct(URL $location, $mediaQuery, $lineNumber = 0)
public function __construct(URL $location, string $mediaQuery, int $lineNumber = 0)
{
$this->location = $location;
$this->mediaQuery = $mediaQuery;
Expand Down
6 changes: 1 addition & 5 deletions src/Property/Selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ public static function isValid($sSelector)
return \preg_match(static::SELECTOR_VALIDATION_RX, $sSelector);
}

/**
* @param string $sSelector
* @param bool $bCalculateSpecificity
*/
public function __construct($sSelector, $bCalculateSpecificity = false)
public function __construct(string $sSelector, bool $bCalculateSpecificity = false)
{
$this->setSelector($sSelector);
if ($bCalculateSpecificity) {
Expand Down
4 changes: 1 addition & 3 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ class Rule implements Renderable, Commentable
protected $comments;

/**
* @param string $sRule
* @param int<0, max> $lineNumber
* @param int $iColNo
*/
public function __construct($sRule, $lineNumber = 0, $iColNo = 0)
public function __construct(string $sRule, int $lineNumber = 0, int $iColNo = 0)
{
$this->sRule = $sRule;
$this->mValue = null;
Expand Down
4 changes: 1 addition & 3 deletions src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ class AtRuleSet extends RuleSet implements AtRule
private $arguments;

/**
* @param string $sType
* @param string $arguments
* @param int<0, max> $lineNumber
*/
public function __construct($sType, $arguments = '', $lineNumber = 0)
public function __construct(string $sType, string $arguments = '', int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->sType = $sType;
Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DeclarationBlock extends RuleSet
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->aSelectors = [];
Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class RuleSet implements Renderable, Commentable
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
$this->aRules = [];
$this->lineNumber = $lineNumber;
Expand Down
4 changes: 1 addition & 3 deletions src/Value/CSSFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ class CSSFunction extends ValueList
protected $sName;

/**
* @param string $sName
* @param RuleValueList|array<array-key, Value|string> $aArguments
* @param string $sSeparator
* @param int<0, max> $lineNumber
*/
public function __construct($sName, $aArguments, $sSeparator = ',', $lineNumber = 0)
public function __construct(string $sName, $aArguments, string $sSeparator = ',', int $lineNumber = 0)
{
if ($aArguments instanceof RuleValueList) {
$sSeparator = $aArguments->getListSeparator();
Expand Down
3 changes: 1 addition & 2 deletions src/Value/CSSString.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ class CSSString extends PrimitiveValue
private $sString;

/**
* @param string $sString
* @param int<0, max> $lineNumber
*/
public function __construct($sString, $lineNumber = 0)
public function __construct(string $sString, int $lineNumber = 0)
{
$this->sString = $sString;
parent::__construct($lineNumber);
Expand Down
2 changes: 1 addition & 1 deletion src/Value/CalcRuleValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CalcRuleValueList extends RuleValueList
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct(',', $lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Color extends CSSFunction
* @param array<array-key, Value|string> $colorValues
* @param int<0, max> $lineNumber
*/
public function __construct(array $colorValues, $lineNumber = 0)
public function __construct(array $colorValues, int $lineNumber = 0)
{
parent::__construct(\implode('', \array_keys($colorValues)), $colorValues, ',', $lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LineName extends ValueList
* @param array<int, Value|string> $aComponents
* @param int<0, max> $lineNumber
*/
public function __construct(array $aComponents = [], $lineNumber = 0)
public function __construct(array $aComponents = [], int $lineNumber = 0)
{
parent::__construct($aComponents, ' ', $lineNumber);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Value/PrimitiveValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class PrimitiveValue extends Value
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
parent::__construct($lineNumber);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Value/RuleValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
class RuleValueList extends ValueList
{
/**
* @param string $sSeparator
* @param int<0, max> $lineNumber
*/
public function __construct($sSeparator = ',', $lineNumber = 0)
public function __construct(string $sSeparator = ',', int $lineNumber = 0)
{
parent::__construct([], $sSeparator, $lineNumber);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ class Size extends PrimitiveValue

/**
* @param float|int|string $fSize
* @param string|null $sUnit
* @param bool $bIsColorComponent
* @param int<0, max> $lineNumber
*/
public function __construct($fSize, $sUnit = null, $bIsColorComponent = false, $lineNumber = 0)
public function __construct($fSize, ?string $sUnit = null, bool $bIsColorComponent = false, int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->fSize = (float) $fSize;
Expand Down
2 changes: 1 addition & 1 deletion src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class URL extends PrimitiveValue
/**
* @param int<0, max> $lineNumber
*/
public function __construct(CSSString $oURL, $lineNumber = 0)
public function __construct(CSSString $oURL, int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->oURL = $oURL;
Expand Down
2 changes: 1 addition & 1 deletion src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class Value implements Renderable
/**
* @param int<0, max> $lineNumber
*/
public function __construct($lineNumber = 0)
public function __construct(int $lineNumber = 0)
{
$this->lineNumber = $lineNumber;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Value/ValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ abstract class ValueList extends Value

/**
* @param array<array-key, Value|string>|Value|string $aComponents
* @param string $sSeparator
* @param int<0, max> $lineNumber
*/
public function __construct($aComponents = [], $sSeparator = ',', $lineNumber = 0)
public function __construct($aComponents = [], string $sSeparator = ',', int $lineNumber = 0)
{
parent::__construct($lineNumber);
if (!\is_array($aComponents)) {
Expand Down

0 comments on commit e511f8c

Please sign in to comment.