Skip to content

adding code_with_match (#1024) - #1031

Merged
acrobat merged 4 commits into
KnpLabs:masterfrom
QuentinRa:code_with_match
Oct 3, 2021
Merged

acrobat merged 4 commits into
KnpLabs:masterfrom
QuentinRa:code_with_match

Conversation

@QuentinRa

Copy link
Copy Markdown
Contributor

Hi! As described in #1024, I added a function code_with_match.

@acrobat acrobat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR @QuentinRa! Few minor comments and can you add a test for this method? See the related code search for a test example

/**
* @test
*/
public function shouldSearchCodeByQuery()
{
$expectedArray = [['total_count' => '0']];
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with(
'/search/code',
['q' => 'query text', 'sort' => 'updated', 'order' => 'desc']
)
->will($this->returnValue($expectedArray));
$this->assertEquals($expectedArray, $api->code('query text'));
}

Comment thread lib/Github/Api/Search.php Outdated
*
* @return array list of code found
*/
public function code_with_match($q, $sort = 'updated', $order = 'desc')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
public function code_with_match($q, $sort = 'updated', $order = 'desc')
public function codeWithMatch(string $q, string $sort = 'updated', string $order = 'desc')

Also remove the redundant phpdoc after this change

     * @param string $q     the filter
     * @param string $sort  the sort field
     * @param string $order asc/desc

Comment thread doc/search.md Outdated
Returns a list of files found by such criteria (containing "@todo" and language==php).

```php
$files = $client->api('search')->code_with_match('@todo language:php');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Update the method after the change below

@akehsanz

This comment has been minimized.

@QuentinRa

QuentinRa commented Oct 3, 2021 •

Copy link
Copy Markdown
Contributor Author

Thanks! I looked for tests, and for CONTRIBUTING.md/code_style.*, but I haven't found any (I should've checked by myself, instead of relying on my IDE 😖).

I added the return type too. I'm not sure if I should remove the "redundant" types in the DOC, my IDE is showing a warning 😶"Update PHPDoc comment - Argument type do not match the declared type" (PHPStorm).

I'm not sure if my tests are what you wanted, I can't run them at all (and I don't have much time to look into it).

@acrobat acrobat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I comment left based on the failing phpstan run. Otherwise the PR is good to go!

Comment thread lib/Github/Api/Search.php Outdated
Comment on lines +70 to +72
* @param $q the filter
* @param $sort the sort field
* @param $order asc/desc

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove these phpdocs as the are redundant with the added typehint's

@acrobat
acrobat merged commit fe55989 into KnpLabs:master Oct 3, 2021
@acrobat

acrobat commented Oct 3, 2021

Copy link
Copy Markdown
Collaborator

Thanks @QuentinRa! And congrats on your first contribution! 🎉

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.

3 participants