Skip to content

[TASK] Use native types for all constructor parameters #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ parameters:
path: ../src/CSSList/Document.php

-
message: '#^Cannot call method render\(\) on string\.$#'
identifier: method.nonObject
message: '#^Method Sabberworm\\CSS\\Property\\CSSNamespace\:\:atRuleArgs\(\) should return array\<int, string\> but returns list\<Sabberworm\\CSS\\Value\\CSSString\|Sabberworm\\CSS\\Value\\URL\|string\>\.$#'
identifier: return.type
count: 1
path: ../src/Property/CSSNamespace.php

Expand Down
13 changes: 7 additions & 6 deletions src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Value\CSSString;
use Sabberworm\CSS\Value\URL;

/**
* `CSSNamespace` represents an `@namespace` rule.
*/
class CSSNamespace implements AtRule
{
/**
* @var string
* @var CSSString|URL
*/
private $url;

Expand All @@ -35,11 +37,10 @@ class CSSNamespace implements AtRule
protected $comments = [];

/**
* @param string $url
* @param string|null $prefix
* @param CSSString|URL $url
* @param int<0, max> $lineNumber
*/
public function __construct($url, $prefix = null, int $lineNumber = 0)
public function __construct($url, ?string $prefix = null, int $lineNumber = 0)
{
$this->url = $url;
$this->prefix = $prefix;
Expand Down Expand Up @@ -69,7 +70,7 @@ public function render(OutputFormat $outputFormat): string
}

/**
* @return string
* @return CSSString|URL
*/
public function getUrl()
{
Expand All @@ -85,7 +86,7 @@ public function getPrefix()
}

/**
* @param string $url
* @param CSSString|URL $url
*/
public function setUrl($url): void
{
Expand Down
4 changes: 1 addition & 3 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ class Rule implements Renderable, Commentable
protected $comments = [];

/**
* @param string $rule
* @param int<0, max> $lineNumber
* @param int $columnNumber
*/
public function __construct($rule, int $lineNumber = 0, $columnNumber = 0)
public function __construct(string $rule, int $lineNumber = 0, int $columnNumber = 0)
{
$this->rule = $rule;
$this->lineNumber = $lineNumber;
Expand Down
3 changes: 1 addition & 2 deletions src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ class AtRuleSet extends RuleSet implements AtRule

/**
* @param non-empty-string $type
* @param string $arguments
* @param int<0, max> $lineNumber
*/
public function __construct($type, $arguments = '', int $lineNumber = 0)
public function __construct(string $type, string $arguments = '', int $lineNumber = 0)
{
parent::__construct($lineNumber);
$this->type = $type;
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 $name;

/**
* @param string $name
* @param RuleValueList|array<array-key, Value|string> $arguments
* @param string $separator
* @param int<0, max> $lineNumber
*/
public function __construct($name, $arguments, $separator = ',', int $lineNumber = 0)
public function __construct(string $name, $arguments, string $separator = ',', int $lineNumber = 0)
{
if ($arguments instanceof RuleValueList) {
$separator = $arguments->getListSeparator();
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 $separator
* @param int<0, max> $lineNumber
*/
public function __construct($separator = ',', int $lineNumber = 0)
public function __construct(string $separator = ',', int $lineNumber = 0)
{
parent::__construct([], $separator, $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 $components
* @param string $separator
* @param int<0, max> $lineNumber
*/
public function __construct($components = [], $separator = ',', int $lineNumber = 0)
public function __construct($components = [], string $separator = ',', int $lineNumber = 0)
{
parent::__construct($lineNumber);
if (!\is_array($components)) {
Expand Down