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

Refactoring, mainly docblocks and CS. #62

Merged
merged 1 commit into from
Mar 2, 2016

Conversation

rayrutjes
Copy link
Member

Started correcting some docblocks, and refactored some small pieces.

Please note that I have not a deep understanding of the behaviour of this client yet, so please tell me if some changes may break something. Hope the tests will catch problems though.

  • Run php-cs-fixer and add a basic .php_cs config
  • Add missing return tags
  • Enhance the docblocks
  • Use more fine grained params and return types
  • Try to refactor some pieces of code that are repeated a lot
  • Better format long docblocks

Do you guys see any interest in these adjustments if they do not introduce BC issues?

Please react on the changes so I can adjust the PR.

Fixes #32

@redox
Copy link
Contributor

redox commented Feb 24, 2016

Thank you for contributing @rayrutjes! I'll let @maxiloc take over regarding the review.

The tests are failing because the API keys are (indeed) not injected, don't worry.

@rayrutjes
Copy link
Member Author

My pleasure @redox.

Regarding the API keys I get the fact that you do not want to pollute Agolia's servers with test traffic.
However I think giving the community feedback about the tests is nice. It is a bit frustrating to get the red flag show up!

Maybe we could isolate the actual transport layer of the client so that we can mock it when doing the tests.

AWS PHP's SDK has a nice approach illustrating what I am saying, here is an interesting snippet: https://github.com/aws/aws-sdk-php/blob/0f54c98d293afda9cff7575227da2a19851a08e5/tests/UsesServiceTrait.php

This would also address #48 by the way, and lower the required time to run the test suite from a few minutes to a few seconds.

I do realize though that this would require quite some work, and that it would probably imply bumping to a new major release.

$queryParameters['tagFilters'] = $tagFilters;
}
if ($userToken != null && strlen($userToken) > 0) {
$queryParameters['userToken'] = $userToken;
}
$urlEncodedQuery = Client::buildQuery($queryParameters);
$urlEncodedQuery = self::buildQuery($queryParameters);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think static would make even more sense here

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, this would eventually allow a child class to override the buildQuery method.

@maxiloc
Copy link
Contributor

maxiloc commented Feb 25, 2016

@rayrutjes Looks good, I did two comments tell me what you think.

@@ -0,0 +1,12 @@
<?php
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this file in the repo ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If we leave this in the repo, we allow everyone to just run php-cs-fixer fix and ensure that everyone as the same code styles.

Just a suggestion though. Could be added as a good practise to the contributing guidelines of the repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Ok good for me

@rayrutjes
Copy link
Member Author

Hi @maxiloc , could you take a look at what has be done so far and tell me how you feel about it?

@@ -41,7 +41,7 @@ public function testSettingsIndex()

public function testSearchFacet()
{
$res = $this->index->addObjects(array(
$this->index->addObjects(array(
array("firstname" => "Robin"),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can go for [] syntax here

@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

Except the [] syntax of my two comments, looks really good, after this, we can merge if you're done with this PR.

@rayrutjes
Copy link
Member Author

I made php-cs-fixer also correct the tests folder.
I also added a param to the phpunit config to avoid a coverage related exception while running the tests in phpunit 5+.

The tests runs fine on my side. Do you have a way of running the tests on this pr before merging?

@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

@rayrutjes Yes I am going to test it right now. Can you rebase your commits in the meantime ?

@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

image

All green !

@rayrutjes
Copy link
Member Author

Sorry for the delay, I have rebased the pr.

@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

Ok cool ! LGTM

@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

Waiting for test to pass on #65

@rayrutjes rayrutjes changed the title [WIP] Refactoring, mainly docblocks and CS. Refactoring, mainly docblocks and CS. Mar 2, 2016
@maxiloc maxiloc merged commit 2d0fcb2 into algolia:master Mar 2, 2016
@rayrutjes rayrutjes deleted the code-styles-suggestion branch March 2, 2016 18:48
@maxiloc
Copy link
Contributor

maxiloc commented Mar 2, 2016

@rayrutjes Thanks for contributing. Much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvements] Tag @return is missing in PhpDoc blocks
3 participants