Skip to content

Commit

Permalink
Unnecessary double quotes in /libraries/joomla (#13372)
Browse files Browse the repository at this point in the history
* Replace unnecessary double quotes in /libraries/joomla

* Formatting

* CS Fix

* Fixes, based on @andrepereiradasilva's comments.

* Change remove string concatenations for some occurrences.

* Fixes, based on @andrepereiradasilva's comments.

* Fixes, based on @andrepereiradasilva's comments.

* Fixes, based on @andrepereiradasilva's comments.
  • Loading branch information
frankmayer authored and wilsonge committed Jan 12, 2017
1 parent 4352229 commit 6ab2a6e
Show file tree
Hide file tree
Showing 53 changed files with 227 additions and 221 deletions.
4 changes: 2 additions & 2 deletions libraries/joomla/application/web.php
Expand Up @@ -534,7 +534,7 @@ public function redirect($url, $status = 303)
// If the headers have already been sent we need to send the redirect statement via JavaScript.
if ($this->checkHeadersSent())
{
echo "<script>document.location.href='" . str_replace("'", "&apos;", $url) . "';</script>\n";
echo "<script>document.location.href='" . str_replace("'", '&apos;', $url) . "';</script>\n";
}
else
{
Expand All @@ -543,7 +543,7 @@ public function redirect($url, $status = 303)
{
$html = '<html><head>';
$html .= '<meta http-equiv="content-type" content="text/html; charset=' . $this->charSet . '" />';
$html .= '<script>document.location.href=\'' . str_replace("'", "&apos;", $url) . '\';</script>';
$html .= '<script>document.location.href=\'' . str_replace("'", '&apos;', $url) . '\';</script>';
$html .= '</head><body></body></html>';

echo $html;
Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/archive/tar.php
Expand Up @@ -164,14 +164,14 @@ protected function _getTarInfo(& $data)
if (version_compare(PHP_VERSION, '5.5', '>='))
{
$info = @unpack(
"Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Ctypeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor",
'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Ctypeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor',
substr($data, $position)
);
}
else
{
$info = @unpack(
"a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor",
'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor',
substr($data, $position)
);
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/joomla/archive/zip.php
Expand Up @@ -296,12 +296,12 @@ protected function extractNative($archive, $destination)
// Read files in the archive
while ($file = @zip_read($zip))
{
if (!zip_entry_open($zip, $file, "r"))
if (!zip_entry_open($zip, $file, 'r'))
{
return $this->raiseWarning(100, 'Unable to read entry');
}

if (substr(zip_entry_name($file), strlen(zip_entry_name($file)) - 1) != "/")
if (substr(zip_entry_name($file), strlen(zip_entry_name($file)) - 1) != '/')
{
$buffer = zip_entry_read($file, zip_entry_filesize($file));

Expand Down Expand Up @@ -384,7 +384,7 @@ private function _readZipInfo(&$data)

$entries[$name] = array(
'attr' => null,
'crc' => sprintf("%08s", dechex($info['CRC32'])),
'crc' => sprintf('%08s', dechex($info['CRC32'])),
'csize' => $info['Compressed'],
'date' => null,
'_dataStart' => null,
Expand Down
6 changes: 3 additions & 3 deletions libraries/joomla/cache/storage/file.php
Expand Up @@ -137,7 +137,7 @@ public function store($id, $group, $data)
// Prepend a die string
$data = $die . $data;

$_fileopen = @fopen($path, "wb");
$_fileopen = @fopen($path, 'wb');

if ($_fileopen)
{
Expand Down Expand Up @@ -280,7 +280,7 @@ public function lock($id, $group, $locktime)

$looptime = $locktime * 10;
$path = $this->_getFilePath($id, $group);
$_fileopen = @fopen($path, "r+b");
$_fileopen = @fopen($path, 'r+b');

if ($_fileopen)
{
Expand Down Expand Up @@ -330,7 +330,7 @@ public function lock($id, $group, $locktime)
public function unlock($id, $group = null)
{
$path = $this->_getFilePath($id, $group);
$_fileopen = @fopen($path, "r+b");
$_fileopen = @fopen($path, 'r+b');

if ($_fileopen)
{
Expand Down
92 changes: 46 additions & 46 deletions libraries/joomla/client/ftp.php
Expand Up @@ -26,19 +26,19 @@
define('CRLF', "\r\n");
}

if (!defined("FTP_AUTOASCII"))
if (!defined('FTP_AUTOASCII'))
{
define("FTP_AUTOASCII", -1);
define('FTP_AUTOASCII', -1);
}

if (!defined("FTP_BINARY"))
if (!defined('FTP_BINARY'))
{
define("FTP_BINARY", 1);
define('FTP_BINARY', 1);
}

if (!defined("FTP_ASCII"))
if (!defined('FTP_ASCII'))
{
define("FTP_ASCII", 0);
define('FTP_ASCII', 0);
}

if (!defined('FTP_NATIVE'))
Expand Down Expand Up @@ -94,27 +94,27 @@ class JClientFtp
* @since 12.1
*/
protected $_autoAscii = array(
"asp",
"bat",
"c",
"cpp",
"csv",
"h",
"htm",
"html",
"shtml",
"ini",
"inc",
"log",
"php",
"php3",
"pl",
"perl",
"sh",
"sql",
"txt",
"xhtml",
"xml",
'asp',
'bat',
'c',
'cpp',
'csv',
'h',
'htm',
'html',
'shtml',
'ini',
'inc',
'log',
'php',
'php3',
'pl',
'perl',
'sh',
'sql',
'txt',
'xhtml',
'xml',
);

/**
Expand Down Expand Up @@ -194,7 +194,7 @@ public function __destruct()
*/
public static function getInstance($host = '127.0.0.1', $port = '21', array $options = array(), $user = null, $pass = null)
{
$signature = $user . ':' . $pass . '@' . $host . ":" . $port;
$signature = $user . ':' . $pass . '@' . $host . ':' . $port;

// Create a new instance, or set the options of an existing one
if (!isset(static::$instances[$signature]) || !is_object(static::$instances[$signature]))
Expand Down Expand Up @@ -428,7 +428,7 @@ public function pwd()
preg_match('/"[^"\r\n]*"/', $this->_response, $match);

// Return the cleaned path
return preg_replace("/\"/", "", $match[0]);
return preg_replace("/\"/", '', $match[0]);
}

/**
Expand Down Expand Up @@ -914,7 +914,7 @@ public function read($remote, &$buffer)
$os = 'WIN';
}

$buffer = preg_replace("/" . CRLF . "/", $this->_lineEndings[$os], $buffer);
$buffer = preg_replace('/' . CRLF . '/', $this->_lineEndings[$os], $buffer);
}

if (!$this->_verifyResponse(226))
Expand Down Expand Up @@ -966,7 +966,7 @@ public function get($local, $remote)
$this->_mode($mode);

// Check to see if the local file can be opened for writing
$fp = fopen($local, "wb");
$fp = fopen($local, 'wb');

if (!$fp)
{
Expand Down Expand Up @@ -1060,7 +1060,7 @@ public function store($local, $remote = null)
// Check to see if the local file exists and if so open it for reading
if (@ file_exists($local))
{
$fp = fopen($local, "rb");
$fp = fopen($local, 'rb');

if (!$fp)
{
Expand Down Expand Up @@ -1111,7 +1111,7 @@ public function store($local, $remote = null)

$line = substr($line, $result);
}
while ($line != "");
while ($line != '');
}

fclose($fp);
Expand Down Expand Up @@ -1202,7 +1202,7 @@ public function write($remote, $buffer)

$buffer = substr($buffer, $result);
}
while ($buffer != "");
while ($buffer != '');

// Close the data connection port [Data transfer complete]
fclose($this->_dataconn);
Expand Down Expand Up @@ -1453,7 +1453,7 @@ public function listNames($path = null)
return false;
}

$data = preg_split("/[" . CRLF . "]+/", $data, -1, PREG_SPLIT_NO_EMPTY);
$data = preg_split('/[' . CRLF . ']+/', $data, -1, PREG_SPLIT_NO_EMPTY);
$data = preg_replace('#^' . preg_quote(substr($path, 1), '#') . '[/\\\\]?#', '', $data);

if ($keys = array_merge(array_keys($data, '.'), array_keys($data, '..')))
Expand Down Expand Up @@ -1612,19 +1612,19 @@ 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;
$tmp_array['type'] = $fType;
$tmp_array['rights'] = $regs[1];

// $tmp_array['number'] = $regs[2];
$tmp_array['user'] = $regs[3];
$tmp_array['user'] = $regs[3];
$tmp_array['group'] = $regs[4];
$tmp_array['size'] = $regs[5];
$tmp_array['date'] = @date("m-d", strtotime($regs[6]));
$tmp_array['time'] = $regs[7];
$tmp_array['name'] = $regs[9];
$tmp_array['size'] = $regs[5];
$tmp_array['date'] = @date('m-d', strtotime($regs[6]));
$tmp_array['time'] = $regs[7];
$tmp_array['name'] = $regs[9];
}

// If we just want files, do not add a folder
Expand Down Expand Up @@ -1739,7 +1739,7 @@ protected function _verifyResponse($expected)
{
$this->_response .= fgets($this->_conn, 4096);
}
while (!preg_match("/^([0-9]{3})(-(.*" . CRLF . ")+\\1)? [^" . CRLF . "]+" . CRLF . "$/", $this->_response, $parts) && time() < $endTime);
while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime);

// Catch a timeout or bad response
if (!isset($parts[1]))
Expand Down Expand Up @@ -1813,7 +1813,7 @@ protected function _passive()
{
$this->_response .= fgets($this->_conn, 4096);
}
while (!preg_match("/^([0-9]{3})(-(.*" . CRLF . ")+\\1)? [^" . CRLF . "]+" . CRLF . "$/", $this->_response, $parts) && time() < $endTime);
while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime);

// Catch a timeout or bad response
if (!isset($parts[1]))
Expand Down Expand Up @@ -1917,7 +1917,7 @@ protected function _mode($mode)
{
if ($mode == FTP_BINARY)
{
if (!$this->_putCmd("TYPE I", 200))
if (!$this->_putCmd('TYPE I', 200))
{
JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_MODE_BINARY', $this->_response), JLog::WARNING, 'jerror');

Expand All @@ -1926,7 +1926,7 @@ protected function _mode($mode)
}
else
{
if (!$this->_putCmd("TYPE A", 200))
if (!$this->_putCmd('TYPE A', 200))
{
JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_MODE_ASCII', $this->_response), JLog::WARNING, 'jerror');

Expand Down
4 changes: 2 additions & 2 deletions libraries/joomla/client/ldap.php
Expand Up @@ -571,7 +571,7 @@ public static function ipToNetAddress($ip)
*/
public static function LDAPNetAddr($networkaddress)
{
$addr = "";
$addr = '';
$addrtype = (int) substr($networkaddress, 0, 1);

// Throw away bytes 0 and 1 which should be the addrtype and the "#" separator
Expand Down Expand Up @@ -612,7 +612,7 @@ public static function LDAPNetAddr($networkaddress)
if (($addrtype == 1) || ($addrtype == 8) || ($addrtype = 9))
{
// Dot separate IP addresses...
$addr .= ".";
$addr .= '.';
}
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/crypt/cipher/mcrypt.php
Expand Up @@ -120,7 +120,7 @@ public function generateKey(array $options = array())
$key->public = mcrypt_create_iv(mcrypt_get_iv_size($this->type, $this->mode), MCRYPT_DEV_URANDOM);

// Get the salt and password setup.
$salt = (isset($options['salt'])) ? $options['salt'] : substr(pack("h*", md5(JCrypt::genRandomBytes())), 0, 16);
$salt = (isset($options['salt'])) ? $options['salt'] : substr(pack('h*', md5(JCrypt::genRandomBytes())), 0, 16);

if (!isset($options['password']))
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver.php
Expand Up @@ -2263,7 +2263,7 @@ public function updateObject($table, &$object, $key, $nulls = false)
}

// Set the query and execute the update.
$this->setQuery(sprintf($statement, implode(",", $fields), implode(' AND ', $where)));
$this->setQuery(sprintf($statement, implode(',', $fields), implode(' AND ', $where)));

return $this->execute();
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/mysql.php
Expand Up @@ -109,7 +109,7 @@ public function connect()
// Turn MySQL profiling ON in debug mode:
if ($this->debug && $this->hasProfiling())
{
mysql_query("SET profiling = 1;", $this->connection);
mysql_query('SET profiling = 1;', $this->connection);
}
}

Expand Down
6 changes: 3 additions & 3 deletions libraries/joomla/database/driver/mysqli.php
Expand Up @@ -201,8 +201,8 @@ public function connect()
// Turn MySQL profiling ON in debug mode:
if ($this->debug && $this->hasProfiling())
{
mysqli_query($this->connection, "SET profiling_history_size = 100;");
mysqli_query($this->connection, "SET profiling = 1;");
mysqli_query($this->connection, 'SET profiling_history_size = 100;');
mysqli_query($this->connection, 'SET profiling = 1;');
}
}

Expand Down Expand Up @@ -444,7 +444,7 @@ public function getTableColumns($table, $typeOnly = true)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace("/[(0-9)]/", '', $field->Type);
$result[$field->Field] = preg_replace('/[(0-9)]/', '', $field->Type);
}
}
// If we want the whole field data object add that to the list.
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/pdo.php
Expand Up @@ -1060,7 +1060,7 @@ protected function getErrorNumber()
protected function getErrorMessage()
{
// The SQL Error Information
$errorInfo = implode(", ", $this->connection->errorInfo());
$errorInfo = implode(', ', $this->connection->errorInfo());

// Replace the Databaseprefix with `#__` if we are not in Debug
if (!$this->debug)
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver/pdomysql.php
Expand Up @@ -324,7 +324,7 @@ public function getTableColumns($table, $typeOnly = true)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace("/[(0-9)]/", '', $field->Type);
$result[$field->Field] = preg_replace('/[(0-9)]/', '', $field->Type);
}
}
// If we want the whole field data object add that to the list.
Expand Down

0 comments on commit 6ab2a6e

Please sign in to comment.