-
Notifications
You must be signed in to change notification settings - Fork 16
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 compatibility with PHP 8 #22
Open
jtojnar
wants to merge
10
commits into
ihor:master
Choose a base branch
from
jtojnar:tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Otherwise it will not execute on PHP 7.4+.
So that we can just run `composer test` to execute tests.
The no args test actually passed null to the partial, which started to fail as PHP got stricter in 8.0. Let’s actually make partial function accept no arguments to get rid of the edge case and then we will be able to test it properly. Let’s also return to the original time function for consistency: ihor@cd9e331
The `each` function has been deprecated in PHP 7.2 and removed in 8.0. Let’s convert arrays to iterators to make it work again and also simplify code.
sortedTest complained: Deprecated: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero
To prevent it from becoming stale
It has been available since PHP 7.1: https://www.php.net/manual/en/language.types.iterable.php
It will be clearer that the functions support 2+ arguments and PHP will check for us the type matches the type hint.
With PHP 8.1 the following warning will be printed: Deprecated: Return type of nspl\a\ChainableSequence::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice To fix it, we are adding proper type hints where we can and the attribute where it is not possible (like when the type hint would be mixed, which is only available since PHP 8.0).
jtojnar
added a commit
to jtojnar/entries
that referenced
this pull request
Oct 31, 2022
It is not compatible with PHP 8.1 and as dead as a dodo: ihor/NSPL#22 Let’s copy the cartesian product function and the tests into the repo, simplifying a bit where possible.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Had to update PHPUnit so it works on PHP 7.4+.