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

Closed
wants to merge 1 commit into 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 <[email protected]>
@Seldaek
Copy link
Contributor

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
Copy link
Collaborator

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.

Copy link
Collaborator

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.

@DannyvdSluijs DannyvdSluijs added the Open discussions There are still one (or more) open discussion which touch upon this issue/PR label May 27, 2024
@DannyvdSluijs
Copy link
Collaborator

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

@elidrissidev
Copy link

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.

@DannyvdSluijs
Copy link
Collaborator

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
Copy link
Collaborator

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 added a commit that referenced this pull request Aug 27, 2024
* ci: Add PHP 8.0 and greater to build matrix

* ci: Remove PHP 5.3 - 7.1 from workflows

* build: Require minimum PHP 7.2

* build: Upgrade to PHPUnit 8.5

* refactor: Add now required void return types for setup() methods

* build: Include phpspec/prophecy dependency

* refactor: Replace setExpectedException with expectException/expectExceptionMessage

* refactor: Replace @ExpectedException annotation for expectException method

* refactor: Replace assertInternalType for assertIsArray

* refactor: Replace getMock for createMock

* test: Improve test assertions

* fix: Solve return type issues with Objectiterator (port of #682)

See #682

* build: Update icecave/parity to ^3.0 as 1.0 uses deprecated each() method

* style: Correct code style issues

* fix: Fix deprecation notices found from GHA workflow run

See https://github.com/jsonrainbow/json-schema/actions/runs/10216569969/job/28268331091

* fix: Add fallback to empty string when null value is passed in UriResolver::parse

* fix: Port #717: Fixes for implicit nullability deprecation

See #717

* ci: Avoid GHA run on each push and pull request; Include PHP 8.4 in matrix

* ci(Drop-PHP-8.4-from-matrix): This PR adds phpspec/prophecy as an explicit dependency which is restrictive and doesnt support upcoming PHP versions

* refactor: Replace ternary variable with explicit cast to string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Open discussions There are still one (or more) open discussion which touch upon this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants