Closed Berdir closed 1 year ago
Hi @Berdir, thanks for the contribution!
The PHP docs show that the method current()
should have a type of mixed
. Where did Traversable
come from?
Looking at the docs for Iterator
, it seems like current()
should have #[ReturnTypeWillChange]
added to resolve the deprecation notice I imagine you are getting in PHP8.1. Would that resolve the problem for you?
Yeah, I don't know what I was thinking, this makes no sense :) It didn't complain about it, strangely enough.
The annotation works, but I suppose you could also just set it to mixed. the annotation afaik is mostly for cases where you provide your own API/interface/base class and don't want to introduce a BC break (yet).
I updated it to mixed now.
Yeah, I don't know what I was thinking, this makes no sense :) It didn't complain about it, strangely enough.
The annotation works, but I suppose you could also just set it to mixed. the annotation afaik is mostly for cases where you provide your own API/interface/base class and don't want to introduce a BC break (yet).
Since mixed
wasn't added as a valid return type until PHP8.0, the annotation will be the best approach for now. I've also merged an update to the automated test suite, so deprecation notices will at least show in the logs.
@Berdir also, could you create a quick unit test for QueryPathIterator::current()
to accompany this PR? Drop it in a new file at tests/QueryPath/QueryPathIteratorTest.php
👍
Thanks!
@Berdir closing in favour of https://github.com/GravityPDF/querypath/pull/32. Thanks again for your contribution!
Fixes #27