Skip to content

Commit 916471d

Browse files
authored
Improve PhpStorm's auto-complete of "DriverInterface" method arguments (#847)
1 parent 44b5966 commit 916471d

File tree

2 files changed

+135
-31
lines changed

2 files changed

+135
-31
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"phpstan/phpstan-phpunit": "^1.3",
2525
"phpunit/phpunit": "^8.5.22 || ^9.5.11",
2626
"symfony/error-handler": "^4.4 || ^5.0 || ^6.0 || ^7.0",
27-
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0"
27+
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0",
28+
"jetbrains/phpstorm-attributes": "*"
2829
},
2930

3031
"suggest": {

src/Driver/DriverInterface.php

Lines changed: 133 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/*
3+
/**
44
* This file is part of the Mink package.
55
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
66
*
@@ -15,6 +15,7 @@
1515
use Behat\Mink\Exception\UnsupportedDriverActionException;
1616
use Behat\Mink\KeyModifier;
1717
use Behat\Mink\Session;
18+
use JetBrains\PhpStorm\Language;
1819

1920
/**
2021
* Driver interface.
@@ -304,7 +305,10 @@ public function getWindowName();
304305
* @throws UnsupportedDriverActionException When operation not supported by the driver
305306
* @throws DriverException When the operation cannot be done
306307
*/
307-
public function find(string $xpath);
308+
public function find(
309+
#[Language('XPath')]
310+
string $xpath
311+
);
308312

309313
/**
310314
* Returns element's tag name by its XPath query.
@@ -316,7 +320,10 @@ public function find(string $xpath);
316320
* @throws UnsupportedDriverActionException When operation not supported by the driver
317321
* @throws DriverException When the operation cannot be done
318322
*/
319-
public function getTagName(string $xpath);
323+
public function getTagName(
324+
#[Language('XPath')]
325+
string $xpath
326+
);
320327

321328
/**
322329
* Returns element's text by its XPath query.
@@ -328,7 +335,10 @@ public function getTagName(string $xpath);
328335
* @throws UnsupportedDriverActionException When operation not supported by the driver
329336
* @throws DriverException When the operation cannot be done
330337
*/
331-
public function getText(string $xpath);
338+
public function getText(
339+
#[Language('XPath')]
340+
string $xpath
341+
);
332342

333343
/**
334344
* Returns element's inner html by its XPath query.
@@ -340,7 +350,10 @@ public function getText(string $xpath);
340350
* @throws UnsupportedDriverActionException When operation not supported by the driver
341351
* @throws DriverException When the operation cannot be done
342352
*/
343-
public function getHtml(string $xpath);
353+
public function getHtml(
354+
#[Language('XPath')]
355+
string $xpath
356+
);
344357

345358
/**
346359
* Returns element's outer html by its XPath query.
@@ -352,7 +365,10 @@ public function getHtml(string $xpath);
352365
* @throws UnsupportedDriverActionException When operation not supported by the driver
353366
* @throws DriverException When the operation cannot be done
354367
*/
355-
public function getOuterHtml(string $xpath);
368+
public function getOuterHtml(
369+
#[Language('XPath')]
370+
string $xpath
371+
);
356372

357373
/**
358374
* Returns element's attribute by its XPath query.
@@ -365,7 +381,11 @@ public function getOuterHtml(string $xpath);
365381
* @throws UnsupportedDriverActionException When operation not supported by the driver
366382
* @throws DriverException When the operation cannot be done
367383
*/
368-
public function getAttribute(string $xpath, string $name);
384+
public function getAttribute(
385+
#[Language('XPath')]
386+
string $xpath,
387+
string $name
388+
);
369389

370390
/**
371391
* Returns element's value by its XPath query.
@@ -379,7 +399,10 @@ public function getAttribute(string $xpath, string $name);
379399
* @throws UnsupportedDriverActionException When operation not supported by the driver
380400
* @throws DriverException When the operation cannot be done
381401
*/
382-
public function getValue(string $xpath);
402+
public function getValue(
403+
#[Language('XPath')]
404+
string $xpath
405+
);
383406

384407
/**
385408
* Sets element's value by its XPath query.
@@ -394,7 +417,11 @@ public function getValue(string $xpath);
394417
* @throws UnsupportedDriverActionException When operation not supported by the driver
395418
* @throws DriverException When the operation cannot be done
396419
*/
397-
public function setValue(string $xpath, $value);
420+
public function setValue(
421+
#[Language('XPath')]
422+
string $xpath,
423+
$value
424+
);
398425

399426
/**
400427
* Checks checkbox by its XPath query.
@@ -408,7 +435,10 @@ public function setValue(string $xpath, $value);
408435
* @throws UnsupportedDriverActionException When operation not supported by the driver
409436
* @throws DriverException When the operation cannot be done
410437
*/
411-
public function check(string $xpath);
438+
public function check(
439+
#[Language('XPath')]
440+
string $xpath
441+
);
412442

413443
/**
414444
* Unchecks checkbox by its XPath query.
@@ -422,7 +452,10 @@ public function check(string $xpath);
422452
* @throws UnsupportedDriverActionException When operation not supported by the driver
423453
* @throws DriverException When the operation cannot be done
424454
*/
425-
public function uncheck(string $xpath);
455+
public function uncheck(
456+
#[Language('XPath')]
457+
string $xpath
458+
);
426459

427460
/**
428461
* Checks whether checkbox or radio button located by its XPath query is checked.
@@ -436,7 +469,10 @@ public function uncheck(string $xpath);
436469
* @throws UnsupportedDriverActionException When operation not supported by the driver
437470
* @throws DriverException When the operation cannot be done
438471
*/
439-
public function isChecked(string $xpath);
472+
public function isChecked(
473+
#[Language('XPath')]
474+
string $xpath
475+
);
440476

441477
/**
442478
* Selects option from select field or value in radio group located by its XPath query.
@@ -452,7 +488,12 @@ public function isChecked(string $xpath);
452488
* @throws UnsupportedDriverActionException When operation not supported by the driver
453489
* @throws DriverException When the operation cannot be done
454490
*/
455-
public function selectOption(string $xpath, string $value, bool $multiple = false);
491+
public function selectOption(
492+
#[Language('XPath')]
493+
string $xpath,
494+
string $value,
495+
bool $multiple = false
496+
);
456497

457498
/**
458499
* Checks whether select option, located by its XPath query, is selected.
@@ -466,7 +507,10 @@ public function selectOption(string $xpath, string $value, bool $multiple = fals
466507
* @throws UnsupportedDriverActionException When operation not supported by the driver
467508
* @throws DriverException When the operation cannot be done
468509
*/
469-
public function isSelected(string $xpath);
510+
public function isSelected(
511+
#[Language('XPath')]
512+
string $xpath
513+
);
470514

471515
/**
472516
* Clicks button or link located by its XPath query.
@@ -478,7 +522,10 @@ public function isSelected(string $xpath);
478522
* @throws UnsupportedDriverActionException When operation not supported by the driver
479523
* @throws DriverException When the operation cannot be done
480524
*/
481-
public function click(string $xpath);
525+
public function click(
526+
#[Language('XPath')]
527+
string $xpath
528+
);
482529

483530
/**
484531
* Double-clicks button or link located by its XPath query.
@@ -490,7 +537,10 @@ public function click(string $xpath);
490537
* @throws UnsupportedDriverActionException When operation not supported by the driver
491538
* @throws DriverException When the operation cannot be done
492539
*/
493-
public function doubleClick(string $xpath);
540+
public function doubleClick(
541+
#[Language('XPath')]
542+
string $xpath
543+
);
494544

495545
/**
496546
* Right-clicks button or link located by its XPath query.
@@ -502,7 +552,10 @@ public function doubleClick(string $xpath);
502552
* @throws UnsupportedDriverActionException When operation not supported by the driver
503553
* @throws DriverException When the operation cannot be done
504554
*/
505-
public function rightClick(string $xpath);
555+
public function rightClick(
556+
#[Language('XPath')]
557+
string $xpath
558+
);
506559

507560
/**
508561
* Attaches file path to file field located by its XPath query.
@@ -517,7 +570,12 @@ public function rightClick(string $xpath);
517570
* @throws UnsupportedDriverActionException When operation not supported by the driver
518571
* @throws DriverException When the operation cannot be done
519572
*/
520-
public function attachFile(string $xpath, string $path);
573+
public function attachFile(
574+
#[Language('XPath')]
575+
string $xpath,
576+
#[Language('file-reference')]
577+
string $path
578+
);
521579

522580
/**
523581
* Checks whether element visible located by its XPath query.
@@ -529,7 +587,10 @@ public function attachFile(string $xpath, string $path);
529587
* @throws UnsupportedDriverActionException When operation not supported by the driver
530588
* @throws DriverException When the operation cannot be done
531589
*/
532-
public function isVisible(string $xpath);
590+
public function isVisible(
591+
#[Language('XPath')]
592+
string $xpath
593+
);
533594

534595
/**
535596
* Simulates a mouse over on the element.
@@ -541,7 +602,10 @@ public function isVisible(string $xpath);
541602
* @throws UnsupportedDriverActionException When operation not supported by the driver
542603
* @throws DriverException When the operation cannot be done
543604
*/
544-
public function mouseOver(string $xpath);
605+
public function mouseOver(
606+
#[Language('XPath')]
607+
string $xpath
608+
);
545609

546610
/**
547611
* Brings focus to element.
@@ -553,7 +617,10 @@ public function mouseOver(string $xpath);
553617
* @throws UnsupportedDriverActionException When operation not supported by the driver
554618
* @throws DriverException When the operation cannot be done
555619
*/
556-
public function focus(string $xpath);
620+
public function focus(
621+
#[Language('XPath')]
622+
string $xpath
623+
);
557624

558625
/**
559626
* Removes focus from element.
@@ -565,7 +632,10 @@ public function focus(string $xpath);
565632
* @throws UnsupportedDriverActionException When operation not supported by the driver
566633
* @throws DriverException When the operation cannot be done
567634
*/
568-
public function blur(string $xpath);
635+
public function blur(
636+
#[Language('XPath')]
637+
string $xpath
638+
);
569639

570640
/**
571641
* Presses specific keyboard key.
@@ -579,7 +649,12 @@ public function blur(string $xpath);
579649
* @throws UnsupportedDriverActionException When operation not supported by the driver
580650
* @throws DriverException When the operation cannot be done
581651
*/
582-
public function keyPress(string $xpath, $char, ?string $modifier = null);
652+
public function keyPress(
653+
#[Language('XPath')]
654+
string $xpath,
655+
$char,
656+
?string $modifier = null
657+
);
583658

584659
/**
585660
* Pressed down specific keyboard key.
@@ -593,7 +668,12 @@ public function keyPress(string $xpath, $char, ?string $modifier = null);
593668
* @throws UnsupportedDriverActionException When operation not supported by the driver
594669
* @throws DriverException When the operation cannot be done
595670
*/
596-
public function keyDown(string $xpath, $char, ?string $modifier = null);
671+
public function keyDown(
672+
#[Language('XPath')]
673+
string $xpath,
674+
$char,
675+
?string $modifier = null
676+
);
597677

598678
/**
599679
* Pressed up specific keyboard key.
@@ -607,7 +687,12 @@ public function keyDown(string $xpath, $char, ?string $modifier = null);
607687
* @throws UnsupportedDriverActionException When operation not supported by the driver
608688
* @throws DriverException When the operation cannot be done
609689
*/
610-
public function keyUp(string $xpath, $char, ?string $modifier = null);
690+
public function keyUp(
691+
#[Language('XPath')]
692+
string $xpath,
693+
$char,
694+
?string $modifier = null
695+
);
611696

612697
/**
613698
* Drag one element onto another.
@@ -620,7 +705,12 @@ public function keyUp(string $xpath, $char, ?string $modifier = null);
620705
* @throws UnsupportedDriverActionException When operation not supported by the driver
621706
* @throws DriverException When the operation cannot be done
622707
*/
623-
public function dragTo(string $sourceXpath, string $destinationXpath);
708+
public function dragTo(
709+
#[Language('XPath')]
710+
string $sourceXpath,
711+
#[Language('XPath')]
712+
string $destinationXpath
713+
);
624714

625715
/**
626716
* Executes JS script.
@@ -632,7 +722,10 @@ public function dragTo(string $sourceXpath, string $destinationXpath);
632722
* @throws UnsupportedDriverActionException When operation not supported by the driver
633723
* @throws DriverException When the operation cannot be done
634724
*/
635-
public function executeScript(string $script);
725+
public function executeScript(
726+
#[Language('JavaScript')]
727+
string $script
728+
);
636729

637730
/**
638731
* Evaluates JS script.
@@ -647,7 +740,10 @@ public function executeScript(string $script);
647740
* @throws UnsupportedDriverActionException When operation not supported by the driver
648741
* @throws DriverException When the operation cannot be done
649742
*/
650-
public function evaluateScript(string $script);
743+
public function evaluateScript(
744+
#[Language('JavaScript')]
745+
string $script
746+
);
651747

652748
/**
653749
* Waits some time or until JS condition turns true.
@@ -660,7 +756,11 @@ public function evaluateScript(string $script);
660756
* @throws UnsupportedDriverActionException When operation not supported by the driver
661757
* @throws DriverException When the operation cannot be done
662758
*/
663-
public function wait(int $timeout, string $condition);
759+
public function wait(
760+
int $timeout,
761+
#[Language('JavaScript')]
762+
string $condition
763+
);
664764

665765
/**
666766
* Set the dimensions of the window.
@@ -700,5 +800,8 @@ public function maximizeWindow(?string $name = null);
700800
* @throws UnsupportedDriverActionException When operation not supported by the driver
701801
* @throws DriverException When the operation cannot be done
702802
*/
703-
public function submitForm(string $xpath);
803+
public function submitForm(
804+
#[Language('XPath')]
805+
string $xpath
806+
);
704807
}

0 commit comments

Comments
 (0)