1 | <?php |
||
2 | |||
3 | namespace Elgg\Friends\Collections; |
||
4 | |||
5 | /** |
||
6 | * Page handler for friends collections |
||
7 | */ |
||
8 | class Router { |
||
9 | |||
10 | /** |
||
11 | * Page handler for friends collections |
||
12 | * |
||
13 | * @param array $segments URL segments |
||
14 | * |
||
15 | * @return bool |
||
16 | * @access private |
||
17 | */ |
||
18 | public static function collectionsPageHandler($segments) { |
||
19 | |||
20 | elgg_push_context('friends'); |
||
21 | |||
22 | $page = array_shift($segments); |
||
23 | |||
24 | switch ($page) { |
||
25 | case 'add': |
||
26 | $username = array_shift($segments); |
||
27 | echo elgg_view_resource('friends/collections/add', [ |
||
28 | 'username' => $username, |
||
29 | ]); |
||
30 | return true; |
||
31 | |||
32 | case 'edit': |
||
33 | $collection_id = array_shift($segments); |
||
34 | echo elgg_view_resource('friends/collections/edit', [ |
||
35 | 'collection_id' => $collection_id, |
||
36 | ]); |
||
37 | return true; |
||
38 | |||
39 | case 'view' : |
||
40 | $collection_id = array_shift($segments); |
||
41 | echo elgg_view_resource('friends/collections/view', [ |
||
42 | 'collection_id' => $collection_id, |
||
43 | ]); |
||
44 | return true; |
||
45 | |||
46 | case 'owner': |
||
47 | default : |
||
48 | $username = array_shift($segments); |
||
49 | echo elgg_view_resource('friends/collections/owner', [ |
||
50 | 'username' => $username, |
||
51 | ]); |
||
52 | return true; |
||
53 | } |
||
54 | |||
55 | return false; |
||
0 ignored issues
–
show
|
|||
56 | } |
||
57 | } |
||
58 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.