Skip to content

Another attempt to make it work under PHP 5.3 and PHP 8+ #693

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

Closed
wants to merge 29 commits into from

Conversation

sanmai
Copy link

@sanmai sanmai commented Aug 31, 2022

Build is passing. I left few comments along the way, please ask if anything isn't clear.

Commit history is a mess. If you're not comfortable squash-merging this PR, I'll be happy to merge everything into one commit.

sanmai added 3 commits August 31, 2022 20:28
git grep --name-only PHPUnit.Framework.TestCase | xargs sed -i 's:PHPUnit.Framework.TestCase:LegacyPHPUnit\\TestCase:g'
} else {
static::assertInternalType('array', $actual, $message);
}
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target PHP versions do not support traits, therefore we can't use off-the-shelf polyfill.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about replacing assertInternalType with an assertTrue(is_array($data), $message) instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the same logic we should use assertTrue(is_array()) instead of assertIsArray(); what do you think?

# dependencies: highest
# experimental: false
# - php-version: "8.1"
# dependencies: lowest-ignore
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to drop this because it leads to installing dependencies broken on PHP 8.1.

},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.2.20 || ~2.19.0",
"json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.35"
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.29 || ^9.5.24",
"sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1",
Copy link
Author

@sanmai sanmai Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a certain bias since I'm the author of this package. In my defense, it is used by several high-profile packages with millions of installs to solve the very this problem.

Check out the readme: https://github.com/sanmai/phpunit-legacy-adapter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably not need this I think there should be another way of managing this, if I understand correctly PHPUnit 9 is not compatible with php < 8 right? IMO we should try to run PHPUnit 9 if possible, if not we should take the highest one possible. We can definitely do this inside the CI directly but leave this requirement to 9.

@sanmai sanmai marked this pull request as ready for review September 1, 2022 02:28
@@ -29,12 +29,14 @@
"require": {
"php": ">=5.3.3",
"marc-mabe/php-enum":"^2.0 || ^3.0 || ^4.0",
"icecave/parity": "1.0.0"
"icecave/parity": ">=1.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"icecave/parity": ">=1.0.0"
"icecave/parity": "^1.0.0"

},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.2.20 || ~2.19.0",
"json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.35"
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.29 || ^9.5.24",
"sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably not need this I think there should be another way of managing this, if I understand correctly PHPUnit 9 is not compatible with php < 8 right? IMO we should try to run PHPUnit 9 if possible, if not we should take the highest one possible. We can definitely do this inside the CI directly but leave this requirement to 9.

"phpunit/phpunit": "^4.8.35"
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.29 || ^9.5.24",
"sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1",
"phpspec/prophecy-phpunit": "^1.1 || ^2.0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this dependency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC most recent PHPUnit does not depend on this library, where in fact it is used by this library.

But I digress: it has been two years; my memory is foggy.

} else {
static::assertInternalType('array', $actual, $message);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about replacing assertInternalType with an assertTrue(is_array($data), $message) instead?

@sanmai
Copy link
Author

sanmai commented Jan 9, 2024

I can't remember why I needed this.

@sanmai sanmai closed this Jan 9, 2024
@sanmai sanmai deleted the pr/php8 branch January 9, 2024 13:28
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.

2 participants