Skip to content

[TASK] Add native type declarations for atRuleName() #1145

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

Merged
merged 2 commits into from
Mar 12, 2025
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Please also have a look at our
- Make all non-private properties `@internal` (#886)
- Use more native type declarations and strict mode
(#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958,
#964, #967, #1000, #1044, #1134, #1136, #1137, #1139, #1140, #1141)
#964, #967, #1000, #1044, #1134, #1136, #1137, #1139, #1140, #1141, #1145)
- Add visibility to all class/interface constants (#469)

### Deprecated
Expand Down
6 changes: 5 additions & 1 deletion src/CSSList/AtRuleBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class AtRuleBlockList extends CSSBlockList implements AtRule
{
/**
* @var string
* @var non-empty-string
*/
private $type;

Expand All @@ -23,6 +23,7 @@ class AtRuleBlockList extends CSSBlockList implements AtRule
private $arguments;

/**
* @param non-empty-string $type
* @param int<0, max> $lineNumber
*/
public function __construct(string $type, string $arguments = '', int $lineNumber = 0)
Expand All @@ -32,6 +33,9 @@ public function __construct(string $type, string $arguments = '', int $lineNumbe
$this->arguments = $arguments;
}

/**
* @return non-empty-string
*/
public function atRuleName(): string
{
return $this->type;
Expand Down
4 changes: 2 additions & 2 deletions src/Property/AtRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ interface AtRule extends Renderable, Commentable
public const BLOCK_RULES = 'media/document/supports/region-style/font-feature-values';

/**
* @return string|null
* @return non-empty-string
*/
public function atRuleName();
public function atRuleName(): string;

/**
* @return string|null
Expand Down
2 changes: 1 addition & 1 deletion src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function setPrefix($prefix): void
}

/**
* @return string
* @return non-empty-string
*/
public function atRuleName(): string
{
Expand Down
3 changes: 3 additions & 0 deletions src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function render(OutputFormat $outputFormat): string
return "{$outputFormat->comments($this)}@charset {$this->charset->render($outputFormat)};";
}

/**
* @return non-empty-string
*/
public function atRuleName(): string
{
return 'charset';
Expand Down
3 changes: 3 additions & 0 deletions src/Property/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public function render(OutputFormat $outputFormat): string
. ($this->mediaQuery === null ? '' : ' ' . $this->mediaQuery) . ';';
}

/**
* @return non-empty-string
*/
public function atRuleName(): string
{
return 'import';
Expand Down
8 changes: 4 additions & 4 deletions src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class AtRuleSet extends RuleSet implements AtRule
{
/**
* @var string
* @var non-empty-string
*/
private $type;

Expand All @@ -26,7 +26,7 @@ class AtRuleSet extends RuleSet implements AtRule
private $arguments;

/**
* @param string $type
* @param non-empty-string $type
* @param string $arguments
* @param int<0, max> $lineNumber
*/
Expand All @@ -38,9 +38,9 @@ public function __construct($type, $arguments = '', int $lineNumber = 0)
}

/**
* @return string
* @return non-empty-string
*/
public function atRuleName()
public function atRuleName(): string
{
return $this->type;
}
Expand Down