| 1 | <?php | ||
| 15 | trait ScreenshotTrait | ||
| 16 | { | ||
| 17 | /** | ||
| 18 | * Taken screenshots directory | ||
| 19 | * | ||
| 20 | * @var string | ||
| 21 | */ | ||
| 22 | protected $screenshotsDir; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @return string | ||
| 26 | */ | ||
| 27 | abstract protected function getBrowser(); | ||
| 28 | |||
| 29 | /** | ||
| 30 | * @return \PHPWebDriver_WebDriverSession|WebDriver\SessionInterface | ||
| 31 | */ | ||
| 32 | abstract protected function getSession(); | ||
| 33 | |||
| 34 | /** | ||
| 35 | * @return string | ||
| 36 | */ | ||
| 37 | protected function screenshot() | ||
| 45 | |||
| 46 | /** | ||
| 47 | * @param string|null $imgName | ||
| 48 | * @return $this | ||
| 49 | */ | ||
| 50 | protected function takeScreenshot($imgName = null) | ||
| 70 | |||
| 71 | /** | ||
| 72 | * @param string|null $caption | ||
| 73 | * @return ScreenshotTrait | ||
|  | |||
| 74 | * @todo remove | ||
| 75 | * @deprecated use takeScreenshot() | ||
| 76 | */ | ||
| 77 | protected function attachScreenshot($caption = null) | ||
| 81 | } | ||
| 82 | 
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.