Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve coding standards #684

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Improve coding standards #684

merged 1 commit into from
Oct 2, 2024

Conversation

norkunas
Copy link
Collaborator

@norkunas norkunas commented Sep 25, 2024

Pull Request

Related issue

Fixes #<issue_number>

What does this PR do?

  • Add missing phpdocs;
  • Replace DateTime with DateTimeinterface to encourage usage of DateTimeImmutable;
  • Add more tests for contracts;
  • Make tests a little bit more consistent;
  • Add missing php typehints;

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

@norkunas
Copy link
Collaborator Author

norkunas commented Sep 25, 2024

I cannot understand if delete tasks query test was properly defined or not because https://www.meilisearch.com/docs/reference/api/tasks#delete-tasks does not indicate the cancelledBy query param type 😑

1) Tests\Contracts\DeleteTasksQueryTest::testSetAnyDateFilter
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     'beforeEnqueuedAt' => '2024-09-25T04:08:50+00:00'
+    'canceledBy' => ''
 )

/home/runner/work/meilisearch-php/meilisearch-php/tests/Contracts/DeleteTasksQueryTest.php:24
phpvfscomposer:///home/runner/work/meilisearch-php/meilisearch-php/vendor/phpunit/phpunit/phpunit:106

But to me it does not make any sense $data = (new DeleteTasksQuery())->setCanceledBy([null])->setBeforeEnqueuedAt($date); to pass null as array item

@norkunas norkunas force-pushed the cs branch 4 times, most recently from 71fa596 to e12088f Compare September 25, 2024 04:30
@curquiza
Copy link
Member

curquiza commented Sep 25, 2024

I don't understand @norkunas, why would you pass null as an array? What's the purpose of this PR?

Also, maybe the docs contains mistakes, but canceledBy is here: https://www.meilisearch.com/docs/reference/api/tasks#canceledby

@norkunas
Copy link
Collaborator Author

I don't understand @norkunas, why would you pass null as an array?

Not null as array, but null as item in array, see the previous code: (new DeleteTasksQuery())->setCanceledBy([null])

What's the purpose of this PR?

To make codebase consistent?

Also, maybe the docs contains mistakes, but canceledBy is here: https://www.meilisearch.com/docs/reference/api/tasks#canceledby

Ok so it accepts an integer and if multiple then it needs to be joined by comma. I've made the contract to explicitly say non-empty-array<int>

@curquiza
Copy link
Member

Not null as array, but null as item in array, see the previous code: (new DeleteTasksQuery())->setCanceledBy([null])

Yes sorry, I got it but not said it correctly. But why do you need to pass null? This is not the purpose of canceling a task. the purpose is to pass the uid of the task(s) to cancel them

@norkunas
Copy link
Collaborator Author

Not null as array, but null as item in array, see the previous code: (new DeleteTasksQuery())->setCanceledBy([null])

Yes sorry, I got it but not said it correctly. But why do you need to pass null? This is not the purpose of canceling a task. the purpose is to pass the uid of the task(s) to cancel them

I don't. That was the existing test which is nonsense

@curquiza
Copy link
Member

I don't. That was the existing test which is nonsense

Indeed, sounds weird to me, we can change it/remove it.

@norkunas norkunas force-pushed the cs branch 4 times, most recently from f3005b7 to a7d5887 Compare September 26, 2024 04:08
@norkunas norkunas requested review from curquiza, ManyTheFish and brunoocasali and removed request for ManyTheFish September 26, 2024 04:09
Copy link

codecov bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 98.15951% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.71%. Comparing base (b82d40e) to head (55dc98f).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
src/Contracts/DeleteTasksQuery.php 66.66% 1 Missing ⚠️
src/Contracts/TasksQuery.php 85.71% 1 Missing ⚠️
src/Endpoints/Indexes.php 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #684      +/-   ##
==========================================
+ Coverage   83.34%   89.71%   +6.36%     
==========================================
  Files          51       52       +1     
  Lines        1303     1322      +19     
==========================================
+ Hits         1086     1186     +100     
+ Misses        217      136      -81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@curquiza
Copy link
Member

curquiza commented Oct 2, 2024

@norkunas can you improve

  • the title of the PR
  • describes in some points (not a lot of details) what you are achieving in this PR?

There are a lot of changes

@norkunas norkunas changed the title CS Improve coding standards Oct 2, 2024
@norkunas
Copy link
Collaborator Author

norkunas commented Oct 2, 2024

@norkunas can you improve

  • the title of the PR
  • describes in some points (not a lot of details) what you are achieving in this PR?

There are a lot of changes

Done

@curquiza curquiza added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Oct 2, 2024
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors merge

@meili-bors meili-bors bot merged commit 0d4c933 into meilisearch:main Oct 2, 2024
30 checks passed
@norkunas norkunas deleted the cs branch October 2, 2024 12:40
meili-bors bot added a commit that referenced this pull request Oct 28, 2024
689: Update version for the next release (v1.11.0) r=brunoocasali a=meili-bot

_This PR is auto-generated._

The automated script updates the version of meilisearch-php to a new version: "v1.11.0"

--- CHANGELOG ---

This version introduces features released on Meilisearch v1.11.0 🎉
Check out the [changelog of Meilisearch v1.11.0](https://github.com/meilisearch/meilisearch/releases/tag/v1.11.0) for more information on the changes.

## ⚠️ Breaking change (experimental feature only)

* Adapt the library to the new usage of [Meilisearch v1.11](https://github.com/meilisearch/meilisearch/releases/tag/v1.11.0) (#683) `@/ManyTheFish` & `@/norkunas` 

## 🚀 Enhancements

* Add facet distribution to `multiSearch` (#683) `@/ManyTheFish` & `@/norkunas` 

## ⚙️ Maintenance/misc

* Improve coding standards (#684) `@/norkunas`

Thanks again to `@/ManyTheFish,`  and `@/norkunas!` 🎉



Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Anything related to maintenance (CI, tests, refactoring...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants