WIP - support latest version, add typehint, add static checks, and add tests#53
WIP - support latest version, add typehint, add static checks, and add tests#53bepsvpt wants to merge 15 commits intotypesense:masterfrom
Conversation
|
@bepsvpt I appreciate the PR, but we are unfortunately unable to entertain a full rewrite of the library, because we want to maintain consistency in the code layout between all the language libraries we officially maintain. |
what do you mean with "consistency in the code layout between all the language libraries"? different languages use a different standard in the project structure, which helps developers keeping their processes lean when dealing with multiple libraries. I do not see a blocker introducing static-code analysis (Phpstan or PSalm) and strict-types, and tests is a blocking issue. |
|
I'd be down to accept a PR to add types, and any static analysis tools, to the existing library. What I meant was, I'd not be down to change the internal file structure and method parameter signatures, to reduce maintenance overhead as we add new features. |
|
I see your point, but I still believe that the current implementation is still leading to headaches. An example is: how do you know if a collection exists? (this is just one of the examples I found out): Try 1:$this->client->getCollections()['collection_name];Does not work, as the collection is always returned/generated even if it does not exist on the server. Try 2:$this->client->getCollections()->offsetExists('collection_name');this is always false if the API is not yet called under the hood Try3:$this->client->getCollections()->retrieve();
// Then one of the (1) or (2) abveNope, the API call is invoked, but the results not used to populate the collection Try4 - conter intiutive (IMO)$this->client->getCollections()['collection_name]->retrieve()`Additional notes:I believe there is a very low DX with this client, which should be tackled IMO how can we help to make the PHP client better? |
|
The actual method call to retrieve a collection is: $client->collections['companies']->retrieve();Essentially Documented under the PHP tab in the docs: https://typesense.org/docs/0.25.2/api/collections.html#retrieve-a-collection It's been a long time since I wrote production-level PHP, but is that not idiomatic PHP? |
Pull Request Not Yet Completed
Feel free to provide any ideas and suggestions.
This Pull Request completely reworks this package to achieve the following goals:
Implemented APIs:
Documentation:
To be supplemented...