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

PHP 7.2: count(): Parameter must be an array or an object that implements Countable #688

Open
vasilvestre opened this issue Oct 9, 2018 · 9 comments

Comments

@vasilvestre
Copy link

Similar to this issue : yiisoft/yii#4167

The default behaviour of count changed, it now fire a warning. It happen for example here : https://github.com/schmittjoh/serializer/blob/1.x/src/JMS/Serializer/XmlDeserializationVisitor.php#L179

- if (!\count($nodes)) {
+ if ($nodes === false || !\count($nodes)) {

Or whatever condition we choose, to keep the default Serializer behaviour the check is needed

@goetas
Copy link
Collaborator

goetas commented Oct 9, 2018

This issue is not related to PHP 7.2 and neither to yiisoft/yii#4167.
It is more related to DX.

The error is thrown because of some wrong syntax in $entryName.

In this case the solution is to throw an exception in $nodes === false and probably in the error message mentioning the value of $entryName.

@vasilvestre
Copy link
Author

(Link to yii was just to give another case of the problem in another case)

So if it's false, an error have to be thrown ?

@goetas
Copy link
Collaborator

goetas commented Oct 9, 2018

So if it's false, an error have to be thrown ?

yes. there is no right "default" behavior the lib could do except of throwing an error.

@vasilvestre
Copy link
Author

I don't know, it's supposed to throw an error if the node is empty ? Isn't it a problem of code logic or content ?

@goetas
Copy link
Collaborator

goetas commented Oct 9, 2018

Do not know it the error was thrown for that reason... I think the error was in $entryName.. wasn't?

@vasilvestre
Copy link
Author

After a short discussion, I think @goetas decided that if the xpath function return false ($nodes is the xpath return) then an exception have to be thrown.

@vasilvestre
Copy link
Author

There's no contributing guide in this repo, I would like to help on this one but I need something to follow

@goetas
Copy link
Collaborator

goetas commented Oct 11, 2018

You have created the ticker in the wrong repo :) (that's why I have added the "serializer issue" label)

The ticket should have been opened on https://github.com/schmittjoh/serializer.
Into that library you have https://github.com/schmittjoh/serializer/blob/master/CONTRIBUTING.md as contributing guide

@goetas
Copy link
Collaborator

goetas commented Oct 11, 2018

Please note that most likely you will have to submit your PR to the 1.x branch.

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

No branches or pull requests

2 participants