Skip to content

Commit 490f547

Browse files
claudedeviantintegral
authored andcommitted
refactor: convert PHPDoc annotations to native PHP type declarations
Converted PHPDoc type annotations to native PHP type declarations where possible: - Added native property type to HarFileRepository::$repositoryPath - Added native property type to TruncatingDateTimeHandler::$innerHandler - Added missing return types to TruncatingDateTimeHandler methods (array, mixed, string) - Added missing parameter and return types to Timings::getDns() and setDns() - Added static return types to MessageInterface::setHeaders() and setHttpVersion() - Updated trait implementations to use static instead of self for fluent interfaces All changes maintain backward compatibility with PHP 8.2+ and pass existing test suite.
1 parent 7a81e3f commit 490f547

File tree

6 files changed

+11
-29
lines changed

6 files changed

+11
-29
lines changed

src/Handler/TruncatingDateTimeHandler.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414
*/
1515
class TruncatingDateTimeHandler implements SubscribingHandlerInterface
1616
{
17-
/**
18-
* @var DateHandler
19-
*/
20-
private $innerHandler;
17+
private DateHandler $innerHandler;
2118

22-
public static function getSubscribingMethods()
19+
public static function getSubscribingMethods(): array
2320
{
2421
$methods = [];
2522
$types = ['DateTime', 'DateTimeImmutable', 'DateInterval'];
@@ -70,17 +67,15 @@ public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor,
7067
/**
7168
* Delegate undefined methods to the inner class.
7269
*/
73-
public function __call(string $name, array $arguments)
70+
public function __call(string $name, array $arguments): mixed
7471
{
7572
return $this->innerHandler->{$name}(...$arguments);
7673
}
7774

7875
/**
7976
* Truncate microseconds in a date to 6 digits of precision, which is the maximum PHP's DateTime supports.
80-
*
81-
* @return string|string[]
8277
*/
83-
public function truncateMicroseconds($data)
78+
public function truncateMicroseconds(string $data): string
8479
{
8580
$microseconds = substr($data, 19);
8681
if (str_contains($data, '+')) {

src/MessageInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public function getHeadersSize(): int;
2020
*/
2121
public function getHeaders(): array;
2222

23-
public function setHeaders(array $headers);
23+
public function setHeaders(array $headers): static;
2424

2525
public function getHttpVersion(): string;
2626

27-
public function setHttpVersion(string $version);
27+
public function setHttpVersion(string $version): static;
2828
}

src/Repository/HarFileRepository.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
*/
1313
class HarFileRepository implements RepositoryInterface
1414
{
15-
/**
16-
* @var string
17-
*/
18-
private $repositoryPath;
15+
private string $repositoryPath;
1916

2017
/**
21-
* HarFileRepository constructor.
22-
*
2318
* @param string $repositoryPath the path to the repository on disk
2419
*/
2520
public function __construct(string $repositoryPath)

src/SharedFields/HeadersTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getHeadersSize(): int
3232
/**
3333
* @param \Deviantintegral\Har\Header[] $headers
3434
*/
35-
public function setHeaders(array $headers): self
35+
public function setHeaders(array $headers): static
3636
{
3737
$this->headers = $headers;
3838

src/SharedFields/HttpVersionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ trait HttpVersionTrait
1313
*/
1414
private string $httpVersion;
1515

16-
public function setHttpVersion(string $httpVersion): self
16+
public function setHttpVersion(string $httpVersion): static
1717
{
1818
$this->httpVersion = $httpVersion;
1919

src/Timings.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,12 @@ public function hasDns(): bool
8888
return -1.0 !== $this->dns;
8989
}
9090

91-
/**
92-
* @return float
93-
*/
94-
public function getDns()
91+
public function getDns(): float
9592
{
9693
return $this->dns;
9794
}
9895

99-
/**
100-
* @param float $dns
101-
*
102-
* @return Timings
103-
*/
104-
public function setDns($dns)
96+
public function setDns(float $dns): self
10597
{
10698
$this->dns = $dns;
10799

0 commit comments

Comments
 (0)