Skip to content

Commit

Permalink
Fixed a bunch of PHP 7.4 syntax errors
Browse files Browse the repository at this point in the history
- FIX: Removed pointless (and invalid) destructor in LinkedIn::__destruct()
- FIX: All files that trigger this deprecation notice in PHP 7.4:
       "Array and string offset access syntax with curly braces is deprecated"
  • Loading branch information
Deltik committed Jan 18, 2020
1 parent d55fe8a commit 524229b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 74 deletions.
6 changes: 3 additions & 3 deletions e107_handlers/e107_class.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4285,11 +4285,11 @@ public function set_paths()
}

//BC temporary fixes
if (!isset($this->e107_dirs['UPLOADS_SERVER']) && $this->e107_dirs['UPLOADS_DIRECTORY']{0} == "/")
if (!isset($this->e107_dirs['UPLOADS_SERVER']) && $this->e107_dirs['UPLOADS_DIRECTORY'][0] == "/")
{
$this->e107_dirs['UPLOADS_SERVER'] = $this->e107_dirs['UPLOADS_DIRECTORY'];
}
if (!isset($this->e107_dirs['DOWNLOADS_SERVER']) && $this->e107_dirs['DOWNLOADS_DIRECTORY']{0} == "/")
if (!isset($this->e107_dirs['DOWNLOADS_SERVER']) && $this->e107_dirs['DOWNLOADS_DIRECTORY'][0] == "/")
{
$this->e107_dirs['DOWNLOADS_SERVER'] = $this->e107_dirs['DOWNLOADS_DIRECTORY'];
}
Expand Down Expand Up @@ -5115,7 +5115,7 @@ public function __get($name)
break;
}

$this->{$name} = $ret;
$this->$name = $ret;
return $ret;
}

Expand Down
8 changes: 4 additions & 4 deletions e107_handlers/e_parse_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1274,10 +1274,10 @@ public function html_truncate_old ($text, $len = 200, $more = ' ... ')
$intag = FALSE;
while($curlen < $len && $curlen < strlen($text))
{
switch($text {$pos} )
switch($text [$pos] )
{
case "<":
if($text {$pos + 1} == "/")
if($text [$pos + 1] == "/")
{
$closing_tag = TRUE;
}
Expand All @@ -1288,7 +1288,7 @@ public function html_truncate_old ($text, $len = 200, $more = ' ... ')


case ">":
if($text {$pos - 1} == "/")
if($text [$pos - 1] == "/")
{
$closing_tag = TRUE;
}
Expand All @@ -1303,7 +1303,7 @@ public function html_truncate_old ($text, $len = 200, $more = ' ... ')


case "&":
if($text {$pos + 1} == "#")
if($text [$pos + 1] == "#")
{
$end = strpos(substr($text, $pos, 7), ";");
if($end !== FALSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ public function __construct($config) {
$this->setCallbackUrl($config['callbackUrl']);
}

/**
* The class destructor.
*
* Explicitly clears LinkedIn object from memory upon destruction.
*/
public function __destruct() {
unset($this);
}

/**
* Bookmark a job.
*
Expand Down
2 changes: 1 addition & 1 deletion e107_handlers/hybridauth/Hybrid/thirdparty/OAuth/OAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function check_signature($request, $consumer, $token, $signature) {
// Avoid a timing leak with a (hopefully) time insensitive compare
$result = 0;
for ($i = 0; $i < strlen($signature); $i++) {
$result |= ord($built{$i}) ^ ord($signature{$i});
$result |= ord($built[$i]) ^ ord($signature[$i]);
}

return $result == 0;
Expand Down
76 changes: 38 additions & 38 deletions e107_handlers/json_compat_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function utf162utf8($utf16)
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}

$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
$bytes = (ord($utf16[0]) << 8) | ord($utf16[1]);

switch(true) {
case ((0x7F & $bytes) == $bytes):
Expand Down Expand Up @@ -204,17 +204,17 @@ function utf82utf16($utf8)
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
return chr(0x07 & (ord($utf8[0]) >> 2))
. chr((0xC0 & (ord($utf8[0]) << 6))
| (0x3F & ord($utf8[1])));

case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
return chr((0xF0 & (ord($utf8[0]) << 4))
| (0x0F & (ord($utf8[1]) >> 2)))
. chr((0xC0 & (ord($utf8[1]) << 6))
| (0x7F & ord($utf8[2])));
}

// ignoring UTF-32 for now, sorry
Expand Down Expand Up @@ -259,7 +259,7 @@ function encode($var)
*/
for ($c = 0; $c < $strlen_var; ++$c) {

$ord_var_c = ord($var{$c});
$ord_var_c = ord($var[$c]);

switch (true) {
case $ord_var_c == 0x08:
Expand All @@ -282,18 +282,18 @@ function encode($var)
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
$ascii .= '\\'.$var[$c];
break;

case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
$ascii .= $var[$c];
break;

case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$char = pack('C*', $ord_var_c, ord($var[$c + 1]));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
Expand All @@ -303,8 +303,8 @@ function encode($var)
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
ord($var[$c + 1]),
ord($var[$c + 2]));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
Expand All @@ -314,9 +314,9 @@ function encode($var)
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
ord($var[$c + 1]),
ord($var[$c + 2]),
ord($var[$c + 3]));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
Expand All @@ -326,10 +326,10 @@ function encode($var)
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
ord($var[$c + 1]),
ord($var[$c + 2]),
ord($var[$c + 3]),
ord($var[$c + 4]));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
Expand All @@ -339,11 +339,11 @@ function encode($var)
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
ord($var[$c + 1]),
ord($var[$c + 2]),
ord($var[$c + 3]),
ord($var[$c + 4]),
ord($var[$c + 5]));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
Expand Down Expand Up @@ -518,7 +518,7 @@ function decode($str)
for ($c = 0; $c < $strlen_chrs; ++$c) {

$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
$ord_chrs_c = ord($chrs[$c]);

switch (true) {
case $substr_chrs_c_2 == '\b':
Expand Down Expand Up @@ -548,7 +548,7 @@ function decode($str)
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
$utf8 .= $chrs[++$c];
}
break;

Expand All @@ -561,7 +561,7 @@ function decode($str)
break;

case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
$utf8 .= $chrs[$c];
break;

case ($ord_chrs_c & 0xE0) == 0xC0:
Expand Down Expand Up @@ -608,7 +608,7 @@ function decode($str)
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation

if ($str{0} == '[') {
if ($str[0] == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
Expand Down Expand Up @@ -647,7 +647,7 @@ function decode($str)
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);

if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
if (($c == $strlen_chrs) || (($chrs[$c] == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
Expand Down Expand Up @@ -689,12 +689,12 @@ function decode($str)

}

} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
} elseif ((($chrs[$c] == '"') || ($chrs[$c] == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs[$c]));
//print("Found start of string at {$c}\n");

} elseif (($chrs{$c} == $top['delim']) &&
} elseif (($chrs[$c] == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
Expand All @@ -703,24 +703,24 @@ function decode($str)
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");

} elseif (($chrs{$c} == '[') &&
} elseif (($chrs[$c] == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");

} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
} elseif (($chrs[$c] == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");

} elseif (($chrs{$c} == '{') &&
} elseif (($chrs[$c] == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");

} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
} elseif (($chrs[$c] == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
Expand Down
24 changes: 12 additions & 12 deletions e107_handlers/pcltar.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function PclTarExtract($p_tarname, $p_path="./", $p_remove_path="", $p_mode="")
}

// ----- Call the extracting fct
if (($v_result = PclTarHandleExtract($p_tarname, 0, &$p_list, "complete", $p_path, $v_tar_mode, $p_remove_path)) != 1)
if (($v_result = PclTarHandleExtract($p_tarname, 0, $p_list, "complete", $p_path, $v_tar_mode, $p_remove_path)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand Down Expand Up @@ -445,7 +445,7 @@ function PclTarExtractList($p_tarname, $p_filelist, $p_path="./", $p_remove_path
if (is_array($p_filelist))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleExtract($p_tarname, $p_filelist, &$p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)
if (($v_result = PclTarHandleExtract($p_tarname, $p_filelist, $p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand All @@ -459,7 +459,7 @@ function PclTarExtractList($p_tarname, $p_filelist, $p_path="./", $p_remove_path
$v_list = explode(" ", $p_filelist);

// ----- Call the extracting fct
if (($v_result = PclTarHandleExtract($p_tarname, $v_list, &$p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)
if (($v_result = PclTarHandleExtract($p_tarname, $v_list, $p_list, "partial", $p_path, $v_tar_mode, $p_remove_path)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand Down Expand Up @@ -534,7 +534,7 @@ function PclTarExtractIndex($p_tarname, $p_index, $p_path="./", $p_remove_path="
if (is_integer($p_index))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, &$p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand All @@ -545,7 +545,7 @@ function PclTarExtractIndex($p_tarname, $p_index, $p_path="./", $p_remove_path="
else if (is_string($p_index))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, &$p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
if (($v_result = PclTarHandleExtractByIndexList($p_tarname, $p_index, $p_list, $p_path, $p_remove_path, $v_tar_mode)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand Down Expand Up @@ -603,7 +603,7 @@ function PclTarDelete($p_tarname, $p_filelist, $p_mode="")
if (is_array($p_filelist))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleDelete($p_tarname, $p_filelist, &$p_list, $p_mode)) != 1)
if (($v_result = PclTarHandleDelete($p_tarname, $p_filelist, $p_list, $p_mode)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand All @@ -617,7 +617,7 @@ function PclTarDelete($p_tarname, $p_filelist, $p_mode="")
$v_list = explode(" ", $p_filelist);

// ----- Call the extracting fct
if (($v_result = PclTarHandleDelete($p_tarname, $v_list, &$p_list, $p_mode)) != 1)
if (($v_result = PclTarHandleDelete($p_tarname, $v_list, $p_list, $p_mode)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand Down Expand Up @@ -676,7 +676,7 @@ function PclTarUpdate($p_tarname, $p_filelist, $p_mode="", $p_add_dir="", $p_rem
if (is_array($p_filelist))
{
// ----- Call the extracting fct
if (($v_result = PclTarHandleUpdate($p_tarname, $p_filelist, &$p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)
if (($v_result = PclTarHandleUpdate($p_tarname, $p_filelist, $p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand All @@ -690,7 +690,7 @@ function PclTarUpdate($p_tarname, $p_filelist, $p_mode="", $p_add_dir="", $p_rem
$v_list = explode(" ", $p_filelist);

// ----- Call the extracting fct
if (($v_result = PclTarHandleUpdate($p_tarname, $v_list, &$p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)
if (($v_result = PclTarHandleUpdate($p_tarname, $v_list, $p_list, $p_mode, $p_add_dir, $p_remove_dir)) != 1)
{
TrFctEnd(__FILE__, __LINE__, 0, PclErrorString());
return(0);
Expand Down Expand Up @@ -2719,7 +2719,7 @@ function PclTarHandleDelete($p_tarname, $p_file_list, &$p_list_detail, $p_tar_mo
$v_binary_data = gzread($v_tar, 512);

// ----- Read the header properties
if (($v_result = PclTarHandleReadHeader($v_binary_data, &$v_header)) != 1)
if (($v_result = PclTarHandleReadHeader($v_binary_data, $v_header)) != 1)
{
// ----- Close the archive file
if ($p_tar_mode == "tar")
Expand Down Expand Up @@ -3011,7 +3011,7 @@ function PclTarHandleUpdate($p_tarname, $p_file_list, &$p_list_detail, $p_tar_mo
$v_binary_data = gzread($v_tar, 512);

// ----- Read the header properties
if (($v_result = PclTarHandleReadHeader($v_binary_data, &$v_header)) != 1)
if (($v_result = PclTarHandleReadHeader($v_binary_data, $v_header)) != 1)
{
// ----- Close the archive file
if ($p_tar_mode == "tar")
Expand Down Expand Up @@ -3556,4 +3556,4 @@ function PclTarHandlePathReduction($p_dir)

// ----- End of double include look
}
?>
?>
Loading

0 comments on commit 524229b

Please sign in to comment.