-
Notifications
You must be signed in to change notification settings - Fork 736
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
Implement Countable on Objects in PHP7.2 #1378
Conversation
lib/Elastica/Response.php
Outdated
@@ -11,7 +11,7 @@ | |||
* | |||
* @author Nicolas Ruflin <[email protected]> | |||
*/ | |||
class Response | |||
class Response implements \Countable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change also needed?
d6974ec
to
378db6b
Compare
5e37075
to
f977003
Compare
f977003
to
a3506a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few minor comments. Happy to get this in as soon as the PR is ready independent of which of the versions is out.
lib/Elastica/Query.php
Outdated
@@ -330,7 +330,8 @@ public function toArray() | |||
$this->setQuery(new MatchAll()); | |||
} | |||
|
|||
if (isset($this->_params['post_filter']) && 0 === count($this->_params['post_filter'])) { | |||
$a = $this->_params['post_filter']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit picking but could we name this variable differently, something more describtive? I'm curious what happens on the next line in case toArray()
does not on the varialbe?
lib/Elastica/Response.php
Outdated
@@ -361,4 +361,18 @@ public function getJsonBigintConversion() | |||
{ | |||
return $this->_jsonBigintConversion; | |||
} | |||
|
|||
// /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove this code if not needed anymore.
a3506a5
to
332c4d5
Compare
@ruflin the pr has been updated :) removed unused code and remove that weird var name :) |
Hi @ruflin Would it be possible to cherry-pick this commit to the 5.x branch? |
@XWB Sound reasonable to me. Do you want to open a backport PR? |
The change at https://github.com/ruflin/Elastica/pull/1378/files#diff-e421c6a76338876301c98a5a7e95ab87R333 broke my implementation today since Noticed exception 'Symfony\Component\Debug\Exception\FatalThrowableError' with message 'Call to a member function toArray() on array' |
@richardfullmer Is this the same issue as in #1429 ? |
Yes, looks the same to me. |
as reported #1377 in PHP 7.2 it's possibile to use the function count() only on Arrays and on \Countable objects.
This is a WIP PR, there are still things to do and some tests to check; more then this I will merge this PR when PHP 7.2 will be released (now it's a RC2).