Skip to content

Commit

Permalink
Dev Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scrutinizer-auto-fixer authored and c-schmitz committed Dec 11, 2017
1 parent e4fa224 commit 55b552c
Show file tree
Hide file tree
Showing 20 changed files with 229 additions and 228 deletions.
2 changes: 1 addition & 1 deletion application/commands/FlushAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function run($aArguments)
{
$sCurrentDir = dirname(__FILE__);
$tmpFolder = realpath($sCurrentDir.'/../../tmp/');
if ($tmpFolder===false)
if ($tmpFolder === false)
{
echo 'Tmp folder '.$sCurrentDir.'/../../tmp/ not found';
return;
Expand Down
2 changes: 1 addition & 1 deletion application/commands/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$app = Yii::createApplication('ConsoleApplication', $config);
define('APPPATH', Yii::app()->getBasePath().DIRECTORY_SEPARATOR);
$app->commandRunner->addCommands(YII_PATH.'/cli/commands');
$env = (string)@getenv('YII_CONSOLE_COMMANDS');
$env = (string) @getenv('YII_CONSOLE_COMMANDS');
if (!empty($env)) {
$app->commandRunner->addCommands($env);
}
Expand Down
16 changes: 8 additions & 8 deletions application/controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function stepWelcome()
private function stepLicense()
{
// $aData array contain all the information required by view.
$aData =[];
$aData = [];
$aData['title'] = gT('License');
$aData['descp'] = gT('GNU General Public License:');
$aData['classesForStep'] = array('off', 'on', 'off', 'off', 'off', 'off');
Expand All @@ -180,7 +180,7 @@ private function stepLicense()
public function stepViewLicense()
{
header('Content-Type: text/plain; charset=UTF-8');
readfile(dirname((string)BASEPATH).'/docs/license.txt');
readfile(dirname((string) BASEPATH).'/docs/license.txt');
exit;
}

Expand Down Expand Up @@ -238,7 +238,7 @@ private function stepDatabaseConfiguration()
}

if (!is_null(Yii::app()->request->getPost('InstallerConfigForm'))) {
$oModel->setAttributes(Yii::app()->request->getPost('InstallerConfigForm'),false);
$oModel->setAttributes(Yii::app()->request->getPost('InstallerConfigForm'), false);

//run validation, if it fails, load the view again else proceed to next step.
if ($oModel->validate()) {
Expand Down Expand Up @@ -319,8 +319,8 @@ private function stepDatabaseConfiguration()
if (version_compare($sMySQLVersion, '4.1', '<')) {
die("<br />Error: You need at least MySQL version 4.1 to run LimeSurvey. Your version: ".$sMySQLVersion);
}
/** @scrutinizer ignore-unhandled */ @$this->connection->createCommand("SET CHARACTER SET 'utf8mb4'")->execute();
/** @scrutinizer ignore-unhandled */ @$this->connection->createCommand("SET NAMES 'utf8mb4'")->execute();
/** @scrutinizer ignore-unhandled */ @$this->connection->createCommand("SET CHARACTER SET 'utf8mb4'")->execute();
/** @scrutinizer ignore-unhandled */ @$this->connection->createCommand("SET NAMES 'utf8mb4'")->execute();
}

// Setting date format for mssql driver. It seems if you don't do that the in- and output format could be different
Expand Down Expand Up @@ -550,7 +550,7 @@ public function stepPopulateDb()
* Optional settings screen
*/
private function stepOptionalConfiguration()
{
{
$aData = [];
$aData['confirmation'] = Yii::app()->session['optconfig_message'];
$aData['title'] = gT("Optional settings");
Expand All @@ -562,7 +562,7 @@ private function stepOptionalConfiguration()
// Backup the default, needed only for $sDefaultAdminPassword
$sDefaultAdminPassword = $model->adminLoginPwd;
if (!is_null(Yii::app()->request->getPost('InstallerConfigForm'))) {
$model->setAttributes(Yii::app()->request->getPost('InstallerConfigForm'),false);
$model->setAttributes(Yii::app()->request->getPost('InstallerConfigForm'), false);

//run validation, if it fails, load the view again else proceed to next step.
if ($model->validate()) {
Expand Down Expand Up @@ -704,7 +704,7 @@ function check_HTML_image($result)
function is_writable_recursive($sDirectory)
{
$sFolder = opendir($sDirectory);
if ($sFolder===false) {
if ($sFolder === false) {
return false; // Dir does not exist
}
while ($sFile = readdir($sFolder)) {
Expand Down
12 changes: 6 additions & 6 deletions application/controllers/admin/checkintegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ protected function _checkintegrity()
$sSurveyIDs = Yii::app()->db->createCommand('select sid from {{surveys}}')->queryColumn();

foreach ($aResult->readAll() as $aRow) {
$sTableName = (string)substr(reset($aRow), strlen($sDBPrefix));
$sTableName = (string) substr(reset($aRow), strlen($sDBPrefix));
if ($sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') {
continue;
}
$aTableName = explode('_', $sTableName);
if (isset($aTableName[1]) && ctype_digit($aTableName[1])) {
$iSurveyID = $aTableName[1];
if (!in_array($iSurveyID, $sSurveyIDs)) {
$sDate = (string)date('YmdHis').rand(1, 1000);
$sDate = (string) date('YmdHis').rand(1, 1000);
$sOldTable = "survey_{$iSurveyID}";
$sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
try {
Expand All @@ -435,10 +435,10 @@ protected function _checkintegrity()
/*** Check for active token tables with missing survey entry ***/
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\_%'));
foreach ($aResult->readAll() as $aRow) {
$sTableName = (string)substr(reset($aRow), strlen($sDBPrefix));
$iSurveyID = (integer)substr($sTableName, strpos($sTableName, '_') + 1);
$sTableName = (string) substr(reset($aRow), strlen($sDBPrefix));
$iSurveyID = (integer) substr($sTableName, strpos($sTableName, '_') + 1);
if (!in_array($iSurveyID, $sSurveyIDs)) {
$sDate = (string)date('YmdHis').rand(1, 1000);
$sDate = (string) date('YmdHis').rand(1, 1000);
$sOldTable = "tokens_{$iSurveyID}";
$sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
try {
Expand Down Expand Up @@ -726,7 +726,7 @@ protected function _checkintegrity()
$iDay = (int) substr($sDateTime, 6, 2);
$iHour = (int) substr($sDateTime, 8, 2);
$iMinute = (int) substr($sDateTime, 10, 2);
$sDate = (string) date('Y-m-d H:i:s', (int)mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));
$sDate = (string) date('Y-m-d H:i:s', (int) mktime($iHour, $iMinute, 0, $iMonth, $iDay, $iYear));

$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
Yii::app()->loadLibrary('Date_Time_Converter');
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/conditionsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function index($subaction, $iSurveyID = null, $gid = null, $qid = null)
if (isset($postquestionscount) && $postquestionscount > 0) {
//Build the array used for the questionNav and copyTo select boxes
foreach ($postrows as $pr) {
$pquestions[] = array("text" => $pr['title'].": ".(string)substr(strip_tags($pr['question']), 0, 80),
$pquestions[] = array("text" => $pr['title'].": ".(string) substr(strip_tags($pr['question']), 0, 80),
"fieldname" => $pr['sid']."X".$pr['gid']."X".$pr['qid']);
}
}
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ class database extends Survey_Common_Action
public function index()
{
$sAction = Yii::app()->request->getPost('action');
$iSurveyID = (isset($_POST['sid'])) ? (int)$_POST['sid'] : (int)returnGlobal('sid');
$iSurveyID = (isset($_POST['sid'])) ? (int) $_POST['sid'] : (int) returnGlobal('sid');

$this->iQuestionGroupID = (int)returnGlobal('gid');
$this->iQuestionID = (int)returnGlobal('qid');
$this->iQuestionGroupID = (int) returnGlobal('gid');
$this->iQuestionID = (int) returnGlobal('qid');

$this->oFixCKeditor = new LSYii_Validators;
$this->oFixCKeditor->fixCKeditor = true;
Expand Down Expand Up @@ -1307,7 +1307,7 @@ private function actionInsertCopyQuestion($iSurveyID)
}
}
if (returnGlobal('copyanswers') == 1) {
$r1 = Answer::model()->getAnswers((int)returnGlobal('oldqid'));
$r1 = Answer::model()->getAnswers((int) returnGlobal('oldqid'));
$aAnswerOptions = $r1->readAll();
foreach ($aAnswerOptions as $qr1) {
Answer::model()->insertRecords(array(
Expand Down
51 changes: 25 additions & 26 deletions application/controllers/admin/dataentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ private function _handleFileUpload($iSurveyId, $aData)
}

/**
* put your comment there...
*
* @param mixed $aData
*/
* put your comment there...
*
* @param mixed $aData
*/
private function _moveUploadedFile($aData)
{
$sFullFilePath = Yii::app()->getConfig('tempdir')."/".randomChars(20);
Expand Down Expand Up @@ -334,7 +334,7 @@ public function import($surveyid)


Yii::app()->session['flashmessage'] = sprintf(gT("%s old response(s) were successfully imported."), $imported);
$sOldTimingsTable = (string)substr(substr($sourceTable->tableName(), 0, (string)strrpos($sourceTable->tableName(), '_')).'_timings'.(string)substr($sourceTable->tableName(), (string)strrpos($sourceTable->tableName(), '_')), strlen(Yii::app()->db->tablePrefix));
$sOldTimingsTable = (string) substr(substr($sourceTable->tableName(), 0, (string) strrpos($sourceTable->tableName(), '_')).'_timings'.(string) substr($sourceTable->tableName(), (string) strrpos($sourceTable->tableName(), '_')), strlen(Yii::app()->db->tablePrefix));
$sNewTimingsTable = "survey_{$surveyid}_timings";

if (isset($_POST['timings']) && $_POST['timings'] == 1 && tableExists($sOldTimingsTable) && tableExists($sNewTimingsTable)) {
Expand Down Expand Up @@ -375,7 +375,7 @@ protected function tableList($tables)

foreach ($tables as $table) {
$count = PluginDynamic::model($table)->count();
$timestamp = date_format(new DateTime((string)substr($table, -14)), 'Y-m-d H:i:s');
$timestamp = date_format(new DateTime((string) substr($table, -14)), 'Y-m-d H:i:s');
$list[$table] = "$timestamp ($count responses)";
}
return $list;
Expand Down Expand Up @@ -505,7 +505,7 @@ public function editdata($subaction, $id, $surveyid)
}

$svresult = SavedControl::model()->findAllByAttributes(array('scid'=>$saver['scid']));
$responses=[];
$responses = [];
foreach ($svresult as $svrow) {
$responses[$svrow['fieldname']] = $svrow['value'];
} // while
Expand All @@ -521,7 +521,7 @@ public function editdata($subaction, $id, $surveyid)
}

$results1['id'] = "";
$results1['datestamp'] = dateShift((string)date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$results1['datestamp'] = dateShift((string) date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$results1['ipaddr'] = $saver['ip'];
$results[] = $results1;
}
Expand Down Expand Up @@ -567,7 +567,7 @@ public function editdata($subaction, $id, $surveyid)
$aDataentryoutput .= "</td>\n"
."<td>\n";
//$aDataentryoutput .= "\t-={$fname[3]}=-"; //Debugging info
$qidattributes=[];
$qidattributes = [];
if (isset($fname['qid']) && isset($fname['type'])) {
$qidattributes = QuestionAttribute::model()->getQuestionAttributes($fname['qid']);
}
Expand All @@ -578,7 +578,7 @@ public function editdata($subaction, $id, $surveyid)
// In case of anonymized responses survey with no datestamp
// then the the answer submitdate gets a conventional timestamp
// 1st Jan 1980
$mysubmitdate = date("Y-m-d H:i", (int)mktime(0, 0, 0, 1, 1, 1980)); // Note that the completed field only supports 17 chars (so no seconds!)
$mysubmitdate = date("Y-m-d H:i", (int) mktime(0, 0, 0, 1, 1, 1980)); // Note that the completed field only supports 17 chars (so no seconds!)
} else {
$mysubmitdate = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust')); // Note that the completed field only supports 17 chars (so no seconds!)
}
Expand Down Expand Up @@ -738,7 +738,7 @@ public function editdata($subaction, $id, $surveyid)

$oquery = "SELECT other FROM {{questions}} WHERE qid={$fname['qid']} AND {{questions}}.language = '{$sDataEntryLanguage}'";
$oresult = dbExecuteAssoc($oquery) or safeDie("Couldn't get other for list question<br />".$oquery."<br />");
$fother='';
$fother = '';
foreach ($oresult->readAll() as $orow) {
$fother = $orow['other'];
}
Expand Down Expand Up @@ -1292,11 +1292,10 @@ public function update()
$subaction = Yii::app()->request->getPost('subaction');
if (isset($_REQUEST['surveyid'])) {
$surveyid = $_REQUEST['surveyid'];
}
else {
} else {
$surveyid = $_REQUEST['sid'];
}
$surveyid = (int)($surveyid);
$surveyid = (int) ($surveyid);
$survey = Survey::model()->findByPk($surveyid);

$id = Yii::app()->request->getPost('id');
Expand Down Expand Up @@ -1392,11 +1391,11 @@ public function update()
public function insert()
{
$subaction = Yii::app()->request->getPost('subaction');
$surveyid = (int)Yii::app()->request->getPost('sid');
$surveyid = (int) Yii::app()->request->getPost('sid');

$lang = isset($_POST['lang']) ? Yii::app()->request->getPost('lang') : null;
$survey = Survey::model()->findByPk($surveyid);
$password='';
$password = '';
$aData = array(
'surveyid' => $surveyid,
'lang' => $lang
Expand All @@ -1408,7 +1407,7 @@ public function insert()
$errormsg = "";

Yii::app()->loadHelper("database");
$aViewUrls=[];
$aViewUrls = [];
$aViewUrls['display']['menu_bars']['browse'] = gT("Data entry");

$aDataentrymsgs = array();
Expand Down Expand Up @@ -1507,12 +1506,12 @@ public function insert()
if ($survey->isDateStamp) { $_POST['startdate'] = $_POST['datestamp']; }
if (isset($_POST['closerecord'])) {
if ($survey->isDateStamp) {
$_POST['submitdate'] = dateShift((string)date("Y-m-d H:i"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$_POST['submitdate'] = dateShift((string) date("Y-m-d H:i"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
} else {
$_POST['submitdate'] = date("Y-m-d H:i", (int)mktime(0, 0, 0, 1, 1, 1980));
$_POST['submitdate'] = date("Y-m-d H:i", (int) mktime(0, 0, 0, 1, 1, 1980));
}
}
$phparray=[];
$phparray = [];
foreach ($fieldmap as $irow) {
$fieldname = $irow['fieldname'];
if (isset($_POST[$fieldname])) {
Expand Down Expand Up @@ -1624,7 +1623,7 @@ public function insert()
$columns = array("sid", "srid", "identifier", "access_code", "email", "ip",
"refurl", 'saved_thisstep', "status", "saved_date");
$values = array("'".$surveyid."'", "'".$srid."'", "'".$saver['identifier']."'", "'".$password."'", "'".$saver['email']."'", "'".$aUserData['ip_address']."'",
"'".(string)getenv("HTTP_REFERER")."'", 0, "'"."S"."'", "'".dateShift((string)date("Y-m-d H:i:s"), "Y-m-d H:i", "'".Yii::app()->getConfig('timeadjust'))."'");
"'".(string) getenv("HTTP_REFERER")."'", 0, "'"."S"."'", "'".dateShift((string) date("Y-m-d H:i:s"), "Y-m-d H:i", "'".Yii::app()->getConfig('timeadjust'))."'");

$SQL = "INSERT INTO $saved_control_table
(".implode(',', $columns).")
Expand Down Expand Up @@ -1746,7 +1745,7 @@ public function view($surveyid)
LimeExpressionManager::StartSurvey($surveyid, 'survey', null, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
LimeExpressionManager::NavigateForwards();

$aData=[];
$aData = [];
$aData['survey'] = $survey;
$aData['thissurvey'] = $thissurvey;
$aData['langlistbox'] = $langlistbox;
Expand Down Expand Up @@ -1905,7 +1904,7 @@ public function view($surveyid)

$oquery = "SELECT other FROM {{questions}} WHERE qid={$deqrow['qid']} AND language='{$sDataEntryLanguage}'";
$oresult = dbExecuteAssoc($oquery) or safeDie("Couldn't get other for list question<br />");
$fother='';
$fother = '';
foreach ($oresult->readAll() as $orow) {
$fother = $orow['other'];
}
Expand Down Expand Up @@ -2073,11 +2072,11 @@ public function view($surveyid)
case ";": //ARRAY (Multi Flexi)

$lquery = "SELECT * FROM {{questions}} WHERE scale_id=1 and parent_qid={$deqrow['qid']} and language='{$sDataEntryLanguage}' ORDER BY question_order";
$lresult = dbExecuteAssoc($lquery) or safeDie ("Couldn't get labels, Type \":\"<br />$lquery<br />");
$lresult = dbExecuteAssoc($lquery) or safeDie("Couldn't get labels, Type \":\"<br />$lquery<br />");
$cdata['lresult'] = $lresult->readAll();

$meaquery = "SELECT * FROM {{questions}} WHERE scale_id=0 and parent_qid={$deqrow['qid']} and language='{$sDataEntryLanguage}' ORDER BY question_order";
$mearesult = dbExecuteAssoc($meaquery) or safeDie ("Couldn't get answers, Type \":\"<br />$meaquery<br />");
$mearesult = dbExecuteAssoc($meaquery) or safeDie("Couldn't get answers, Type \":\"<br />$meaquery<br />");

$cdata['mearesult'] = $mearesult->readAll();

Expand Down Expand Up @@ -2171,7 +2170,7 @@ private function _array_filter_help($qidattributes, $surveyprintlang, $surveyid)
protected function _renderWrappedTemplate($sAction = 'dataentry', $aViewUrls = array(), $aData = array())
{
if (!isset($aData['display']['menu_bars']['browse'])) {
$iSurveyId=0;
$iSurveyId = 0;
if (isset($aData['surveyid'])) {
$iSurveyId = $aData['surveyid'];
}
Expand Down

0 comments on commit 55b552c

Please sign in to comment.