Skip to content

Commit 9261cbc

Browse files
committed
make more clear where to find the type custom definitions
1 parent 60a28db commit 9261cbc

11 files changed

Lines changed: 39 additions & 39 deletions

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77
- examples/
88

99
typeAliases:
10-
TypeAlias_InternalOptions: 'array<string, bool|int|null|\alsvanzelf\jsonapi\enums\ContentTypeEnum>'
10+
PHPStanTypeAlias_InternalOptions: 'array<string, bool|int|null|\alsvanzelf\jsonapi\enums\ContentTypeEnum>'
1111
treatPhpDocTypesAsCertain: false
1212

1313
strictRules:

src/CollectionDocument.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class CollectionDocument extends DataDocument implements PaginableInterface, ResourceContainerInterface {
2222
/** @var ResourceInterface[] */
2323
protected array $resources = [];
24-
/** @var TypeAlias_InternalOptions */
24+
/** @var PHPStanTypeAlias_InternalOptions */
2525
protected static array $defaults = [
2626
/**
2727
* add resources inside relationships to /included when adding resources to the collection
@@ -89,7 +89,7 @@ public function setPaginationLinks(
8989
*
9090
* adds included resources if found inside the resource's relationships, unless $options['includeContainedResources'] is set to false
9191
*
92-
* @param TypeAlias_InternalOptions $options {@see CollectionDocument::$defaults}
92+
* @param PHPStanTypeAlias_InternalOptions $options {@see CollectionDocument::$defaults}
9393
*
9494
* @throws InputException if the resource is empty
9595
*/

src/Document.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class Document implements DocumentInterface, \JsonSerializable, HasLink
4343
protected array $extensions = [];
4444
/** @var ProfileInterface[] */
4545
protected array $profiles = [];
46-
/** @var TypeAlias_InternalOptions */
46+
/** @var PHPStanTypeAlias_InternalOptions */
4747
protected static array $defaults = [
4848
/**
4949
* encode to json with these default options

src/ErrorsDocument.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ErrorsDocument extends Document {
1515
protected array $errors = [];
1616
/** @var array<number, array<number, true>> */
1717
protected array $httpStatusCodes;
18-
/** @var TypeAlias_InternalOptions */
18+
/** @var PHPStanTypeAlias_InternalOptions */
1919
protected static array $defaults = [
2020
/**
2121
* add the trace of exceptions when adding exceptions
@@ -42,7 +42,7 @@ public function __construct(?ErrorObject $errorObject=null) {
4242
*/
4343

4444
/**
45-
* @param TypeAlias_InternalOptions $options {@see ErrorsDocument::$defaults}
45+
* @param PHPStanTypeAlias_InternalOptions $options {@see ErrorsDocument::$defaults}
4646
*/
4747
public static function fromException(\Throwable $exception, array $options=[]): self {
4848
$options = array_merge(self::$defaults, $options);
@@ -58,7 +58,7 @@ public static function fromException(\Throwable $exception, array $options=[]):
5858
*
5959
* recursively adds multiple ErrorObjects if $exception carries a ->getPrevious()
6060
*
61-
* @param TypeAlias_InternalOptions $options {@see ErrorsDocument::$defaults}
61+
* @param PHPStanTypeAlias_InternalOptions $options {@see ErrorsDocument::$defaults}
6262
*/
6363
public function addException(\Throwable $exception, array $options=[]): void {
6464
$options = array_merge(self::$defaults, $options);
@@ -77,9 +77,9 @@ public function addException(\Throwable $exception, array $options=[]): void {
7777
/**
7878
* @param string|int $genericCode developer-friendly code of the generic type of error
7979
* @param string $genericTitle human-friendly title of the generic type of error
80-
* @param string $specificDetails optional, human-friendly explanation of the specific error
81-
* @param string $specificAboutLink optional, human-friendly explanation of the specific error
82-
* @param string $genericTypeLink optional, human-friendly explanation of the generic type of error
80+
* @param string $specificDetails human-friendly explanation of the specific error
81+
* @param string $specificAboutLink human-friendly explanation of the specific error
82+
* @param string $genericTypeLink human-friendly explanation of the generic type of error
8383
*/
8484
public function add(
8585
string|int $genericCode,

src/ResourceDocument.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class ResourceDocument extends DataDocument implements HasAttributesInterface, ResourceInterface {
2929
protected ResourceIdentifierObject|ResourceObject $resource;
30-
/** @var TypeAlias_InternalOptions */
30+
/** @var PHPStanTypeAlias_InternalOptions */
3131
protected static array $defaults = [
3232
/**
3333
* add resources inside relationships to /included when adding resources to the collection
@@ -51,7 +51,7 @@ public function __construct(?string $type=null, string|int|null $id=null) {
5151
*/
5252

5353
/**
54-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults} {@see ResourceObject::$defaults}
54+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults} {@see ResourceObject::$defaults}
5555
*/
5656
public static function fromArray(
5757
array $attributes,
@@ -66,7 +66,7 @@ public static function fromArray(
6666
}
6767

6868
/**
69-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
69+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
7070
*/
7171
public static function fromObject(
7272
object $attributes,
@@ -82,8 +82,8 @@ public static function fromObject(
8282
/**
8383
* add key-value pairs to the resource's attributes
8484
*
85-
* @param mixed $value objects will be converted using `get_object_vars()`
86-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
85+
* @param mixed $value objects will be converted using `get_object_vars()`
86+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
8787
*/
8888
public function add(string $key, mixed $value, array $options=[]): void {
8989
if ($this->resource instanceof ResourceObject === false) {
@@ -101,7 +101,7 @@ public function add(string $key, mixed $value, array $options=[]): void {
101101
* @param CollectionDocument|ResourceInterface|ResourceInterface[]|null $relation
102102
* @param array<string, ?string> $links
103103
* @param array<string, mixed> $meta
104-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
104+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
105105
*/
106106
public function addRelationship(
107107
string $key,
@@ -191,7 +191,7 @@ public function setLocalId(string|int $localId): void {
191191
}
192192

193193
/**
194-
* @param TypeAlias_InternalOptions $options {@see ResourceObject::$defaults}
194+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceObject::$defaults}
195195
*/
196196
public function setAttributesObject(AttributesObject $attributesObject, array $options=[]): void {
197197
if ($this->resource instanceof ResourceObject === false) {
@@ -206,7 +206,7 @@ public function setAttributesObject(AttributesObject $attributesObject, array $o
206206
*
207207
* adds included resources if found inside the RelationshipObject, unless $options['includeContainedResources'] is set to false
208208
*
209-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
209+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
210210
*/
211211
public function addRelationshipObject(string $key, RelationshipObject $relationshipObject, array $options=[]): void {
212212
if ($this->resource instanceof ResourceObject === false) {
@@ -227,7 +227,7 @@ public function addRelationshipObject(string $key, RelationshipObject $relations
227227
*
228228
* adds included resources if found inside the RelationshipObjects inside the RelationshipsObject, unless $options['includeContainedResources'] is set to false
229229
*
230-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
230+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
231231
*/
232232
public function setRelationshipsObject(RelationshipsObject $relationshipsObject, array $options=[]): void {
233233
if ($this->resource instanceof ResourceObject === false) {
@@ -252,7 +252,7 @@ public function setRelationshipsObject(RelationshipsObject $relationshipsObject,
252252
*
253253
* adds included resources if found inside the resource's relationships, unless $options['includeContainedResources'] is set to false
254254
*
255-
* @param TypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
255+
* @param PHPStanTypeAlias_InternalOptions $options {@see ResourceDocument::$defaults}
256256
*
257257
* @throws InputException if the $resource is a ResourceDocument itself
258258
*/

src/helpers/RequestParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Psr\Http\Message\ServerRequestInterface;
1111

1212
class RequestParser {
13-
/** @var TypeAlias_InternalOptions */
13+
/** @var PHPStanTypeAlias_InternalOptions */
1414
protected static array $defaults = [
1515
/**
1616
* reformat the include query parameter paths to nested arrays
@@ -105,7 +105,7 @@ public function hasIncludePaths(): bool {
105105
* the nested format allows easier processing on each step of the chain
106106
* the raw format allows for custom processing
107107
*
108-
* @param TypeAlias_InternalOptions $options {@see RequestParser::$defaults}
108+
* @param PHPStanTypeAlias_InternalOptions $options {@see RequestParser::$defaults}
109109
* @return string[]|array
110110
*/
111111
public function getIncludePaths(array $options=[]): array {
@@ -163,7 +163,7 @@ public function hasSortFields(): bool {
163163
*
164164
* @todo return some kind of SortFieldObject
165165
*
166-
* @param TypeAlias_InternalOptions $options {@see RequestParser::$defaults}
166+
* @param PHPStanTypeAlias_InternalOptions $options {@see RequestParser::$defaults}
167167
* @return string[]|array<array{
168168
* field: string, // the sort field, without any minus sign for descending sort order
169169
* order: SortOrderEnum,

src/helpers/Validator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Validator {
1717
protected array $usedFields = [];
1818
/** @var array<string, true> */
1919
protected array $usedResourceIdentifiers = [];
20-
/** @var TypeAlias_InternalOptions */
20+
/** @var PHPStanTypeAlias_InternalOptions */
2121
protected static array $defaults = [
2222
/**
2323
* blocks 'type' as a keyword inside attributes or relationships
@@ -32,8 +32,8 @@ class Validator {
3232
*
3333
* @see https://jsonapi.org/format/1.1/#document-resource-object-fields
3434
*
35-
* @param string[] $fieldNames
36-
* @param TypeAlias_InternalOptions $options {@see Validator::$defaults}
35+
* @param string[] $fieldNames
36+
* @param PHPStanTypeAlias_InternalOptions $options {@see Validator::$defaults}
3737
*
3838
* @throws DuplicateException
3939
*/

src/interfaces/DocumentInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function toArray(): array;
1717
/**
1818
* generate json with the contents of the document, used by {@see ->sendResponse()}
1919
*
20-
* @param TypeAlias_InternalOptions $options
20+
* @param PHPStanTypeAlias_InternalOptions $options
2121
*
2222
* @throws Exception if generating json fails
2323
*/
@@ -28,7 +28,7 @@ public function toJson(array $options=[]): string;
2828
*
2929
* @note will set http status code and content type, and echo json
3030
*
31-
* @param TypeAlias_InternalOptions $options
31+
* @param PHPStanTypeAlias_InternalOptions $options
3232
*/
3333
public function sendResponse(array $options=[]): void;
3434
}

src/interfaces/HasAttributesInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface HasAttributesInterface {
1010
*
1111
* @see ResourceObject::$defaults
1212
*
13-
* @param TypeAlias_InternalOptions $options
13+
* @param PHPStanTypeAlias_InternalOptions $options
1414
*/
1515
public function addAttribute(string $key, mixed $value, array $options=[]): void;
1616
}

src/objects/ErrorObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ErrorObject extends AbstractObject implements HasLinksInterface, HasMetaIn
2424
/** @var array{pointer?: string, parameter?: string, header?: string} */
2525
protected array $source = [];
2626
protected MetaObject $meta;
27-
/** @var TypeAlias_InternalOptions */
27+
/** @var PHPStanTypeAlias_InternalOptions */
2828
protected static array $defaults = [
2929
/**
3030
* add the trace of exceptions when adding exceptions
@@ -66,7 +66,7 @@ public function __construct(
6666
*/
6767

6868
/**
69-
* @param TypeAlias_InternalOptions $options {@see ErrorObject::$defaults}
69+
* @param PHPStanTypeAlias_InternalOptions $options {@see ErrorObject::$defaults}
7070
*/
7171
public static function fromException(\Throwable $exception, array $options=[]): self {
7272
$options = array_merge(self::$defaults, $options);

0 commit comments

Comments
 (0)