json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

Fix ObjectIterator for PHP8

Open R4c00n opened this issue 3 years ago • 5 comments

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

R4c00n avatar Jan 30 '22 19:01 R4c00n

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]

Seldaek avatar Apr 13 '22 07:04 Seldaek

@R4c00n #689

fenric avatar Apr 20 '22 23:04 fenric

See #726 for the topic of raising the minimum PHP level and supporting newer versions PHP.

DannyvdSluijs avatar May 27 '24 15:05 DannyvdSluijs

Any chance of this making it into the next 5.x release? Adding #[ReturnTypeWillChange] should be enough for now and it would still be compatible with PHP 5.3.

elidrissidev avatar Jun 14 '24 10:06 elidrissidev

Any chance of this making it into the next 5.x release? Adding #[ReturnTypeWillChange] should be enough for now and it would still be compatible with PHP 5.3.

We are working on bringing the project back alive, you can see more in the discussions. We are however not planning to do anything with the 5.x branch but only focus on the upcoming 6.x and forward. Secondly in it's current state this PR would break the support of older PHP versions which is still part of the 5.x branch.

DannyvdSluijs avatar Jun 19 '24 14:06 DannyvdSluijs

This PR was ported in #746 which address the raising on the minimum version PHP as a whole including pipelines. Closing this PR for now

DannyvdSluijs avatar Aug 09 '24 07:08 DannyvdSluijs