Skip to content

[TASK] Initialize KeyFrame properties #1146

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 1 commit 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Please also have a look at our

### Changed

- Initialize `KeyFrame` properties to sensible defaults (#1146)
- Make `OutputFormat` `final` (#1128)
- Mark the `OutputFormat` constructor as `@internal` (#1131)
- Mark `OutputFormatter` as `@internal` (#896)
Expand Down
6 changes: 0 additions & 6 deletions config/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ parameters:
count: 1
path: ../src/CSSList/KeyFrame.php

-
message: '#^Parameters should have "string" types as the only types passed to this method$#'
identifier: typePerfect.narrowPublicClassMethodParamType
count: 2
path: ../src/CSSList/KeyFrame.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
Expand Down
32 changes: 16 additions & 16 deletions src/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@
class KeyFrame extends CSSList implements AtRule
{
/**
* @var string|null
* @var non-empty-string
*/
private $vendorKeyFrame;
private $vendorKeyFrame = 'keyframes';

/**
* @var string|null
* @var non-empty-string
*/
private $animationName;
private $animationName = 'none';

/**
* @param string $vendorKeyFrame
* @param non-empty-string $vendorKeyFrame
*/
public function setVendorKeyFrame($vendorKeyFrame): void
public function setVendorKeyFrame(string $vendorKeyFrame): void
{
$this->vendorKeyFrame = $vendorKeyFrame;
}

/**
* @return string|null
* @return non-empty-string
*/
public function getVendorKeyFrame()
public function getVendorKeyFrame(): string
{
return $this->vendorKeyFrame;
}

/**
* @param string $animationName
* @param non-empty-string $animationName
*/
public function setAnimationName($animationName): void
public function setAnimationName(string $animationName): void
{
$this->animationName = $animationName;
}

/**
* @return string|null
* @return non-empty-string
*/
public function getAnimationName()
public function getAnimationName(): string
{
return $this->animationName;
}
Expand Down Expand Up @@ -74,17 +74,17 @@ public function isRootList(): bool
}

/**
* @return string|null
* @return non-empty-string
*/
public function atRuleName()
public function atRuleName(): string
{
return $this->vendorKeyFrame;
}

/**
* @return string|null
* @return non-empty-string
*/
public function atRuleArgs()
public function atRuleArgs(): string
{
return $this->animationName;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/Unit/CSSList/KeyFrameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,24 @@ public function getLineNoReturnsLineNumberProvidedToConstructor(): void

self::assertSame($lineNumber, $subject->getLineNo());
}

/**
* @test
*/
public function getAnimationNameByDefaultReturnsNone(): void
{
$subject = new KeyFrame();

self::assertSame('none', $subject->getAnimationName());
}

/**
* @test
*/
public function getVendorKeyFrameByDefaultReturnsKeyframes(): void
{
$subject = new KeyFrame();

self::assertSame('keyframes', $subject->getVendorKeyFrame());
}
}