Skip to content

Commit

Permalink
Move docblock under the StructuredFieldProvider class
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Nov 18, 2024
1 parent 9a6f75d commit 329a28d
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.2
*
* @phpstan-import-type SfMemberInput from StructuredField
* @phpstan-import-type SfMemberInput from StructuredFieldProvider
*
* @implements ArrayAccess<string, InnerList|Item>
* @implements IteratorAggregate<int, array{0:string, 1:InnerList|Item}>
Expand Down
8 changes: 4 additions & 4 deletions src/InnerList.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
/**
* @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.1
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfItemInput from StructuredField
* @phpstan-import-type SfInnerListPair from StructuredField
* @phpstan-import-type SfParameterInput from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
* @phpstan-import-type SfItemInput from StructuredFieldProvider
* @phpstan-import-type SfInnerListPair from StructuredFieldProvider
* @phpstan-import-type SfParameterInput from StructuredFieldProvider
*
* @implements ArrayAccess<int, Item>
* @implements IteratorAggregate<int, Item>
Expand Down
8 changes: 4 additions & 4 deletions src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
/**
* @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.3
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfItemInput from StructuredField
* @phpstan-import-type SfItemPair from StructuredField
* @phpstan-import-type SfTypeInput from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
* @phpstan-import-type SfItemInput from StructuredFieldProvider
* @phpstan-import-type SfItemPair from StructuredFieldProvider
* @phpstan-import-type SfTypeInput from StructuredFieldProvider
*/
final class Item implements StructuredField
{
Expand Down
6 changes: 3 additions & 3 deletions src/OuterList.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
/**
* @see https://www.rfc-editor.org/rfc/rfc9651.html#name-lists
*
* @phpstan-import-type SfMemberInput from StructuredField
* @phpstan-import-type SfInnerListPair from StructuredField
* @phpstan-import-type SfItemPair from StructuredField
* @phpstan-import-type SfMemberInput from StructuredFieldProvider
* @phpstan-import-type SfInnerListPair from StructuredFieldProvider
* @phpstan-import-type SfItemPair from StructuredFieldProvider
*
* @implements ArrayAccess<int, InnerList|Item>
* @implements IteratorAggregate<int, InnerList|Item>
Expand Down
4 changes: 2 additions & 2 deletions src/ParameterAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* Common manipulation methods used when interacting with an object
* with a Parameters instance attached to it.
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfItemInput from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
* @phpstan-import-type SfItemInput from StructuredFieldProvider
*/
trait ParameterAccess
{
Expand Down
4 changes: 2 additions & 2 deletions src/Parameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
/**
* @see https://www.rfc-editor.org/rfc/rfc9651.html#section-3.1.2
*
* @phpstan-import-type SfItemInput from StructuredField
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfItemInput from StructuredFieldProvider
* @phpstan-import-type SfType from StructuredFieldProvider
*
* @implements ArrayAccess<string, InnerList|Item>
* @implements IteratorAggregate<int, array{0:string, 1:Item}>
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @internal Do not use directly this class as it's behaviour and return type
* MAY change significantly even during a major release cycle.
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
*/
final class Parser
{
Expand Down
24 changes: 11 additions & 13 deletions src/StructuredField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

namespace Bakame\Http\StructuredFields;

use DateTimeImmutable;
use DateTimeInterface;
use Stringable;

/**
* @internal The interface MUST not be implemented outside the package codebase
*
* @phpstan-type SfType ByteSequence|Token|DisplayString|DateTimeImmutable|string|int|float|bool
* @phpstan-type SfTypeInput SfType|DateTimeInterface
* @phpstan-type SfItemInput Item|SfTypeInput|StructuredFieldProvider|StructuredField
* @phpstan-type SfMemberInput iterable<SfItemInput>|SfItemInput
* @phpstan-type SfParameterInput iterable<array{0:string, 1?:SfItemInput}>
* @phpstan-type SfInnerListPair array{0:iterable<SfItemInput>, 1?:Parameters|SfParameterInput}
* @phpstan-type SfItemPair array{0:SfTypeInput, 1?:Parameters|SfParameterInput}
*/
interface StructuredField extends Stringable
{
/**
* Returns a new instance from an HTTP Header or Trailer value string in compliance to an accepted RFC.
* Returns a new instance from an HTTP Header or Trailer value string in compliance to an RFC.
*
* @throws StructuredFieldError If the HTTP value can not be parsed
*/
Expand All @@ -38,8 +28,16 @@ public function toHttpValue(?Ietf $rfc = null): string;
/**
* Returns the serialize-representation of the Structured Field as a textual HTTP field value
* using the last accepted RFC protocol.
*
* @throws StructuredFieldError If the object can not be serialized
*/
public function __toString(): string;

/**
* Tells whether the object is identical as the one submitted.
* Returns true on success, false otherwise.
*
* Two objects are considered equals if they are instance of the same class
* and if their serialize-representation of the Structured Field as a
* textual HTTP field value is identical.
*/
public function equals(mixed $other): bool;
}
12 changes: 12 additions & 0 deletions src/StructuredFieldProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

namespace Bakame\Http\StructuredFields;

use DateTimeImmutable;
use DateTimeInterface;

/**
* @phpstan-type SfType ByteSequence|Token|DisplayString|DateTimeImmutable|string|int|float|bool
* @phpstan-type SfTypeInput SfType|DateTimeInterface
* @phpstan-type SfItemInput Item|SfTypeInput|StructuredFieldProvider|StructuredField
* @phpstan-type SfMemberInput iterable<SfItemInput>|SfItemInput
* @phpstan-type SfParameterInput iterable<array{0:string, 1?:SfItemInput}>
* @phpstan-type SfInnerListPair array{0:iterable<SfItemInput>, 1?:Parameters|SfParameterInput}
* @phpstan-type SfItemPair array{0:SfTypeInput, 1?:Parameters|SfParameterInput}
*/
interface StructuredFieldProvider
{
/**
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ItemValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace Bakame\Http\StructuredFields\Validation;

use Bakame\Http\StructuredFields\Item;
use Bakame\Http\StructuredFields\StructuredField;
use Bakame\Http\StructuredFields\StructuredFieldProvider;
use Bakame\Http\StructuredFields\SyntaxError;
use Stringable;

/**
* Structured field Item validator.
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
*/
final class ItemValidator
{
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ParametersValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace Bakame\Http\StructuredFields\Validation;

use Bakame\Http\StructuredFields\Parameters;
use Bakame\Http\StructuredFields\StructuredField;
use Bakame\Http\StructuredFields\StructuredFieldProvider;
use Bakame\Http\StructuredFields\SyntaxError;
use Stringable;

/**
* Structured field Item validator.
*
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
*
* @phpstan-type SfParameterKeyRule array{validate?:callable(SfType): (bool|string), required?:bool|string, default?:SfType|null}
* @phpstan-type SfParameterIndexRule array{validate?:callable(SfType, string): (bool|string), required?:bool|string, default?:array{0:string, 1:SfType}|array{}}
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/ValidatedParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use ArrayAccess;
use Bakame\Http\StructuredFields\ForbiddenOperation;
use Bakame\Http\StructuredFields\InvalidOffset;
use Bakame\Http\StructuredFields\StructuredField;
use Bakame\Http\StructuredFields\StructuredFieldProvider;
use Countable;
use Iterator;
use IteratorAggregate;

/**
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
*
* @implements ArrayAccess<array-key, array{0:string, 1:SfType}|array{}|SfType|null>
* @implements IteratorAggregate<array-key, array{0:string, 1:SfType}|array{}|SfType|null>
Expand Down
2 changes: 1 addition & 1 deletion tests/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Stringable;

/**
* @phpstan-import-type SfItemInput from StructuredField
* @phpstan-import-type SfItemInput from StructuredFieldProvider
*/
final class ItemTest extends StructuredFieldTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PHPUnit\Framework\Attributes\Test;

/**
* @phpstan-import-type SfType from StructuredField
* @phpstan-import-type SfType from StructuredFieldProvider
*/
final class ParserTest extends StructuredFieldTestCase
{
Expand Down

0 comments on commit 329a28d

Please sign in to comment.