Failed Conditions
Pull Request — master (#1327)
by Nick
69:15 queued 59:17
created
classes/Homepage.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
         $gid = $featured->get_gid();
58 58
         $gidCheck = new Gid($gid);
59 59
         $gid = $gidCheck->checkForRedirect();
60
-        if ( $gid ) {
60
+        if ($gid) {
61 61
             $title = $featured->get_title();
62 62
             $context = $featured->get_context();
63 63
             $related = $featured->get_related();
64 64
             $item = $this->getFeaturedDebate($gid, $title, $context, $related);
65 65
         } else {
66 66
             $item = $debatelist->display('recent_debates', array('days' => 7, 'num' => 1), 'none');
67
-            if ( isset($item['data']) && count($item['data']) ) {
67
+            if (isset($item['data']) && count($item['data'])) {
68 68
                 $item = $item['data'][0];
69 69
                 $more_url = new Url('debates');
70 70
                 $item['more_url'] = $more_url->generate();
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
         $item['featured'] = true;
96 96
 
97 97
         $related_debates = array();
98
-        foreach ( $related as $related_gid ) {
99
-            if ( $related_gid ) {
98
+        foreach ($related as $related_gid) {
99
+            if ($related_gid) {
100 100
                 $related_item = $debatelist->display('featured_gid', array('gid' => $related_gid), 'none');
101 101
                 $related_debates[] = $related_item['data'];
102 102
             }
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 
122 122
         $recent_content = array();
123 123
 
124
-        foreach ( $this->recent_types as $class => $recent ) {
124
+        foreach ($this->recent_types as $class => $recent) {
125 125
             $class = "\\$class";
126 126
             $instance = new $class();
127 127
             $more_url = new Url($recent[1]);
128
-            if ( $recent[0] == 'recent_pbc_debates' ) {
129
-                $content = array( 'data' => $instance->display($recent[0], array('num' => 5), 'none') );
128
+            if ($recent[0] == 'recent_pbc_debates') {
129
+                $content = array('data' => $instance->display($recent[0], array('num' => 5), 'none'));
130 130
             } else {
131 131
                 $content = $instance->display($recent[0], array('days' => 7, 'num' => 1), 'none');
132
-                if ( isset($content['data']) && count($content['data']) ) {
132
+                if (isset($content['data']) && count($content['data'])) {
133 133
                     $content = $content['data'][0];
134 134
                 } else {
135 135
                     $content = array();
136 136
                 }
137 137
             }
138
-            if ( $content ) {
138
+            if ($content) {
139 139
                 $content['more_url'] = $more_url->generate();
140 140
                 $content['desc'] = $recent[2];
141 141
                 $recent_content[] = $content;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             WHERE event_date >= :date
155 155
             AND deleted = 0
156 156
             ORDER BY event_date, chamber, pos",
157
-            array( ':date' => $date )
157
+            array(':date' => $date)
158 158
         );
159 159
 
160 160
         if (!$q->rows()) {
Please login to merge, or discard this patch.
classes/Utility/Hansard.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $parts = parse_url($url);
16 16
         parse_str($parts['query'], $query);
17 17
 
18
-        if ( $query['id'] ) {
18
+        if ($query['id']) {
19 19
             if (strpos($parts['path'], 'lords') !== false) {
20 20
                 $gid = 'uk.org.publicwhip/lords/';
21 21
             } elseif (strpos($parts['path'], 'whall') !== false) {
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
     public static function gid_to_url($gid) {
33
-        if ( !$gid ) {
33
+        if (!$gid) {
34 34
             return '';
35 35
         }
36 36
         global $hansardmajors;
37 37
         $db = new \ParlDB();
38 38
 
39
-        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ));
39
+        $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
40 40
         $url_gid = fix_gid_from_db($gid);
41 41
         $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q->field(0, 'major')]['page']);
42 42
         $url->insert(array('id' => $url_gid));
Please login to merge, or discard this patch.
classes/SectionView/NiView.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
     protected function getSearchSections() {
34 34
         return array(
35
-            array( 'section' => 'ni' )
35
+            array('section' => 'ni')
36 36
         );
37 37
     }
38 38
 
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 
53 53
         $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
54 54
         $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront');
55
-        $MOREURL->insert( array( 'more' => 1 ) );
55
+        $MOREURL->insert(array('more' => 1));
56 56
 
57 57
         // this makes sure that we don't repeat this debate in the list below
58 58
         $random_debate = NULL;
59
-        if ( isset($debates['data']) && count($debates['data']) ) {
59
+        if (isset($debates['data']) && count($debates['data'])) {
60 60
             $random_debate = $debates['data'][0];
61 61
         }
62 62
 
63 63
         $recent = array();
64
-        if ( isset($debates['data']) && count($debates['data']) ) {
64
+        if (isset($debates['data']) && count($debates['data'])) {
65 65
             // at the start of a session there may be less than 6
66 66
             // debates
67 67
             $max = 6;
68
-            if ( count($debates['data']) < 6 ) {
68
+            if (count($debates['data']) < 6) {
69 69
                 $max = count($debates['data']);
70 70
             }
71
-            for ( $i = 1; $i < $max; $i++ ) {
71
+            for ($i = 1; $i < $max; $i++) {
72 72
                 $debate = $debates['data'][$i];
73 73
                 $debate['desc'] = "Northern Ireland Assembly debates";
74 74
                 $debate['more_url'] = $MOREURL->generate();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         }
78 78
 
79 79
         $featured = array();
80
-        if ( $random_debate ) {
80
+        if ($random_debate) {
81 81
             $featured = $random_debate;
82 82
             $featured['more_url'] = $MOREURL->generate();
83 83
             $featured['desc'] = 'Northern Ireland Assembly debate';
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         $data['featured'] = $featured;
89
-        $data['debates'] = array( 'recent' => $recent);
89
+        $data['debates'] = array('recent' => $recent);
90 90
 
91 91
         $data['regional'] = $this->getMLAList();
92 92
         $data['template'] = 'ni/index';
Please login to merge, or discard this patch.
classes/Utility/LibFilter.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             }, $data);
210 210
 
211 211
         foreach (array_keys($this->tag_counts) as $tag) {
212
-            for ($i=0; $i<$this->tag_counts[$tag]; $i++) {
212
+            for ($i = 0; $i < $this->tag_counts[$tag]; $i++) {
213 213
                 $data .= "</$tag>";
214 214
             }
215 215
         }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
                 if (!in_array($name, $this->no_close)) {
229 229
                     if (isset($this->tag_counts[$name])) {
230 230
                         $this->tag_counts[$name]--;
231
-                        return '</'.$name.'>';
231
+                        return '</' . $name . '>';
232 232
                     }
233 233
                 }
234 234
             } else {
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
             $ending = $matches[3];
245 245
             if (in_array($name, array_keys($this->allowed))) {
246 246
                 $params = "";
247
-                preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER);		# <foo a="b" />
248
-                preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER);		# <foo a=b />
249
-                preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER);	# <foo a="b />
247
+                preg_match_all("/([a-z0-9]+)=([\"'])(.*?)\\2/si", $body, $matches_2, PREG_SET_ORDER); # <foo a="b" />
248
+                preg_match_all("/([a-z0-9]+)(=)([^\"\s']+)/si", $body, $matches_1, PREG_SET_ORDER); # <foo a=b />
249
+                preg_match_all("/([a-z0-9]+)=([\"'])([^\"']*?)\s*$/si", $body, $matches_3, PREG_SET_ORDER); # <foo a="b />
250 250
                 $matches = array_merge($matches_1, $matches_2, $matches_3);
251 251
 
252 252
                 foreach ($matches as $match) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 if ($ending) {
276 276
                     $ending = ' /';
277 277
                 }
278
-                return '<'.$name.$params.$ending.'>';
278
+                return '<' . $name . $params . $ending . '>';
279 279
             } else {
280 280
                 return '';
281 281
             }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
             if ($this->strip_comments) {
287 287
                 return '';
288 288
             } else {
289
-                return '<'.$data.'>';
289
+                return '<' . $data . '>';
290 290
             }
291 291
         }
292 292
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
         if (preg_match("/^([^:]+)\:/si", $data, $matches)) {
304 304
             if (!in_array($matches[1], $this->allowed_protocols)) {
305
-                $data = '#'.substr($data, strlen($matches[1])+1);
305
+                $data = '#' . substr($data, strlen($matches[1]) + 1);
306 306
             }
307 307
         }
308 308
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         # if there are less than 5, just allow it as-is
353 353
         #
354 354
 
355
-        if (strlen($data_notags)<5) {
355
+        if (strlen($data_notags) < 5) {
356 356
             return $data;
357 357
         }
358 358
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             $data
398 398
         );
399 399
 
400
-        return $m[1].$data.$m[3];
400
+        return $m[1] . $data . $m[3];
401 401
     }
402 402
 
403 403
     #####################################################################################
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
 
476 476
 
477
-        return $m[1].$m[2].$m[3];
477
+        return $m[1] . $m[2] . $m[3];
478 478
     }
479 479
 
480 480
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 
497 497
         if ($term != ';') {
498 498
 
499
-            return '&amp;'.$preamble;
499
+            return '&amp;' . $preamble;
500 500
         }
501 501
 
502 502
         #
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
         if ($this->is_valid_entity($preamble)) {
507 507
 
508
-            return '&'.$preamble;
508
+            return '&' . $preamble;
509 509
         }
510 510
 
511 511
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         # not an allowed antity, so escape the ampersand
514 514
         #
515 515
 
516
-        return '&amp;'.$preamble;
516
+        return '&amp;' . $preamble;
517 517
     }
518 518
 
519 519
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     # inside strings. within general text, we decode hex/dec entities.
563 563
     #
564 564
 
565
-    public function decode_entities($data, $in_attribute=1) {
565
+    public function decode_entities($data, $in_attribute = 1) {
566 566
 
567 567
         $data = preg_replace_callback('!(&)#(\d+);?!', array($this, 'decode_dec_entity'), $data);
568 568
         $data = preg_replace_callback('!(&)#x([0-9a-f]+);?!i', array($this, 'decode_hex_entity'), $data);
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
         #
604 604
 
605 605
         if ($d > 127) {
606
-            if ($orig_type == '%') { return '%'.dechex($d); }
606
+            if ($orig_type == '%') { return '%' . dechex($d); }
607 607
             if ($orig_type == '&') { return "&#$d;"; }
608 608
         }
609 609
 
Please login to merge, or discard this patch.
classes/Data.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function __construct() {
56 56
 
57
-        include_once METADATAPATH;	// defined in config.php
57
+        include_once METADATAPATH; // defined in config.php
58 58
 
59 59
     }
60 60
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
 
116 116
     public function set_page_metadata($page, $key, $value) {
117
-        $this->setMetadata(array("page"=>$page,"key"=>$key,"value"=>$value));
117
+        $this->setMetadata(array("page"=>$page, "key"=>$key, "value"=>$value));
118 118
     }
119 119
 
120 120
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
 
128 128
     public function set_section_metadata($section, $key, $value) {
129
-        $this->setMetadata(array("section"=>$section,"key"=>$key,"value"=>$value));
129
+        $this->setMetadata(array("section"=>$section, "key"=>$key, "value"=>$value));
130 130
     }
131 131
 
132 132
     /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
 
152 152
     public function test_for_metadata($type, $item, $key) {
153
-        $dataarray =& $this->$type;
153
+        $dataarray = & $this->$type;
154 154
 
155 155
         if (isset($dataarray[$item][$key])) {
156 156
             return true;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         }
160 160
     }
161 161
 
162
-    private function getMetadata($args="", $type) {
162
+    private function getMetadata($args = "", $type) {
163 163
         // $type is either 'page' or 'section'
164 164
         global $this_page, $this_section;
165 165
 
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
             $item = $args[$type];
168 168
             $key = $args['key'];
169 169
         } else {
170
-            $var = "this_".$type;
170
+            $var = "this_" . $type;
171 171
             $item = $$var; // $this_page or $this_section.
172 172
             $key = $args;
173 173
         }
174 174
 
175 175
         twfy_debug("DATA", "$type: $item, $key");
176
-        $dataarray =& $this->$type;
176
+        $dataarray = & $this->$type;
177 177
 
178 178
         if ($this->test_for_metadata($type, $item, $key)) {
179 179
             $return = $dataarray[$item][$key];
180
-            $debugtext = "Key: ".$type."[".$item."][".$key."]";
180
+            $debugtext = "Key: " . $type . "[" . $item . "][" . $key . "]";
181 181
 
182 182
         } elseif ($this->test_for_metadata($type, "default", $key)) {
183 183
             $return = $dataarray["default"][$key];
184
-            $debugtext = "Key: ".$type."['default'][".$key."]";
184
+            $debugtext = "Key: " . $type . "['default'][" . $key . "]";
185 185
 
186 186
         } else {
187 187
             $return = false;
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
         $key = $args["key"];
207 207
         $value = $args["value"];
208 208
 
209
-        twfy_debug("DATA", "Setting: ".$type."[".$item."][".$key."] = '" . print_r($value, 1) . "'");
209
+        twfy_debug("DATA", "Setting: " . $type . "[" . $item . "][" . $key . "] = '" . print_r($value, 1) . "'");
210 210
 
211
-        $dataarray =& $this->$type;
211
+        $dataarray = & $this->$type;
212 212
         $dataarray[$item][$key] = $value;
213 213
     }
214 214
 
Please login to merge, or discard this patch.
classes/Db/Connection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $duration = getmicrotime() - $start;
112 112
         global $mysqltotalduration;
113 113
         $mysqltotalduration += $duration;
114
-        twfy_debug ("SQL", "Complete after $duration seconds.");
114
+        twfy_debug("SQL", "Complete after $duration seconds.");
115 115
         // We could also output $q->mysql_info() here, but that's for
116 116
         // PHP >= 4.3.0.
117 117
         return $q;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function display_total_duration() {
128 128
         global $mysqltotalduration;
129
-        twfy_debug ("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds.");
129
+        twfy_debug("TIME", "Total time for MySQL queries on this page: " . $mysqltotalduration . " seconds.");
130 130
     }
131 131
 
132 132
     /**
Please login to merge, or discard this patch.
classes/Db/Query.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $this->conn = $conn;
88 88
     }
89 89
 
90
-    public function query($sql="", $params = NULL) {
90
+    public function query($sql = "", $params = NULL) {
91 91
 
92 92
         if (empty($sql)) {
93 93
             $this->success = false;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-        twfy_debug ("SQL", $sql);
105
-        twfy_debug ("SQL", print_r($params, 1));
104
+        twfy_debug("SQL", $sql);
105
+        twfy_debug("SQL", print_r($params, 1));
106 106
 
107 107
         if ($params !== NULL) {
108 108
             // Prepare and execute a statement
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         if (!$this->success) return;
135 135
 
136
-        if ( (!$pdoStatement) or (empty($pdoStatement)) ) {
136
+        if ((!$pdoStatement) or (empty($pdoStatement))) {
137 137
             // A failed query.
138 138
             $this->success = false;
139 139
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             }
156 156
             $this->affected_rows = $pdoStatement->rowCount();
157 157
 
158
-            twfy_debug ("SQLRESULT", array($this, 'displayResult'));
158
+            twfy_debug("SQLRESULT", array($this, 'displayResult'));
159 159
             // mysql_free_result($q);
160 160
         }
161 161
     }
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/comments_recent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $date = format_date($date, SHORTDATEFORMAT);
34 34
         $time = format_time($time, TIMEFORMAT);
35 35
 
36
-        $count = $n+1;
36
+        $count = $n + 1;
37 37
 
38 38
         $USERURL->insert(array('u'=>$comment['user_id']));
39 39
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     if ($this_page == 'home') {
48 48
         $MOREURL = new \MySociety\TheyWorkForYou\Url('comments_recent');
49 49
         ?>
50
-                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p>
50
+                        <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments']) + 1; ?>">See more annotations posted recently</a></p>
51 51
 <?php
52 52
     }
53 53
     if ($this_page != 'home') $PAGE->page_links($data);
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/calendar_date.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         print "<h2 class='calendar'>$chamber";
26 26
         if (in_array($major[$i], $data['majors'])) {
27 27
             $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']);
28
-            $URL->insert( array( 'd' => $date ) );
28
+            $URL->insert(array('d' => $date));
29 29
             print ' &nbsp; <a href="' . $URL->generate() . '">See this day &rarr;</a>';
30 30
         }
31 31
         print "</h2>\n";
Please login to merge, or discard this patch.