Completed
Push — master ( fd92f5...bc11d0 )
by Nick
06:37
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/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 \MySociety\TheyWorkForYou\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
@@ -416,47 +416,47 @@  discard block
 block discarded – undo
416 416
 
417 417
     private function getCountryDetails() {
418 418
         $details = array(
419
-            1 => array (
419
+            1 => array(
420 420
                 'country' => 'UK',
421 421
                 'assembly' => 'uk-commons',
422 422
                 'location' => '&ndash; in the House of Commons'
423 423
             ),
424
-            2 => array (
424
+            2 => array(
425 425
                 'country' => 'UK',
426 426
                 'assembly' => 'uk-commons',
427 427
                 'location' => '&ndash; in Westminster Hall'
428 428
             ),
429
-            3 => array (
429
+            3 => array(
430 430
                 'country' => 'UK',
431 431
                 'assembly' => 'uk-commons',
432 432
                 'location' => 'written question &ndash; answered'
433 433
             ),
434
-            4 => array (
434
+            4 => array(
435 435
                 'country' => 'UK',
436 436
                 'assembly' => 'uk-commons',
437 437
                 'location' => 'written statement &ndash; made'
438 438
             ),
439
-            5 => array (
439
+            5 => array(
440 440
                 'country' => 'NORTHERN IRELAND',
441 441
                 'assembly' => 'ni',
442 442
                 'location' => '&ndash; in the Northern Ireland Assembly'
443 443
             ),
444
-            6 => array (
444
+            6 => array(
445 445
                 'country' => 'UK',
446 446
                 'assembly' => 'uk-commons',
447 447
                 'location' => '&ndash; in a Public Bill Committee'
448 448
             ),
449
-            7 => array (
449
+            7 => array(
450 450
                 'country' => 'SCOTLAND',
451 451
                 'assembly' => 'scotland',
452 452
                 'location' => '&ndash; in the Scottish Parliament'
453 453
             ),
454
-            8 => array (
454
+            8 => array(
455 455
                 'country' => 'SCOTLAND',
456 456
                 'assembly' => 'scotland',
457 457
                 'location' => '&ndash; Scottish Parliament written question &ndash; answered'
458 458
             ),
459
-            101 => array (
459
+            101 => array(
460 460
                 'country' => 'UK',
461 461
                 'assembly' => 'uk-lords',
462 462
                 'location' => '&ndash; in the House of Lords'
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         global $DATA, $this_page;
472 472
         $this_page = $this->page_base . 'front';
473 473
         $data = array();
474
-        if ( $this->index_template ) {
474
+        if ($this->index_template) {
475 475
             $data['template'] = $this->index_template;
476 476
         }
477 477
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
         $content['calendar'] = $class->display('calendar', array('months' => 1), 'none');
483 483
 
484
-        if ( $rssurl = $DATA->page_metadata($this_page, 'rss') ) {
484
+        if ($rssurl = $DATA->page_metadata($this_page, 'rss')) {
485 485
             $content['rssurl'] = $rssurl;
486 486
         }
487 487
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
     }
497 497
 
498 498
     //$totalcomments, $comment, $commenturl
499
-    function generate_commentteaser ($row) {
499
+    function generate_commentteaser($row) {
500 500
         // Returns HTML for the one fragment of comment and link for the sidebar.
501 501
         // $totalcomments is the number of comments this item has on it.
502 502
         // $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.
www/docs/postcode/index.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -46,6 +46,9 @@  discard block
 block discarded – undo
46 46
 
47 47
 # ---
48 48
 
49
+/**
50
+ * @param string $error
51
+ */
49 52
 function postcode_error($error) {
50 53
     global $PAGE;
51 54
     $PAGE->page_start();
@@ -160,6 +163,9 @@  discard block
 block discarded – undo
160 163
     return array($out, $sidebar);
161 164
 }
162 165
 
166
+/**
167
+ * @param MySociety\TheyWorkForYou\Member $MEMBER
168
+ */
163 169
 function member_redirect(&$MEMBER) {
164 170
     if ($MEMBER->valid) {
165 171
         $url = $MEMBER->url();
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,7 +89,9 @@  discard block
 block discarded – undo
89 89
     $mp = array();
90 90
     if ($q->rows()) {
91 91
         $mp = $q->row(0);
92
-        if ($mp['left_house'] != '9999-12-31') $mp['former'] = true;
92
+        if ($mp['left_house'] != '9999-12-31') {
93
+            $mp['former'] = true;
94
+        }
93 95
     }
94 96
 
95 97
     $a = array_values($areas);
@@ -128,7 +130,9 @@  discard block
 block discarded – undo
128 130
     $out = '';
129 131
     $out .= '<p>That postcode has multiple results, please pick who you are interested in:</p>';
130 132
     $out .= '<ul><li>Your ';
131
-    if (isset($mp['former'])) $out .= 'former ';
133
+    if (isset($mp['former'])) {
134
+        $out .= 'former ';
135
+    }
132 136
     $out .= '<strong>MP</strong> (Member of Parliament) is <a href="/mp/?p=' . $mp['person_id'] . '">';
133 137
     $out .= $mp['given_name'] . ' ' . $mp['family_name'] . '</a>, ' . $mp['constituency'] . '</li>';
134 138
     if ($mcon) {
@@ -138,7 +142,9 @@  discard block
 block discarded – undo
138 142
         $out .= $mcon['given_name'] . ' ' . $mcon['family_name'] . '</a>, ' . $mcon['constituency'] . '</li>';
139 143
     }
140 144
     $out .= '<li>Your <strong>' . $areas[$area_type] . ' ' . $rep_type . 's</strong> ';
141
-    if ($rep_type=='MLA') $out .= '(Members of the Legislative Assembly)';
145
+    if ($rep_type=='MLA') {
146
+        $out .= '(Members of the Legislative Assembly)';
147
+    }
142 148
     $out .= ' ' . ($current ? 'are' : 'were') . ':';
143 149
     $out .= '<ul>';
144 150
     foreach ($mreg as $reg) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 $pc = preg_replace('#[^a-z0-9]#i', '', $pc);
16 16
 if (!validate_postcode($pc)) {
17
-    twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
17
+    twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
18 18
     postcode_error("Sorry, " . _htmlentities($pc) . " isn't a valid postcode");
19 19
 }
20 20
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     exit;
58 58
 }
59 59
 
60
-function fetch_mp($pc, $constituencies, $house=null) {
60
+function fetch_mp($pc, $constituencies, $house = null) {
61 61
     global $THEUSER;
62 62
     $args = array('constituency' => $constituencies['WMC']);
63 63
     if ($house) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     }
66 66
     try {
67 67
         $MEMBER = new MEMBER($args);
68
-    } catch (MySociety\TheyWorkForYou\MemberException $e){
68
+    } catch (MySociety\TheyWorkForYou\MemberException $e) {
69 69
         postcode_error($e->getMessage());
70 70
     }
71 71
     if ($MEMBER->person_id()) {
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
     $mcon = array(); $mreg = array();
111
-    for ($i=0; $i<$q->rows(); $i++) {
111
+    for ($i = 0; $i < $q->rows(); $i++) {
112 112
         $house = $q->field($i, 'house');
113 113
         $cons = $q->field($i, 'constituency');
114
-        if ($house==3) {
114
+        if ($house == 3) {
115 115
             $mreg[] = $q->row($i);
116
-        } elseif ($house==4) {
116
+        } elseif ($house == 4) {
117 117
             if ($cons == $areas['SPC']) {
118 118
                 $mcon = $q->row($i);
119 119
             } elseif ($cons == $areas['SPE']) {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $out .= $mcon['given_name'] . ' ' . $mcon['family_name'] . '</a>, ' . $mcon['constituency'] . '</li>';
139 139
     }
140 140
     $out .= '<li>Your <strong>' . $areas[$area_type] . ' ' . $rep_type . 's</strong> ';
141
-    if ($rep_type=='MLA') $out .= '(Members of the Legislative Assembly)';
141
+    if ($rep_type == 'MLA') $out .= '(Members of the Legislative Assembly)';
142 142
     $out .= ' ' . ($current ? 'are' : 'were') . ':';
143 143
     $out .= '<ul>';
144 144
     foreach ($mreg as $reg) {
Please login to merge, or discard this patch.