These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * Auto Groups extension for the phpBB Forum Software package. |
||
5 | * |
||
6 | * @copyright (c) 2014 phpBB Limited <https://www.phpbb.com> |
||
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | namespace phpbb\autogroups; |
||
12 | |||
13 | /** |
||
14 | * This ext class is optional and can be omitted if left empty. |
||
15 | * However you can add special (un)installation commands in the |
||
16 | * methods enable_step(), disable_step() and purge_step(). As it is, |
||
17 | * these methods are defined in \phpbb\extension\base, which this |
||
18 | * class extends, but you can overwrite them to give special |
||
19 | * instructions for those cases. |
||
20 | */ |
||
21 | class ext extends \phpbb\extension\base |
||
22 | { |
||
23 | /** |
||
24 | * Overwrite enable_step to enable Auto Groups notifications |
||
25 | * before any included migrations are installed. |
||
26 | * |
||
27 | * @param mixed $old_state State returned by previous call of this method |
||
28 | * @return mixed Returns false after last step, otherwise temporary state |
||
29 | * @access public |
||
30 | */ |
||
31 | public function enable_step($old_state) |
||
32 | { |
||
33 | switch ($old_state) |
||
34 | { |
||
35 | case '': // Empty means nothing has run yet |
||
0 ignored issues
–
show
|
|||
36 | |||
37 | // Enable Auto Groups notifications |
||
38 | return $this->notification_handler('enable', array( |
||
39 | 'phpbb.autogroups.notification.type.group_added', |
||
40 | 'phpbb.autogroups.notification.type.group_removed', |
||
41 | )); |
||
42 | |||
43 | break; |
||
44 | |||
45 | default: |
||
0 ignored issues
–
show
The default body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a default statement must start on the line immediately following the statement. switch ($expr) {
default:
doSomething(); //right
break;
}
switch ($expr) {
default:
doSomething(); //wrong
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
46 | |||
47 | // Run parent enable step method |
||
48 | return parent::enable_step($old_state); |
||
49 | |||
50 | break; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Overwrite disable_step to disable Auto Groups notifications |
||
56 | * before the extension is disabled. |
||
57 | * |
||
58 | * @param mixed $old_state State returned by previous call of this method |
||
59 | * @return mixed Returns false after last step, otherwise temporary state |
||
60 | * @access public |
||
61 | */ |
||
62 | public function disable_step($old_state) |
||
63 | { |
||
64 | switch ($old_state) |
||
65 | { |
||
66 | case '': // Empty means nothing has run yet |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
67 | |||
68 | // Disable Auto Groups notifications |
||
69 | return $this->notification_handler('disable', array( |
||
70 | 'phpbb.autogroups.notification.type.group_added', |
||
71 | 'phpbb.autogroups.notification.type.group_removed', |
||
72 | )); |
||
73 | |||
74 | break; |
||
75 | |||
76 | default: |
||
0 ignored issues
–
show
The default body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a default statement must start on the line immediately following the statement. switch ($expr) {
default:
doSomething(); //right
break;
}
switch ($expr) {
default:
doSomething(); //wrong
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
77 | |||
78 | // Run parent disable step method |
||
79 | return parent::disable_step($old_state); |
||
80 | |||
81 | break; |
||
82 | } |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Overwrite purge_step to purge Auto Groups notifications before |
||
87 | * any included and installed migrations are reverted. |
||
88 | * |
||
89 | * @param mixed $old_state State returned by previous call of this method |
||
90 | * @return mixed Returns false after last step, otherwise temporary state |
||
91 | * @access public |
||
92 | */ |
||
93 | public function purge_step($old_state) |
||
94 | { |
||
95 | switch ($old_state) |
||
96 | { |
||
97 | case '': // Empty means nothing has run yet |
||
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
98 | |||
99 | // Purge Auto Groups notifications |
||
100 | return $this->notification_handler('purge', array( |
||
101 | 'phpbb.autogroups.notification.type.group_added', |
||
102 | 'phpbb.autogroups.notification.type.group_removed', |
||
103 | )); |
||
104 | |||
105 | break; |
||
106 | |||
107 | default: |
||
0 ignored issues
–
show
The default body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a default statement must start on the line immediately following the statement. switch ($expr) {
default:
doSomething(); //right
break;
}
switch ($expr) {
default:
doSomething(); //wrong
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
108 | |||
109 | // Run parent purge step method |
||
110 | return parent::purge_step($old_state); |
||
111 | |||
112 | break; |
||
113 | } |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Notification handler to call notification enable/disable/purge steps |
||
118 | * |
||
119 | * @param string $step The step (enable, disable, purge) |
||
120 | * @param array $notification_types The notification type names |
||
121 | * @return string Return notifications as temporary state |
||
122 | * @access protected |
||
123 | */ |
||
124 | protected function notification_handler($step, $notification_types) |
||
125 | { |
||
126 | $phpbb_notifications = $this->container->get('notification_manager'); |
||
127 | |||
128 | foreach ($notification_types as $notification_type) |
||
129 | { |
||
130 | $phpbb_notifications->{$step . '_notifications'}($notification_type); |
||
131 | } |
||
132 | |||
133 | return 'notifications'; |
||
134 | } |
||
135 | } |
||
136 |
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.