Skip to content

Commit 46da4b2

Browse files
authored
[TASK] Initialize KeyFrame properties (#1146)
They fortunately have obvious default values. This change means it can be enforced that they are always non-empty strings. Type declarations have been updated to reflect that.
1 parent 66718c1 commit 46da4b2

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Please also have a look at our
2121

2222
### Changed
2323

24+
- Initialize `KeyFrame` properties to sensible defaults (#1146)
2425
- Make `OutputFormat` `final` (#1128)
2526
- Mark the `OutputFormat` constructor as `@internal` (#1131)
2627
- Mark `OutputFormatter` as `@internal` (#896)

config/phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ parameters:
9696
count: 1
9797
path: ../src/CSSList/KeyFrame.php
9898

99-
-
100-
message: '#^Parameters should have "string" types as the only types passed to this method$#'
101-
identifier: typePerfect.narrowPublicClassMethodParamType
102-
count: 2
103-
path: ../src/CSSList/KeyFrame.php
104-
10599
-
106100
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
107101
identifier: equal.notAllowed

src/CSSList/KeyFrame.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@
1010
class KeyFrame extends CSSList implements AtRule
1111
{
1212
/**
13-
* @var string|null
13+
* @var non-empty-string
1414
*/
15-
private $vendorKeyFrame;
15+
private $vendorKeyFrame = 'keyframes';
1616

1717
/**
18-
* @var string|null
18+
* @var non-empty-string
1919
*/
20-
private $animationName;
20+
private $animationName = 'none';
2121

2222
/**
23-
* @param string $vendorKeyFrame
23+
* @param non-empty-string $vendorKeyFrame
2424
*/
25-
public function setVendorKeyFrame($vendorKeyFrame): void
25+
public function setVendorKeyFrame(string $vendorKeyFrame): void
2626
{
2727
$this->vendorKeyFrame = $vendorKeyFrame;
2828
}
2929

3030
/**
31-
* @return string|null
31+
* @return non-empty-string
3232
*/
33-
public function getVendorKeyFrame()
33+
public function getVendorKeyFrame(): string
3434
{
3535
return $this->vendorKeyFrame;
3636
}
3737

3838
/**
39-
* @param string $animationName
39+
* @param non-empty-string $animationName
4040
*/
41-
public function setAnimationName($animationName): void
41+
public function setAnimationName(string $animationName): void
4242
{
4343
$this->animationName = $animationName;
4444
}
4545

4646
/**
47-
* @return string|null
47+
* @return non-empty-string
4848
*/
49-
public function getAnimationName()
49+
public function getAnimationName(): string
5050
{
5151
return $this->animationName;
5252
}
@@ -74,17 +74,17 @@ public function isRootList(): bool
7474
}
7575

7676
/**
77-
* @return string|null
77+
* @return non-empty-string
7878
*/
79-
public function atRuleName()
79+
public function atRuleName(): string
8080
{
8181
return $this->vendorKeyFrame;
8282
}
8383

8484
/**
85-
* @return string|null
85+
* @return non-empty-string
8686
*/
87-
public function atRuleArgs()
87+
public function atRuleArgs(): string
8888
{
8989
return $this->animationName;
9090
}

tests/Unit/CSSList/KeyFrameTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,24 @@ public function getLineNoReturnsLineNumberProvidedToConstructor(): void
6868

6969
self::assertSame($lineNumber, $subject->getLineNo());
7070
}
71+
72+
/**
73+
* @test
74+
*/
75+
public function getAnimationNameByDefaultReturnsNone(): void
76+
{
77+
$subject = new KeyFrame();
78+
79+
self::assertSame('none', $subject->getAnimationName());
80+
}
81+
82+
/**
83+
* @test
84+
*/
85+
public function getVendorKeyFrameByDefaultReturnsKeyframes(): void
86+
{
87+
$subject = new KeyFrame();
88+
89+
self::assertSame('keyframes', $subject->getVendorKeyFrame());
90+
}
7191
}

0 commit comments

Comments
 (0)