Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Increase readability #741

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changing the constructs intval($var) and floatval($var) to (int)$var
and (float)$var, it's faster and more future proof
  • Loading branch information
rotelok committed Jun 16, 2018
commit 2caa32a0f0af3688fba861474560f1f1bbcbe47c
2 changes: 1 addition & 1 deletion lib/file-control-xhr.php
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function rrmdir($dir) {
// ==========================

if (!isset($ftpSite) && !$error && $_GET['action']=="getRemoteFile") {
$lineNumber = max(isset($_REQUEST['lineNumber'])?intval($_REQUEST['lineNumber']):1, 1);
$lineNumber = max(isset($_REQUEST['lineNumber'])? (int)$_REQUEST['lineNumber'] :1, 1);
if ($remoteFile = toUTF8noBOM(getData($file,'curl'),true)) {
// replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
$remoteFile = str_replace("\r\n", $ICEcoder["lineEnding"], $remoteFile);
Expand Down
2 changes: 1 addition & 1 deletion lib/file-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
// If we're due to open a file...
if ($_GET['action']=="load") {
echo 'action="load";';
$lineNumber = max(isset($_REQUEST['lineNumber'])?intval($_REQUEST['lineNumber']):1, 1);
$lineNumber = max(isset($_REQUEST['lineNumber'])? (int)$_REQUEST['lineNumber'] :1, 1);
// Check this file isn't on the banned list at all
$canOpen = true;
for ($i=0;$i<count($_SESSION['bannedFiles']);$i++) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

// Redo the arrays using the form data
for ($i=0; $i<count($oldPlugins); $i++) {
$timer = intval($_POST['timer'.$i]);
$timer = (int)$_POST['timer' . $i];
if ($timer == 0) {
$timer = "";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// If it's a dir, get the dir size
if (is_dir($fileName)) {
$io = popen('/usr/bin/du -sb '.$fileName, 'r');
$bytes = intval(fgets($io,80));
$bytes = (int)fgets($io, 80);
pclose($io);
}
// Change into kilobytes
Expand Down
6 changes: 3 additions & 3 deletions lib/settings-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function strClean($var) {

// returns a number, whole or decimal or null
function numClean($var) {
return is_numeric($var) ? floatval($var) : false;
return is_numeric($var) ? (float)$var : false;
}

// Clean XSS attempts using different contexts
Expand Down Expand Up @@ -287,8 +287,8 @@ function getVersionsCount($fileLoc,$fileName) {
if (strpos($versionsInfo[$j],$fileRef) === 0) {
// We have a match, so split on the " = " and we can grab number as 2nd part
$lineInfo = explode(" = ",$versionsInfo[$j]);
$count += intval($lineInfo[1]);
$dateCounts[$backupDateDirs[$i]] = intval($lineInfo[1]);
$count += (int)$lineInfo[1];
$dateCounts[$backupDateDirs[$i]] = (int)$lineInfo[1];
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/settings-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$ICEcoder["updateDiffOnSave"] = isset($_POST['updateDiffOnSave']) && $_POST['updateDiffOnSave'] ? "true" : "false";
$ICEcoder["languageUser"] = strClean($_POST['languageUser']);
$ICEcoder["backupsKept"] = isset($_POST['backupsKept']) && $_POST['backupsKept'] ? "true" : "false";
$ICEcoder["backupsDays"] = intval($_POST['backupsDays']);
$ICEcoder["backupsDays"] = (int)$_POST['backupsDays'];
$ICEcoder["deleteToTmp"] = isset($_POST['deleteToTmp']) && $_POST['deleteToTmp'] ? "true" : "false";
$ICEcoder["findFilesExclude"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['findFilesExclude']))).'")';
$ICEcoder["codeAssist"] = isset($_POST['codeAssist']) && $_POST['codeAssist'] ? "true" : "false";
Expand All @@ -32,7 +32,7 @@
$ICEcoder["bannedFiles"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['bannedFiles']))).'")';
$ICEcoder["bannedPaths"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['bannedPaths']))).'")';
$ICEcoder["allowedIPs"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['allowedIPs']))).'")';
$ICEcoder["autoLogoutMins"] = intval($_POST['autoLogoutMins']);
$ICEcoder["autoLogoutMins"] = (int)$_POST['autoLogoutMins'];
$ICEcoder["theme"] = strClean($_POST['theme']);
$ICEcoder["fontSize"] = strClean($_POST['fontSize']);
$ICEcoder["lineWrapping"] = strClean($_POST['lineWrapping']);
Expand All @@ -43,11 +43,11 @@
$ICEcoder["autoCloseBrackets"] = strClean($_POST['autoCloseBrackets']);
$ICEcoder["indentWithTabs"] = strClean($_POST['indentWithTabs']);
$ICEcoder["indentAuto"] = strClean($_POST['indentAuto']);
$ICEcoder["indentSize"] = intval($_POST['indentSize']);
$ICEcoder["indentSize"] = (int)$_POST['indentSize'];
$ICEcoder["pluginPanelAligned"] = strClean($_POST['pluginPanelAligned']);
$ICEcoder["bugFilePaths"] = 'array("'.str_replace(',','","',str_replace(" ","",strClean($_POST['bugFilePaths']))).'")';
$ICEcoder["bugFileCheckTimer"] = intval($_POST['bugFileCheckTimer']) >= 0 ? intval($_POST['bugFileCheckTimer']) : 0;
$ICEcoder["bugFileMaxLines"] = intval($_POST['bugFileMaxLines']);
$ICEcoder["bugFileCheckTimer"] = (int)$_POST['bugFileCheckTimer'] >= 0 ? (int)$_POST['bugFileCheckTimer'] : 0;
$ICEcoder["bugFileMaxLines"] = (int)$_POST['bugFileMaxLines'];
$ICEcoder["githubAuthToken"] = strClean($_POST['githubAuthToken']);

$settingsArray = array("root","checkUpdates","openLastFiles","updateDiffOnSave","languageUser","backupsKept","backupsDays","deleteToTmp","findFilesExclude","codeAssist","visibleTabs","lockedNav","tagWrapperCommand","autoComplete","password","bannedFiles","bannedPaths","allowedIPs","autoLogoutMins","theme","fontSize","lineWrapping","lineNumbers","showTrailingSpace","matchBrackets","autoCloseTags","autoCloseBrackets","indentWithTabs","indentAuto","indentSize","pluginPanelAligned","bugFilePaths","bugFileCheckTimer","bugFileMaxLines","githubAuthToken");
Expand Down
4 changes: 2 additions & 2 deletions lib/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
clearstatcache();
$configfilemtime = filemtime(__DIR__."/"."config___settings.php");
// Make it a number (avoids null, undefined etc)
$configfilemtime = intval($configfilemtime);
$configfilemtime = (int)$configfilemtime;
// Set it to the epoch time now if we don't have a real value
if ($configfilemtime == 0) {
$configfilemtime = time();
Expand Down Expand Up @@ -114,7 +114,7 @@
$tRemaining = ($ICEcoder['configCreateDate']+$tPeriod)-time();
if ($tRemaining > $tPeriod || $ICEcoder['configCreateDate'] == 0) {$tRemaining = $tPeriod;}
$tRemainingPerc = number_format($tRemaining/$tPeriod,2);
$tDaysRemaining = intval($tRemaining/(60*60*24));
$tDaysRemaining = (int)($tRemaining / (60 * 60 * 24));

// Update this config file?
include __DIR__."/settings-update.php";
Expand Down