Skip to content

Commit 41ae93d

Browse files
committed
Add and fix typehints
1 parent 70872c4 commit 41ae93d

29 files changed

+197
-86
lines changed

lib/Chrome/ChromeDriver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function start(DesiredCapabilities $desired_capabilities = null, C
4040
return $driver;
4141
}
4242

43-
public function startSession($desired_capabilities)
43+
public function startSession(DesiredCapabilities $desired_capabilities)
4444
{
4545
$command = new WebDriverCommand(
4646
null,
@@ -76,6 +76,7 @@ public static function create(
7676
* @param string $url The url of the remote server
7777
*
7878
* @throws WebDriverException
79+
* @return RemoteWebDriver|void
7980
*/
8081
public static function createBySessionID(
8182
$session_id,

lib/Interactions/Internal/WebDriverCoordinates.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
namespace Facebook\WebDriver\Interactions\Internal;
1717

18-
use Closure;
1918
use Facebook\WebDriver\Exception\UnsupportedOperationException;
2019
use Facebook\WebDriver\WebDriverPoint;
2120

@@ -24,12 +23,30 @@
2423
*/
2524
class WebDriverCoordinates
2625
{
26+
/**
27+
* @var null
28+
*/
2729
private $onScreen;
30+
/**
31+
* @var callable
32+
*/
2833
private $inViewPort;
34+
/**
35+
* @var callable
36+
*/
2937
private $onPage;
38+
/**
39+
* @var string
40+
*/
3041
private $auxiliary;
3142

32-
public function __construct($on_screen, Closure $in_view_port, Closure $on_page, $auxiliary)
43+
/**
44+
* @param null $on_screen
45+
* @param callable $in_view_port
46+
* @param callable $on_page
47+
* @param string $auxiliary
48+
*/
49+
public function __construct($on_screen, callable $in_view_port, callable $on_page, $auxiliary)
3350
{
3451
$this->onScreen = $on_screen;
3552
$this->inViewPort = $in_view_port;
@@ -65,7 +82,7 @@ public function onPage()
6582
}
6683

6784
/**
68-
* @return object The attached object.
85+
* @return string The attached object id.
6986
*/
7087
public function getAuxiliary()
7188
{

lib/Interactions/Internal/WebDriverKeysRelatedAction.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@
2424
*/
2525
abstract class WebDriverKeysRelatedAction
2626
{
27+
/**
28+
* @var WebDriverKeyboard
29+
*/
2730
protected $keyboard;
31+
/**
32+
* @var WebDriverMouse
33+
*/
2834
protected $mouse;
35+
/**
36+
* @var WebDriverLocatable|null
37+
*/
2938
protected $locationProvider;
3039

3140
/**

lib/Interactions/Internal/WebDriverMouseAction.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class WebDriverMouseAction
3232
*/
3333
protected $locationProvider;
3434

35+
/**
36+
* @param WebDriverMouse $mouse
37+
* @param WebDriverLocatable|null $location_provider
38+
*/
3539
public function __construct(WebDriverMouse $mouse, WebDriverLocatable $location_provider = null)
3640
{
3741
$this->mouse = $mouse;

lib/Interactions/Internal/WebDriverMoveToOffsetAction.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@
2121

2222
class WebDriverMoveToOffsetAction extends WebDriverMouseAction implements WebDriverAction
2323
{
24+
/**
25+
* @var int|null
26+
*/
2427
private $xOffset;
28+
/**
29+
* @var int|null
30+
*/
2531
private $yOffset;
2632

33+
/**
34+
* @param WebDriverMouse $mouse
35+
* @param WebDriverLocatable|null $location_provider
36+
* @param int|null $x_offset
37+
* @param int|null $y_offset
38+
*/
2739
public function __construct(
2840
WebDriverMouse $mouse,
2941
WebDriverLocatable $location_provider = null,

lib/Interactions/Internal/WebDriverSendKeysAction.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222

2323
class WebDriverSendKeysAction extends WebDriverKeysRelatedAction implements WebDriverAction
2424
{
25-
private $keys;
25+
/**
26+
* @var string
27+
*/
28+
private $keys = '';
2629

2730
/**
2831
* @param WebDriverKeyboard $keyboard
@@ -34,7 +37,7 @@ public function __construct(
3437
WebDriverKeyboard $keyboard,
3538
WebDriverMouse $mouse,
3639
WebDriverLocatable $location_provider = null,
37-
$keys = null
40+
$keys = ''
3841
) {
3942
parent::__construct($keyboard, $mouse, $location_provider);
4043
$this->keys = $keys;

lib/Interactions/Internal/WebDriverSingleKeyAction.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222

2323
abstract class WebDriverSingleKeyAction extends WebDriverKeysRelatedAction implements WebDriverAction
2424
{
25-
protected $key;
25+
/** @var string */
26+
protected $key = '';
2627

2728
public function __construct(
2829
WebDriverKeyboard $keyboard,
2930
WebDriverMouse $mouse,
3031
WebDriverLocatable $location_provider = null,
31-
$key = null
32+
$key = ''
3233
) {
3334
parent::__construct($keyboard, $mouse, $location_provider);
3435
$this->key = $key;

lib/Interactions/Touch/WebDriverDownAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919

2020
class WebDriverDownAction extends WebDriverTouchAction implements WebDriverAction
2121
{
22+
/**
23+
* @var int
24+
*/
2225
private $x;
26+
/**
27+
* @var int
28+
*/
2329
private $y;
2430

2531
/**

lib/Interactions/Touch/WebDriverFlickAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919

2020
class WebDriverFlickAction extends WebDriverTouchAction implements WebDriverAction
2121
{
22+
/**
23+
* @var int
24+
*/
2225
private $x;
26+
/**
27+
* @var int
28+
*/
2329
private $y;
2430

2531
/**

lib/Interactions/Touch/WebDriverFlickFromElementAction.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@
2020

2121
class WebDriverFlickFromElementAction extends WebDriverTouchAction implements WebDriverAction
2222
{
23+
/**
24+
* @var int
25+
*/
2326
private $x;
27+
/**
28+
* @var int
29+
*/
2430
private $y;
31+
/**
32+
* @var int
33+
*/
2534
private $speed;
2635

2736
/**

lib/Interactions/WebDriverActions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class WebDriverActions
3838
protected $mouse;
3939
protected $action;
4040

41+
/**
42+
* @param WebDriver $driver
43+
*/
4144
public function __construct(WebDriver $driver)
4245
{
4346
$this->driver = $driver;

lib/Interactions/WebDriverCompositeAction.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
class WebDriverCompositeAction implements WebDriverAction
2424
{
25+
/**
26+
* @var array
27+
*/
2528
private $actions = [];
2629

2730
/**

lib/Remote/DesiredCapabilities.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
class DesiredCapabilities implements WebDriverCapabilities
2727
{
28+
/**
29+
* @var array
30+
*/
2831
private $capabilities;
2932

3033
public function __construct(array $capabilities = [])

lib/Remote/RemoteExecuteMethod.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
class RemoteExecuteMethod implements ExecuteMethod
1919
{
20+
/**
21+
* @var RemoteWebDriver
22+
*/
2023
private $driver;
2124

2225
/**

lib/Remote/RemoteTargetLocator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
*/
2626
class RemoteTargetLocator implements WebDriverTargetLocator
2727
{
28+
/**
29+
* @var ExecuteMethod
30+
*/
2831
protected $executor;
32+
/**
33+
* @var WebDriver
34+
*/
2935
protected $driver;
3036

3137
public function __construct($executor, $driver)
@@ -103,7 +109,7 @@ public function alert()
103109
*/
104110
public function activeElement()
105111
{
106-
$response = $this->driver->execute(DriverCommand::GET_ACTIVE_ELEMENT);
112+
$response = $this->driver->execute(DriverCommand::GET_ACTIVE_ELEMENT, []);
107113
$method = new RemoteExecuteMethod($this->driver);
108114

109115
return new RemoteWebElement($method, $response['ELEMENT']);

lib/Remote/RemoteWebDriver.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ public function close()
142142
* Find the first WebDriverElement using the given mechanism.
143143
*
144144
* @param WebDriverBy $by
145-
* @return RemoteWebElement NoSuchElementException is thrown in
146-
* HttpCommandExecutor if no element is found.
145+
* @return RemoteWebElement NoSuchElementException is thrown in HttpCommandExecutor if no element is found.
147146
* @see WebDriverBy
148147
*/
149148
public function findElement(WebDriverBy $by)
@@ -158,12 +157,10 @@ public function findElement(WebDriverBy $by)
158157
}
159158

160159
/**
161-
* Find all WebDriverElements within the current page using the given
162-
* mechanism.
160+
* Find all WebDriverElements within the current page using the given mechanism.
163161
*
164162
* @param WebDriverBy $by
165-
* @return RemoteWebElement[] A list of all WebDriverElements, or an empty
166-
* array if nothing matches
163+
* @return RemoteWebElement[] A list of all WebDriverElements, or an empty array if nothing matches
167164
* @see WebDriverBy
168165
*/
169166
public function findElements(WebDriverBy $by)
@@ -228,8 +225,7 @@ public function getTitle()
228225
}
229226

230227
/**
231-
* Return an opaque handle to this window that uniquely identifies it within
232-
* this driver instance.
228+
* Return an opaque handle to this window that uniquely identifies it within this driver instance.
233229
*
234230
* @return string The current window handle.
235231
*/
@@ -369,8 +365,7 @@ public function wait($timeout_in_second = 30, $interval_in_millisecond = 250)
369365
}
370366

371367
/**
372-
* An abstraction for managing stuff you would do in a browser menu. For
373-
* example, adding and deleting cookies.
368+
* An abstraction for managing stuff you would do in a browser menu. For example, adding and deleting cookies.
374369
*
375370
* @return WebDriverOptions
376371
*/
@@ -380,8 +375,7 @@ public function manage()
380375
}
381376

382377
/**
383-
* An abstraction allowing the driver to access the browser's history and to
384-
* navigate to a given URL.
378+
* An abstraction allowing the driver to access the browser's history and to navigate to a given URL.
385379
*
386380
* @return WebDriverNavigation
387381
* @see WebDriverNavigation
@@ -438,6 +432,9 @@ public function getTouch()
438432
return $this->touch;
439433
}
440434

435+
/**
436+
* @return RemoteExecuteMethod
437+
*/
441438
protected function getExecuteMethod()
442439
{
443440
if (!$this->executeMethod) {

lib/Remote/RemoteWebElement.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function __construct(RemoteExecuteMethod $executor, $id)
5555
}
5656

5757
/**
58-
* If this element is a TEXTAREA or text INPUT element, this will clear the
59-
* value.
58+
* If this element is a TEXTAREA or text INPUT element, this will clear the value.
6059
*
6160
* @return RemoteWebElement The current instance.
6261
*/
@@ -86,8 +85,7 @@ public function click()
8685
}
8786

8887
/**
89-
* Find the first WebDriverElement within this element using the given
90-
* mechanism.
88+
* Find the first WebDriverElement within this element using the given mechanism.
9189
*
9290
* @param WebDriverBy $by
9391
* @return RemoteWebElement NoSuchElementException is thrown in
@@ -403,8 +401,7 @@ public function setFileDetector(FileDetector $detector)
403401
}
404402

405403
/**
406-
* If this current element is a form, or an element within a form, then this
407-
* will be submitted to the remote server.
404+
* If this current element is a form, or an element within a form, then this will be submitted to the remote server.
408405
*
409406
* @return RemoteWebElement The current instance.
410407
*/

lib/Remote/UselessFileDetector.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
class UselessFileDetector implements FileDetector
1919
{
20-
/**
21-
* @param string $file
22-
*/
2320
public function getLocalFile($file)
2421
{
2522
return null;

0 commit comments

Comments
 (0)