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

Implement Countable on Objects in PHP7.2 #1378

Merged
merged 1 commit into from
Nov 12, 2017

Conversation

p365labs
Copy link
Collaborator

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).

@@ -11,7 +11,7 @@
*
* @author Nicolas Ruflin <[email protected]>
*/
class Response
class Response implements \Countable
Copy link
Owner

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?

@p365labs p365labs force-pushed the es6_php72_implement_countable branch 2 times, most recently from d6974ec to 378db6b Compare September 21, 2017 04:24
@p365labs p365labs force-pushed the es6_php72_implement_countable branch 3 times, most recently from 5e37075 to f977003 Compare October 9, 2017 23:21
@p365labs p365labs force-pushed the es6_php72_implement_countable branch from f977003 to a3506a5 Compare November 9, 2017 11:33
@p365labs p365labs changed the title [WIP] Implement Countable on Objects in PHP7.2 Implement Countable on Objects in PHP7.2 Nov 9, 2017
@p365labs
Copy link
Collaborator Author

p365labs commented Nov 9, 2017

@ruflin Now the PR# it's not in WIP anymore, tests now pass also with PHP 7.2-rc (which is now RC5). Today will be released php7.2-rc6 and for the end of the current month PHP7.2 GA will be released. Feel free to merge it or wait till PHP7.2 . GA.

Copy link
Owner

@ruflin ruflin left a 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.

@@ -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'];
Copy link
Owner

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?

@@ -361,4 +361,18 @@ public function getJsonBigintConversion()
{
return $this->_jsonBigintConversion;
}

// /**
Copy link
Owner

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.

@p365labs p365labs force-pushed the es6_php72_implement_countable branch from a3506a5 to 332c4d5 Compare November 10, 2017 06:16
@p365labs
Copy link
Collaborator Author

@ruflin the pr has been updated :) removed unused code and remove that weird var name :)

@ruflin ruflin merged commit 136e366 into ruflin:master Nov 12, 2017
@p365labs p365labs deleted the es6_php72_implement_countable branch November 13, 2017 09:49
@p365labs p365labs mentioned this pull request Nov 15, 2017
@XWB
Copy link
Contributor

XWB commented Dec 15, 2017

Hi @ruflin

Would it be possible to cherry-pick this commit to the 5.x branch?

@ruflin
Copy link
Owner

ruflin commented Dec 19, 2017

@XWB Sound reasonable to me. Do you want to open a backport PR?

XWB pushed a commit to XWB/Elastica that referenced this pull request Dec 19, 2017
@XWB
Copy link
Contributor

XWB commented Dec 19, 2017

@ruflin Done #1428

ruflin pushed a commit that referenced this pull request Dec 20, 2017
@richardfullmer
Copy link

The change at https://github.com/ruflin/Elastica/pull/1378/files#diff-e421c6a76338876301c98a5a7e95ab87R333 broke my implementation today since $this->_params['post_filter'] was already an array.

Noticed exception 'Symfony\Component\Debug\Exception\FatalThrowableError' with message 'Call to a member function toArray() on array'

@ruflin
Copy link
Owner

ruflin commented Feb 26, 2018

@richardfullmer Is this the same issue as in #1429 ?

@richardfullmer
Copy link

Yes, looks the same to me.

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.

4 participants