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: use brick/math and ramsey/uuid 4 #71

Closed
wants to merge 6 commits into from

Conversation

pmccarren
Copy link

@pmccarren pmccarren commented Mar 22, 2020

Use brick/math and upgrade ramsey/uuid to new 4.x release.

closes #68

Note: php 7.1 support is dropped, following support of ramsey/uuid@4

@Majkl578
Copy link

ramsey/uuid is already being upgraded in #69

composer.json Outdated
"ramsey/uuid": "^3.0"
"php": "^7.2",
"brick/math": "^0.8",
"ramsey/uuid": "^4.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any reason to force downstream users to upgrade to ramsey/uuid 4, unless this library uses features only available in version 4, and I don't think it does.

@pascaldevink
Copy link
Owner

I agree with @ramsey about forcing users to upgrade. However, to maintain the close compatibility, I would like to use this strategy:

  1. Release a new minor version (2.3.0) with ramsey/uuid 3 and 4 support
  2. Release a new major version (3.0.0) with only ramsey/uuid 4 and brick/math support

This way, current ramsey/uuid version 3 users are not forced to upgrade, but will have a convenient upgrade path.

@pmccarren With that in mind, could you rebase this PR with master (which already features the support for ramsey/uuid 3 and 4)? I will then base the new major version of this lib on your work for the support for brick/math

@pmccarren
Copy link
Author

@pascaldevink absolutely, I'd be happy to. Stand by

@@ -11,12 +11,13 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.2 || ^8",
Copy link

Choose a reason for hiding this comment

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

This is bad idea, PHP 8 is not even close to getting an alpha release and more BC breaks are coming.

Copy link
Author

@pmccarren pmccarren Apr 5, 2020

Choose a reason for hiding this comment

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

I was on the fence myself. but this matches the requirements of ramsey/uuid which this package is based on, so it should be safe.

ref: ramsey/[email protected]

Copy link
Contributor

Choose a reason for hiding this comment

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

The builds consistently fail for nightlies on Travis CI, but when I completely ignore platform requirements locally and tweak a few things (e.g., Reflection APIs), then everything runs smoothly on 8.0.0-dev. My hope is that, over time, more projects will start using || ^8 and addressing the issues in their libraries that break on PHP 8 (and are known to be stable right now, such as Reflection APIs). One day, it will be nice to see the nightlies magically start passing. 😉

Copy link

@Majkl578 Majkl578 Apr 5, 2020

Choose a reason for hiding this comment

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

If anyone wants to juggle with PHP 8 before at least first beta is out they can use --ignore-platform-reqs made for that purpose (you'd run composer install --ignore-platform-reqs in CI against php-nightly). But allowing PHP 8 in stable packages at this point is really bad idea, you're claiming to be compatible with something that doesn't even exist yet (remember PHP 6 book? 😃).

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why it's a problem in stable packages. No one should be running PHP 8 in production, so having || ^8 in composer.json shouldn't cause any problems.

PHP 6 was an entirely different situation.

{
$output = '';
while ($number->getValue() > 0) {
while ($number->compareTo(0) > 0) {

Choose a reason for hiding this comment

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

Could use isPositive() here


$output .= $this->alphabet[(int)$digit->getValue()];
$number = BigInteger::of(
bcdiv(

Choose a reason for hiding this comment

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

This does not seem right to me. You could do:

$number = $number->dividedBy($this->alphabetLength, RoundingMode::DOWN);

);

$digit = $previousNumber->mod($this->alphabetLength);
$output .= $this->alphabet[(int)$digit->toInt()];

Choose a reason for hiding this comment

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

No need to cast to int as toInt already returns an int.

{
$number = new BigNumber(0);
$number = BigInteger::of(0);

Choose a reason for hiding this comment

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

Just a tip, there is a BigInteger::zero() method for this purpose.

@pascaldevink
Copy link
Owner

Thanks all! I know it was a long time coming, but I've taken the commits from this PR by @pmccarren, used the feedback by @Majkl578 @ramsey and @marmichalski, and packages up version 3.0 that is all about introducing php 8 compatibility, and dropping support for php 7.1, 7.2, ramsey/uuid 3.x, and moontoast/math

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.

Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
5 participants