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

[3.0] Remove PHP 5 support #107

Merged
merged 1 commit into from
Mar 12, 2018
Merged

[3.0] Remove PHP 5 support #107

merged 1 commit into from
Mar 12, 2018

Conversation

vinkla
Copy link
Owner

@vinkla vinkla commented Feb 26, 2018

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.

@vinkla vinkla force-pushed the php7 branch 2 times, most recently from 5007e6a to a17d348 Compare March 1, 2018 07:57
Copy link
Contributor

@Nyholm Nyholm left a 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)) {
Copy link
Contributor

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?

Copy link
Owner Author

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
Copy link
Contributor

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?

Copy link
Owner Author

@vinkla vinkla Mar 1, 2018

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.

@vinkla vinkla force-pushed the php7 branch 2 times, most recently from 3c6a349 to 4d07693 Compare March 12, 2018 14:35
@vinkla vinkla changed the title [WIP] Remove PHP 5 support [3.0] Remove PHP 5 support Mar 12, 2018
@vinkla vinkla merged commit 214c871 into master Mar 12, 2018
@vinkla vinkla deleted the php7 branch March 12, 2018 14:37
@Yogarine
Copy link

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.
Right now this is a PHP 5.6 compatible package that is synthetically made incompatible. It doesn't actually "[remove] support for legacy PHP versions". It just artificially breaks compatibility.

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?

@vinkla
Copy link
Owner Author

vinkla commented Mar 13, 2018

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.

@GeorgeGardiner
Copy link

Bumping requirements without actually implementing new features is very irritating. I could waste my day fixing this, downgrade to 3.0.0, or just ditch the project altogether and write my own algo.

Screenshot 2019-04-29 at 13 44 25

@Yogarine
Copy link

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 “*”.

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.

4 participants