Skip to content

Commit e8ae83a

Browse files
committed
Add soft @return type declarations to interfaces and base classes
1 parent a9653d7 commit e8ae83a

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed

UPGRADING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Upgrade notes for FriendsOfBehat/MinkExtension
2+
3+
This document summarizes the changes relevant for users when upgrading to new versions.
4+
5+
# Upgrade to 2.8
6+
7+
## Soft `@return` types added
8+
9+
`@return` type hints have been added to the `MinkAwareContext` and `DriverFactory` interfaces and to all methods
10+
in `MinkContext` and `RawMinkContext`.
11+
12+
If you implement or extend these classes or any of the drivers shipped here, make sure to add _real_ corresponding
13+
return types to your implementations now. Signatures will be changed to include return types in the next major version.

src/Behat/MinkExtension/Context/MinkAwareContext.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ interface MinkAwareContext extends Context
2424
* Sets Mink instance.
2525
*
2626
* @param Mink $mink Mink session manager
27+
*
28+
* @return void
2729
*/
2830
public function setMink(Mink $mink);
2931

3032
/**
3133
* Sets parameters provided for Mink.
3234
*
3335
* @param array $parameters
36+
*
37+
* @return void
3438
*/
3539
public function setMinkParameters(array $parameters);
3640
}

src/Behat/MinkExtension/Context/MinkContext.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class MinkContext extends RawMinkContext implements TranslatableContext
2929
*
3030
* @Given /^(?:|I )am on (?:|the )homepage$/
3131
* @When /^(?:|I )go to (?:|the )homepage$/
32+
*
33+
* @return void
3234
*/
3335
public function iAmOnHomepage()
3436
{
@@ -43,6 +45,8 @@ public function iAmOnHomepage()
4345
*
4446
* @Given /^(?:|I )am on "(?P<page>[^"]+)"$/
4547
* @When /^(?:|I )go to "(?P<page>[^"]+)"$/
48+
*
49+
* @return void
4650
*/
4751
public function visit($page)
4852
{
@@ -55,6 +59,8 @@ public function visit($page)
5559
* Example: And I reload the page
5660
*
5761
* @When /^(?:|I )reload the page$/
62+
*
63+
* @return void
5864
*/
5965
public function reload()
6066
{
@@ -66,6 +72,8 @@ public function reload()
6672
* Example: When I move backward one page
6773
*
6874
* @When /^(?:|I )move backward one page$/
75+
*
76+
* @return void
6977
*/
7078
public function back()
7179
{
@@ -77,6 +85,8 @@ public function back()
7785
* Example: And I move forward one page
7886
*
7987
* @When /^(?:|I )move forward one page$/
88+
*
89+
* @return void
8090
*/
8191
public function forward()
8292
{
@@ -89,6 +99,8 @@ public function forward()
8999
* Example: And I press "Log In"
90100
*
91101
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
102+
*
103+
* @return void
92104
*/
93105
public function pressButton($button)
94106
{
@@ -102,6 +114,8 @@ public function pressButton($button)
102114
* Example: And I follow "Log In"
103115
*
104116
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
117+
*
118+
* @return void
105119
*/
106120
public function clickLink($link)
107121
{
@@ -117,6 +131,8 @@ public function clickLink($link)
117131
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
118132
* @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
119133
* @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
134+
*
135+
* @return void
120136
*/
121137
public function fillField($field, $value)
122138
{
@@ -135,6 +151,8 @@ public function fillField($field, $value)
135151
* | password | iLoveBats123 |
136152
*
137153
* @When /^(?:|I )fill in the following:$/
154+
*
155+
* @return void
138156
*/
139157
public function fillFields(TableNode $fields)
140158
{
@@ -149,6 +167,8 @@ public function fillFields(TableNode $fields)
149167
* Example: And I select "Bats" from "user_fears"
150168
*
151169
* @When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
170+
*
171+
* @return void
152172
*/
153173
public function selectOption($select, $option)
154174
{
@@ -163,6 +183,8 @@ public function selectOption($select, $option)
163183
* Example: And I additionally select "Deceased" from "parents_alive_status"
164184
*
165185
* @When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
186+
*
187+
* @return void
166188
*/
167189
public function additionallySelectOption($select, $option)
168190
{
@@ -177,6 +199,8 @@ public function additionallySelectOption($select, $option)
177199
* Example: And I check "Pearl Necklace"
178200
*
179201
* @When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
202+
*
203+
* @return void
180204
*/
181205
public function checkOption($option)
182206
{
@@ -190,6 +214,8 @@ public function checkOption($option)
190214
* Example: And I uncheck "Broadway Plays"
191215
*
192216
* @When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
217+
*
218+
* @return void
193219
*/
194220
public function uncheckOption($option)
195221
{
@@ -203,6 +229,8 @@ public function uncheckOption($option)
203229
* Example: And I attach the file "bwayne_profile.png" to "profileImageUpload"
204230
*
205231
* @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
232+
*
233+
* @return void
206234
*/
207235
public function attachFileToField($field, $path)
208236
{
@@ -225,6 +253,8 @@ public function attachFileToField($field, $path)
225253
* Example: And I should be on "http://google.com"
226254
*
227255
* @Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
256+
*
257+
* @return void
228258
*/
229259
public function assertPageAddress($page)
230260
{
@@ -237,6 +267,8 @@ public function assertPageAddress($page)
237267
* Example: And I should be on the homepage
238268
*
239269
* @Then /^(?:|I )should be on (?:|the )homepage$/
270+
*
271+
* @return void
240272
*/
241273
public function assertHomepage()
242274
{
@@ -250,6 +282,8 @@ public function assertHomepage()
250282
* Example: And the url should match "log in"
251283
*
252284
* @Then /^the (?i)url(?-i) should match (?P<pattern>"(?:[^"]|\\")*")$/
285+
*
286+
* @return void
253287
*/
254288
public function assertUrlRegExp($pattern)
255289
{
@@ -262,6 +296,8 @@ public function assertUrlRegExp($pattern)
262296
* Example: And the response status code should be 400
263297
*
264298
* @Then /^the response status code should be (?P<code>\d+)$/
299+
*
300+
* @return void
265301
*/
266302
public function assertResponseStatus($code)
267303
{
@@ -274,6 +310,8 @@ public function assertResponseStatus($code)
274310
* Example: And the response status code should not be 404
275311
*
276312
* @Then /^the response status code should not be (?P<code>\d+)$/
313+
*
314+
* @return void
277315
*/
278316
public function assertResponseStatusIsNot($code)
279317
{
@@ -286,6 +324,8 @@ public function assertResponseStatusIsNot($code)
286324
* Example: And I should see "Who is the Batman?"
287325
*
288326
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
327+
*
328+
* @return void
289329
*/
290330
public function assertPageContainsText($text)
291331
{
@@ -298,6 +338,8 @@ public function assertPageContainsText($text)
298338
* Example: And I should not see "Batman is Bruce Wayne"
299339
*
300340
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
341+
*
342+
* @return void
301343
*/
302344
public function assertPageNotContainsText($text)
303345
{
@@ -310,6 +352,8 @@ public function assertPageNotContainsText($text)
310352
* Example: And I should not see "Batman, the vigilante"
311353
*
312354
* @Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
355+
*
356+
* @return void
313357
*/
314358
public function assertPageMatchesText($pattern)
315359
{
@@ -322,6 +366,8 @@ public function assertPageMatchesText($pattern)
322366
* Example: And I should not see "Bruce Wayne, the vigilante"
323367
*
324368
* @Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
369+
*
370+
* @return void
325371
*/
326372
public function assertPageNotMatchesText($pattern)
327373
{
@@ -334,6 +380,8 @@ public function assertPageNotMatchesText($pattern)
334380
* Example: And the response should contain "Batman is the hero Gotham deserves."
335381
*
336382
* @Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
383+
*
384+
* @return void
337385
*/
338386
public function assertResponseContains($text)
339387
{
@@ -346,6 +394,8 @@ public function assertResponseContains($text)
346394
* Example: And the response should not contain "Bruce Wayne is a billionaire, play-boy, vigilante."
347395
*
348396
* @Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
397+
*
398+
* @return void
349399
*/
350400
public function assertResponseNotContains($text)
351401
{
@@ -358,6 +408,8 @@ public function assertResponseNotContains($text)
358408
* Example: And I should see "Batman" in the "heroes_list" element
359409
*
360410
* @Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
411+
*
412+
* @return void
361413
*/
362414
public function assertElementContainsText($element, $text)
363415
{
@@ -370,6 +422,8 @@ public function assertElementContainsText($element, $text)
370422
* Example: And I should not see "Bruce Wayne" in the "heroes_alter_egos" element
371423
*
372424
* @Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
425+
*
426+
* @return void
373427
*/
374428
public function assertElementNotContainsText($element, $text)
375429
{
@@ -382,6 +436,8 @@ public function assertElementNotContainsText($element, $text)
382436
* Example: And the "body" element should contain "style=\"color:black;\""
383437
*
384438
* @Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
439+
*
440+
* @return void
385441
*/
386442
public function assertElementContains($element, $value)
387443
{
@@ -394,6 +450,8 @@ public function assertElementContains($element, $value)
394450
* Example: And the "body" element should not contain "style=\"color:black;\""
395451
*
396452
* @Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
453+
*
454+
* @return void
397455
*/
398456
public function assertElementNotContains($element, $value)
399457
{
@@ -406,6 +464,8 @@ public function assertElementNotContains($element, $value)
406464
* Example: And I should see a "body" element
407465
*
408466
* @Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
467+
*
468+
* @return void
409469
*/
410470
public function assertElementOnPage($element)
411471
{
@@ -418,6 +478,8 @@ public function assertElementOnPage($element)
418478
* Example: And I should not see a "canvas" element
419479
*
420480
* @Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
481+
*
482+
* @return void
421483
*/
422484
public function assertElementNotOnPage($element)
423485
{
@@ -430,6 +492,8 @@ public function assertElementNotOnPage($element)
430492
* Example: And the "username" field should contain "bwayne"
431493
*
432494
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
495+
*
496+
* @return void
433497
*/
434498
public function assertFieldContains($field, $value)
435499
{
@@ -444,6 +508,8 @@ public function assertFieldContains($field, $value)
444508
* Example: And the "username" field should not contain "batman"
445509
*
446510
* @Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
511+
*
512+
* @return void
447513
*/
448514
public function assertFieldNotContains($field, $value)
449515
{
@@ -458,6 +524,8 @@ public function assertFieldNotContains($field, $value)
458524
* Example: And I should see 5 "div" elements
459525
*
460526
* @Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
527+
*
528+
* @return void
461529
*/
462530
public function assertNumElements($num, $element)
463531
{
@@ -472,6 +540,8 @@ public function assertNumElements($num, $element)
472540
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
473541
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox is checked$/
474542
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
543+
*
544+
* @return void
475545
*/
476546
public function assertCheckboxChecked($checkbox)
477547
{
@@ -488,6 +558,8 @@ public function assertCheckboxChecked($checkbox)
488558
* @Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox is (?:unchecked|not checked)$/
489559
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/
490560
* @Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" is (?:unchecked|not checked)$/
561+
*
562+
* @return void
491563
*/
492564
public function assertCheckboxNotChecked($checkbox)
493565
{
@@ -500,6 +572,8 @@ public function assertCheckboxNotChecked($checkbox)
500572
* Example: And print current URL
501573
*
502574
* @Then /^print current URL$/
575+
*
576+
* @return void
503577
*/
504578
public function printCurrentUrl()
505579
{
@@ -512,6 +586,8 @@ public function printCurrentUrl()
512586
* Example: And print last response
513587
*
514588
* @Then /^print last response$/
589+
*
590+
* @return void
515591
*/
516592
public function printLastResponse()
517593
{
@@ -527,6 +603,8 @@ public function printLastResponse()
527603
* Example: And show last response
528604
*
529605
* @Then /^show last response$/
606+
*
607+
* @return void
530608
*/
531609
public function showLastResponse()
532610
{

0 commit comments

Comments
 (0)