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

Replace curly braces for PHP 7.4 compatibility #25782

Merged
merged 8 commits into from Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions build/phpcs/Joomla/Sniffs/Commenting/FileCommentSniff.php
Expand Up @@ -593,9 +593,9 @@ protected function processPackage($errorPos)
$newContent = str_replace(' ', '_', $content);
$nameBits = explode('_', $newContent);
$firstBit = array_shift($nameBits);
$newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
$newName = strtoupper($firstBit[0]).substr($firstBit, 1).'_';
foreach ($nameBits as $bit) {
$newName .= strtoupper($bit{0}).substr($bit, 1).'_';
$newName .= strtoupper($bit[0]).substr($bit, 1).'_';
}

$error = 'Package name "%s" is not valid; consider "%s" instead';
Expand Down Expand Up @@ -632,9 +632,9 @@ protected function processSubpackage($errorPos)
// $newContent = str_replace(' ', '_', $content);
// $nameBits = explode('_', $newContent);
// $firstBit = array_shift($nameBits);
// $newName = strtoupper($firstBit{0}).substr($firstBit, 1).'_';
// $newName = strtoupper($firstBit[0]).substr($firstBit, 1).'_';
// foreach ($nameBits as $bit) {
// $newName .= strtoupper($bit{0}).substr($bit, 1).'_';
// $newName .= strtoupper($bit[0]).substr($bit, 1).'_';
// }
//
// $error = 'Subpackage name "%s" is not valid; consider "%s" instead';
Expand Down
4 changes: 2 additions & 2 deletions build/phpcs/Joomla/Sniffs/Commenting/SingleCommentSniff.php
Expand Up @@ -51,7 +51,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
* The exception to this is if the preceding line consists of a single open bracket.
*/

if (isset($comment{2}) && $comment{2} != ' ')
if (isset($comment[2]) && $comment[2] != ' ')
{
$phpcsFile->addError('Please put a space between the // and the start of comment text; found "%s"'
, $stackPtr, 'NoSpace', array($comment));
Expand All @@ -65,7 +65,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
* The term is code and is case sensitive.(@todo)
*/

if (isset($comment{3}) && $comment{3} != strtoupper($comment{3}))
if (isset($comment[3]) && $comment[3] != strtoupper($comment[3]))
{
// Comment does not start with an upper case letter

Expand Down
2 changes: 1 addition & 1 deletion installation/model/database.php
Expand Up @@ -1199,7 +1199,7 @@ public function populateDatabase($db, $schema)
$query = trim($query);

// If the query isn't empty and is not a MySQL or PostgreSQL comment, execute it.
if (!empty($query) && ($query{0} != '#') && ($query{0} != '-'))
if (!empty($query) && ($query[0] != '#') && ($query[0] != '-'))
{
/**
* If we don't have UTF-8 Multibyte support we'll have to convert queries to plain UTF-8
Expand Down
5 changes: 3 additions & 2 deletions libraries/fof/database/driver.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects
* instead of plain stdClass objects
Expand Down Expand Up @@ -1898,7 +1899,7 @@ protected function quoteNameStr($strArr)
}
else
{
$parts[] = $q{0} . $part . $q{1};
$parts[] = $q[0] . $part . $q[1];
}
}

Expand Down Expand Up @@ -1974,7 +1975,7 @@ public function replacePrefix($sql, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $sql{$l} == '\\')
while ($l >= 0 && $sql[$l] == '\\')
{
$l--;
$escaped = !$escaped;
Expand Down
3 changes: 2 additions & 1 deletion libraries/fof/database/driver/joomla.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects
* instead of plain stdClass objects
Expand Down Expand Up @@ -596,7 +597,7 @@ protected function quoteNameStr($strArr)
}
else
{
$parts[] = $q{0} . $part . $q{1};
$parts[] = $q[0] . $part . $q[1];
}
}

Expand Down
3 changes: 2 additions & 1 deletion libraries/fof/database/driver/oracle.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects
* instead of plain stdClass objects
Expand Down Expand Up @@ -595,7 +596,7 @@ public function replacePrefix($query, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $query{$l} == '\\')
while ($l >= 0 && $query[$l] == '\\')
{
$l--;
$escaped = !$escaped;
Expand Down
3 changes: 2 additions & 1 deletion libraries/fof/database/driver/sqlsrv.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage database
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*
* This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects
* instead of plain stdClass objects
Expand Down Expand Up @@ -783,7 +784,7 @@ public function replacePrefix($query, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $query{$l} == '\\')
while ($l >= 0 && $query[$l] == '\\')
{
$l--;
$escaped = !$escaped;
Expand Down
5 changes: 3 additions & 2 deletions libraries/fof/less/less.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage less
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
// Protect from unauthorized access
defined('FOF_INCLUDED') or die;
Expand Down Expand Up @@ -1064,7 +1065,7 @@ protected function compileProp($prop, $block, $out)
if ($suffix !== null
&& $subProp[0] == "assign"
&& is_string($subProp[1])
&& $subProp[1]{0} != $this->vPrefix)
&& $subProp[1][0] != $this->vPrefix)
{
$subProp[2] = array(
'list', ' ',
Expand Down Expand Up @@ -2819,7 +2820,7 @@ protected function injectVariables($args)
/** FOF -- END CHANGE * */
foreach ($args as $name => $strValue)
{
if ($name{0} != '@')
if ($name[0] != '@')
{
$name = '@' . $name;
}
Expand Down
7 changes: 4 additions & 3 deletions libraries/fof/less/parser/parser.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage less
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
// Protect from unauthorized access
defined('FOF_INCLUDED') or die;
Expand Down Expand Up @@ -345,7 +346,7 @@ protected function parseChunk()
{
foreach ($block->tags as $tag)
{
if (!is_string($tag) || $tag{0} != $this->lessc->mPrefix)
if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix)
{
$hidden = false;
break;
Expand Down Expand Up @@ -428,7 +429,7 @@ protected function fixTags($tags)
// Move @ tags out of variable namespace
foreach ($tags as &$tag)
{
if ($tag{0} == $this->lessc->vPrefix)
if ($tag[0] == $this->lessc->vPrefix)
{
$tag[0] = $this->lessc->mPrefix;
}
Expand Down Expand Up @@ -1676,7 +1677,7 @@ protected function end()
{
return true;
}
elseif ($this->count == strlen($this->buffer) || $this->buffer{$this->count} == '}')
elseif ($this->count == strlen($this->buffer) || $this->buffer[$this->count] == '}')
{
// If there is end of file or a closing block next then we don't need a ;
return true;
Expand Down
9 changes: 5 additions & 4 deletions libraries/fof/utils/ini/parser.php
Expand Up @@ -4,6 +4,7 @@
* @subpackage utils
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/

defined('FOF_INCLUDED') or die;
Expand Down Expand Up @@ -102,7 +103,7 @@ static function parse_ini_file_php($file, $process_sections = false, $rawdata =
}

// Sections
if ($line{0} == '[')
if ($line[0] == '[')
{
$tmp = explode(']', $line);
$sections[] = trim(substr($tmp[0], 1));
Expand All @@ -125,7 +126,7 @@ static function parse_ini_file_php($file, $process_sections = false, $rawdata =
$tmp = explode(';', $value);
if (count($tmp) == 2)
{
if ((($value{0} != '"') && ($value{0} != "'")) ||
if ((($value[0] != '"') && ($value[0] != "'")) ||
preg_match('/^".*"\s*;/', $value) || preg_match('/^".*;[^"]*$/', $value) ||
preg_match("/^'.*'\s*;/", $value) || preg_match("/^'.*;[^']*$/", $value)
)
Expand All @@ -135,11 +136,11 @@ static function parse_ini_file_php($file, $process_sections = false, $rawdata =
}
else
{
if ($value{0} == '"')
if ($value[0] == '"')
{
$value = preg_replace('/^"(.*)".*/', '$1', $value);
}
elseif ($value{0} == "'")
elseif ($value[0] == "'")
{
$value = preg_replace("/^'(.*)'.*/", '$1', $value);
}
Expand Down
9 changes: 5 additions & 4 deletions libraries/idna_convert/idna_convert.class.php
Expand Up @@ -49,6 +49,7 @@
* @author Matthias Sommerfeld <mso@phlylabs.de>
* @copyright 2004-2011 phlyLabs Berlin, http://phlylabs.de
* @version 0.8.0 2011-03-11
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
class idna_convert
{
Expand Down Expand Up @@ -418,7 +419,7 @@ protected function _decode($encoded)
$delim_pos = strrpos($encoded, '-');
if ($delim_pos > self::byteLength($this->_punycode_prefix)) {
for ($k = self::byteLength($this->_punycode_prefix); $k < $delim_pos; ++$k) {
$decoded[] = ord($encoded{$k});
$decoded[] = ord($encoded[$k]);
}
}
$deco_len = count($decoded);
Expand All @@ -432,7 +433,7 @@ protected function _decode($encoded)

for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
$digit = $this->_decode_digit($encoded{$enco_idx++});
$digit = $this->_decode_digit($encoded[$enco_idx++]);
$idx += $digit * $w;
$t = ($k <= $bias) ? $this->_tmin :
(($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
Expand Down Expand Up @@ -823,7 +824,7 @@ protected function _utf8_to_ucs4($input)
$mode = 'next';
$test = 'none';
for ($k = 0; $k < $inp_len; ++$k) {
$v = ord($input{$k}); // Extract byte from input string
$v = ord($input[$k]); // Extract byte from input string
if ($v < 128) { // We found an ASCII char - put into stirng as is
$output[$out_len] = $v;
++$out_len;
Expand Down Expand Up @@ -954,7 +955,7 @@ protected function _ucs4_string_to_ucs4($input)
$out_len++;
$output[$out_len] = 0;
}
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
$output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
}
return $output;
}
Expand Down
5 changes: 3 additions & 2 deletions libraries/idna_convert/transcode_wrapper.php
Expand Up @@ -15,6 +15,7 @@
*[@param bool Safe Mode: if set to TRUE, the original string is retunred on errors]
* @return string The encoded string or false on failure
* @since 0.0.1
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
function encode_utf8($string = '', $encoding = 'iso-8859-1', $safe_mode = false)
{
Expand Down Expand Up @@ -92,7 +93,7 @@ function map_w1252_iso8859_1($string = '')
if ($string == '') return '';
$return = '';
for ($i = 0; $i < strlen($string); ++$i) {
$c = ord($string{$i});
$c = ord($string[$i]);
switch ($c) {
case 129: $return .= chr(252); break;
case 132: $return .= chr(228); break;
Expand All @@ -119,7 +120,7 @@ function map_iso8859_1_w1252($string = '')
if ($string == '') return '';
$return = '';
for ($i = 0; $i < strlen($string); ++$i) {
$c = ord($string{$i});
$c = ord($string[$i]);
switch ($c) {
case 196: $return .= chr(142); break;
case 214: $return .= chr(153); break;
Expand Down
11 changes: 6 additions & 5 deletions libraries/idna_convert/uctc.php
Expand Up @@ -14,6 +14,7 @@
* @author Matthias Sommerfeld <mso@phlyLabs.de>
* @copyright 2003-2009 phlyLabs Berlin, http://phlylabs.de
* @version 0.0.6 2009-05-10
* @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author.
*/
class uctc {
private static $mechs = array('ucs4', /*'ucs4le', 'ucs4be', */'ucs4array', /*'utf16', 'utf16le', 'utf16be', */'utf8', 'utf7', 'utf7imap');
Expand Down Expand Up @@ -59,7 +60,7 @@ private static function utf8_ucs4array($input)
$mode = 'next';
$test = 'none';
for ($k = 0; $k < $inp_len; ++$k) {
$v = ord($input{$k}); // Extract byte from input string
$v = ord($input[$k]); // Extract byte from input string

if ($v < 128) { // We found an ASCII char - put into stirng as is
$output[$out_len] = $v;
Expand Down Expand Up @@ -176,7 +177,7 @@ private static function utf7_ucs4array($input, $sc = '+')
$b64 = '';

for ($k = 0; $k < $inp_len; ++$k) {
$c = $input{$k};
$c = $input[$k];
if (0 == ord($c)) continue; // Ignore zero bytes
if ('b' == $mode) {
// Sequence got terminated
Expand All @@ -193,10 +194,10 @@ private static function utf7_ucs4array($input, $sc = '+')
$tmp = substr($tmp, -1 * (strlen($tmp) % 2));
for ($i = 0; $i < strlen($tmp); $i++) {
if ($i % 2) {
$output[$out_len] += ord($tmp{$i});
$output[$out_len] += ord($tmp[$i]);
$out_len++;
} else {
$output[$out_len] = ord($tmp{$i}) << 8;
$output[$out_len] = ord($tmp[$i]) << 8;
}
}
$mode = 'd';
Expand Down Expand Up @@ -292,7 +293,7 @@ private static function ucs4_ucs4array($input)
$out_len++;
$output[$out_len] = 0;
}
$output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
$output[$out_len] += ord($input[$i]) << (8 * (3 - ($i % 4) ) );
}
return $output;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/database/driver.php
Expand Up @@ -1968,7 +1968,7 @@ protected function quoteNameStr($strArr)
}
else
{
$parts[] = $q{0} . str_replace($q{1}, $q{1} . $q{1}, $part) . $q{1};
$parts[] = $q[0] . str_replace($q[1], $q[1] . $q[1], $part) . $q[1];
}
}

Expand Down Expand Up @@ -2044,7 +2044,7 @@ public function replacePrefix($sql, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $sql{$l} == '\\')
while ($l >= 0 && $sql[$l] == '\\')
{
$l--;
$escaped = !$escaped;
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/oracle.php
Expand Up @@ -582,7 +582,7 @@ public function replacePrefix($query, $prefix = '#__')

$l = $k - 1;

while ($l >= 0 && $query{$l} == '\\')
while ($l >= 0 && $query[$l] == '\\')
{
$l--;
$escaped = !$escaped;
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Client/FtpClient.php
Expand Up @@ -1644,7 +1644,7 @@ public function listDetails($path = null, $type = 'all')

if (@preg_match($regexp, $file, $regs))
{
$fType = (int) strpos('-dl', $regs[1]{0});
$fType = (int) strpos('-dl', $regs[1][0]);

// $tmp_array['line'] = $regs[0];
$tmp_array['type'] = $fType;
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Filesystem/Path.php
Expand Up @@ -145,13 +145,13 @@ public static function getPermissions($path)
for ($i = 0; $i < 3; $i++)
{
// Read
$parsed_mode .= ($mode{$i} & 04) ? 'r' : '-';
$parsed_mode .= ($mode[$i] & 04) ? 'r' : '-';

// Write
$parsed_mode .= ($mode{$i} & 02) ? 'w' : '-';
$parsed_mode .= ($mode[$i] & 02) ? 'w' : '-';

// Execute
$parsed_mode .= ($mode{$i} & 01) ? 'x' : '-';
$parsed_mode .= ($mode[$i] & 01) ? 'x' : '-';
}

return $parsed_mode;
Expand Down