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

Fix ObjectIterator for PHP8 #682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

R4c00n
Copy link

@R4c00n R4c00n commented Jan 30, 2022

Hi, with PHP8.1 the iterator methods of ObjectIterator must be covariant with the PHP core interfaces.

I didn't know if theres a specific return type for ::current, so I went with the suppress annotation here. Happy to change this to a return type, if there is one?

Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 42

Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 52

Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 61

Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 71

Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 81

Deprecated: Return type of JsonSchema\Iterator\ObjectIterator::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 90

Signed-off-by: Marcel Kempf <marcel.kempf93@gmail.com>
@Seldaek
Copy link
Collaborator

Seldaek commented Apr 13, 2022

Thanks but given the min php version is still 5.3.3 on this repo, it'd probably be more appropriate to mark all methods with #[ReturnTypeWillChange]

@fenric
Copy link

fenric commented Apr 20, 2022

@R4c00n #689

@@ -49,7 +50,7 @@ public function current()
/**
* {@inheritdoc}
*/
public function next()
public function next(): void

Choose a reason for hiding this comment

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

In it's current state the library supports >=5.3.3 as percomposer.json requirements. The void keyword was introduced only in PHP 7.1. I know there are plans to drop support for PHP <7.2 (Even approved by @Seldaek) but in an attempt to revive the library and doing some initial triage I did want to point this out for ourselves.

It also applies to the int and bool return types which where added in PHP 7.0.

In order to make this PR considered for merging into the repo changing all to #[\ReturnTypeWillChange] would be needed I guess.

Choose a reason for hiding this comment

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

@R4c00n in an attempt to cleanup this repo we are trying to filter the pull request and see which ones might be closed and which ones we can help resolve. Do you still feel like pursuing this PR or did time catch up on us and are you working on other priorities? Feel free to close it yourself or comments if helpful.

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.

None yet

4 participants