Repository navigation
Conversation
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
|
Thanks! |
This file contains hidden or 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
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.
Fixes #104
PHP 8.6 deprecates using
isas the name of a class or a function, so loadingHamcrest\Core\Isor the globalis()function emits a deprecation notice. This PR keeps both working for backward compatibility, but makes it possible to avoid them.Changes
Hamcrest\Core\IsMatcheris the new name of theIsmatcher.Matchers::is()and the globalis()now return it.Hamcrest\Core\Isstays as a deprecated subclass ofIsMatcher, so existing code keeps working. It is only autoloaded (and so only emits the deprecation) when something references it directly.is()function cannot be declared without a deprecation on PHP 8.6, so the generator now writes it into its own file,hamcrest/HamcrestIs.php. The other functions move tohamcrest/HamcrestFunctions.php(the oldHamcrest.phpwithoutis();git diff -Cshows it as a copy).hamcrest/Hamcrest.phpis now a small loader that requires both files, so code that requires it directly behaves as before.Util::registerGlobalFunctions()gets an optional$includeIs = trueparameter.registerGlobalFunctions(false)registers everything exceptis(), andMatchers::is()can be used instead. The README documents this.Testing
The test suite passes on PHP 8.2, 8.5 and 8.6. On PHP 8.6 the only remaining deprecation comes from
tests/bootstrap.php, which still registersis()on purpose so the global function stays covered. The test for the deprecatedIsclass is skipped on PHP 8.6 for the same reason.