Completed
Branch master (cfcf82)
by Nick
04:51
created
classes/People.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@
 block discarded – undo
30 30
         $this->db = new \ParlDB();
31 31
     }
32 32
 
33
+    /**
34
+     * @param User $user
35
+     */
33 36
     protected function getRegionalReps($user) {
34 37
         return $user->getRegionalReps($this->reg_cons_type, $this->house);
35 38
     }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace MySociety\TheyWorkForYou;
9 9
 
10
-include_once( dirname(__FILE__) . '/../www/includes/easyparliament/people.php' );
10
+include_once(dirname(__FILE__) . '/../www/includes/easyparliament/people.php');
11 11
 
12 12
 /**
13 13
  * People
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $data = $this->display($this->type, $args, 'none');
39 39
 
40 40
         $user = new User();
41
-        if ( $reps = $this->getRegionalReps($user) ) {
41
+        if ($reps = $this->getRegionalReps($user)) {
42 42
             $data['reps'] = $reps;
43 43
         }
44 44
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $args['all'] = true;
71 71
         }
72 72
 
73
-        if ( $this->type == 'peers' ) {
73
+        if ($this->type == 'peers') {
74 74
             $args['order'] = 'name';
75 75
         }
76 76
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 
137 137
     private function addImagesToData($data) {
138 138
         $new_data = array();
139
-        foreach ( $data as $pid => $details ) {
140
-            list($image, ) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
139
+        foreach ($data as $pid => $details) {
140
+            list($image,) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
141 141
             $details['image'] = $image;
142 142
             $new_data[$pid] = $details;
143 143
         }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
 
155 155
         $urls['plain'] = $URL->generate();
156 156
 
157
-        $URL->insert(array( 'o' => 'n'));
157
+        $URL->insert(array('o' => 'n'));
158 158
         $urls['by_name'] = $URL->generate();
159 159
 
160
-        $URL->insert(array( 'o' => 'l'));
160
+        $URL->insert(array('o' => 'l'));
161 161
         $urls['by_last'] = $URL->generate();
162 162
 
163
-        $URL->insert(array( 'o' => 'f'));
163
+        $URL->insert(array('o' => 'f'));
164 164
         $urls['by_first'] = $URL->generate();
165 165
 
166
-        $URL->insert(array( 'o' => 'p'));
166
+        $URL->insert(array('o' => 'p'));
167 167
         $urls['by_party'] = $URL->generate();
168 168
 
169
-        $URL->insert(array( 'f' => 'csv'));
170
-        $URL->remove(array( 'o'));
171
-        if ( $date = get_http_var('date') ) {
169
+        $URL->insert(array('f' => 'csv'));
170
+        $URL->remove(array('o'));
171
+        if ($date = get_http_var('date')) {
172 172
             $URL->insert(array('date' => $date));
173 173
         }
174 174
         $urls['by_csv'] = $URL->generate();
Please login to merge, or discard this patch.
classes/Renderer/Header.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -110,6 +110,9 @@
 block discarded – undo
110 110
         }
111 111
     }
112 112
 
113
+    /**
114
+     * @param string $linktype
115
+     */
113 116
     private function generate_next_prev_link($nextprev, $linktype) {
114 117
         $link = null;
115 118
         if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
     private function get_page_url() {
50 50
         $protocol = 'https://';
51 51
         if (DEVSITE) {
52
-          $protocol = 'http://';
52
+            $protocol = 'http://';
53 53
         }
54 54
         $url = $protocol . DOMAIN;
55 55
         if (array_key_exists('REQUEST_URI', $_SERVER)) {
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -81,7 +81,9 @@  discard block
 block discarded – undo
81 81
 
82 82
             $parent_page = $DATA->page_metadata($this_page, 'parent');
83 83
             if ($parent_title = $DATA->page_metadata($parent_page, 'title')) {
84
-                if ($this->data['page_title']) $this->data['page_title'] .= ': ';
84
+                if ($this->data['page_title']) {
85
+                    $this->data['page_title'] .= ': ';
86
+                }
85 87
                 $this->data['page_title'] .= $parent_title;
86 88
             }
87 89
 
@@ -103,7 +105,9 @@  discard block
 block discarded – undo
103 105
         // Meta keywords
104 106
         if (!$this->data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords")) {
105 107
             $this->data['meta_keywords'] = $this->keywords_title;
106
-            if ($this->data['meta_keywords']) $this->data['meta_keywords'] .= ', ';
108
+            if ($this->data['meta_keywords']) {
109
+                $this->data['meta_keywords'] .= ', ';
110
+            }
107 111
             $this->data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs';
108 112
         }
109 113
 
@@ -204,7 +208,9 @@  discard block
 block discarded – undo
204 208
             $p = $parent;
205 209
             while ($p) {
206 210
                 $p = $DATA->page_metadata($p, 'parent');
207
-                if ($p) $parents[] = $p;
211
+                if ($p) {
212
+                    $parents[] = $p;
213
+                }
208 214
             }
209 215
 
210 216
             $top_highlight = array_pop($parents);
@@ -279,7 +285,9 @@  discard block
 block discarded – undo
279 285
             $menudata = $DATA->page_metadata($toppage, 'menu');
280 286
                 $text = $menudata['text'];
281 287
                 $title = $menudata['title'];
282
-            if (!$title) continue;
288
+            if (!$title) {
289
+                continue;
290
+            }
283 291
 
284 292
                 //get link and description for the menu ans add it to the array
285 293
             $class = $toppage == $this->nav_highlights['top'] ? 'on' : '';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
136 136
 
137 137
             if (isset($nextprev[$linktype]['body'])) {
138
-                $linktitle = _htmlentities( trim_characters($nextprev[$linktype]['body'], 0, 40) );
138
+                $linktitle = _htmlentities(trim_characters($nextprev[$linktype]['body'], 0, 40));
139 139
                 if (isset($nextprev[$linktype]['speaker']) &&
140 140
                     count($nextprev[$linktype]['speaker']) > 0) {
141 141
                     $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle;
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 
163 163
         if ($nextprev) {
164 164
             // Four different kinds of back/forth links we might build.
165
-            $links = array ("first", "prev", "up", "next", "last");
165
+            $links = array("first", "prev", "up", "next", "last");
166 166
 
167 167
             foreach ($links as $type) {
168
-                if ( $link = $this->generate_next_prev_link( $nextprev, $type ) ) {
168
+                if ($link = $this->generate_next_prev_link($nextprev, $type)) {
169 169
 
170 170
                     $this->data['header_links'][] = $link;
171 171
                 }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         // Page names mapping to those in metadata.php.
259 259
         // Links in the top menu, and the sublinks we see if
260 260
         // we're within that section.
261
-        $nav_items = array (
261
+        $nav_items = array(
262 262
             array('home'),
263 263
             array('hansard', 'mps', 'peers', 'alldebatesfront', 'wranswmsfront', 'pbc_front', 'divisions_recent', 'calendar_summary', 'contact'),
264 264
             array('sp_home', 'spoverview', 'msps', 'spdebatesfront', 'spwransfront', 'contact'),
Please login to merge, or discard this patch.
classes/Search/Normal.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -177,6 +177,9 @@
 block discarded – undo
177 177
         return $items;
178 178
     }
179 179
 
180
+    /**
181
+     * @param \URL $url
182
+     */
180 183
     private function generate_pagination_links($data, $url, $first, $last) {
181 184
         $links = array();
182 185
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,9 @@
 block discarded – undo
141 141
 
142 142
     private function find_members() {
143 143
         $searchstring = trim(preg_replace('#-?[a-z]+:[a-z0-9]+#', '', $this->searchstring));
144
-        if (!$searchstring) return array();
144
+        if (!$searchstring) {
145
+            return array();
146
+        }
145 147
 
146 148
         $members = array();
147 149
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
         }
13 13
 
14 14
         $o = get_http_var('o');
15
-        $args = array (
15
+        $args = array(
16 16
             's' => $this->searchstring,
17 17
             'p' => $pagenum,
18 18
             'num' => get_http_var('num'),
19 19
             'pop' => get_http_var('pop'),
20
-            'o' => ($o=='d' || $o=='r' || $o=='o') ? $o : 'd',
20
+            'o' => ($o == 'd' || $o == 'r' || $o == 'o') ? $o : 'd',
21 21
         );
22 22
 
23 23
         return $args;
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
         }
56 56
 
57 57
         $sort_order = 'newest';
58
-        if ( $args['o'] == 'o' ) {
58
+        if ($args['o'] == 'o') {
59 59
             $sort_order = 'oldest';
60
-        } else if ( $args['o'] == 'r' ) {
60
+        } else if ($args['o'] == 'r') {
61 61
             $sort_order = 'relevance';
62 62
         }
63 63
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             return array('error' => $SEARCHENGINE->error);
74 74
         } else {
75 75
             $LIST = new \HANSARDLIST();
76
-            $data = $LIST->display('search', $args , 'none');
76
+            $data = $LIST->display('search', $args, 'none');
77 77
             $data['search_type'] = 'normal';
78 78
             $data['sort_order'] = $sort_order;
79 79
             $data['members'] = $members;
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
             return false;
94 94
         }
95 95
 
96
-        list ($constituencies, ) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
96
+        list ($constituencies,) = \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery($searchterm);
97 97
 
98 98
         $constituency = "";
99
-        if (count($constituencies)==1) {
99
+        if (count($constituencies) == 1) {
100 100
             $constituency = $constituencies[0];
101 101
         }
102 102
 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
                 $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
114 114
                 $cons[] = $MEMBER;
115
-                if ( $MEMBER->current_member(1) ) {
115
+                if ($MEMBER->current_member(1)) {
116 116
                     $mp_types['mp']++;
117 117
                 } else {
118 118
                     $mp_types['former']++;
119 119
                 }
120
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
120
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
121 121
                 $cons = array();
122 122
             }
123 123
         } elseif (count($constituencies)) {
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
                 try {
126 126
                     $MEMBER = new \MySociety\TheyWorkForYou\Member(array('constituency'=>$constituency, 'house' => 1));
127 127
                     $cons[] = $MEMBER;
128
-                    if ( $MEMBER->current_member(1) ) {
128
+                    if ($MEMBER->current_member(1)) {
129 129
                         $mp_types['mp']++;
130 130
                     } else {
131 131
                         $mp_types['former']++;
132 132
                     }
133
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
133
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
134 134
                     continue;
135 135
                 }
136 136
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
         $q = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookup($searchstring);
149 149
         $row_count = $q->rows();
150
-        for ($n=0; $n<$row_count; $n++) {
150
+        for ($n = 0; $n < $row_count; $n++) {
151 151
             $members[] = $q->field($n, 'person_id');
152 152
         }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $q = $db->query("SELECT person FROM moffice WHERE position LIKE :pos ORDER BY from_date DESC, moffice_id",
156 156
             array('pos' => "%$searchstring%"));
157 157
         $row_count = $q->rows();
158
-        for ($n=0; $n<$row_count; $n++) {
158
+        for ($n = 0; $n < $row_count; $n++) {
159 159
             $members[] = $q->field($n, 'person');
160 160
         }
161 161
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $link = array(
204 204
                 'url' => $url->generate(),
205 205
                 'page' => $n,
206
-                'current' => ( $n == $data['page'] )
206
+                'current' => ($n == $data['page'])
207 207
             );
208 208
 
209 209
             $links[] = $link;
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
             $numlinks = $this->generate_pagination_links($data, $URL, $firstpage, $lastpage);
245 245
 
246 246
             $pagelinks['nums'] = $numlinks;
247
-            $pagelinks['first_result'] = $page == 1 ? 1 : ( ( $page - 1 ) * $results_per_page ) + 1;
248
-            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ( $results_per_page - 1 );
247
+            $pagelinks['first_result'] = $page == 1 ? 1 : (($page - 1) * $results_per_page) + 1;
248
+            $pagelinks['last_result'] = $page == $numpages ? $total_results : $pagelinks['first_result'] + ($results_per_page - 1);
249 249
 
250
-            if ( $page != 1 ) {
250
+            if ($page != 1) {
251 251
                 $prev_page = $page - 1;
252
-                $URL->insert(array( 'p' => $prev_page ) );
252
+                $URL->insert(array('p' => $prev_page));
253 253
                 $pagelinks['prev'] = array(
254 254
                     'url' => $URL->generate()
255 255
                 );
256
-                $URL->insert(array( 'p' => 1 ) );
256
+                $URL->insert(array('p' => 1));
257 257
                 $pagelinks['firstpage'] = array(
258 258
                     'url' => $URL->generate()
259 259
                 );
260 260
             }
261 261
             if ($page != $numpages) {
262 262
                 $next_page = $page + 1;
263
-                $URL->insert(array( 'p' => $next_page ) );
263
+                $URL->insert(array('p' => $next_page));
264 264
                 $pagelinks['next'] = array(
265 265
                     'url' => $URL->generate()
266 266
                 );
267
-                $URL->insert(array( 'p' => $numpages ) );
267
+                $URL->insert(array('p' => $numpages));
268 268
                 $pagelinks['lastpage'] = array(
269 269
                     'url' => $URL->generate()
270 270
                 );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
         $links['rss'] = $DATA->page_metadata($this_page, 'rss');
282 282
 
283 283
         if ($SEARCHENGINE) {
284
-            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch='.urlencode($this->searchstring) : '');
284
+            $links['email'] = '/alert/?' . ($this->searchstring ? 'alertsearch=' . urlencode($this->searchstring) : '');
285 285
             $links['email_desc'] = $SEARCHENGINE->query_description_long();
286 286
         }
287 287
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             $search_engine = new \SEARCHENGINE($filter_ss);
296 296
             $links['email_section'] = $links['email'];
297 297
             $links['email_desc_section'] = $links['email_desc'];
298
-            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch='.urlencode($filter_ss) : '');
298
+            $links['email'] = '/alert/?' . ($filter_ss ? 'alertsearch=' . urlencode($filter_ss) : '');
299 299
             $links['email_desc'] = $search_engine->query_description_long();
300 300
         }
301 301
 
Please login to merge, or discard this patch.
classes/SectionView/SectionView.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -347,6 +347,9 @@
 block discarded – undo
347 347
         return array($bodies, $speeches);
348 348
     }
349 349
 
350
+    /**
351
+     * @param integer $speeches
352
+     */
350 353
     private function annotateSpeeches($data, $bodies, $speeches) {
351 354
         global $THEUSER;
352 355
         $first_speech = null;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
             if ($row['totalcomments'] > 1) {
513 513
                 $morecount = $row['totalcomments'] - 1;
514 514
                 $plural = $morecount == 1 ? 'annotation' : 'annotations';
515
-                $linktext = "Read $morecount more $plural";
515
+                $linktext = "read $morecount more $plural";
516 516
             }
517 517
 
518 518
         } else {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $data = $this->addCommonData($data);
33 33
         } elseif ($date = get_http_var('d')) {
34 34
             $data = $this->display_day($date);
35
-            if ( !isset($data['template']) ) {
35
+            if (!isset($data['template'])) {
36 36
                 $data['template'] = 'section/day';
37 37
             }
38 38
             $data = $this->addCommonData($data);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             $data = $this->display_section_or_speech();
41 41
         } else {
42 42
             $data = $this->display_front();
43
-            if ( !isset($data['template']) ) {
43
+            if (!isset($data['template'])) {
44 44
                 $data['template'] = 'section/recent';
45 45
             }
46 46
             $data['search_sections'] = $this->getSearchSections();
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         $data['recess_major'] = $this->getRecessMajor($data);
60 60
 
61 61
         $nextprev = $DATA->page_metadata($this_page, 'nextprev');
62
-        if ( isset($nextprev['next']['url']) ) {
62
+        if (isset($nextprev['next']['url'])) {
63 63
             $data['next'] = $nextprev['next'];
64 64
         }
65
-        if ( isset($nextprev['prev']['url']) ) {
65
+        if (isset($nextprev['prev']['url'])) {
66 66
             $data['prev'] = $nextprev['prev'];
67 67
         }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         if (!isset($data['title']) && $parent_page != '') {
72 72
             $data['title'] = $DATA->page_metadata($parent_page, 'title');
73 73
         }
74
-        if ( $parent_page ) {
74
+        if ($parent_page) {
75 75
             $data['parent_title'] = $DATA->page_metadata($parent_page, 'title');
76 76
         }
77 77
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
         $urls = array_merge($urls, $this->getViewUrls());
89 89
 
90
-        if ( isset($data['info']['page']) ) {
90
+        if (isset($data['info']['page'])) {
91 91
             $day = new \URL($data['info']['page']);
92 92
             $urls['day'] = $day;
93 93
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             $DATA->set_page_metadata($this_page, 'title', $year);
134 134
         }
135 135
 
136
-        $args = array ( 'year' => $year );
136
+        $args = array('year' => $year);
137 137
         $data = $this->list->display('calendar', $args, 'none');
138 138
         return $data;
139 139
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     protected function display_column($date, $column) {
142 142
         global $this_page;
143 143
         $this_page = $this->page_base;
144
-        $args = array( 'date' => $date, 'column' => $column );
144
+        $args = array('date' => $date, 'column' => $column);
145 145
         $content = $this->list->display('column', $args, 'none');
146 146
 
147 147
         $data = array();
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
     protected function display_day($date) {
167 167
         global $this_page;
168 168
         $this_page = $this->page_base . 'day';
169
-        $args = array ( 'date' => get_http_var('d') );
169
+        $args = array('date' => get_http_var('d'));
170 170
         $data = $this->list->display('date', $args, 'none');
171 171
         list($year, $month, $day) = explode('-', $date);
172
-        $args = array( 'year' => $year, 'month' => $month, 'day' => $day);
172
+        $args = array('year' => $year, 'month' => $month, 'day' => $day);
173 173
         $calendar = $this->list->display('calendar', $args, 'none');
174
-        if ( isset($calendar['years']) ) {
174
+        if (isset($calendar['years'])) {
175 175
             $data['calendar'] = $calendar['years'];
176 176
         }
177 177
         return $data;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         global $DATA, $this_page, $THEUSER;
182 182
 
183 183
         # += as we *don't* want to override any already supplied argument
184
-        $args += array (
184
+        $args += array(
185 185
             'gid' => get_http_var('id'),
186 186
             's' => get_http_var('s'), // Search terms to be highlighted.
187 187
             'member_id' => get_http_var('m'), // Member's speeches to be highlighted.
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
             if ($this->major == 6) {
199 199
                 # Magically (as in I can't remember quite why), pbc_clause will
200 200
                 # contain the new URL without any change...
201
-                $URL->remove( array('id') );
201
+                $URL->remove(array('id'));
202 202
             } else {
203
-                $URL->insert( array('id'=>$e->getMessage()) );
203
+                $URL->insert(array('id'=>$e->getMessage()));
204 204
             }
205 205
             # put the search term back in so highlighting works.
206 206
             # NB: as we don't see the # part of the URL we lose this :(
207
-            if ( $args['s'] !== '' ) {
208
-                $URL->insert( array('s'=>$args['s']) );
207
+            if ($args['s'] !== '') {
208
+                $URL->insert(array('s'=>$args['s']));
209 209
             }
210 210
             redirect($URL->generate('none'));
211 211
         }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         if (array_key_exists('text_heading', $data['info'])) {
274 274
             // avoid having Clause 1 etc as the alert text search string on PBC pages as it's
275 275
             // almost certainly not what the person wants
276
-            if ( $this->major == 6 ) {
276
+            if ($this->major == 6) {
277 277
                 $data['email_alert_text'] = $data['section_title'];
278 278
             } else {
279 279
                 $data['email_alert_text'] = $data['info']['text_heading'];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
             $body = preg_replace('#<phrase class="honfriend" id="uk.org.publicwhip/member/(\d+)" name="([^"]*?)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?m=$1" title="Our page on $2 - \'$3\'">$4</a>', $body);
321 321
             $body = preg_replace('#<phrase class="honfriend" name="([^"]*?)" person_id="uk.org.publicwhip/person/(\d+)">(.*?\s*\((.*?)\))</phrase>#', '<a href="/mp/?p=$2" title="Our page on $1 - \'$3\'">$4</a>', $body);
322 322
             $body = preg_replace_callback('#<phrase class="offrep" id="(.*?)/(\d+)-(\d+)-(\d+)\.(.*?)">(.*?)</phrase>#', function($matches) {
323
-                return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] .'">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
323
+                return '<a href="/search/?pop=1&s=date:' . $matches[2] . $matches[3] . $matches[4] . '+column:' . $matches[5] . '+section:' . $matches[1] . '">' . str_replace("Official Report", "Hansard", $matches[6]) . '</a>';
324 324
             }, $body);
325 325
             #$body = preg_replace('#<phrase class="offrep" id="((.*?)/(\d+)-(\d+)-(\d+)\.(.*?))">(.*?)</phrase>#e', "\"<a href='/search/?pop=1&amp;s=date:$3$4$5+column:$6+section:$2&amp;match=$1'>\" . str_replace('Official Report', 'Hansard', '$7') . '</a>'", $body);
326 326
             $bodies[] = $body;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         $first_speech = null;
353 353
         $data['section_title'] = '';
354 354
         $subsection_title = '';
355
-        for ($i=0; $i<count($data['rows']); $i++) {
355
+        for ($i = 0; $i < count($data['rows']); $i++) {
356 356
             $row = $data['rows'][$i];
357 357
             $htype = $row['htype'];
358 358
             // HPOS should be defined below if it's needed; otherwise default to 0
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 # Voting links
376 376
                 $data['rows'][$i]['voting_data'] = '';
377 377
                 if (isset($row['votes'])) {
378
-                    $data['rows'][$i]['voting_data'] = $this->generate_votes( $row['votes'], $row['epobject_id'], $row['gid'] );
378
+                    $data['rows'][$i]['voting_data'] = $this->generate_votes($row['votes'], $row['epobject_id'], $row['gid']);
379 379
                 }
380 380
 
381 381
                 # Annotation link
@@ -398,47 +398,47 @@  discard block
 block discarded – undo
398 398
 
399 399
     private function getCountryDetails() {
400 400
         $details = array(
401
-            1 => array (
401
+            1 => array(
402 402
                 'country' => 'UK',
403 403
                 'assembly' => 'uk-commons',
404 404
                 'location' => '&ndash; in the House of Commons'
405 405
             ),
406
-            2 => array (
406
+            2 => array(
407 407
                 'country' => 'UK',
408 408
                 'assembly' => 'uk-commons',
409 409
                 'location' => '&ndash; in Westminster Hall'
410 410
             ),
411
-            3 => array (
411
+            3 => array(
412 412
                 'country' => 'UK',
413 413
                 'assembly' => 'uk-commons',
414 414
                 'location' => 'written question &ndash; answered'
415 415
             ),
416
-            4 => array (
416
+            4 => array(
417 417
                 'country' => 'UK',
418 418
                 'assembly' => 'uk-commons',
419 419
                 'location' => 'written statement &ndash; made'
420 420
             ),
421
-            5 => array (
421
+            5 => array(
422 422
                 'country' => 'NORTHERN IRELAND',
423 423
                 'assembly' => 'ni',
424 424
                 'location' => '&ndash; in the Northern Ireland Assembly'
425 425
             ),
426
-            6 => array (
426
+            6 => array(
427 427
                 'country' => 'UK',
428 428
                 'assembly' => 'uk-commons',
429 429
                 'location' => '&ndash; in a Public Bill Committee'
430 430
             ),
431
-            7 => array (
431
+            7 => array(
432 432
                 'country' => 'SCOTLAND',
433 433
                 'assembly' => 'scotland',
434 434
                 'location' => '&ndash; in the Scottish Parliament'
435 435
             ),
436
-            8 => array (
436
+            8 => array(
437 437
                 'country' => 'SCOTLAND',
438 438
                 'assembly' => 'scotland',
439 439
                 'location' => '&ndash; Scottish Parliament written question &ndash; answered'
440 440
             ),
441
-            101 => array (
441
+            101 => array(
442 442
                 'country' => 'UK',
443 443
                 'assembly' => 'uk-lords',
444 444
                 'location' => '&ndash; in the House of Lords'
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
         global $DATA, $this_page;
454 454
         $this_page = $this->page_base . 'front';
455 455
         $data = array();
456
-        if ( $this->index_template ) {
456
+        if ($this->index_template) {
457 457
             $data['template'] = $this->index_template;
458 458
         }
459 459
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 
464 464
         $content['calendar'] = $class->display('calendar', array('months' => 1), 'none');
465 465
 
466
-        if ( $rssurl = $DATA->page_metadata($this_page, 'rss') ) {
466
+        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
467 467
             $content['rssurl'] = $rssurl;
468 468
         }
469 469
 
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     }
479 479
 
480 480
     //$totalcomments, $comment, $commenturl
481
-    function generate_commentteaser ($row) {
481
+    function generate_commentteaser($row) {
482 482
         // Returns HTML for the one fragment of comment and link for the sidebar.
483 483
         // $totalcomments is the number of comments this item has on it.
484 484
         // $comment is an array like:
Please login to merge, or discard this patch.
tests/PartyTest.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@
 block discarded – undo
118 118
         $this->assertEquals($expected, $position);
119 119
     }
120 120
 
121
+    /**
122
+     * @param string $method
123
+     */
121 124
     private function getAllPositions($method, $party = 'A Party') {
122 125
         $party = new MySociety\TheyWorkForYou\Party($party);
123 126
         $policies = new MySociety\TheyWorkForYou\Policies();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/party.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/party.xml');
15 15
     }
16 16
 
17 17
     private function fetch_page($vars)
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
         $party = new MySociety\TheyWorkForYou\Party('A Party');
24 24
 
25 25
         $this->assertNotNull($party);
26
-        $this->assertEquals( 'A Party', $party->name );
26
+        $this->assertEquals('A Party', $party->name);
27 27
     }
28 28
 
29 29
     public function testCountMembers() {
30 30
         $party = new MySociety\TheyWorkForYou\Party('A Party');
31
-        $this->assertEquals( $party->getCurrentMemberCount(HOUSE_TYPE_COMMONS), 2 );
31
+        $this->assertEquals($party->getCurrentMemberCount(HOUSE_TYPE_COMMONS), 2);
32 32
     }
33 33
 
34 34
     public function testGetPolicyPositions() {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $this->assertEquals($expectedResults, $positions);
116 116
 
117 117
         $party = new MySociety\TheyWorkForYou\Party('Labour/Co-operative');
118
-        $party->cache_position( $positions['810'] );
118
+        $party->cache_position($positions['810']);
119 119
 
120 120
         $position = $party->policy_position(810);
121 121
         $expected = ('voted a mixture of for and against');
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function testMPPartyPolicyTextWhenDiffers()
135 135
     {
136
-        $page = $this->fetch_page( array( 'pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency' ) );
136
+        $page = $this->fetch_page(array('pid' => 2, 'url' => '/mp/2/test_current-mp/test_westminster_constituency'));
137 137
         $this->assertContains('Test Current-MP', $page);
138 138
         $this->assertContains('is a A Party MP', $page);
139 139
         $this->assertContains('sometimes <b>differs</b> from their party', $page);
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 
142 142
     public function testSingleMemberPartyPolicyText()
143 143
     {
144
-        $page = $this->fetch_page( array( 'pid' => 7, 'url' => '/mp/7/test_second-party-mp/test_westminster_constituency' ) );
144
+        $page = $this->fetch_page(array('pid' => 7, 'url' => '/mp/7/test_second-party-mp/test_westminster_constituency'));
145 145
         $this->assertContains('Test Second-Party-MP', $page);
146 146
         $this->assertNotContains('is a A Second Party MP', $page);
147 147
     }
148 148
 
149 149
     public function testMPPartyPolicyWherePartyMissingPositions()
150 150
     {
151
-        $page = $this->fetch_page( array( 'pid' => 3, 'url' => '/mp/3/test_current-mp/test_westminster_constituency' ) );
151
+        $page = $this->fetch_page(array('pid' => 3, 'url' => '/mp/3/test_current-mp/test_westminster_constituency'));
152 152
         $this->assertContains('Test Current-MP', $page);
153 153
         $this->assertContains('is a A Party MP', $page);
154 154
         $this->assertNotContains('while most A Party MPs voted', $page);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
     public function testMPPartyPolicyTextWhenAgrees()
158 158
     {
159
-        $page = $this->fetch_page( array( 'pid' => 6, 'url' => '/mp/6/test_further-mp/test_westminster_constituency' ) );
159
+        $page = $this->fetch_page(array('pid' => 6, 'url' => '/mp/6/test_further-mp/test_westminster_constituency'));
160 160
         $this->assertContains('Test Further-MP', $page);
161 161
         $this->assertContains('This is a selection of Miss Test Further-MP&rsquo;s votes', $page);
162 162
     }
Please login to merge, or discard this patch.
www/docs/admin/report.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -146,6 +146,9 @@
 block discarded – undo
146 146
 
147 147
 
148 148
 
149
+/**
150
+ * @param string $template
151
+ */
149 152
 function get_template_contents($template) {
150 153
     // Fetches the contents of an email template so we can then
151 154
     // display it on the screen.
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 // where rid is a report_id and cid is a comment_id.
7 7
 
8 8
 include_once '../../includes/easyparliament/init.php';
9
-include_once (INCLUDESPATH."easyparliament/commentreport.php");
9
+include_once (INCLUDESPATH . "easyparliament/commentreport.php");
10 10
 
11 11
 $this_page = "admin_commentreport";
12 12
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
     global $this_page;
178 178
 
179 179
 #	$commentermail = preg_replace("/\n/", "<br>\n", get_template_contents('comment_deleted') );
180
-    $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted') );
181
-    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld') );
180
+    $commentermail = preg_replace('/^Subject:.*\n/', '', get_template_contents('comment_deleted'));
181
+    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_upheld'));
182 182
 
183 183
     ?>
184 184
         <p><strong>You've chosen to delete this comment.</strong> You can now send an email to both the person who posted the comment, and the person who made the report. Uncheck a box to prevent an email from being sent. The comment will not be deleted until you click the button below.</p>
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 
212 212
     global $this_page;
213 213
 
214
-    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined') );
214
+    $reportermail = preg_replace("/\n/", "<br>\n", get_template_contents('report_declined'));
215 215
 
216 216
     ?>
217 217
         <p><strong>You have chosen not to delete this comment.</strong> You can now send an email to the person who made the report (uncheck the box to send no email). The report will not be resolved until you click the button below.</p>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         $upheld = false;
244 244
     }
245 245
 
246
-    $success = $REPORT->resolve ($upheld, $COMMENT);
246
+    $success = $REPORT->resolve($upheld, $COMMENT);
247 247
 
248 248
     if ($success) {
249 249
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 // The reporting user was logged in at the time,
262 262
                 // so get their email address.
263 263
                 $USER = new USER;
264
-                $USER->init( $REPORT->user_id() );
264
+                $USER->init($REPORT->user_id());
265 265
                 $email = $USER->email();
266 266
             } else {
267 267
                 // Non-logged-in user; they should have left their address.
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
             }
270 270
 
271 271
             // Prepare the data needed for either email.
272
-            $data = array (
272
+            $data = array(
273 273
                 'to' 			=> $email
274 274
             );
275
-            $merge = array (
275
+            $merge = array(
276 276
                 'FIRSTNAME' 	=> $REPORT->firstname(),
277 277
                 'LASTNAME' 		=> $REPORT->lastname(),
278 278
                 'REPORTBODY' 	=> strip_tags($REPORT->body())
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
             // Remove the anchor for their now deleted comment.
309 309
             $addcommentsurl = 'https://' . DOMAIN . preg_replace("/#.*$/", '#addcomment', $COMMENT->url());
310 310
 
311
-            $data = array (
311
+            $data = array(
312 312
                 'to' => $USER->email(),
313 313
                 'template' => 'comment_deleted_blank',
314 314
                 'subject' => 'One of your comments has been deleted',
315 315
             );
316
-            $merge = array (
316
+            $merge = array(
317 317
                 'REPLYBODY' => get_http_var('commentermail'),
318 318
                 'FIRSTNAME' 	=> $USER->firstname(),
319 319
                 'LASTNAME' 	=> $USER->lastname(),
Please login to merge, or discard this patch.
www/docs/api/api_functions.php 5 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -197,6 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 # Output functions
199 199
 
200
+/**
201
+ * @param integer $last_mod
202
+ */
200 203
 function api_output($arr, $last_mod=null) {
201 204
     $output = get_http_var('output');
202 205
     if (!get_http_var('docs')) {
@@ -325,6 +328,11 @@  discard block
 block discarded – undo
325 328
 
326 329
 # Call an API function
327 330
 
331
+/**
332
+ * @param string $function
333
+ * @param string $error
334
+ * @param string $type
335
+ */
328 336
 function api_call_user_func_or_error($function, $params, $error, $type) {
329 337
     if (function_exists($function))
330 338
         call_user_func_array($function, $params);
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 }
147 147
 
148 148
 function api_is_superuser_key($key) {
149
-  $db = new ParlDB;
150
-  $q = $db->query('SELECT api_key.user_id, users.status
149
+    $db = new ParlDB;
150
+    $q = $db->query('SELECT api_key.user_id, users.status
151 151
                FROM   api_key, users
152 152
                WHERE  users.user_id = api_key.user_id
153 153
                AND    api_key.api_key = :key', array(
154 154
                 ':key' => $key
155 155
                 ));
156
-  if (!$q->rows())
156
+    if (!$q->rows())
157 157
     return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
158
+    if ($q->field(0, 'status') == 'Superuser')
159 159
     return true;
160
-  else
160
+    else
161 161
     return false;
162 162
 }
163 163
 
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
     // we only want to convert to iso if it's an actual API call
336 336
     // so skip this if it's a documentation page
337 337
     if (!get_http_var('docs')) {
338
-      // and then catch any errors in the conversion and just ignore
339
-      // them and return the unconverted results
340
-      $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
338
+        // and then catch any errors in the conversion and just ignore
339
+        // them and return the unconverted results
340
+        $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
+        if ($converted_out !== FALSE) {
342 342
         $out = $converted_out;
343
-      }
343
+        }
344 344
     }
345 345
 
346 346
     return $out;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@
 block discarded – undo
338 338
       // and then catch any errors in the conversion and just ignore
339 339
       // them and return the unconverted results
340 340
       $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
341
+      if ($converted_out !== false) {
342 342
         $out = $converted_out;
343 343
       }
344 344
     }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key == 'DOCS') return;
136 136
     $ip = $_SERVER['REMOTE_ADDR'];
137 137
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 138
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 
198 198
 # Output functions
199 199
 
200
-function api_output($arr, $last_mod=null) {
200
+function api_output($arr, $last_mod = null) {
201 201
     $output = get_http_var('output');
202 202
     if (!get_http_var('docs')) {
203 203
         $cond = api_header($output, $last_mod);
204 204
         if ($cond) return;
205 205
     }
206 206
     if ($output == 'xml') {
207
-        $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
207
+        $out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
208 208
         $out .= '<twfy>' . api_output_xml($arr) . '</twfy>';
209 209
     } elseif ($output == 'php') {
210 210
         $out = api_output_php($arr);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     print $out;
223 223
 }
224 224
 
225
-function api_header($o, $last_mod=null) {
225
+function api_header($o, $last_mod = null) {
226 226
     if ($last_mod && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
227 227
         $t = cond_parse_http_date($_SERVER['HTTP_IF_MODIFIED_SINCE']);
228 228
         if (isset($t) && $t >= $last_mod) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     }
249 249
     #$type = 'text/plain';
250 250
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
251
+    if ($last_mod > 0)
252 252
         header('Last-Modified: ' . date('r', $last_mod));
253 253
     return false;
254 254
 }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 }
272 272
 
273 273
 $api_xml_arr = 0;
274
-function api_output_xml($v, $k=null) {
274
+function api_output_xml($v, $k = null) {
275 275
     global $api_xml_arr;
276 276
     $verbose = get_http_var('verbose') ? "\n" : '';
277 277
     if (is_array($v)) {
278
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
278
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
279 279
             $elt = 'match';
280 280
             $api_xml_arr++;
281 281
             $out = "<$elt>";
@@ -296,36 +296,36 @@  discard block
 block discarded – undo
296 296
     }
297 297
 }
298 298
 
299
-function api_output_js($v, $level=0) {
299
+function api_output_js($v, $level = 0) {
300 300
     $verbose = get_http_var('verbose') ? "\n" : '';
301 301
     $out = '';
302 302
     if (is_array($v)) {
303 303
         # PHP arrays are both JS arrays and objects
304
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
305
-            $out = '[' . join(",$verbose" , array_map('api_output_js', $v)) . ']';
304
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
305
+            $out = '[' . join(",$verbose", array_map('api_output_js', $v)) . ']';
306 306
         } else {
307 307
             $out = '{' . $verbose;
308 308
             $b = false;
309 309
             foreach ($v as $k => $vv) {
310 310
                 if ($b) $out .= ",$verbose";
311 311
                 if ($verbose) {
312
-                    $out .= str_repeat(' ', ($level+1)*2);
312
+                    $out .= str_repeat(' ', ($level + 1) * 2);
313 313
                     $out .= '"' . $k . '" : ';
314 314
                 } else {
315 315
                     $out .= '"' . $k . '":';
316 316
                 }
317
-                $out .= api_output_js($vv, $level+1);
317
+                $out .= api_output_js($vv, $level + 1);
318 318
                 $b = true;
319 319
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
320
+            if ($verbose) $out .= "\n" . str_repeat(' ', $level * 2);
321 321
             $out .= '}';
322 322
         }
323 323
     } elseif (is_null($v)) {
324 324
         $out = "null";
325 325
     } elseif (is_string($v)) {
326 326
         $out = '"' . str_replace(
327
-            array("\\",'"',"\n","\t","\r", "‶", "″", "“", "”"),
328
-            array("\\\\",'\"','\n','\t','\r', '\"', '\"', '\"', '\"'), $v) . '"';
327
+            array("\\", '"', "\n", "\t", "\r", "‶", "″", "“", "”"),
328
+            array("\\\\", '\"', '\n', '\t', '\r', '\"', '\"', '\"', '\"'), $v) . '"';
329 329
     } elseif (is_bool($v)) {
330 330
         $out = $v ? 'true' : 'false';
331 331
     } elseif (is_int($v) || is_float($v)) {
Please login to merge, or discard this patch.
Braces   +49 added lines, -29 removed lines patch added patch discarded remove patch
@@ -132,7 +132,9 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key=='DOCS') {
136
+        return;
137
+    }
136 138
     $ip = $_SERVER['REMOTE_ADDR'];
137 139
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 140
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -153,23 +155,27 @@  discard block
 block discarded – undo
153 155
                AND    api_key.api_key = :key', array(
154 156
                 ':key' => $key
155 157
                 ));
156
-  if (!$q->rows())
157
-    return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
159
-    return true;
160
-  else
161
-    return false;
162
-}
158
+  if (!$q->rows()) {
159
+      return false;
160
+  }
161
+  if ($q->field(0, 'status') == 'Superuser') {
162
+      return true;
163
+  } else {
164
+      return false;
165
+  }
166
+  }
163 167
 
164 168
 function api_check_key($key) {
165 169
     $db = new ParlDB;
166 170
     $q = $db->query('SELECT user_id, disabled FROM api_key WHERE api_key = :key', array(
167 171
         ':key' => $key
168 172
         ));
169
-    if (!$q->rows())
170
-        return false;
171
-    if ($q->field(0, 'disabled'))
172
-        return 'disabled';
173
+    if (!$q->rows()) {
174
+            return false;
175
+    }
176
+    if ($q->field(0, 'disabled')) {
177
+            return 'disabled';
178
+    }
173 179
     return true;
174 180
 }
175 181
 
@@ -201,7 +207,9 @@  discard block
 block discarded – undo
201 207
     $output = get_http_var('output');
202 208
     if (!get_http_var('docs')) {
203 209
         $cond = api_header($output, $last_mod);
204
-        if ($cond) return;
210
+        if ($cond) {
211
+            return;
212
+        }
205 213
     }
206 214
     if ($output == 'xml') {
207 215
         $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
@@ -212,7 +220,8 @@  discard block
 block discarded – undo
212 220
         $out = api_output_rabx($arr);
213 221
     } elseif ($output == 'json') {
214 222
         $out = json_encode($arr, JSON_PRETTY_PRINT);
215
-    } else { # JS
223
+    } else {
224
+# JS
216 225
         $out = api_output_js($arr);
217 226
         $callback = get_http_var('callback');
218 227
         if (preg_match('#^[A-Za-z0-9._[\]]+$#', $callback)) {
@@ -248,8 +257,9 @@  discard block
 block discarded – undo
248 257
     }
249 258
     #$type = 'text/plain';
250 259
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
252
-        header('Last-Modified: ' . date('r', $last_mod));
260
+    if ($last_mod>0) {
261
+            header('Last-Modified: ' . date('r', $last_mod));
262
+    }
253 263
     return false;
254 264
 }
255 265
 
@@ -259,14 +269,18 @@  discard block
 block discarded – undo
259 269
 
260 270
 function api_output_php($arr) {
261 271
     $out = serialize($arr);
262
-    if (get_http_var('verbose')) $out = str_replace(';', ";\n", $out);
272
+    if (get_http_var('verbose')) {
273
+        $out = str_replace(';', ";\n", $out);
274
+    }
263 275
     return $out;
264 276
 }
265 277
 
266 278
 function api_output_rabx($arr) {
267 279
     $out = '';
268 280
     rabx_wire_wr($arr, $out);
269
-    if (get_http_var('verbose')) $out = str_replace(',', ",\n", $out);
281
+    if (get_http_var('verbose')) {
282
+        $out = str_replace(',', ",\n", $out);
283
+    }
270 284
     return $out;
271 285
 }
272 286
 
@@ -307,7 +321,9 @@  discard block
 block discarded – undo
307 321
             $out = '{' . $verbose;
308 322
             $b = false;
309 323
             foreach ($v as $k => $vv) {
310
-                if ($b) $out .= ",$verbose";
324
+                if ($b) {
325
+                    $out .= ",$verbose";
326
+                }
311 327
                 if ($verbose) {
312 328
                     $out .= str_repeat(' ', ($level+1)*2);
313 329
                     $out .= '"' . $k . '" : ';
@@ -317,7 +333,9 @@  discard block
 block discarded – undo
317 333
                 $out .= api_output_js($vv, $level+1);
318 334
                 $b = true;
319 335
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
336
+            if ($verbose) {
337
+                $out .= "\n" . str_repeat(' ', $level*2);
338
+            }
321 339
             $out .= '}';
322 340
         }
323 341
     } elseif (is_null($v)) {
@@ -349,13 +367,14 @@  discard block
 block discarded – undo
349 367
 # Call an API function
350 368
 
351 369
 function api_call_user_func_or_error($function, $params, $error, $type) {
352
-    if (function_exists($function))
353
-        call_user_func_array($function, $params);
354
-    elseif ($type == 'api')
355
-        api_error($error);
356
-    else
357
-        print "<p style='color:#cc0000'>$error</p>";
358
-}
370
+    if (function_exists($function)) {
371
+            call_user_func_array($function, $params);
372
+    } elseif ($type == 'api') {
373
+            api_error($error);
374
+    } else {
375
+            print "<p style='color:#cc0000'>$error</p>";
376
+    }
377
+    }
359 378
 
360 379
 # Used for testing for conditional responses
361 380
 
@@ -405,8 +424,9 @@  discard block
 block discarded – undo
405 424
         $H = $ma[4];
406 425
         $M = $ma[5];
407 426
         $S = $ma[6];
408
-    } else
409
-        return null;
427
+    } else {
428
+            return null;
429
+    }
410 430
 
411 431
     return gmmktime($H, $M, $S, $m, $d, $Y);
412 432
 }
Please login to merge, or discard this patch.
www/docs/api/api_getConstituencies.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -143,6 +143,10 @@
 block discarded – undo
143 143
  * Given two angles A1 and A2 on a circle expressed in radians, return the
144 144
  * smallest angle between them.
145 145
  */
146
+/**
147
+ * @param double $a1
148
+ * @param double $a2
149
+ */
146 150
 function _api_angle_between($a1, $a2) {
147 151
     if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
148 152
     return abs($a1 - $a2);
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,7 +108,9 @@  discard block
 block discarded – undo
108 108
     $geometry = _api_getGeometry();
109 109
     $out = array();
110 110
     foreach ($geometry['data'] as $name => $data) {
111
-        if (!isset($data['centre_lat']) || !isset($data['centre_lon'])) continue;
111
+        if (!isset($data['centre_lat']) || !isset($data['centre_lon'])) {
112
+            continue;
113
+        }
112 114
         $distance = R_e * acos(
113 115
             sin(deg2rad($lat)) * sin(deg2rad($data['centre_lat']))
114 116
             + cos(deg2rad($lat)) * cos(deg2rad($data['centre_lat']))
@@ -144,7 +146,9 @@  discard block
 block discarded – undo
144 146
  * smallest angle between them.
145 147
  */
146 148
 function _api_angle_between($a1, $a2) {
147
-    if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
149
+    if (abs($a1 - $a2) > M_PI) {
150
+        return 2*M_PI - abs($a1 - $a2);
151
+    }
148 152
     return abs($a1 - $a2);
149 153
 }
150 154
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
         and c_main.main_name and constituency.name like :constituency_name and constituency.from_date <= date(now())
42 42
         and date(now()) <= constituency.to_date
43 43
         order by name', array(
44
-        ':constituency_name' => '%' . $s .'%'
44
+        ':constituency_name' => '%' . $s . '%'
45 45
         ));
46 46
     $output = array();
47 47
     $done = array();
48
-    for ($i=0; $i<$q->rows(); $i++) {
48
+    for ($i = 0; $i < $q->rows(); $i++) {
49 49
         $name = $q->field($i, 'name');
50 50
         if (!in_array($name, $done)) {
51 51
             $output[] = array(
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
 function api_getConstituencies($date = 'now()') {
71 71
     $db = new ParlDB;
72 72
     $q = $db->query('select cons_id, name from constituency
73
-        where main_name and from_date <= date('.$date.') and date('.$date.') <= to_date
73
+        where main_name and from_date <= date('.$date . ') and date(' . $date . ') <= to_date
74 74
         order by name');
75 75
     $output = array();
76
-    for ($i=0; $i<$q->rows(); $i++) {
76
+    for ($i = 0; $i < $q->rows(); $i++) {
77 77
         $output[] = array(
78 78
             # 'id' => $q->field($i, 'cons_id'),
79 79
             'name' => $q->field($i, 'name')
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * smallest angle between them.
145 145
  */
146 146
 function _api_angle_between($a1, $a2) {
147
-    if (abs($a1 - $a2) > M_PI) return 2*M_PI - abs($a1 - $a2);
147
+    if (abs($a1 - $a2) > M_PI) return 2 * M_PI - abs($a1 - $a2);
148 148
     return abs($a1 - $a2);
149 149
 }
150 150
 
Please login to merge, or discard this patch.
www/docs/api/api_getHansard.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -36,11 +36,17 @@  discard block
 block discarded – undo
36 36
     ));
37 37
 }
38 38
 
39
+/**
40
+ * @param string $type
41
+ */
39 42
 function _api_getHansard_date($type, $d) {
40 43
     $args = array ('date' => $d);
41 44
     $LIST = _api_getListObject($type);
42 45
     $LIST->display('date', $args, 'api');
43 46
 }
47
+/**
48
+ * @param string $type
49
+ */
44 50
 function _api_getHansard_year($type, $y) {
45 51
     $args = array('year' => $y);
46 52
     $LIST = _api_getListObject($type);
@@ -98,6 +104,9 @@  discard block
 block discarded – undo
98 104
     $LIST->display('search', $args, 'api');
99 105
 }
100 106
 
107
+/**
108
+ * @param string $type
109
+ */
101 110
 function _api_getHansard_gid($type, $gid) {
102 111
     $args = array('gid' => $gid);
103 112
     $LIST = _api_getListObject($type);
@@ -112,6 +121,9 @@  discard block
 block discarded – undo
112 121
     }
113 122
 }
114 123
 
124
+/**
125
+ * @param string $type
126
+ */
115 127
 function _api_getHansard_department($type, $dept) {
116 128
     $args = array('department' => $dept);
117 129
     $LIST = _api_getListObject($type);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@
 block discarded – undo
66 66
     if ($o == 'p') {
67 67
         $data = \MySociety\TheyWorkForYou\Utility\Search::searchByUsage($search);
68 68
         $out = array();
69
-        if (!isset($data['speakers'])) $data['speakers'] = array();
69
+        if (!isset($data['speakers'])) {
70
+            $data['speakers'] = array();
71
+        }
70 72
         foreach ($data['speakers'] as $pid => $s) {
71 73
             $out[$pid] = array(
72 74
                 'house' => $s['house'],
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH."easyparliament/member.php";
3
+include_once INCLUDESPATH . "easyparliament/member.php";
4 4
 
5 5
 function api_getHansard_front() {
6 6
 ?>
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 }
30 30
 
31 31
 function api_getHansard_search($s) {
32
-    _api_getHansard_search( array(
32
+    _api_getHansard_search(array(
33 33
         's' => $s,
34 34
         'pid' => get_http_var('person')
35
-    ) );
35
+    ));
36 36
 }
37 37
 function api_getHansard_person($pid) {
38 38
     _api_getHansard_search(array(
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 }
42 42
 
43 43
 function _api_getHansard_date($type, $d) {
44
-    $args = array ('date' => $d);
44
+    $args = array('date' => $d);
45 45
     $LIST = _api_getListObject($type);
46 46
     $LIST->display('date', $args, 'api');
47 47
 }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     $type = isset($array['type']) ? $array['type'] : '';
57 57
     $search = filter_user_input($search, 'strict');
58 58
     if ($pid) {
59
-        $search .= ($search?' ':'') . 'speaker:' . $pid;
59
+        $search .= ($search ? ' ' : '') . 'speaker:' . $pid;
60 60
     }
61 61
     if ($type) {
62 62
         $search .= " section:" . $type;
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     }
92 92
 #    $query_desc_short = $SEARCHENGINE->query_description_short();
93 93
     $pagenum = get_http_var('page');
94
-    $args = array (
94
+    $args = array(
95 95
         's' => $search,
96 96
         'p' => $pagenum,
97 97
         'num' => get_http_var('num'),
98 98
         'pop' => 1,
99
-        'o' => ($o=='d' || $o=='r') ? $o : 'd',
99
+        'o' => ($o == 'd' || $o == 'r') ? $o : 'd',
100 100
     );
101 101
     $LIST = new HANSARDLIST();
102 102
     $LIST->display('search', $args, 'api');
Please login to merge, or discard this patch.