Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
Compatibility with PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Jan 12, 2020
1 parent 7e851af commit c6e066d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ language: php
dist: trusty
sudo: false
php:
- 7.1
- 7.2
- 7.3
- 7.4
matrix:
fast_finish: true
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"files": ["bootstrap.php"]
},
"require": {
"php": ">=5.6.0"
"php": ">=7.2.0"
},
"archive": {
"exclude": ["/.gitignore", "/.travis.yml", "/phpunit.xml", "/test"]
Expand Down
4 changes: 3 additions & 1 deletion lib/password.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public static function hash($plaintext) {
* @return boolean
*/
public static function isHash($hash) {
return password_get_info($hash)['algo'] !== 0;
$algo = password_get_info($hash)['algo'];

return $algo !== 0 && $algo !== null;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/str.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,9 @@ public static function utf8($string) {
*/
public static function stripslashes($string) {
if(is_array($string)) return $string;
return get_magic_quotes_gpc() ? stripslashes($string) : $string;
// this was "get_magic_quotes_gpc() ? stripslashes($string) : $string",
// but as magic quotes are not supported since PHP 5.4.0, this method does nothing
return $string;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/toolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class Toolkit {

public static $version = '2.5.12';
public static $version = '2.5.13';

public static function version() {
return static::$version;
Expand Down
2 changes: 2 additions & 0 deletions test/RTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function testSet() {

public function testGet() {

r::set('testvar', 'testvalue');

$this->assertEquals('testvalue', r::get('testvar'));
$this->assertEquals('defaultvalue', r::get('nonexistent', 'defaultvalue'));

Expand Down
14 changes: 7 additions & 7 deletions vendors/mimereader/mimereader.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ protected function match_pattern( $pattern, $mask, $ignore ) {
if ( !empty( $ignore ) ) {
for ( $s = 0; $s < $seq_len; ) {
// This letter should not be ignored.
if ( strpos( $ignore, $sequence{$s} ) === false ) {
if ( strpos( $ignore, $sequence[$s] ) === false ) {
break;
}

Expand All @@ -547,9 +547,9 @@ protected function match_pattern( $pattern, $mask, $ignore ) {

// Now we will compare. If it doesn't match the mask, we return false.
for ( $i = 0; $i < $pattern_len; ) {
$masked_data = @$sequence{$s} & @$mask{$i};
$masked_data = @$sequence[$s] & @$mask[$i];

if ( $masked_data !== $pattern{$i} ) {
if ( $masked_data !== $pattern[$i] ) {
return false;
}

Expand Down Expand Up @@ -579,7 +579,7 @@ protected function html_match_pattern( $pattern, $mask, $ignore ) {
if ( !empty( $ignore ) ) {
for (; $s < $seq_len; ) {
// This letter should not be ignored.
if ( strpos( $ignore, $sequence{$s} ) === false ) {
if ( strpos( $ignore, $sequence[$s] ) === false ) {
break;
}

Expand All @@ -589,17 +589,17 @@ protected function html_match_pattern( $pattern, $mask, $ignore ) {

// Now we will compare. If it doesn't match the mask, we return false.
for (; $i < $pattern_len; ) {
$masked_data = $sequence{$s} & $mask{$i};
$masked_data = $sequence[$s] & $mask[$i];

if ( $masked_data !== $pattern{$i} ) {
if ( $masked_data !== $pattern[$i] ) {
return false;
}

++$i; ++$s;
}

// Mask matched. This pattern matches if the last character is tag-terminating.
return strpos( self::$tag_terminating_character, $sequence{$s} );
return strpos( self::$tag_terminating_character, $sequence[$s] );
}

protected function detect_type() {
Expand Down

0 comments on commit c6e066d

Please sign in to comment.