| @@ -130,7 +130,7 @@ | ||
| 130 | 130 |        <?php } elseif ($step !== '') { ?> | 
| 131 | 131 | <?php include '_alert_form.php'; | 
| 132 | 132 |        } elseif ($this_step == '') { | 
| 133 | - if( | |
| 133 | + if ( | |
| 134 | 134 | !$results && ( | 
| 135 | 135 | $members || | 
| 136 | 136 | (isset($constituencies) && count($constituencies) > 0) || | 
| @@ -350,7 +350,7 @@ | ||
| 350 | 350 | $members_from_names = []; | 
| 351 | 351 | $names_from_pids = array_values(\MySociety\TheyWorkForYou\Utility\Search::speakerNamesForIDs($text)); | 
| 352 | 352 |              foreach ($names_from_pids as $name) { | 
| 353 | - $members_from_names = array_merge($members_from_names,\MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookupWithNames($name)); | |
| 353 | + $members_from_names = array_merge($members_from_names, \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookupWithNames($name)); | |
| 354 | 354 | } | 
| 355 | 355 | $members_from_words = \MySociety\TheyWorkForYou\Utility\Search::searchMemberDbLookupWithNames($text, true); | 
| 356 | 356 | $this->data['members'] = array_merge($members_from_words, $members_from_names); | 
| @@ -105,7 +105,7 @@ | ||
| 105 | 105 | |
| 106 | 106 | # and then create an array with the words and phrases | 
| 107 | 107 | $criteria = []; | 
| 108 | -                if ( $alert_criteria != "") { | |
| 108 | +                if ($alert_criteria != "") { | |
| 109 | 109 |                      $criteria = explode(' ', $alert_criteria); | 
| 110 | 110 | } | 
| 111 | 111 | $criteria = array_merge($criteria, $phrases[1]); | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | } | 
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | -        uasort($speakers, function ($a, $b) { | |
| 116 | +        uasort($speakers, function($a, $b) { | |
| 117 | 117 | |
| 118 | 118 |              if ($a['count'] > $b['count']) { | 
| 119 | 119 | return -1; | 
| @@ -249,18 +249,18 @@ discard block | ||
| 249 | 249 | * saying whether it was a postcode used. | 
| 250 | 250 | */ | 
| 251 | 251 | |
| 252 | -    public static function searchConstituenciesByQuery($searchterm, $mp_only=true) { | |
| 252 | +    public static function searchConstituenciesByQuery($searchterm, $mp_only = true) { | |
| 253 | 253 |          if (validate_postcode($searchterm)) { | 
| 254 | 254 | // Looks like a postcode - can we find the constituency? | 
| 255 | 255 |              if ($mp_only) { | 
| 256 | 256 | $constituency = Postcode::postcodeToConstituency($searchterm); | 
| 257 | 257 |                  if ($constituency) { | 
| 258 | - return [ [$constituency], true ]; | |
| 258 | + return [[$constituency], true]; | |
| 259 | 259 | } | 
| 260 | 260 |              } else { | 
| 261 | 261 | $constituencies = Postcode::postcodeToConstituencies($searchterm); | 
| 262 | 262 |                  if ($constituencies) { | 
| 263 | - return [ $constituencies, true ]; | |
| 263 | + return [$constituencies, true]; | |
| 264 | 264 | } | 
| 265 | 265 | } | 
| 266 | 266 | } | 
| @@ -279,7 +279,7 @@ discard block | ||
| 279 | 279 | $constituencies[] = $row['name']; | 
| 280 | 280 | } | 
| 281 | 281 | |
| 282 | - return [ $constituencies, false ]; | |
| 282 | + return [$constituencies, false]; | |
| 283 | 283 | } | 
| 284 | 284 | |
| 285 | 285 | /** | 
| @@ -21,11 +21,11 @@ discard block | ||
| 21 | 21 | |
| 22 | 22 |      public function testConstituencySearch() { | 
| 23 | 23 | $this->assertEquals( | 
| 24 | - [ [ 'Alyn and Deeside' ], false ], | |
| 24 | + [['Alyn and Deeside'], false], | |
| 25 | 25 |              \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn') | 
| 26 | 26 | ); | 
| 27 | 27 | $this->assertEquals( | 
| 28 | - [ [ 'Alyn and Deeside' ], false ], | |
| 28 | + [['Alyn and Deeside'], false], | |
| 29 | 29 |              \MySociety\TheyWorkForYou\Utility\Search::searchConstituenciesByQuery('Alyn and Deeside') | 
| 30 | 30 | ); | 
| 31 | 31 | } | 
| @@ -109,7 +109,7 @@ discard block | ||
| 109 | 109 | * @group xapian | 
| 110 | 110 | */ | 
| 111 | 111 |      public function testSearchPage() { | 
| 112 | - $page = $this->fetch_page([ ]); | |
| 112 | + $page = $this->fetch_page([]); | |
| 113 | 113 |          $this->assertStringContainsString('Search', $page); | 
| 114 | 114 | } | 
| 115 | 115 | |
| @@ -119,7 +119,7 @@ discard block | ||
| 119 | 119 | * @group xapian | 
| 120 | 120 | */ | 
| 121 | 121 |      public function testSearchPageMP() { | 
| 122 | - $page = $this->fetch_page([ 'q' => 'Mary Smith' ]); | |
| 122 | + $page = $this->fetch_page(['q' => 'Mary Smith']); | |
| 123 | 123 |          $this->assertStringContainsString('Mary Smith', $page); | 
| 124 | 124 |          $this->assertMatchesRegularExpression('/MP *for Amber Valley/', $page); | 
| 125 | 125 | } | 
| @@ -130,7 +130,7 @@ discard block | ||
| 130 | 130 | * @group xapian | 
| 131 | 131 | */ | 
| 132 | 132 |      public function testSearchPageMultipleMP() { | 
| 133 | - $page = $this->fetch_page([ 'q' => 'Jones' ]); | |
| 133 | + $page = $this->fetch_page(['q' => 'Jones']); | |
| 134 | 134 |          $this->assertStringContainsString('People matching <em class="current-search-term">Jones</em>', $page); | 
| 135 | 135 |          $this->assertStringContainsString('Andrew Jones', $page); | 
| 136 | 136 |          $this->assertStringContainsString('Simon Jones', $page); | 
| @@ -142,7 +142,7 @@ discard block | ||
| 142 | 142 | * @group xapian | 
| 143 | 143 | */ | 
| 144 | 144 |      public function testSearchPageCons() { | 
| 145 | - $page = $this->fetch_page([ 'q' => 'Amber' ]); | |
| 145 | + $page = $this->fetch_page(['q' => 'Amber']); | |
| 146 | 146 |          $this->assertStringContainsString('MP for <em class="current-search-term">Amber</em>', $page); | 
| 147 | 147 |          $this->assertStringContainsString('Mary Smith', $page); | 
| 148 | 148 | } | 
| @@ -154,7 +154,7 @@ discard block | ||
| 154 | 154 | * @group xapian | 
| 155 | 155 | */ | 
| 156 | 156 |      public function testSearchPageConsWithNoMp() { | 
| 157 | - $page = $this->fetch_page([ 'q' => 'Alyn' ]); | |
| 157 | + $page = $this->fetch_page(['q' => 'Alyn']); | |
| 158 | 158 |          $this->assertStringNotContainsString('MP for <em class="current-search-term">Alyn</em>', $page); | 
| 159 | 159 |          $this->assertStringNotContainsString('MPs in constituencies matching', $page); | 
| 160 | 160 | } | 
| @@ -166,7 +166,7 @@ discard block | ||
| 166 | 166 | * @group xapian | 
| 167 | 167 | */ | 
| 168 | 168 |      public function testSearchPageMultipleCons() { | 
| 169 | - $page = $this->fetch_page([ 'q' => 'Liverpool' ]); | |
| 169 | + $page = $this->fetch_page(['q' => 'Liverpool']); | |
| 170 | 170 |          $this->assertStringContainsString('MPs in constituencies matching <em class="current-search-term">Liverpool</em>', $page); | 
| 171 | 171 |          $this->assertStringContainsString('Susan Brown', $page); | 
| 172 | 172 |          $this->assertMatchesRegularExpression('/MP *for Liverpool, Riverside/', $page); | 
| @@ -180,7 +180,7 @@ discard block | ||
| 180 | 180 | * @group xapian | 
| 181 | 181 | */ | 
| 182 | 182 |      public function testSearchPageGlossary() { | 
| 183 | - $page = $this->fetch_page([ 'q' => 'other place' ]); | |
| 183 | + $page = $this->fetch_page(['q' => 'other place']); | |
| 184 | 184 |          $this->assertStringContainsString('Glossary items matching', $page); | 
| 185 | 185 |          $this->assertStringContainsString('<a href="/glossary/?gl=1">“other place', $page); | 
| 186 | 186 | } | 
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | * @group xapian | 
| 192 | 192 | */ | 
| 193 | 193 |      public function testSearchPageSpellCorrect() { | 
| 194 | - $page = $this->fetch_page([ 'q' => 'plice' ]); | |
| 194 | + $page = $this->fetch_page(['q' => 'plice']); | |
| 195 | 195 |          $this->assertStringContainsString('Did you mean <a href="/search/?q=place">place', $page); | 
| 196 | 196 | } | 
| 197 | 197 | |
| @@ -201,7 +201,7 @@ discard block | ||
| 201 | 201 | * @group xapian | 
| 202 | 202 | */ | 
| 203 | 203 |      public function testSearchBySpeakerNoResults() { | 
| 204 | - $page = $this->fetch_page([ 'q' => 'splice', 'o' => 'p' ]); | |
| 204 | + $page = $this->fetch_page(['q' => 'splice', 'o' => 'p']); | |
| 205 | 205 |          $this->assertStringContainsString('Who says splice the most', $page); | 
| 206 | 206 |          $this->assertStringContainsString('No results', $page); | 
| 207 | 207 | } | 
| @@ -228,7 +228,7 @@ discard block | ||
| 228 | 228 | * @group xapian | 
| 229 | 229 | */ | 
| 230 | 230 |      public function testSearchPageRSS() { | 
| 231 | - $page = $this->fetch_page([ 'q' => 'test' ]); | |
| 231 | + $page = $this->fetch_page(['q' => 'test']); | |
| 232 | 232 |          $this->assertStringContainsString('<a href="/search/rss/?s=test">get an RSS feed', $page); | 
| 233 | 233 | } | 
| 234 | 234 | |
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 | public $token_checked = null; | 
| 41 | 41 | private $alert_id = ""; | 
| 42 | 42 | public $email = ""; | 
| 43 | - public $criteria = ""; // Sets the terms that are used to produce the search results. | |
| 43 | + public $criteria = ""; // Sets the terms that are used to produce the search results. | |
| 44 | 44 | public $ignore_speaker_votes = 0; | 
| 45 | 45 | |
| 46 | 46 | private $db; | 
| @@ -72,7 +72,7 @@ discard block | ||
| 72 | 72 | $contents = ['criteria' => $row['criteria'], 'count' => $row['cnt']]; | 
| 73 | 73 | $data[] = $contents; | 
| 74 | 74 | } | 
| 75 | - $data = ['alerts' => $data]; | |
| 75 | + $data = ['alerts' => $data]; | |
| 76 | 76 | return $data; | 
| 77 | 77 | } | 
| 78 | 78 | |
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 | |
| 102 | 102 | $data = $q->fetchAll(); | 
| 103 | 103 | $info = "Alert"; | 
| 104 | - $data = ['info' => $info, 'data' => $data]; | |
| 104 | + $data = ['info' => $info, 'data' => $data]; | |
| 105 | 105 | |
| 106 | 106 | return $data; | 
| 107 | 107 | } | 
| @@ -300,12 +300,12 @@ discard block | ||
| 300 | 300 | } | 
| 301 | 301 | |
| 302 | 302 | // Arrays we need to send a templated email. | 
| 303 | - $data = [ | |
| 303 | + $data = [ | |
| 304 | 304 | 'to' => $details['email'], | 
| 305 | 305 | 'template' => 'alert_confirmation', | 
| 306 | 306 | ]; | 
| 307 | 307 | |
| 308 | - $merge = [ | |
| 308 | + $merge = [ | |
| 309 | 309 | 'CONFIRMURL' => $confirmurl, | 
| 310 | 310 | 'CRITERIA' => $this->criteria_pretty(), | 
| 311 | 311 | ]; | 
| @@ -319,7 +319,7 @@ discard block | ||
| 319 | 319 | } | 
| 320 | 320 | |
| 321 | 321 |      public function send_already_signedup_email($details) { | 
| 322 | - $data = [ | |
| 322 | + $data = [ | |
| 323 | 323 | 'to' => $details['email'], | 
| 324 | 324 | 'template' => 'alert_already_signedup', | 
| 325 | 325 | ]; | 
| @@ -327,7 +327,7 @@ discard block | ||
| 327 | 327 | $criteria = \MySociety\TheyWorkForYou\Utility\Alert::detailsToCriteria($details); | 
| 328 | 328 | $this->criteria = $criteria; | 
| 329 | 329 | |
| 330 | - $merge = [ | |
| 330 | + $merge = [ | |
| 331 | 331 | 'CRITERIA' => $this->criteria_pretty(), | 
| 332 | 332 | ]; | 
| 333 | 333 | |
| @@ -25,66 +25,66 @@ discard block | ||
| 25 | 25 | } | 
| 26 | 26 | |
| 27 | 27 |      public function testKeywordOnly() { | 
| 28 | - $page = $this->fetch_page([ 'alertsearch' => 'elephant']); | |
| 28 | + $page = $this->fetch_page(['alertsearch' => 'elephant']); | |
| 29 | 29 |          $this->assertStringContainsString('What word or phrase would you like to receive alerts about', $page); | 
| 30 | 30 |          $this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value="elephant"', $page); | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | 33 |      public function testSpeakerId() { | 
| 34 | - $page = $this->fetch_page([ 'alertsearch' => 'speaker:2']); | |
| 34 | + $page = $this->fetch_page(['alertsearch' => 'speaker:2']); | |
| 35 | 35 |          $this->assertStringContainsString('Mrs Test Current-MP', $page); | 
| 36 | 36 | } | 
| 37 | 37 | |
| 38 | 38 |      public function testPostCodeOnly() { | 
| 39 | - $page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE']); | |
| 39 | + $page = $this->fetch_page(['alertsearch' => 'SE17 3HE']); | |
| 40 | 40 |          $this->assertStringContainsString('Mrs Test Current-MP', $page); | 
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | 43 |      public function testPostCodeWithKeyWord() { | 
| 44 | - $page = $this->fetch_page([ 'alertsearch' => 'SE17 3HE elephant']); | |
| 44 | + $page = $this->fetch_page(['alertsearch' => 'SE17 3HE elephant']); | |
| 45 | 45 |          $this->assertStringContainsString('You have used a postcode and something else', $page); | 
| 46 | 46 |          $this->assertStringContainsString('Mentions of [elephant] by your MP, Mrs Test Current-MP', $page); | 
| 47 | 47 |          $this->assertStringNotContainsString('by your MSP', $page); | 
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 |      public function testScottishPostcodeWithKeyword() { | 
| 51 | - $page = $this->fetch_page([ 'alertsearch' => 'PH6 2DB elephant']); | |
| 51 | + $page = $this->fetch_page(['alertsearch' => 'PH6 2DB elephant']); | |
| 52 | 52 |          $this->assertStringContainsString('You have used a postcode and something else', $page); | 
| 53 | 53 |          $this->assertStringContainsString('Mentions of [elephant] by your MP, Mr Test2 Current-MP', $page); | 
| 54 | 54 |          $this->assertStringContainsString('Mentions of [elephant] by your MSP, Mrs Test Current-MSP', $page); | 
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | 57 |      public function testPostcodeAndKeywordWithNoSittingMP() { | 
| 58 | - $page = $this->fetch_page([ 'alertsearch' => 'OX1 4LF elephant']); | |
| 58 | + $page = $this->fetch_page(['alertsearch' => 'OX1 4LF elephant']); | |
| 59 | 59 |          $this->assertStringContainsString('You have used a postcode and something else', $page); | 
| 60 | 60 |          $this->assertStringNotContainsString('Did you mean to get alerts for when your MP', $page); | 
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 |      public function testBasicKeyWordAlertsCreation() { | 
| 64 | - $page = $this->fetch_page([ 'step' => 'define']); | |
| 64 | + $page = $this->fetch_page(['step' => 'define']); | |
| 65 | 65 |          $this->assertStringContainsString('What word or phrase would you like to receive alerts about', $page); | 
| 66 | 66 |          $this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | 
| 67 | 67 | |
| 68 | - $page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => 'fish']); | |
| 68 | + $page = $this->fetch_page(['step' => 'review', 'email' => '[email protected]', 'words[]' => 'fish']); | |
| 69 | 69 |          $this->assertStringContainsString('Review Your Alert', $page); | 
| 70 | 70 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | 
| 71 | 71 | |
| 72 | - $page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => 'fish']); | |
| 72 | + $page = $this->fetch_page(['step' => 'confirm', 'email' => '[email protected]', 'words[]' => 'fish']); | |
| 73 | 73 |          $this->assertStringContainsString('We’re nearly done', $page); | 
| 74 | 74 |          $this->assertStringContainsString('You should receive an email shortly', $page); | 
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 |      public function testMultipleKeyWordAlertsCreation() { | 
| 78 | - $page = $this->fetch_page([ 'step' => 'define']); | |
| 78 | + $page = $this->fetch_page(['step' => 'define']); | |
| 79 | 79 |          $this->assertStringContainsString('What word or phrase would you like to receive alerts about', $page); | 
| 80 | 80 |          $this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | 
| 81 | 81 | |
| 82 | - $page = $this->fetch_page([ 'step' => 'review', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | |
| 82 | + $page = $this->fetch_page(['step' => 'review', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | |
| 83 | 83 |          $this->assertStringContainsString('Review Your Alert', $page); | 
| 84 | 84 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | 
| 85 | 85 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); | 
| 86 | 86 | |
| 87 | - $page = $this->fetch_page([ 'step' => 'confirm', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | |
| 87 | + $page = $this->fetch_page(['step' => 'confirm', 'email' => '[email protected]', 'words[]' => ['fish', 'salmon']]); | |
| 88 | 88 |          $this->assertStringContainsString('You should receive an email shortly', $page); | 
| 89 | 89 | } | 
| 90 | 90 | |
| @@ -93,12 +93,12 @@ discard block | ||
| 93 | 93 |          $this->assertStringContainsString('What word or phrase would you like to receive alerts about', $page); | 
| 94 | 94 |          $this->assertStringContainsString('<input type="text" id="words0" name="words[]" aria-required="true" value=""', $page); | 
| 95 | 95 | |
| 96 | - $page = $this->get_page([ 'step' => 'review', 'words[]' => ['fish', 'salmon']]); | |
| 96 | + $page = $this->get_page(['step' => 'review', 'words[]' => ['fish', 'salmon']]); | |
| 97 | 97 |          $this->assertStringContainsString('Review Your Alert', $page); | 
| 98 | 98 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | 
| 99 | 99 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="salmon"', $page); | 
| 100 | 100 | |
| 101 | - $page = $this->get_page([ 'step' => 'confirm', 'words[]' => ['fish', 'salmon']]); | |
| 101 | + $page = $this->get_page(['step' => 'confirm', 'words[]' => ['fish', 'salmon']]); | |
| 102 | 102 |          $this->assertStringContainsString('You will now receive email alerts on any day when [fish salmon] is mentioned in parliament', $page); | 
| 103 | 103 | } | 
| 104 | 104 | |
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 |          $this->assertStringContainsString('<input type="hidden" name="words[]" value="fish"', $page); | 
| 126 | 126 |          $this->assertStringContainsString('<input type="hidden" name="representative" value="Mrs Test Current-MP"', $page); | 
| 127 | 127 | |
| 128 | - $page = $this->get_page([ 'step' => 'confirm', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); | |
| 128 | + $page = $this->get_page(['step' => 'confirm', 'words[]' => 'fish', 'representative' => 'Mrs Test Current-MP']); | |
| 129 | 129 |          $this->assertStringContainsString('You will now receive email alerts on any day when Mrs Test Current-MP mentions [fish] in parliament', $page); | 
| 130 | 130 | } | 
| 131 | 131 | } |