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 compatibility with PHP 8 #22

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Fix compatibility with PHP 8 #22

wants to merge 10 commits into from

Conversation

jtojnar
Copy link

@jtojnar jtojnar commented Dec 10, 2021

Had to update PHPUnit so it works on PHP 7.4+.

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
@jtojnar jtojnar changed the title Add CI for running tests Fix compatibility with PHP 8 Dec 10, 2021
To prevent it from becoming stale
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant