Skip to content

Commit 2c4073a

Browse files
committed
Update phpstan and phpunit, fixes PR#5 and PR#6
1 parent 69ec7cf commit 2c4073a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"digitalrevolution/php-codesniffer-baseline": "^1.1",
2828
"phpmd/phpmd": "^2.12",
2929
"phpstan/extension-installer": "^1.2",
30-
"phpstan/phpstan": "^1.9.1",
31-
"phpstan/phpstan-phpunit": "^1.2.2",
32-
"phpunit/phpunit": "^11.5",
30+
"phpstan/phpstan": "^2.0.0",
31+
"phpstan/phpstan-phpunit": "^2.0.0",
32+
"phpunit/phpunit": "^12.0",
3333
"roave/security-advisories": "dev-latest",
3434
"squizlabs/php_codesniffer": "^3.7",
3535
"slevomat/coding-standard": "^8.16"

src/Protocol/IppAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __toString(): string
4343
} elseif ($this->type === IppTypeEnum::Bool) {
4444
$binary .= pack('n', 1) . pack('c', (int)Assert::boolean($this->value));
4545
} else {
46-
$binary .= pack('n', strlen(Assert::string($this->value))) . $this->value;
46+
$binary .= pack('n', strlen(Assert::string($this->value))) . Assert::string($this->value);
4747
}
4848

4949
return $binary;

src/Protocol/IppResponseParser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private function consume(string $response, int $length, ?IppTypeEnum $type): arr
9494
private function unpackDateTime(string $response): DateTime
9595
{
9696
// Datetime in rfc2579 format: https://datatracker.ietf.org/doc/html/rfc2579
97+
/** @var array{year: int, month: int, day: int, hour: int, min: int, sec: int, int, tz: string, tzhour:int, tzmin: int}|false $dateTime */
9798
$dateTime = @unpack('nyear/cmonth/cday/chour/cmin/csec/c/atz/ctzhour/ctzmin', $response);
9899
if ($dateTime === false) {
99100
throw new RuntimeException('Failed to unpack IPP datetime');
@@ -113,7 +114,7 @@ private function unpackDateTime(string $response): DateTime
113114
private function unpack(string $unpack, string $string): string|int
114115
{
115116
$data = @unpack($unpack, $string);
116-
if ($data === false || isset($data[1]) === false) {
117+
if ($data === false || isset($data[1]) === false || (is_string($data[1]) === false && is_int($data[1]) === false)) {
117118
throw new RuntimeException();
118119
}
119120

0 commit comments

Comments
 (0)