Skip to content

Commit

Permalink
Fix a couple psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Jan 14, 2024
1 parent 6c63063 commit add726f
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/StructuredFields/Boolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read bool $item
* @template-extends Item<void>
* @template-extends Item<bool>
*/
class Boolean extends Item
{
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/Bytes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read string $item
* @template-extends Item<void>
* @template-extends Item<string>
*/
class Bytes extends Item
{
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read int $item
* @template-extends Item<void>
* @template-extends Item<int>
*/
class Date extends Item
{
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/DisplayString.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read string $item
* @template-extends Item<void>
* @template-extends Item<string>
*/
class DisplayString extends Item
{
Expand Down
6 changes: 3 additions & 3 deletions src/StructuredFields/InnerList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read list<Item<void>> $item
* @template-extends Item<list<Item<void>>>
* @psalm-import-type Rfc8941BareItem from \Amp\Http\StructuredFields\Rfc8941
* @template-extends Item<list<Item<Rfc8941BareItem>>>
*/
class InnerList extends Item
{
/**
* @psalm-param list<Item<void>> $item
* @psalm-param list<Item<Rfc8941BareItem>> $item
* @psalm-param Rfc8941Parameters $parameters
*/
public function __construct(array $item, array $parameters)
Expand Down
4 changes: 2 additions & 2 deletions src/StructuredFields/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Amp\Http\StructuredFields;

/**
* @psalm-template Inner
* @template-covariant Inner
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
*/
class Item
{
/**
* @psalm-param int|float|string|bool|Inner $item
* @psalm-param Inner $item
* @psalm-param Rfc8941Parameters $parameters
*/
protected function __construct(public readonly int|float|string|bool|array $item, public readonly array $parameters)
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read int|float $item
* @template-extends Item<void>
* @template-extends Item<int|float>
*/
class Number extends Item
{
Expand Down
6 changes: 4 additions & 2 deletions src/StructuredFields/Rfc8941.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Including support for the extension for RFC 8941, see https://datatracker.ietf.org/doc/draft-ietf-httpbis-sfbis
/**
* @psalm-type Rfc8941SingleItem = Item<void>
* @psalm-type Rfc8941SingleItem = Item<Rfc8941BareItem>
* @psalm-type Rfc8941ListItem = InnerList|Rfc8941SingleItem
* @psalm-type Rfc8941BareItem = int|float|string|bool
* @psalm-type Rfc8941Parameters = array<string, Rfc8941BareItem>
Expand All @@ -27,9 +27,11 @@ public static function parseList(array|string $value): ?array

$list = [];
while (true) {
if (null === $list[] = self::parseItemOrInnerList($string, $i)) {
$item = self::parseItemOrInnerList($string, $i);
if (null === $item) {
return null;
}
$list[] = $item;
$i += \strspn($string, " \t", $i);
if ($i >= $len) {
return $list;
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read string $item
* @template-extends Item<void>
* @template-extends Item<string>
*/
class Str extends Item
{
Expand Down
3 changes: 1 addition & 2 deletions src/StructuredFields/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

/**
* @psalm-import-type Rfc8941Parameters from \Amp\Http\StructuredFields\Rfc8941
* @property-read string $item
* @template-extends Item<void>
* @template-extends Item<string>
*/
class Token extends Item
{
Expand Down

0 comments on commit add726f

Please sign in to comment.