for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* _ __ __ _____ _____ ___ ____ _____
* | | / // // ___//_ _// || __||_ _|
* | |/ // /(__ ) / / / /| || | | |
* |___//_//____/ /_/ /_/ |_||_| |_|
* @link https://vistart.me/
* @copyright Copyright (c) 2016 - 2017 vistart
* @license https://vistart.me/license/
*/
namespace rhosocial\organization\web\organization\controllers\my;
use rhosocial\organization\Organization;
use rhosocial\user\User;
use Yii;
use yii\base\Action;
* @version 1.0
* @author vistart <[email protected]>
class IndexAction extends Action
{
const ORG_ONLY = '1';
const ORG_ALL = '0';
*
* @param string $orgOnly
* @return string rendering result.
public function run($orgOnly = self::ORG_ALL)
$user = Yii::$app->user->identity;
/* @var $user User */
$noInitOrg = $user->getNoInitOrganization();
/* @var $noInitOrg Organization */
$searchModel = $noInitOrg->getSearchModel();
$dataProvider = $searchModel->search(Yii::$app->request->post());
$query = ($orgOnly == self::ORG_ONLY) ? $user->getAtOrganizationsOnly() : $user->getAtOrganizations();
$query
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
return $this->controller->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'user' => $user,
'orgOnly' => $orgOnly == self::ORG_ONLY,
]);
}
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.