Skip to content

Commit 2d40e31

Browse files
dbudwinOndraM
authored andcommitted
Update PHPDoc for functions that return static instances of a class
Previously, functions that contained functionality similar to `return new static(...)` had their `@return` PHPDoc tag to specify the class name like `@return SomeClass` where the preferred documentation should be `@return static`. Some support for this decision: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc.md#keyword https://netbeans.org/bugzilla/show_bug.cgi?id=196565 https://blog.madewithlove.be/post/return-types/
1 parent 5c724f1 commit 2d40e31

File tree

9 files changed

+32
-25
lines changed

9 files changed

+32
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project versioning adheres to [Semantic Versioning](http://semver.org/).
44
## Unreleased
55
### Added
66
- Connection and request timeouts could be specified also when creating RemoteWebDriver from existing session ID.
7+
- Update PHPDoc for functions that return static instances of a class.
78

89
## 1.5.0 - 2017-11-15
910
### Changed

lib/Chrome/ChromeDriver.php

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

2525
class ChromeDriver extends RemoteWebDriver
2626
{
27+
/**
28+
* @return static
29+
*/
2730
public static function start(DesiredCapabilities $desired_capabilities = null, ChromeDriverService $service = null)
2831
{
2932
if ($desired_capabilities === null) {

lib/Chrome/ChromeDriverService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class ChromeDriverService extends DriverService
2222
// The environment variable storing the path to the chrome driver executable.
2323
const CHROME_DRIVER_EXE_PROPERTY = 'webdriver.chrome.driver';
2424

25+
/**
26+
* @return static
27+
*/
2528
public static function createDefaultService()
2629
{
2730
$exe = getenv(self::CHROME_DRIVER_EXE_PROPERTY);

lib/Remote/DesiredCapabilities.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function toArray()
178178
}
179179

180180
/**
181-
* @return DesiredCapabilities
181+
* @return static
182182
*/
183183
public static function android()
184184
{
@@ -189,7 +189,7 @@ public static function android()
189189
}
190190

191191
/**
192-
* @return DesiredCapabilities
192+
* @return static
193193
*/
194194
public static function chrome()
195195
{
@@ -200,7 +200,7 @@ public static function chrome()
200200
}
201201

202202
/**
203-
* @return DesiredCapabilities
203+
* @return static
204204
*/
205205
public static function firefox()
206206
{
@@ -218,7 +218,7 @@ public static function firefox()
218218
}
219219

220220
/**
221-
* @return DesiredCapabilities
221+
* @return static
222222
*/
223223
public static function htmlUnit()
224224
{
@@ -229,7 +229,7 @@ public static function htmlUnit()
229229
}
230230

231231
/**
232-
* @return DesiredCapabilities
232+
* @return static
233233
*/
234234
public static function htmlUnitWithJS()
235235
{
@@ -242,7 +242,7 @@ public static function htmlUnitWithJS()
242242
}
243243

244244
/**
245-
* @return DesiredCapabilities
245+
* @return static
246246
*/
247247
public static function internetExplorer()
248248
{
@@ -253,7 +253,7 @@ public static function internetExplorer()
253253
}
254254

255255
/**
256-
* @return DesiredCapabilities
256+
* @return static
257257
*/
258258
public static function microsoftEdge()
259259
{
@@ -264,7 +264,7 @@ public static function microsoftEdge()
264264
}
265265

266266
/**
267-
* @return DesiredCapabilities
267+
* @return static
268268
*/
269269
public static function iphone()
270270
{
@@ -275,7 +275,7 @@ public static function iphone()
275275
}
276276

277277
/**
278-
* @return DesiredCapabilities
278+
* @return static
279279
*/
280280
public static function ipad()
281281
{
@@ -286,7 +286,7 @@ public static function ipad()
286286
}
287287

288288
/**
289-
* @return DesiredCapabilities
289+
* @return static
290290
*/
291291
public static function opera()
292292
{
@@ -297,7 +297,7 @@ public static function opera()
297297
}
298298

299299
/**
300-
* @return DesiredCapabilities
300+
* @return static
301301
*/
302302
public static function safari()
303303
{
@@ -308,7 +308,7 @@ public static function safari()
308308
}
309309

310310
/**
311-
* @return DesiredCapabilities
311+
* @return static
312312
*/
313313
public static function phantomjs()
314314
{

lib/Remote/RemoteWebDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function __construct(
8787
* @param string|null $http_proxy The proxy to tunnel requests to the remote Selenium WebDriver through
8888
* @param int|null $http_proxy_port The proxy port to tunnel requests to the remote Selenium WebDriver through
8989
* @param DesiredCapabilities $required_capabilities The required capabilities
90-
* @return RemoteWebDriver
90+
* @return static
9191
*/
9292
public static function create(
9393
$selenium_server_url = 'http://localhost:4444/wd/hub',
@@ -141,7 +141,7 @@ public static function create(
141141
* @param string $session_id The existing session id
142142
* @param int|null $connection_timeout_in_ms Set timeout for the connect phase to remote Selenium WebDriver server
143143
* @param int|null $request_timeout_in_ms Set the maximum time of a request to remote Selenium WebDriver server
144-
* @return RemoteWebDriver
144+
* @return static
145145
*/
146146
public static function createBySessionID(
147147
$session_id,

lib/Remote/RemoteWebElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function equals(WebDriverElement $other)
408408
*
409409
* @param string $id
410410
*
411-
* @return RemoteWebElement
411+
* @return static
412412
*/
413413
protected function newElement($id)
414414
{

lib/Support/Events/EventFiringWebElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ protected function dispatch($method, ...$arguments)
405405

406406
/**
407407
* @param WebDriverElement $element
408-
* @return EventFiringWebElement
408+
* @return static
409409
*/
410410
protected function newElement(WebDriverElement $element)
411411
{

lib/WebDriverBy.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getValue()
6060
* names are not permitted.
6161
*
6262
* @param string $class_name
63-
* @return WebDriverBy
63+
* @return static
6464
*/
6565
public static function className($class_name)
6666
{
@@ -71,7 +71,7 @@ public static function className($class_name)
7171
* Locates elements matching a CSS selector.
7272
*
7373
* @param string $css_selector
74-
* @return WebDriverBy
74+
* @return static
7575
*/
7676
public static function cssSelector($css_selector)
7777
{
@@ -82,7 +82,7 @@ public static function cssSelector($css_selector)
8282
* Locates elements whose ID attribute matches the search value.
8383
*
8484
* @param string $id
85-
* @return WebDriverBy
85+
* @return static
8686
*/
8787
public static function id($id)
8888
{
@@ -93,7 +93,7 @@ public static function id($id)
9393
* Locates elements whose NAME attribute matches the search value.
9494
*
9595
* @param string $name
96-
* @return WebDriverBy
96+
* @return static
9797
*/
9898
public static function name($name)
9999
{
@@ -104,7 +104,7 @@ public static function name($name)
104104
* Locates anchor elements whose visible text matches the search value.
105105
*
106106
* @param string $link_text
107-
* @return WebDriverBy
107+
* @return static
108108
*/
109109
public static function linkText($link_text)
110110
{
@@ -116,7 +116,7 @@ public static function linkText($link_text)
116116
* value.
117117
*
118118
* @param string $partial_link_text
119-
* @return WebDriverBy
119+
* @return static
120120
*/
121121
public static function partialLinkText($partial_link_text)
122122
{
@@ -127,7 +127,7 @@ public static function partialLinkText($partial_link_text)
127127
* Locates elements whose tag name matches the search value.
128128
*
129129
* @param string $tag_name
130-
* @return WebDriverBy
130+
* @return static
131131
*/
132132
public static function tagName($tag_name)
133133
{
@@ -138,7 +138,7 @@ public static function tagName($tag_name)
138138
* Locates elements matching an XPath expression.
139139
*
140140
* @param string $xpath
141-
* @return WebDriverBy
141+
* @return static
142142
*/
143143
public static function xpath($xpath)
144144
{

lib/WebDriverExpectedCondition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ function (WebDriver $driver) {
564564
* An expectation checking the number of opened windows.
565565
*
566566
* @param int $expectedNumberOfWindows
567-
* @return WebDriverExpectedCondition
567+
* @return static
568568
*/
569569
public static function numberOfWindowsToBe($expectedNumberOfWindows)
570570
{

0 commit comments

Comments
 (0)