1 | <?php |
||
19 | class AppController extends Controller { |
||
20 | |||
21 | /** |
||
22 | * @var Chat OCA\Chat\App\Chat; |
||
23 | */ |
||
24 | private $app; |
||
25 | |||
26 | /** |
||
27 | * @var \OCP\IConfig |
||
28 | */ |
||
29 | private $config; |
||
30 | |||
31 | /** |
||
32 | * @var \OCP\Contacts\IManager |
||
33 | */ |
||
34 | private $cm; |
||
35 | |||
36 | /** |
||
37 | * @var \OCA\Chat\OCH\Commands\Greet |
||
38 | */ |
||
39 | private $greet; |
||
40 | |||
41 | public function __construct( |
||
42 | $appName, |
||
43 | IRequest $request, |
||
44 | Chat $app, |
||
45 | IManager $cm, |
||
46 | IConfig $config, |
||
47 | Greet $greet |
||
48 | ){ |
||
49 | parent::__construct($appName, $request); |
||
50 | $this->app = $app; |
||
51 | $this->cm = $cm; |
||
52 | $this->config = $config; |
||
53 | $this->greet = $greet; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @NoCSRFRequired |
||
58 | * @NoAdminRequired |
||
59 | * @return TemplateResponse |
||
60 | */ |
||
61 | public function index() { |
||
62 | session_write_close(); |
||
63 | $this->greet->setRequestData(array( |
||
64 | "timestamp" => time(), |
||
65 | "user" => $this->app->getCurrentUser(), |
||
66 | )); |
||
67 | $sessionId = $this->greet->execute(); |
||
68 | $contacts = $this->app->getContacts(); |
||
69 | $backends = $this->app->getBackends(); |
||
70 | $backendsToArray = array(); |
||
71 | foreach($backends as $backend){ |
||
72 | $backendsToArray[$backend->getId()] = $backend->toArray(); |
||
73 | } |
||
74 | $initConvs = $this->app->getInitConvs(); |
||
75 | $params = array( |
||
76 | "initvar" => json_encode(array( |
||
77 | "contacts" => $contacts['contacts'], |
||
78 | "contactsList" => $contacts['contactsList'], |
||
79 | "contactsObj" => $contacts['contactsObj'], |
||
80 | "backends" => $backendsToArray, |
||
81 | "initConvs" => $initConvs, |
||
82 | "sessionId" => $sessionId['session_id'], |
||
83 | "avatars_enabled" => $this->config->getSystemValue('enable_avatars', true) |
||
84 | )), |
||
85 | ); |
||
86 | return new TemplateResponse($this->appName, 'main', $params); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @NoAdminRequired |
||
91 | * @return JSONResponse |
||
92 | */ |
||
93 | public function contacts(){ |
||
97 | |||
98 | /** |
||
99 | * @NoAdminRequired |
||
100 | * @return JSONResponse |
||
101 | */ |
||
102 | public function addContact($contacts){ |
||
123 | |||
124 | /** |
||
125 | * @NoAdminRequired |
||
126 | * @return JSONResponse |
||
127 | */ |
||
128 | public function removeContact($contacts){ |
||
136 | |||
137 | |||
138 | /** |
||
139 | * @NoAdminRequired |
||
140 | * @return JSONResponse |
||
141 | */ |
||
142 | public function initVar(){ |
||
167 | |||
168 | } |
||
169 |
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.