Skip to content

Commit

Permalink
[5.1] Fixed support for PHP 7.1 (#14549)
Browse files Browse the repository at this point in the history
* Test on PHP 7.1

* Fixed cache incrementing on php 7.1

* Skipped the legacy encrypter test on PHP 7.1+
  • Loading branch information
GrahamCampbell authored and taylorotwell committed Aug 1, 2016
1 parent bf064f5 commit 2c40396
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

env:
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/ArrayStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function put($key, $value, $minutes)
*/
public function increment($key, $value = 1)
{
$this->storage[$key] = $this->storage[$key] + $value;
$this->storage[$key] = ((int) $this->storage[$key]) + $value;

return $this->storage[$key];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected function incrementOrDecrement($key, $value, Closure $callback)
}

$current = $this->encrypter->decrypt($cache->value);
$new = $callback($current, $value);
$new = $callback((int) $current, $value);

if (! is_numeric($current)) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions tests/Encryption/EncrypterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function testOpenSslEncrypterCanDecryptMcryptedData()
$this->markTestSkipped('Mcrypt module not installed');
}

if (version_compare(PHP_VERSION, '7.1') > 0) {
$this->markTestSkipped('Not compatable with PHP 7.1+');
}

$key = Str::random(32);
$encrypter = new Illuminate\Encryption\McryptEncrypter($key);
$encrypted = $encrypter->encrypt('foo');
Expand Down

0 comments on commit 2c40396

Please sign in to comment.