Skip to content

Commit c20931e

Browse files
authored
Adds types to stubs (#1004)
1 parent 9629ff1 commit c20931e

File tree

7 files changed

+22
-47
lines changed

7 files changed

+22
-47
lines changed

src/Console/stubs/component.stub

+4-9
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ class DummyClass extends BaseComponent
99
{
1010
/**
1111
* Get the root selector for the component.
12-
*
13-
* @return string
1412
*/
15-
public function selector()
13+
public function selector(): string
1614
{
1715
return '#selector';
1816
}
1917

2018
/**
2119
* Assert that the browser page contains the component.
22-
*
23-
* @param Browser $browser
24-
* @return void
2520
*/
26-
public function assert(Browser $browser)
21+
public function assert(Browser $browser): void
2722
{
2823
$browser->assertVisible($this->selector());
2924
}
3025

3126
/**
3227
* Get the element shortcuts for the component.
3328
*
34-
* @return array
29+
* @return array<string, string>
3530
*/
36-
public function elements()
31+
public function elements(): array
3732
{
3833
return [
3934
'@element' => '#selector',

src/Console/stubs/page.stub

+4-9
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ class DummyClass extends Page
99
{
1010
/**
1111
* Get the URL for the page.
12-
*
13-
* @return string
1412
*/
15-
public function url()
13+
public function url(): string
1614
{
1715
return '/';
1816
}
1917

2018
/**
2119
* Assert that the browser is on the page.
22-
*
23-
* @param Browser $browser
24-
* @return void
2520
*/
26-
public function assert(Browser $browser)
21+
public function assert(Browser $browser): void
2722
{
2823
$browser->assertPathIs($this->url());
2924
}
3025

3126
/**
3227
* Get the element shortcuts for the page.
3328
*
34-
* @return array
29+
* @return array<string, string>
3530
*/
36-
public function elements()
31+
public function elements(): array
3732
{
3833
return [
3934
'@element' => '#selector',

src/Console/stubs/test.stub

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ class DummyClass extends DuskTestCase
1010
{
1111
/**
1212
* A Dusk test example.
13-
*
14-
* @return void
1513
*/
16-
public function testExample()
14+
public function testExample(): void
1715
{
1816
$this->browse(function (Browser $browser) {
1917
$browser->visit('/')

stubs/DuskTestCase.stub

+6-12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Tests;
44

5+
use Illuminate\Support\Collection;
56
use Facebook\WebDriver\Chrome\ChromeOptions;
67
use Facebook\WebDriver\Remote\DesiredCapabilities;
78
use Facebook\WebDriver\Remote\RemoteWebDriver;
@@ -15,9 +16,8 @@ abstract class DuskTestCase extends BaseTestCase
1516
* Prepare for Dusk test execution.
1617
*
1718
* @beforeClass
18-
* @return void
1919
*/
20-
public static function prepare()
20+
public static function prepare(): void
2121
{
2222
if (! static::runningInSail()) {
2323
static::startChromeDriver();
@@ -26,14 +26,12 @@ abstract class DuskTestCase extends BaseTestCase
2626

2727
/**
2828
* Create the RemoteWebDriver instance.
29-
*
30-
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
3129
*/
32-
protected function driver()
30+
protected function driver(): RemoteWebDriver
3331
{
3432
$options = (new ChromeOptions)->addArguments(collect([
3533
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
36-
])->unless($this->hasHeadlessDisabled(), function ($items) {
34+
])->unless($this->hasHeadlessDisabled(), function (Collection $items) {
3735
return $items->merge([
3836
'--disable-gpu',
3937
'--headless',
@@ -50,21 +48,17 @@ abstract class DuskTestCase extends BaseTestCase
5048

5149
/**
5250
* Determine whether the Dusk command has disabled headless mode.
53-
*
54-
* @return bool
5551
*/
56-
protected function hasHeadlessDisabled()
52+
protected function hasHeadlessDisabled(): bool
5753
{
5854
return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
5955
isset($_ENV['DUSK_HEADLESS_DISABLED']);
6056
}
6157

6258
/**
6359
* Determine if the browser window should start maximized.
64-
*
65-
* @return bool
6660
*/
67-
protected function shouldStartMaximized()
61+
protected function shouldStartMaximized(): bool
6862
{
6963
return isset($_SERVER['DUSK_START_MAXIMIZED']) ||
7064
isset($_ENV['DUSK_START_MAXIMIZED']);

stubs/ExampleTest.stub

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ class ExampleTest extends DuskTestCase
1010
{
1111
/**
1212
* A basic browser test example.
13-
*
14-
* @return void
1513
*/
16-
public function testBasicExample()
14+
public function testBasicExample(): void
1715
{
1816
$this->browse(function (Browser $browser) {
1917
$browser->visit('/')

stubs/HomePage.stub

+4-9
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,26 @@ class HomePage extends Page
88
{
99
/**
1010
* Get the URL for the page.
11-
*
12-
* @return string
1311
*/
14-
public function url()
12+
public function url(): string
1513
{
1614
return '/';
1715
}
1816

1917
/**
2018
* Assert that the browser is on the page.
21-
*
22-
* @param \Laravel\Dusk\Browser $browser
23-
* @return void
2419
*/
25-
public function assert(Browser $browser)
20+
public function assert(Browser $browser): void
2621
{
2722
//
2823
}
2924

3025
/**
3126
* Get the element shortcuts for the page.
3227
*
33-
* @return array
28+
* @return array<string, string>
3429
*/
35-
public function elements()
30+
public function elements(): array
3631
{
3732
return [
3833
'@element' => '#selector',

stubs/Page.stub

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ abstract class Page extends BasePage
99
/**
1010
* Get the global element shortcuts for the site.
1111
*
12-
* @return array
12+
* @return array<string, string>
1313
*/
14-
public static function siteElements()
14+
public static function siteElements(): array
1515
{
1616
return [
1717
'@element' => '#selector',

0 commit comments

Comments
 (0)