Skip to content

Commit

Permalink
Dev: Code inspection app/models missing @return & @throws (#822)
Browse files Browse the repository at this point in the history
Dev: Code inspection app/models missing @return & @throws
Dev: Code inspection app/models missing PHPDoc
  • Loading branch information
TonisOrmisson authored and LouisGac committed Oct 9, 2017
1 parent 8e04413 commit 0d069c9
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 29 deletions.
2 changes: 2 additions & 0 deletions application/models/Condition.php
Expand Up @@ -220,6 +220,7 @@ public function getAllCfieldnameWithDependenciesForOneSurvey($sid)

/**
* @param int $qid
* @param string $language
* @param Condition $scenarionr
* @return int
*/
Expand All @@ -246,6 +247,7 @@ public function getConditionCount($qid, $language, Condition $scenarionr)

/**
* @param int $qid
* @param $language
* @param Condition $scenarionr
* @return array
*/
Expand Down
1 change: 1 addition & 0 deletions application/models/LSActiveRecord.php
Expand Up @@ -59,6 +59,7 @@ public function behaviors()
* This method is mainly internally used by other AR query methods.
* @param CDbCriteria $criteria the query criteria
* @param boolean $all whether to return all data
* @param bool $asAR
* @return mixed the AR objects populated with the query result
* @since 1.1.7
*/
Expand Down
13 changes: 10 additions & 3 deletions application/models/Participant.php
Expand Up @@ -254,6 +254,7 @@ public function getAllExtraAttributes(){

/**
* Get options for a drop-down attribute
* @param string $attribute_id
* @return array
*/
public function getOptionsForAttribute($attribute_id) {
Expand Down Expand Up @@ -287,7 +288,7 @@ public function getAllUsedLanguagesWithRealName(){
/**
* @param string $attributeTextId E.g. ea_145
* @param mixed $attribute_id
* @return
* @return string
*/
public function getParticipantAttribute($attributeTextId, $attribute_id=false)
{
Expand Down Expand Up @@ -663,6 +664,7 @@ public function getParticipantsOwner($userid)
}

/**
* @param integer $userid
* @return int
*/
public function getParticipantsOwnerCount($userid)
Expand Down Expand Up @@ -742,8 +744,13 @@ public function getParticipantsCount($attid, $search = null, $userid = null) {
}

/**
* @param bool $count
* @param array $attid
* @param CDbCriteria $search
* @param integer $userid
* @param integer $page
* @param integer $limit
* @param null $order
* @return CDbCommand
*/
private function getParticipantsSelectCommand($count = false, $attid, $search = null, $userid = null, $page = null, $limit = null, $order = null)
Expand Down Expand Up @@ -798,7 +805,6 @@ private function getParticipantsSelectCommand($count = false, $attid, $search =
$data->setJoin($joinValue);

if (!empty($search)) {
/* @var $search CDbCriteria */
$aSearch = $search->toArray();
$aConditions[] = $aSearch['condition'];
$aParams = $aSearch['params'];
Expand Down Expand Up @@ -855,8 +861,9 @@ public function getSurveyCount($participant_id)
* references in the survey_links table (but not in matching tokens tables)
* and then all the participants attributes.
* @param string $rows Participants ID separated by comma
* @param bool $bFilter
* @return int number of deleted participants
**/
*/
public function deleteParticipants($rows, $bFilter=true)
{
// Converting the comma separated IDs to an array and assign chunks of 100 entries to have a reasonable query size
Expand Down
1 change: 1 addition & 0 deletions application/models/ParticipantAttributeName.php
Expand Up @@ -601,6 +601,7 @@ function saveAttribute($data)

/**
* @todo Doc
* @param array $data
*/
function saveAttributeLanguages($data)
{
Expand Down
17 changes: 9 additions & 8 deletions application/models/Permission.php
Expand Up @@ -437,6 +437,7 @@ public function setGlobalPermission($iNewUID,$sPermType,array $aPermissions=arra
}

/**
* @param integer $iUserID
* @param integer $iSurveyID
*/
public function giveAllSurveyPermissions($iUserID, $iSurveyID)
Expand Down Expand Up @@ -653,21 +654,21 @@ public function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD='read', $iU
}

/**
* Returns true if a user has permission to read/create/update a certain template
* @param $sPermission string Name of the permission - see function getGlobalPermissions
* @param $sCRUD string The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'
* @param $iUserID integer User ID - if not given the one of the current user is used
* @return bool True if user has the permission
*/
* Returns true if a user has permission to read/create/update a certain template
* @param string $sTemplateName
* @param $sCRUD string The permission detailsyou want to check on: 'create','read','update','delete','import' or 'export'
* @param $iUserID integer User ID - if not given the one of the current user is used
* @return bool True if user has the permission
*/
public function hasTemplatePermission($sTemplateName, $sCRUD='read', $iUserID=null)
{
return $this->hasPermission(0, 'global', 'templates', $sCRUD, $iUserID) || $this->hasPermission(0, 'template', $sTemplateName, $sCRUD, $iUserID);
}

/**
* function used to order Permission by language string
* @param aApermission array The first permission information
* @param aBpermission array The second permission information
* @param array $aApermission The first permission information
* @param array $aBpermission The second permission information
* @return integer
*/
private static function comparePermissionTitle($aApermission,$aBpermission)
Expand Down
2 changes: 2 additions & 0 deletions application/models/PluginDynamic.php
Expand Up @@ -35,9 +35,11 @@ protected function instantiate($attributes = null)
$model=new $class($this->tableName(), null);
return $model;
}

/**
* We have a custom implementation here since the parents' implementation
* does not create a new model for each table name.
* @param string $sTableName
* @return Plugin
*/
public static function model($sTableName = null)
Expand Down
8 changes: 5 additions & 3 deletions application/models/Question.php
Expand Up @@ -787,9 +787,11 @@ public function getOrderedAnswers($random=0, $alpha=0)
}

/**
* get subquestions fort the current question object in the right order
* @return self[]
*/
* get subquestions fort the current question object in the right order
* @param int $random
* @param string $exclude_all_others
* @return array
*/
public function getOrderedSubQuestions($random=0, $exclude_all_others='')
{
$criteria = (new CDbCriteria());
Expand Down
10 changes: 6 additions & 4 deletions application/models/Response.php
Expand Up @@ -31,11 +31,13 @@ public static function model($className = null) {
public static function create($surveyId, $scenario = 'insert') {
return parent::create($surveyId, $scenario);
}

/**
* Get all files related to this response and (optionally) question ID.
*
* @param integer $sQID The question ID - optional - Default 0
*/
* Get all files related to this response and (optionally) question ID.
*
* @param integer $sQID The question ID - optional - Default 0
* @return array
*/
public function getFiles($sQID=0)
{
$survey = Survey::model()->findByPk($this->dynamicId);
Expand Down
3 changes: 1 addition & 2 deletions application/models/Template.php
Expand Up @@ -200,8 +200,7 @@ public static function getTemplatePath($sTemplateName = "")
*
* @param string $sTemplateName the name of the template to load. The string come from the template selector in survey settings
* @param integer $iSurveyId the id of the survey.
* @param integer $iSurveyId the id of the survey.
* @param integer $bForceXML the id of the survey.
* @param boolean $bForceXML
* @return StdClass
*/
public static function getTemplateConfiguration($sTemplateName=null, $iSurveyId=null, $iSurveyGroupId=null, $bForceXML=false)
Expand Down
18 changes: 10 additions & 8 deletions application/models/TemplateConfig.php
Expand Up @@ -107,12 +107,13 @@ public function getTemplateURL()


/**
* Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates
*
* @param string $sFile the file to look for (must contain relative path, unless it's a view file)
* @param string $oRTemplate template from which the recurrence should start
* @return TemplateManifest
*/
* Get the template for a given file. It checks if a file exist in the current template or in one of its mother templates
*
* @param string $sFile the file to look for (must contain relative path, unless it's a view file)
* @param string $oRTemplate template from which the recurrence should start
* @return TemplateManifest
* @throws Exception
*/
public function getTemplateForFile($sFile, $oRTemplate)
{
while (!file_exists($oRTemplate->path.'/'.$sFile) && !file_exists($oRTemplate->viewPath.$sFile)){
Expand Down Expand Up @@ -190,8 +191,9 @@ protected function createTemplatePackage($oTemplate)
* It will check if css/js (relative to path), or view (view path)
* It will search for current template and mother templates
*
* @param string $sFile relative path to the file
* @param string $oTemplate the template where to look for (and its mother templates)
* @param string $sFile relative path to the file
* @param string $oTemplate the template where to look for (and its mother templates)
* @return bool|string
*/
protected function getFilePath($sFile, $oTemplate)
{
Expand Down
8 changes: 7 additions & 1 deletion application/models/TemplateConfiguration.php
Expand Up @@ -304,6 +304,7 @@ public function getPreview()
* Create a new entry in {{templates}} and {{template_configuration}} table using the template manifest
* @param string $sTemplateName the name of the template to import
* @return mixed true on success | exception
* @throws Exception
*/
public static function importManifest($sTemplateName)
{
Expand Down Expand Up @@ -373,6 +374,7 @@ public function checkTemplate()
*
* @param string $sTemplateName the name of the template to load. The string comes from the template selector in survey settings
* @param string $iSurveyId the id of the survey. If
* @param bool $bUseMagicInherit
* @return $this
*/
public function prepareTemplateRendering($sTemplateName='', $iSurveyId='', $bUseMagicInherit=true)
Expand All @@ -396,6 +398,8 @@ public function prepareTemplateRendering($sTemplateName='', $iSurveyId='', $bUse
*
* @param string $sFile the file to replace
* @param string $sType css|js
* @return bool|void
* @throws Exception
*/
public function addFileReplacement($sFile, $sType)
{
Expand Down Expand Up @@ -481,8 +485,10 @@ public function getOptionPage()
/**
* From a list of json files in db it will generate a PHP array ready to use by removeFileFromPackage()
*
* @var $jFiles string json
* @param TemplateConfiguration $oTemplate
* @param string $sType
* @return array
* @internal param string $jFiles json
*/
protected function getFilesToLoad($oTemplate, $sType)
{
Expand Down

0 comments on commit 0d069c9

Please sign in to comment.