Skip to content

Commit

Permalink
fixed src phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
derpoho committed Feb 21, 2024
1 parent ac6dd2c commit 261569a
Show file tree
Hide file tree
Showing 24 changed files with 89 additions and 411 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ parameters:
level: 5
paths:
- src
- tests
# - tests
1 change: 1 addition & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
)
{
// (Temporary) Workaround for https://github.com/probots-io/pinecone-php/issues/3
/* @phpstan-ignore-next-line */
$this->sender()->addMiddleware(function (callable $handler) {
return function (RequestInterface $request, array $options) use ($handler) {
return $handler(FetchVectors::queryIdsWorkaround($request), $options);
Expand Down
12 changes: 0 additions & 12 deletions src/Requests/Control/ConfigureIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@

/**
* @link https://docs.pinecone.io/reference/configure_index
*
* @param string $name
* @param int $replicas
* @param string $pod_type
*
* @response
* string ""
*
* @error_codes
* 400 | Bad request,not enough quota.
* 404 | Index not found.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class ConfigureIndex extends Request
{
Expand Down
14 changes: 0 additions & 14 deletions src/Requests/Control/CreateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,11 @@

/**
* @link https://docs.pinecone.io/reference/create_collection
*
* @param string $name
* @param string $source
*
* @response
* string ""
*
* @error_codes
* 400 | Bad request. Request exceeds quota or collection name is invalid.
* 409 | A collection with the name provided already exists.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class CreateCollection extends Request
{
use HasJsonBody;

/**
* @var Method
*/
protected Method $method = Method::POST;


Expand Down
10 changes: 1 addition & 9 deletions src/Requests/Control/CreateIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@

/**
* @link https://docs.pinecone.io/reference/create_index
*
* @response
* string ""
*
* @error_codes
* 400 | Bad request. Encountered when request exceeds quota or an invalid index name.
* 409 | Index of given name already exists.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class CreateIndex extends Request
{
Expand Down Expand Up @@ -124,7 +116,7 @@ protected function defaultBody(): array
return $payload;
}

public function hasRequestFailed(Response|\Saloon\Contracts\Response $response): ?bool
public function hasRequestFailed(Response $response): ?bool
{
return $response->status() !== 201;
}
Expand Down
9 changes: 0 additions & 9 deletions src/Requests/Control/DeleteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/delete_collection
*
* @param string $name
*
* @response
* string ""
*
* @error_codes
* 404 | Collection not found.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class DeleteCollection extends Request
{
Expand Down
9 changes: 0 additions & 9 deletions src/Requests/Control/DeleteIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/delete_index
*
* @param string $name
*
* @response
* string ""
*
* @error_codes
* 404 | Index not found.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class DeleteIndex extends Request
{
Expand Down
12 changes: 0 additions & 12 deletions src/Requests/Control/DescribeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/describe_collection
*
* @param string $name
*
* @response
* object
* name | string
* size | integer
* status | string
*
* @error_codes
* 404 | Collection not found.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class DescribeCollection extends Request
{
Expand Down
24 changes: 0 additions & 24 deletions src/Requests/Control/DescribeIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/describe_index
*
* @param string $name
*
* @response
* object
* database | object
* name | string
* dimension | string
* metric | string
* pods | integer
* replicas | integer
* shards | integer
* pod_type | string
* index_config | object
* k_bits | integer
* hybrid | boolean
* metadata_config | object
* status | object
* ready | boolean
* state | string | Initializing ScalingUp ScalingDown Terminating Ready
*
* @error_codes
* 404 | Index not found.
* 500 | Internal error. Can be caused by invalid parameters.
*/
class DescribeIndex extends Request
{
Expand Down
3 changes: 0 additions & 3 deletions src/Requests/Control/ListCollections.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/list_collections
*
* @response
* array of strings "$collectionName"
*/
class ListCollections extends Request
{
Expand Down
3 changes: 0 additions & 3 deletions src/Requests/Control/ListIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

/**
* @link https://docs.pinecone.io/reference/list_indexes
*
* @response
* array of strings "$indexName"
*/
class ListIndexes extends Request
{
Expand Down
42 changes: 2 additions & 40 deletions src/Requests/Data/DeleteVectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,32 @@
namespace Probots\Pinecone\Requests\Index\Vectors;

use Saloon\Contracts\Body\HasBody;
use Saloon\Contracts\Response;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;

/**
* @link https://docs.pinecone.io/reference/delete_post
*
* @param array $index
* @param array $ids
* @param string|null $namespace
* @param bool $deleteAll
* @param array $filter
*
* @response
* object (empty)
*
* @error_response
* object
* code | integer
* message | string
* details | array of objects
* typeUrl | string
* value | string
*/
class DeleteVectors extends Request implements HasBody
{
use HasJsonBody;

/**
* @var Method
*/
protected Method $method = Method::DELETE;

/**
* @param array $index
* @param array $ids
* @param string|null $namespace
* @param bool $deleteAll
* @param array $filter
*/
public function __construct(
protected array $index,
protected array $ids = [],
protected ?string $namespace = null,
protected bool $deleteAll = false,
protected array $filter = []
) {}

/**
* @return string
*/
public function resolveEndpoint(): string
{
return 'https://' . $this->index['status']['host'] . '/vectors/delete';
return '/vectors/delete';
}

/**
* @return bool[]
*/
protected function defaultBody(): array
{
$payload = [
Expand All @@ -84,10 +50,6 @@ protected function defaultBody(): array
return $payload;
}

/**
* @param Response $response
* @return bool|null
*/
public function hasRequestFailed(Response $response): ?bool
{
return $response->status() !== 200;
Expand Down
77 changes: 0 additions & 77 deletions src/Requests/Data/DescribeIndexStats.php

This file was deleted.

Loading

0 comments on commit 261569a

Please sign in to comment.