Skip to content

Commit 846329c

Browse files
committed
Added more typehints
1 parent 1c4706d commit 846329c

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

src/Codeception/Lib/InnerBrowser.php

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Codeception\Util\Uri;
2424
use DOMDocument;
2525
use DOMNode;
26+
use Exception;
2627
use InvalidArgumentException;
2728
use LogicException;
2829
use Symfony\Component\BrowserKit\AbstractBrowser;
@@ -78,7 +79,7 @@ class InnerBrowser extends Module implements Web, PageSourceSaver, ElementLocato
7879
*/
7980
private $baseUrl;
8081

81-
public function _failed(TestInterface $test, $fail)
82+
public function _failed(TestInterface $test, Exception $fail)
8283
{
8384
try {
8485
if (!$this->client || !$this->client->getInternalResponse()) {
@@ -260,7 +261,7 @@ protected function clientRequest(
260261
return $this->redirectIfNecessary($result, $maxRedirects, 0);
261262
}
262263

263-
protected function isInternalDomain($domain): bool
264+
protected function isInternalDomain(string $domain): bool
264265
{
265266
if ($this->internalDomains === null) {
266267
$this->internalDomains = $this->getInternalDomains();
@@ -591,8 +592,9 @@ public function seeLink($text, $url = null)
591592
$this->assertTrue(true);
592593
}
593594

594-
public function dontSeeLink($text, $url = '')
595+
public function dontSeeLink($text, $url = null)
595596
{
597+
$url = (string) $url;
596598
$crawler = $this->getCrawler()->selectLink($text);
597599
if (!$url && $crawler->count() > 0) {
598600
$this->fail("Link containing text '$text' was found in page " . $this->_getCurrentUri());
@@ -1294,10 +1296,10 @@ public function attachFile($field, $filename)
12941296
* Sends an ajax GET request with the passed parameters.
12951297
* See `sendAjaxPostRequest()`
12961298
*
1297-
* @param $uri
1299+
* @param string $uri
12981300
* @param array $params
12991301
*/
1300-
public function sendAjaxGetRequest($uri, array $params = []): void
1302+
public function sendAjaxGetRequest(string $uri, array $params = []): void
13011303
{
13021304
$this->sendAjaxRequest('GET', $uri, $params);
13031305
}
@@ -1339,11 +1341,11 @@ public function sendAjaxPostRequest(string $uri, array $params = []): void
13391341
* $I->sendAjaxRequest('PUT', '/posts/7', ['title' => 'new title']);
13401342
* ```
13411343
*
1342-
* @param $method
1343-
* @param $uri
1344+
* @param string $method
1345+
* @param string $uri
13441346
* @param array $params
13451347
*/
1346-
public function sendAjaxRequest($method, $uri, array $params = []): void
1348+
public function sendAjaxRequest(string $method, string $uri, array $params = []): void
13471349
{
13481350
$this->clientRequest($method, $uri, $params, [], ['HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest'], null, false);
13491351
}
@@ -1802,7 +1804,7 @@ protected function assertDomNotContains($nodes, string $message, string $text =
18021804
$this->assertThat($nodes, $constraint, $message);
18031805
}
18041806

1805-
protected function assertPageContains($needle, string $message = ''): void
1807+
protected function assertPageContains(string $needle, string $message = ''): void
18061808
{
18071809
$constraint = new PageConstraint($needle, $this->_getCurrentUri());
18081810
$this->assertThat(
@@ -1812,10 +1814,7 @@ protected function assertPageContains($needle, string $message = ''): void
18121814
);
18131815
}
18141816

1815-
/**
1816-
* @param string $message
1817-
*/
1818-
protected function assertPageNotContains($needle, string $message = ''): void
1817+
protected function assertPageNotContains(string $needle, string $message = ''): void
18191818
{
18201819
$constraint = new PageConstraint($needle, $this->_getCurrentUri());
18211820
$this->assertThatItsNot(
@@ -1825,10 +1824,7 @@ protected function assertPageNotContains($needle, string $message = ''): void
18251824
);
18261825
}
18271826

1828-
/**
1829-
* @param string $message
1830-
*/
1831-
protected function assertPageSourceContains($needle, string $message = ''): void
1827+
protected function assertPageSourceContains(string $needle, string $message = ''): void
18321828
{
18331829
$constraint = new PageConstraint($needle, $this->_getCurrentUri());
18341830
$this->assertThat(
@@ -1838,10 +1834,7 @@ protected function assertPageSourceContains($needle, string $message = ''): void
18381834
);
18391835
}
18401836

1841-
/**
1842-
* @param string $message
1843-
*/
1844-
protected function assertPageSourceNotContains($needle, string $message = ''): void
1837+
protected function assertPageSourceNotContains(string $needle, string $message = ''): void
18451838
{
18461839
$constraint = new PageConstraint($needle, $this->_getCurrentUri());
18471840
$this->assertThatItsNot(
@@ -1872,23 +1865,15 @@ protected function matchFormField(string $name, $form, FormField $dynamicField)
18721865
throw new TestRuntimeException("None of form fields by {$name}[] were not matched");
18731866
}
18741867

1875-
/**
1876-
* @param $locator
1877-
* @return SymfonyCrawler
1878-
*/
1879-
protected function filterByCSS($locator): SymfonyCrawler
1868+
protected function filterByCSS(string $locator): SymfonyCrawler
18801869
{
18811870
if (!Locator::isCSS($locator)) {
18821871
throw new MalformedLocatorException($locator, 'css');
18831872
}
18841873
return $this->getCrawler()->filter($locator);
18851874
}
18861875

1887-
/**
1888-
* @param $locator
1889-
* @return SymfonyCrawler
1890-
*/
1891-
protected function filterByXPath($locator): SymfonyCrawler
1876+
protected function filterByXPath(string $locator): SymfonyCrawler
18921877
{
18931878
if (!Locator::isXPath($locator)) {
18941879
throw new MalformedLocatorException($locator, 'xpath');

0 commit comments

Comments
 (0)