1 | <?php |
||
17 | trait ScreenshotTrait |
||
18 | { |
||
19 | use AttachmentSupport; |
||
20 | |||
21 | /** |
||
22 | * @return string |
||
23 | */ |
||
24 | abstract protected function getBrowser(); |
||
25 | |||
26 | /** |
||
27 | * @return \PHPWebDriver_WebDriverSession|WebDriver\SessionInterface |
||
28 | */ |
||
29 | abstract protected function getSession(); |
||
30 | |||
31 | /** |
||
32 | * @return string |
||
33 | */ |
||
34 | protected function screenshot() |
||
42 | |||
43 | /** |
||
44 | * @param string|null $caption |
||
45 | * @return $this |
||
46 | */ |
||
47 | protected function takeScreenshot($caption = null) |
||
60 | |||
61 | /** |
||
62 | * @param string|null $caption |
||
63 | * @return ScreenshotTrait |
||
|
|||
64 | * @todo remove |
||
65 | * @deprecated use takeScreenshot() |
||
66 | */ |
||
67 | protected function attachScreenshot($caption = null) |
||
71 | } |
||
72 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.