3232use JetBrains \PhpStorm \Language ;
3333
3434/**
35+ * @phpstan-type TTimeouts array{script?: null|numeric, implicit?: null|numeric, page?: null|numeric, "page load"?: null|numeric, pageLoad?: null|numeric}
36+ * @phpstan-type TCapabilities array<string, mixed>
37+ * @phpstan-type TElementValue array<array-key, mixed>|bool|mixed|string|null
3538 * @phpstan-type TWebDriverInstantiator callable(string $driverHost, DesiredCapabilities $capabilities): RemoteWebDriver
3639 */
3740class WebdriverClassicDriver extends CoreDriver
@@ -80,6 +83,9 @@ class WebdriverClassicDriver extends CoreDriver
8083
8184 private DesiredCapabilities $ desiredCapabilities ;
8285
86+ /**
87+ * @var TTimeouts
88+ */
8389 private array $ timeouts = [];
8490
8591 private string $ webDriverHost ;
@@ -93,6 +99,7 @@ class WebdriverClassicDriver extends CoreDriver
9399
94100 /**
95101 * @param string $browserName One of 'edge', 'firefox', 'chrome' or any one of {@see WebDriverBrowserType} constants.
102+ * @param TCapabilities $desiredCapabilities
96103 * @param TWebDriverInstantiator|null $webDriverInstantiator
97104 */
98105 public function __construct (
@@ -340,12 +347,16 @@ public function getAttribute(
340347 return $ this ->executeJsOnXpath ($ xpath , $ script );
341348 }
342349
350+ /**
351+ * {@inheritdoc}
352+ * @return TElementValue
353+ */
343354 public function getValue (
344355 #[Language('XPath ' )]
345356 string $ xpath
346357 ) {
347358 $ element = $ this ->findElement ($ xpath );
348- $ widgetType = strtolower ( $ element ->getTagName () ?? '' );
359+ $ widgetType = $ element ->getTagName ();
349360 if ($ widgetType === 'input ' ) {
350361 $ widgetType = strtolower ((string )$ element ->getAttribute ('type ' ));
351362 }
@@ -380,13 +391,17 @@ public function getValue(
380391 }
381392 }
382393
394+ /**
395+ * {@inheritdoc}
396+ * @param TElementValue $value
397+ */
383398 public function setValue (
384399 #[Language('XPath ' )]
385400 string $ xpath ,
386401 $ value
387402 ): void {
388403 $ element = $ this ->findElement ($ xpath );
389- $ widgetType = strtolower ( $ element ->getTagName () ?? '' );
404+ $ widgetType = $ element ->getTagName ();
390405 if ($ widgetType === 'input ' ) {
391406 $ widgetType = strtolower ((string )$ element ->getAttribute ('type ' ));
392407 }
@@ -519,7 +534,7 @@ public function selectOption(
519534 bool $ multiple = false
520535 ): void {
521536 $ element = $ this ->findElement ($ xpath );
522- $ tagName = strtolower ( $ element ->getTagName () ?? '' );
537+ $ tagName = $ element ->getTagName ();
523538
524539 if ($ tagName === 'input ' && strtolower ((string )$ element ->getAttribute ('type ' )) === 'radio ' ) {
525540 $ this ->selectRadioValue ($ element , $ value );
@@ -747,7 +762,7 @@ public function getWebDriverSessionId(): ?string
747762 /**
748763 * Sets the timeouts to apply to the webdriver session
749764 *
750- * @param array $timeouts The session timeout settings: Array of {script, implicit, page} => time in milliseconds
765+ * @param TTimeouts $timeouts The session timeout settings: Array of {script, implicit, page} => time in milliseconds
751766 * @throws DriverException
752767 * @api
753768 */
@@ -805,6 +820,8 @@ private function getNormalisedBrowserName(): string
805820 /**
806821 * Detect and assign appropriate browser capabilities
807822 *
823+ * @param TCapabilities $desiredCapabilities
824+ *
808825 * @see https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
809826 */
810827 private function initCapabilities (array $ desiredCapabilities ): DesiredCapabilities
0 commit comments