-
Notifications
You must be signed in to change notification settings - Fork 415
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
[3.0] Remove PHP 5 support #107
Conversation
5007e6a
to
a17d348
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good thing you go straight to PHP 7.1
src/Hashids.php
Outdated
@@ -263,7 +265,7 @@ public function decode($hash) | |||
foreach ($hashArray as $subHash) { | |||
$alphabet = $this->shuffle($alphabet, substr($lottery.$this->salt.$alphabet, 0, strlen($alphabet))); | |||
$result = $this->unhash($subHash, $alphabet); | |||
if ($this->math->greaterThan($result, PHP_INT_MAX)) { | |||
if ($this->math->greaterThan($result, (string) PHP_INT_MAX)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks weird... why is this type cast needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. This is just me testing what works and not. This is still very much work in progress.
src/Hashids.php
Outdated
*/ | ||
protected function unhash($input, $alphabet) | ||
protected function unhash(string $input, string $alphabet): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should this return a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't, I'm just testing. Will fix in this in future commits.
3c6a349
to
4d07693
Compare
I realise this pull request has already been merged but I wanted to comment here just to make sure this mistake won't be made in the future. Just bumping requirements without actually implementing new features "just because PHP 5 will be EOL" doesn't add anything useful. Bumping requirements should be a natural process where you decide to use a new feature which in turn requires you to break compatibility. As long as there is no actual pressing need to do so, you shouldn't just bump requirements. The more compatible your code is, the better. I do realise you might want to incentivise your user base to upgrade to a newer version of PHP, but there are many cases where this simply might not be feasible, or necessary. (For example, PHP is used in internal systems that aren't web-facing and therefore are not susceptible to being hacked, while stability is more important than having the newest features. Also on embedded systems it's not always possible to update to the newest PHP versions.) So, hey, if you really want to bump to PHP 7.1 go ahead. But how about actually using some PHP 7.1 features like types while you're at it? |
We welcome any pull request you send our way. |
Exactly. It doesn’t even make sense. Why would you arbitrarily bump a requirement without using it? On the other side. This is why you should always pin composer requirements to specific major versions and never use “master” or “*”. |
This pull request removes support for legacy PHP versions. PHP 5.6 and 7.0 sees EOL this year and a lot of frameworks such as Laravel and Symfony has already dropped support for those versions.
This wont be an issue for users of older PHP versions since this will be a part of an major release and we won't be adding any breaking changes.