@@ -127,12 +127,15 @@ public function _after(TestInterface $test)
127
127
$ this ->headers = [];
128
128
}
129
129
130
- public function _conflicts ()
130
+ /**
131
+ * @return class-string
132
+ */
133
+ public function _conflicts (): string
131
134
{
132
135
return \Codeception \Lib \Interfaces \Web::class;
133
136
}
134
137
135
- public function _findElements ($ locator )
138
+ public function _findElements (array $ locator )
136
139
{
137
140
return $ this ->match ($ locator );
138
141
}
@@ -339,7 +342,7 @@ private function getRunningClient(): AbstractBrowser
339
342
return $ this ->client ;
340
343
}
341
344
342
- public function _savePageSource ($ filename )
345
+ public function _savePageSource (string $ filename ): void
343
346
{
344
347
file_put_contents ($ filename , $ this ->_getResponseContent ());
345
348
}
@@ -409,12 +412,12 @@ public function deleteHeader(string $name): void
409
412
unset($ this ->headers [$ name ]);
410
413
}
411
414
412
- public function amOnPage ($ page )
415
+ public function amOnPage (string $ page ): void
413
416
{
414
417
$ this ->_loadPage ('GET ' , $ page );
415
418
}
416
419
417
- public function click ($ link , $ context = null )
420
+ public function click ($ link , $ context = null ): void
418
421
{
419
422
if ($ context ) {
420
423
$ this ->crawler = $ this ->match ($ context );
@@ -548,7 +551,7 @@ private function retrieveBaseUrl(): string
548
551
return $ this ->getAbsoluteUrlFor ($ baseUrl );
549
552
}
550
553
551
- public function see ($ text , $ selector = null )
554
+ public function see (string $ text , $ selector = null ): void
552
555
{
553
556
if (!$ selector ) {
554
557
$ this ->assertPageContains ($ text );
@@ -559,7 +562,7 @@ public function see($text, $selector = null)
559
562
$ this ->assertDomContains ($ nodes , $ this ->stringifySelector ($ selector ), $ text );
560
563
}
561
564
562
- public function dontSee ($ text , $ selector = null )
565
+ public function dontSee (string $ text , $ selector = null ): void
563
566
{
564
567
if (!$ selector ) {
565
568
$ this ->assertPageNotContains ($ text );
@@ -570,17 +573,17 @@ public function dontSee($text, $selector = null)
570
573
$ this ->assertDomNotContains ($ nodes , $ this ->stringifySelector ($ selector ), $ text );
571
574
}
572
575
573
- public function seeInSource ($ raw )
576
+ public function seeInSource (string $ raw ): void
574
577
{
575
578
$ this ->assertPageSourceContains ($ raw );
576
579
}
577
580
578
- public function dontSeeInSource ($ raw )
581
+ public function dontSeeInSource (string $ raw ): void
579
582
{
580
583
$ this ->assertPageSourceNotContains ($ raw );
581
584
}
582
585
583
- public function seeLink ($ text , $ url = null )
586
+ public function seeLink (string $ text , string $ url = null ): void
584
587
{
585
588
$ crawler = $ this ->getCrawler ()->selectLink ($ text );
586
589
if ($ crawler ->count () === 0 ) {
@@ -595,16 +598,15 @@ public function seeLink($text, $url = null)
595
598
$ this ->assertTrue (true );
596
599
}
597
600
598
- public function dontSeeLink ($ text , $ url = null )
601
+ public function dontSeeLink (string $ text , string $ url = null ): void
599
602
{
600
- $ url = (string ) $ url ;
601
603
$ crawler = $ this ->getCrawler ()->selectLink ($ text );
602
604
if (!$ url && $ crawler ->count () > 0 ) {
603
605
$ this ->fail ("Link containing text ' $ text' was found in page " . $ this ->_getCurrentUri ());
604
606
}
605
607
$ crawler = $ crawler ->filterXPath (
606
608
sprintf ('.//a[substring(@href, string-length(@href) - string-length(%1$s) + 1)=%1$s] ' ,
607
- SymfonyCrawler::xpathLiteral ($ url ))
609
+ SymfonyCrawler::xpathLiteral (( string ) $ url ))
608
610
);
609
611
if ($ crawler ->count () > 0 ) {
610
612
$ this ->fail ("Link containing text ' $ text' and URL ' $ url' was found in page " . $ this ->_getCurrentUri ());
@@ -620,37 +622,37 @@ public function _getCurrentUri(): string
620
622
return Uri::retrieveUri ($ this ->getRunningClient ()->getHistory ()->current ()->getUri ());
621
623
}
622
624
623
- public function seeInCurrentUrl ($ uri )
625
+ public function seeInCurrentUrl (string $ uri ): void
624
626
{
625
627
$ this ->assertStringContainsString ($ uri , $ this ->_getCurrentUri ());
626
628
}
627
629
628
- public function dontSeeInCurrentUrl ($ uri )
630
+ public function dontSeeInCurrentUrl (string $ uri ): void
629
631
{
630
632
$ this ->assertStringNotContainsString ($ uri , $ this ->_getCurrentUri ());
631
633
}
632
634
633
- public function seeCurrentUrlEquals ($ uri )
635
+ public function seeCurrentUrlEquals (string $ uri ): void
634
636
{
635
637
$ this ->assertEquals (rtrim ($ uri , '/ ' ), rtrim ($ this ->_getCurrentUri (), '/ ' ));
636
638
}
637
639
638
- public function dontSeeCurrentUrlEquals ($ uri )
640
+ public function dontSeeCurrentUrlEquals (string $ uri ): void
639
641
{
640
642
$ this ->assertNotEquals (rtrim ($ uri , '/ ' ), rtrim ($ this ->_getCurrentUri (), '/ ' ));
641
643
}
642
644
643
- public function seeCurrentUrlMatches ($ uri )
645
+ public function seeCurrentUrlMatches (string $ uri ): void
644
646
{
645
647
$ this ->assertRegExp ($ uri , $ this ->_getCurrentUri ());
646
648
}
647
649
648
- public function dontSeeCurrentUrlMatches ($ uri )
650
+ public function dontSeeCurrentUrlMatches (string $ uri ): void
649
651
{
650
652
$ this ->assertNotRegExp ($ uri , $ this ->_getCurrentUri ());
651
653
}
652
654
653
- public function grabFromCurrentUrl ($ uri = null )
655
+ public function grabFromCurrentUrl (string $ uri = null )
654
656
{
655
657
if (!$ uri ) {
656
658
return $ this ->_getCurrentUri ();
@@ -666,36 +668,36 @@ public function grabFromCurrentUrl($uri = null)
666
668
return $ matches [1 ];
667
669
}
668
670
669
- public function seeCheckboxIsChecked ($ checkbox )
671
+ public function seeCheckboxIsChecked ($ checkbox ): void
670
672
{
671
673
$ checkboxes = $ this ->getFieldsByLabelOrCss ($ checkbox );
672
674
$ this ->assertDomContains ($ checkboxes ->filter ('input[checked=checked] ' ), 'checkbox ' );
673
675
}
674
676
675
- public function dontSeeCheckboxIsChecked ($ checkbox )
677
+ public function dontSeeCheckboxIsChecked ($ checkbox ): void
676
678
{
677
679
$ checkboxes = $ this ->getFieldsByLabelOrCss ($ checkbox );
678
680
$ this ->assertEquals (0 , $ checkboxes ->filter ('input[checked=checked] ' )->count ());
679
681
}
680
682
681
- public function seeInField ($ field , $ value )
683
+ public function seeInField ($ field , $ value ): void
682
684
{
683
685
$ nodes = $ this ->getFieldsByLabelOrCss ($ field );
684
686
$ this ->assert ($ this ->proceedSeeInField ($ nodes , $ value ));
685
687
}
686
688
687
- public function dontSeeInField ($ field , $ value )
689
+ public function dontSeeInField ($ field , $ value ): void
688
690
{
689
691
$ nodes = $ this ->getFieldsByLabelOrCss ($ field );
690
692
$ this ->assertNot ($ this ->proceedSeeInField ($ nodes , $ value ));
691
693
}
692
694
693
- public function seeInFormFields ($ formSelector , array $ params )
695
+ public function seeInFormFields ($ formSelector , array $ params ): void
694
696
{
695
697
$ this ->proceedSeeInFormFields ($ formSelector , $ params , false );
696
698
}
697
699
698
- public function dontSeeInFormFields ($ formSelector , array $ params )
700
+ public function dontSeeInFormFields ($ formSelector , array $ params ): void
699
701
{
700
702
$ this ->proceedSeeInFormFields ($ formSelector , $ params , true );
701
703
}
@@ -954,7 +956,7 @@ protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $b
954
956
$ this ->forms = [];
955
957
}
956
958
957
- public function submitForm ($ selector , array $ params , $ button = null )
959
+ public function submitForm ($ selector , array $ params , $ button = null ): void
958
960
{
959
961
$ form = $ this ->match ($ selector )->first ();
960
962
if (count ($ form ) === 0 ) {
@@ -1112,7 +1114,7 @@ protected function getFormValuesFor(SymfonyForm $form): array
1112
1114
return $ values ;
1113
1115
}
1114
1116
1115
- public function fillField ($ field , $ value)
1117
+ public function fillField ($ field , $ value = '' ): void
1116
1118
{
1117
1119
$ input = $ this ->getFieldByLabelOrCss ($ field );
1118
1120
$ form = $ this ->getFormFor ($ input );
@@ -1174,7 +1176,7 @@ protected function getFieldByLabelOrCss($field): SymfonyCrawler
1174
1176
return $ input ->first ();
1175
1177
}
1176
1178
1177
- public function selectOption ($ select , $ option )
1179
+ public function selectOption ($ select , $ option ): void
1178
1180
{
1179
1181
$ field = $ this ->getFieldByLabelOrCss ($ select );
1180
1182
$ form = $ this ->getFormFor ($ field );
@@ -1244,12 +1246,12 @@ protected function matchOption(Crawler $field, $option)
1244
1246
return $ option ;
1245
1247
}
1246
1248
1247
- public function checkOption ($ option )
1249
+ public function checkOption ($ option ): void
1248
1250
{
1249
1251
$ this ->proceedCheckOption ($ option )->tick ();
1250
1252
}
1251
1253
1252
- public function uncheckOption ($ option )
1254
+ public function uncheckOption ($ option ): void
1253
1255
{
1254
1256
$ this ->proceedCheckOption ($ option )->untick ();
1255
1257
}
@@ -1275,7 +1277,7 @@ protected function proceedCheckOption($option): ChoiceFormField
1275
1277
return $ formField ;
1276
1278
}
1277
1279
1278
- public function attachFile ($ field , $ filename )
1280
+ public function attachFile ($ field , string $ filename ): void
1279
1281
{
1280
1282
$ form = $ this ->getFormFor ($ field = $ this ->getFieldByLabelOrCss ($ field ));
1281
1283
$ filePath = codecept_data_dir () . $ filename ;
@@ -1364,7 +1366,7 @@ protected function debugResponse($url)
1364
1366
$ this ->debugSection ('Response Headers ' , $ this ->getRunningClient ()->getInternalResponse ()->getHeaders ());
1365
1367
}
1366
1368
1367
- public function makeHtmlSnapshot ($ name = null )
1369
+ public function makeHtmlSnapshot (string $ name = null ): void
1368
1370
{
1369
1371
if (empty ($ name )) {
1370
1372
$ name = uniqid (date ("Y-m-d_H-i-s_ " ), true );
@@ -1468,7 +1470,7 @@ public function grabTextFrom($cssOrXPathOrRegex)
1468
1470
throw new ElementNotFound ($ cssOrXPathOrRegex , 'Element that matches CSS or XPath or Regex ' );
1469
1471
}
1470
1472
1471
- public function grabAttributeFrom ($ cssOrXpath , $ attribute )
1473
+ public function grabAttributeFrom ($ cssOrXpath , string $ attribute )
1472
1474
{
1473
1475
$ nodes = $ this ->match ($ cssOrXpath );
1474
1476
if ($ nodes ->count () === 0 ) {
@@ -1477,7 +1479,7 @@ public function grabAttributeFrom($cssOrXpath, $attribute)
1477
1479
return $ nodes ->first ()->attr ($ attribute );
1478
1480
}
1479
1481
1480
- public function grabMultiple ($ cssOrXpath , $ attribute = null )
1482
+ public function grabMultiple ($ cssOrXpath , string $ attribute = null ): array
1481
1483
{
1482
1484
$ result = [];
1483
1485
$ nodes = $ this ->match ($ cssOrXpath );
@@ -1528,7 +1530,7 @@ public function grabValueFrom($field)
1528
1530
$ this ->fail ("Element {$ nodes } is not a form field or does not contain a form field " );
1529
1531
}
1530
1532
1531
- public function setCookie ($ name , $ val , array $ params = [])
1533
+ public function setCookie (string $ name , ? string $ val , array $ params = [])
1532
1534
{
1533
1535
$ cookies = $ this ->client ->getCookieJar ();
1534
1536
$ params = array_merge ($ this ->defaultCookieParameters , $ params );
@@ -1548,7 +1550,7 @@ public function setCookie($name, $val, array $params = [])
1548
1550
$ this ->debugCookieJar ();
1549
1551
}
1550
1552
1551
- public function grabCookie ($ cookie , array $ params = [])
1553
+ public function grabCookie (string $ cookie , array $ params = [])
1552
1554
{
1553
1555
$ params = array_merge ($ this ->defaultCookieParameters , $ params );
1554
1556
$ this ->debugCookieJar ();
@@ -1565,26 +1567,26 @@ public function grabCookie($cookie, array $params = [])
1565
1567
* @throws ModuleException if no page was opened.
1566
1568
* @return string Current page source code.
1567
1569
*/
1568
- public function grabPageSource ()
1570
+ public function grabPageSource (): string
1569
1571
{
1570
1572
return $ this ->_getResponseContent ();
1571
1573
}
1572
1574
1573
- public function seeCookie ($ cookie , array $ params = [])
1575
+ public function seeCookie (string $ cookie , array $ params = [])
1574
1576
{
1575
1577
$ params = array_merge ($ this ->defaultCookieParameters , $ params );
1576
1578
$ this ->debugCookieJar ();
1577
1579
$ this ->assertNotNull ($ this ->client ->getCookieJar ()->get ($ cookie , $ params ['path ' ], $ params ['domain ' ]));
1578
1580
}
1579
1581
1580
- public function dontSeeCookie ($ cookie , array $ params = [])
1582
+ public function dontSeeCookie (string $ cookie , array $ params = [])
1581
1583
{
1582
1584
$ params = array_merge ($ this ->defaultCookieParameters , $ params );
1583
1585
$ this ->debugCookieJar ();
1584
1586
$ this ->assertNull ($ this ->client ->getCookieJar ()->get ($ cookie , $ params ['path ' ], $ params ['domain ' ]));
1585
1587
}
1586
1588
1587
- public function resetCookie ($ cookie , array $ params = [])
1589
+ public function resetCookie (string $ cookie , array $ params = [])
1588
1590
{
1589
1591
$ params = array_merge ($ this ->defaultCookieParameters , $ params );
1590
1592
$ this ->client ->getCookieJar ()->expire ($ cookie , $ params ['path ' ], $ params ['domain ' ]);
@@ -1599,7 +1601,7 @@ private function stringifySelector($selector): string
1599
1601
return $ selector ;
1600
1602
}
1601
1603
1602
- public function seeElement ($ selector , $ attributes = [])
1604
+ public function seeElement ($ selector , array $ attributes = []): void
1603
1605
{
1604
1606
$ nodes = $ this ->match ($ selector );
1605
1607
$ selector = $ this ->stringifySelector ($ selector );
@@ -1610,7 +1612,7 @@ public function seeElement($selector, $attributes = [])
1610
1612
$ this ->assertDomContains ($ nodes , $ selector );
1611
1613
}
1612
1614
1613
- public function dontSeeElement ($ selector , $ attributes = [])
1615
+ public function dontSeeElement ($ selector , array $ attributes = []): void
1614
1616
{
1615
1617
$ nodes = $ this ->match ($ selector );
1616
1618
$ selector = $ this ->stringifySelector ($ selector );
@@ -1621,7 +1623,7 @@ public function dontSeeElement($selector, $attributes = [])
1621
1623
$ this ->assertDomNotContains ($ nodes , $ selector );
1622
1624
}
1623
1625
1624
- public function seeNumberOfElements ($ selector , $ expected )
1626
+ public function seeNumberOfElements ($ selector , $ expected ): void
1625
1627
{
1626
1628
$ counted = count ($ this ->match ($ selector ));
1627
1629
if (is_array ($ expected )) {
@@ -1639,7 +1641,7 @@ public function seeNumberOfElements($selector, $expected)
1639
1641
}
1640
1642
}
1641
1643
1642
- public function seeOptionIsSelected ($ selector , $ optionText )
1644
+ public function seeOptionIsSelected ($ selector , string $ optionText )
1643
1645
{
1644
1646
$ selected = $ this ->matchSelectedOption ($ selector );
1645
1647
$ this ->assertDomContains ($ selected , 'selected option ' );
@@ -1650,7 +1652,7 @@ public function seeOptionIsSelected($selector, $optionText)
1650
1652
$ this ->assertEquals ($ optionText , $ value );
1651
1653
}
1652
1654
1653
- public function dontSeeOptionIsSelected ($ selector , $ optionText )
1655
+ public function dontSeeOptionIsSelected ($ selector , string $ optionText )
1654
1656
{
1655
1657
$ selected = $ this ->matchSelectedOption ($ selector );
1656
1658
if ($ selected ->count () === 0 ) {
@@ -1776,7 +1778,7 @@ public function seeResponseCodeIsServerError()
1776
1778
$ this ->seeResponseCodeIsBetween (500 , 599 );
1777
1779
}
1778
1780
1779
- public function seeInTitle ($ title )
1781
+ public function seeInTitle (string $ title )
1780
1782
{
1781
1783
$ nodes = $ this ->getCrawler ()->filter ('title ' );
1782
1784
if ($ nodes ->count () === 0 ) {
@@ -1785,7 +1787,7 @@ public function seeInTitle($title)
1785
1787
$ this ->assertStringContainsString ($ title , $ nodes ->first ()->text (), "page title contains $ title " );
1786
1788
}
1787
1789
1788
- public function dontSeeInTitle ($ title )
1790
+ public function dontSeeInTitle (string $ title )
1789
1791
{
1790
1792
$ nodes = $ this ->getCrawler ()->filter ('title ' );
1791
1793
if ($ nodes ->count () === 0 ) {
0 commit comments