bearsunday /
BEAR.Resource
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace BEAR\Resource; |
||
| 6 | |||
| 7 | use OutOfRangeException; |
||
| 8 | use Override; |
||
| 9 | |||
| 10 | use function array_merge; |
||
| 11 | use function in_array; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @property $this $lazy |
||
| 15 | * @property $this $eager |
||
| 16 | * @psalm-suppress PropertyNotSetInConstructor for DSL |
||
| 17 | * @psalm-import-type Query from Types |
||
| 18 | */ |
||
| 19 | final class Request extends AbstractRequest |
||
| 20 | { |
||
| 21 | public const GET = 'get'; |
||
| 22 | public const POST = 'post'; |
||
| 23 | public const PUT = 'put'; |
||
| 24 | public const PATCH = 'patch'; |
||
| 25 | public const DELETE = 'delete'; |
||
| 26 | public const HEAD = 'head'; |
||
| 27 | public const OPTIONS = 'options'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @psalm-suppress ImplementedReturnTypeMismatch |
||
| 31 | * @psalm-suppress PossiblyUnusedReturnValue - Return value used implicitly via magic property access |
||
| 32 | */ |
||
| 33 | #[Override] |
||
| 34 | public function __get(string $name): mixed |
||
| 35 | { |
||
| 36 | if ($name === 'eager' || $name === 'lazy') { |
||
| 37 | $this->in = $name; |
||
| 38 | |||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (in_array($name, ['code', 'headers', 'body'], true)) { |
||
| 43 | return parent::__get($name); |
||
| 44 | } |
||
| 45 | |||
| 46 | throw new OutOfRangeException($name); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritDoc} |
||
| 51 | * |
||
| 52 | * @param Query $query |
||
| 53 | */ |
||
| 54 | #[Override] |
||
| 55 | public function withQuery(array $query): RequestInterface |
||
| 56 | { |
||
| 57 | $this->query = $query; |
||
|
0 ignored issues
–
show
|
|||
| 58 | |||
| 59 | return $this; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritDoc} |
||
| 64 | */ |
||
| 65 | #[Override] |
||
| 66 | public function addQuery(array $query): RequestInterface |
||
| 67 | { |
||
| 68 | $this->query = array_merge($this->query, $query); |
||
|
0 ignored issues
–
show
It seems like
array_merge($this->query, $query) of type array is incompatible with the declared type BEAR\Resource\Query of property $query.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 69 | |||
| 70 | return $this; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * {@inheritDoc} |
||
| 75 | */ |
||
| 76 | #[Override] |
||
| 77 | public function toUriWithMethod(): string |
||
| 78 | { |
||
| 79 | $uri = $this->toUri(); |
||
| 80 | |||
| 81 | return "{$this->method} {$uri}"; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * {@inheritDoc} |
||
| 86 | */ |
||
| 87 | #[Override] |
||
| 88 | public function toUri(): string |
||
| 89 | { |
||
| 90 | $this->resourceObject->uri->query = $this->query; |
||
|
0 ignored issues
–
show
It seems like
$this->query of type array is incompatible with the declared type BEAR\Resource\Query of property $query.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 91 | |||
| 92 | return (string) $this->resourceObject->uri; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * {@inheritDoc} |
||
| 97 | */ |
||
| 98 | #[Override] |
||
| 99 | public function linkSelf(string $linkKey): RequestInterface |
||
| 100 | { |
||
| 101 | $this->links[] = new LinkType($linkKey, LinkType::SELF_LINK); |
||
| 102 | |||
| 103 | return $this; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * {@inheritDoc} |
||
| 108 | */ |
||
| 109 | #[Override] |
||
| 110 | public function linkNew(string $linkKey): RequestInterface |
||
| 111 | { |
||
| 112 | $this->links[] = new LinkType($linkKey, LinkType::NEW_LINK); |
||
| 113 | |||
| 114 | return $this; |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * {@inheritDoc} |
||
| 119 | */ |
||
| 120 | #[Override] |
||
| 121 | public function linkCrawl(string $linkKey): RequestInterface |
||
| 122 | { |
||
| 123 | $this->links[] = new LinkType($linkKey, LinkType::CRAWL_LINK); |
||
| 124 | |||
| 125 | return $this; |
||
| 126 | } |
||
| 127 | } |
||
| 128 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..