Replace array return types from api to object
Description Currently all enqueued tasks are returned as an array without defined structure, so basically we cannot be sure that is safe to access any data from it. As I've seen structure can differ per task status, but I could be mistaken. This idea came up to my mind after I've seen https://github.com/meilisearch/meilisearch-js/blob/main/src/enqueued-task.ts
Basic example
class EnqueuedTask implements \ArrayAccess
{
private int $taskUid;
private string indexUid;
private string $status; // 'succeeded'|'processing'|'failed'|'enqueued'|'canceled'; // this could be class constants and later migrated to enums after bumping up php requirement to 8+
private string $type; // ...
private DateTimeImmutable $enqueuedAt;
}
This could act as a base, and if response data is really different per task status, then we could extend this object into many ones with more additional information. another approach of course would be just add all data to EnqueuedTask and for consumers to check status before accessing it
Other This is related to #573
To break things less the returned lets say EnqueuedTask object could implement the ArrayAccess interface so array access would still work, it would just break things if someone has extended any of Endpoint classes.
We could make this change and also move on to the minimum supported PHP version to 8.0, WDYT?
I'd even say 8.1 or 8.2 :)
Would dropping support for php 7 require new release (2.0)? I would imagine so.
@tacman not necessarily. if app is on php 7 and meilisearch starts to support only ^php8, then the composer won't update the package and that's all, unless ignore-platform-reqs flag would be used
yes, though generally a bump like changing the minimum PHP version is also tied to a version bump.
Additionally, we could rename some of the methods to indicate which ones actually make an API call. Or maybe once I'm more familiar with the library, it'll be obvious, and certainly getting an enqueued task will be a huge indicator.
@tacman version bump can be minor - as I'd say it's a feature, not necessarily a breaking change
Is there a branch that has the EnqueuedTask class written? I think the ArrayAccess idea is a pretty cool way to maintain b/c.
https://github.com/meilisearch/meilisearch-php/compare/main...norkunas:meilisearch-php:enqueued-task i had this locally for at least 3-4 months, but commited now, if you want to complete go ahead