Failed Conditions
Pull Request — master (#1326)
by Nick
26:02 queued 20:44
created
www/docs/api/api_convertURL.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     $LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
41 41
     $fragment = '';
42 42
     if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
43
-        $LISTURL->insert( array( 'id' => $id_data['gid'] ) );
43
+        $LISTURL->insert(array('id' => $id_data['gid']));
44 44
     } else {
45 45
         $parent_epobject_id = $id_data['subsection_id'];
46 46
         $parent_gid = '';
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
                     ':epobject_id' => $parent_epobject_id
51 51
                     ));
52 52
         if ($r->rows() > 0) {
53
-            $parent_gid = fix_gid_from_db( $r->field(0, 'gid') );
53
+            $parent_gid = fix_gid_from_db($r->field(0, 'gid'));
54 54
         }
55 55
         if ($parent_gid != '') {
56
-            $LISTURL->insert( array( 'id' => $parent_gid ) );
57
-            $fragment = '#g' . gid_to_anchor($id_data['gid']);
56
+            $LISTURL->insert(array('id' => $parent_gid));
57
+            $fragment = '#g'.gid_to_anchor($id_data['gid']);
58 58
         }
59 59
     }
60
-    return $LISTURL->generate('none') . $fragment;
60
+    return $LISTURL->generate('none').$fragment;
61 61
 }
62 62
 
63 63
 function api_converturl_url_output($q) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     $url = get_listurl($q);
66 66
     $output = array(
67 67
         'gid' => $gid,
68
-        'url' => 'https://www.theyworkforyou.com' . $url
68
+        'url' => 'https://www.theyworkforyou.com'.$url
69 69
     );
70 70
     api_output($output);
71 71
 }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         return api_converturl_url_output($q);
80 80
 
81 81
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
82
-        ':url' => $url_nohash . '%'
82
+        ':url' => $url_nohash.'%'
83 83
         ));
84 84
     if ($q->rows())
85 85
         return api_converturl_url_output($q);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
88 88
     if ($url_bound != $url_nohash) {
89 89
         $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
90
-            ':url' => $url_bound . '%'
90
+            ':url' => $url_bound.'%'
91 91
             ));
92 92
         if ($q->rows())
93 93
             return api_converturl_url_output($q);
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,22 +75,25 @@
 block discarded – undo
75 75
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array(
76 76
         ':url' => $url
77 77
         ));
78
-    if ($q->rows())
79
-        return api_converturl_url_output($q);
78
+    if ($q->rows()) {
79
+            return api_converturl_url_output($q);
80
+    }
80 81
 
81 82
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
82 83
         ':url' => $url_nohash . '%'
83 84
         ));
84
-    if ($q->rows())
85
-        return api_converturl_url_output($q);
85
+    if ($q->rows()) {
86
+            return api_converturl_url_output($q);
87
+    }
86 88
 
87 89
     $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
88 90
     if ($url_bound != $url_nohash) {
89 91
         $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
90 92
             ':url' => $url_bound . '%'
91 93
             ));
92
-        if ($q->rows())
93
-            return api_converturl_url_output($q);
94
+        if ($q->rows()) {
95
+                    return api_converturl_url_output($q);
96
+        }
94 97
     }
95 98
     api_error('Sorry, URL could not be converted');
96 99
 }
Please login to merge, or discard this patch.
www/docs/api/api_getLords.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getMembers.php';
3
+include_once dirname(__FILE__).'/api_getMembers.php';
4 4
 
5 5
 function api_getLords_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getPerson.php 4 patches
Spacing   +13 added lines, -13 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_getPerson_front() {
6 6
 ?>
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party = FALSE) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
     }
27 27
     if ($row['house'] == 1) {
28 28
         $URL = new URL('mp');
29
-        $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
29
+        $row['url'] = $URL->generate('none').make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31 31
     if ($has_party && isset($parties[$row['party']]))
32 32
         $row['party'] = $parties[$row['party']];
33
-    list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
33
+    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 34
     if ($image) {
35
-        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
35
+        list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR.'/images/', $image));
36 36
         $row['image'] = $image;
37 37
         $row['image_height'] = $height;
38 38
         $row['image_width'] = $width;
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
     if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || (isset($dissolution[1]) && $row['left_house'] == $dissolution[1]))) {
43 43
         # Ministerialships and Select Committees
44 44
         $db = new ParlDB;
45
-        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
46
-        for ($i=0; $i<$q->rows(); $i++) {
45
+        $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person='.$row['person_id'].' ORDER BY from_date DESC');
46
+        for ($i = 0; $i < $q->rows(); $i++) {
47 47
             $row['office'][] = $q->row($i);
48 48
         }
49 49
     }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     return $row;
56 56
 }
57 57
 
58
-function api_getPerson_id($id, $house='') {
58
+function api_getPerson_id($id, $house = '') {
59 59
     $db = new ParlDB;
60 60
     $params = array(
61 61
         ':person_id' => $id
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
-function _api_getPerson_output($q, $flatten=false) {
80
+function _api_getPerson_output($q, $flatten = false) {
81 81
     $output = array();
82 82
     $last_mod = 0;
83
-    for ($i=0; $i<$q->rows(); $i++) {
83
+    for ($i = 0; $i < $q->rows(); $i++) {
84 84
         $house = $q->field($i, 'house');
85 85
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 86
         $output[] = $out;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
     $cons_params = array();
150 150
     $params = array(':house' => $house);
151 151
     foreach ($cons as $key => $constituency) {
152
-        $cons_params[] = ':constituency' . $key;
153
-        $params[':constituency' . $key] = $constituency;
152
+        $cons_params[] = ':constituency'.$key;
153
+        $params[':constituency'.$key] = $constituency;
154 154
     }
155 155
 
156 156
     $query_base = "SELECT member.*, p.title, p.given_name, p.family_name, p.lordofname
157 157
         FROM member, person_names p
158
-        WHERE constituency in (" . join(",", $cons_params) . ")
158
+        WHERE constituency in (" . join(",", $cons_params).")
159 159
             AND member.person_id = p.person_id AND p.type = 'name'
160 160
             AND p.start_date <= left_house AND left_house <= p.end_date
161 161
         AND house = :house";
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new URL('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
         $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true);
86 89
         $output[] = $out;
87 90
         $time = strtotime($q->field($i, 'lastupdate'));
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
91
+        if ($time > $last_mod) {
92
+                    $last_mod = $time;
93
+        }
90 94
     }
91 95
     # Only one MP, not an array
92 96
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -134,13 +138,18 @@  discard block
 block discarded – undo
134 138
 
135 139
     $cons = array();
136 140
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
141
+        if ($constituency == '') {
142
+            continue;
143
+        }
144
+        if ($constituency == 'Orkney ') {
145
+                    $constituency = 'Orkney & Shetland';
146
+        }
140 147
 
141 148
         if ($house == HOUSE_TYPE_COMMONS) {
142 149
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
150
+            if ($normalised) {
151
+                $constituency = $normalised;
152
+            }
144 153
         }
145 154
 
146 155
         $cons[] = $constituency;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party=false) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -77,6 +77,9 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
+/**
81
+ * @param MySociety\TheyWorkForYou\Db\Query $q
82
+ */
80 83
 function _api_getPerson_output($q, $flatten=false) {
81 84
     $output = array();
82 85
     $last_mod = 0;
@@ -95,10 +98,16 @@  discard block
 block discarded – undo
95 98
     api_output($output, $last_mod);
96 99
 }
97 100
 
101
+/**
102
+ * @param integer $house
103
+ */
98 104
 function api_getPerson_constituency($constituency, $house) {
99 105
     _api_getPerson_constituency(array($constituency), $house);
100 106
 }
101 107
 
108
+/**
109
+ * @param integer $house
110
+ */
102 111
 function api_getPerson_postcode($pc, $house) {
103 112
     $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc);
104 113
     $types = array();
Please login to merge, or discard this patch.
www/docs/api/api_getLord.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getPerson.php';
3
+include_once dirname(__FILE__).'/api_getPerson.php';
4 4
 
5 5
 function api_getLord_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getComments.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 }
25 25
 
26 26
 function api_getComments_start_date($start_date) {
27
-        $args = array (
27
+        $args = array(
28 28
             'start_date' => $start_date,
29 29
             'end_date' => get_http_var('end_date')
30 30
         );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 }
34 34
 
35 35
 function api_getComments_search($s) {
36
-        $args = array (
36
+        $args = array(
37 37
             's' => $s,
38 38
             'p' => get_http_var('page'),
39 39
             'num' => get_http_var('num'),
Please login to merge, or discard this patch.
www/docs/api/api_getMLA.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH . 'easyparliament/member.php';
4
-include_once dirname(__FILE__) . '/api_getPerson.php';
3
+include_once INCLUDESPATH.'easyparliament/member.php';
4
+include_once dirname(__FILE__).'/api_getPerson.php';
5 5
 
6 6
 function api_getMLA_front() {
7 7
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getMSPs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getMembers.php';
3
+include_once dirname(__FILE__).'/api_getMembers.php';
4 4
 
5 5
 function api_getMSPs_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getWMS.php 1 patch
Spacing   +3 added lines, -3 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 dirname(__FILE__) . '/api_getHansard.php';
3
+include_once dirname(__FILE__).'/api_getHansard.php';
4 4
 
5 5
 function api_getWMS_front() {
6 6
 ?>
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     _api_getHansard_year('WMS', $y);
101 101
 }
102 102
 function api_getWMS_search($s) {
103
-    _api_getHansard_search( array(
103
+    _api_getHansard_search(array(
104 104
         's' => $s,
105 105
         'pid' => get_http_var('person'),
106 106
         'type' => 'wms',
107
-    ) );
107
+    ));
108 108
 }
109 109
 function api_getWMS_person($pid) {
110 110
     _api_getHansard_search(array(
Please login to merge, or discard this patch.
www/docs/api/api_getMPsInfo.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     $db = new ParlDB;
28 28
     $last_mod = 0;
29 29
     $q = $db->query("select person_id, data_key, data_value, lastupdate from personinfo
30
-        where person_id in (" . $ids . ")");
30
+        where person_id in (" . $ids.")");
31 31
     if ($q->rows()) {
32 32
         $output = array();
33
-        for ($i=0; $i<$q->rows(); $i++) {
33
+        for ($i = 0; $i < $q->rows(); $i++) {
34 34
             $data_key = $q->field($i, 'data_key');
35 35
             if (count($fields) && !in_array($data_key, $fields))
36 36
                 continue;
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
                 $last_mod = $time;
42 42
         }
43 43
         $q = $db->query("select memberinfo.*, person_id from memberinfo, member
44
-            where memberinfo.member_id=member.member_id and person_id in (" . $ids . ")
44
+            where memberinfo.member_id=member.member_id and person_id in (" . $ids.")
45 45
             order by person_id,member_id");
46 46
         if ($q->rows()) {
47
-            for ($i=0; $i<$q->rows(); $i++) {
47
+            for ($i = 0; $i < $q->rows(); $i++) {
48 48
                 $data_key = $q->field($i, 'data_key');
49 49
                 if (count($fields) && !in_array($data_key, $fields))
50 50
                     continue;
Please login to merge, or discard this patch.
Braces   +21 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
     $ids = preg_split('#\s*,\s*#', $ids, -1, PREG_SPLIT_NO_EMPTY);
21 21
     $safe_ids = array(0);
22 22
     foreach ($ids as $id) {
23
-        if (ctype_digit($id)) $safe_ids[] = $id;
23
+        if (ctype_digit($id)) {
24
+            $safe_ids[] = $id;
25
+        }
24 26
     }
25 27
     $ids = join(',', $safe_ids);
26 28
 
@@ -32,13 +34,15 @@  discard block
 block discarded – undo
32 34
         $output = array();
33 35
         for ($i=0; $i<$q->rows(); $i++) {
34 36
             $data_key = $q->field($i, 'data_key');
35
-            if (count($fields) && !in_array($data_key, $fields))
36
-                continue;
37
+            if (count($fields) && !in_array($data_key, $fields)) {
38
+                            continue;
39
+            }
37 40
             $pid = $q->field($i, 'person_id');
38 41
             $output[$pid][$data_key] = $q->field($i, 'data_value');
39 42
             $time = strtotime($q->field($i, 'lastupdate'));
40
-            if ($time > $last_mod)
41
-                $last_mod = $time;
43
+            if ($time > $last_mod) {
44
+                            $last_mod = $time;
45
+            }
42 46
         }
43 47
         $q = $db->query("select memberinfo.*, person_id from memberinfo, member
44 48
             where memberinfo.member_id=member.member_id and person_id in (" . $ids . ")
@@ -46,16 +50,22 @@  discard block
 block discarded – undo
46 50
         if ($q->rows()) {
47 51
             for ($i=0; $i<$q->rows(); $i++) {
48 52
                 $data_key = $q->field($i, 'data_key');
49
-                if (count($fields) && !in_array($data_key, $fields))
50
-                    continue;
53
+                if (count($fields) && !in_array($data_key, $fields)) {
54
+                                    continue;
55
+                }
51 56
                 $mid = $q->field($i, 'member_id');
52 57
                 $pid = $q->field($i, 'person_id');
53
-                if (!isset($output[$pid]['by_member_id'])) $output[$pid]['by_member_id'] = array();
54
-                if (!isset($output[$pid]['by_member_id'][$mid])) $output[$pid]['by_member_id'][$mid] = array();
58
+                if (!isset($output[$pid]['by_member_id'])) {
59
+                    $output[$pid]['by_member_id'] = array();
60
+                }
61
+                if (!isset($output[$pid]['by_member_id'][$mid])) {
62
+                    $output[$pid]['by_member_id'][$mid] = array();
63
+                }
55 64
                 $output[$pid]['by_member_id'][$mid][$data_key] = $q->field($i, 'data_value');
56 65
                 $time = strtotime($q->field($i, 'lastupdate'));
57
-                if ($time > $last_mod)
58
-                    $last_mod = $time;
66
+                if ($time > $last_mod) {
67
+                                    $last_mod = $time;
68
+                }
59 69
             }
60 70
         }
61 71
         ksort($output);
Please login to merge, or discard this patch.