1 | <?php |
||
11 | trait JavascriptTrait { |
||
12 | |||
13 | /** |
||
14 | * Helper function to fix javascript code before sending it to the phantomjs API |
||
15 | * @param $script |
||
16 | * @return string |
||
17 | */ |
||
18 | protected function fixJavascriptForUse($script){ |
||
31 | |||
32 | /** |
||
33 | * Executes a script on the browser |
||
34 | * @param string $script |
||
35 | */ |
||
36 | public function executeScript($script) { |
||
39 | |||
40 | /** |
||
41 | * Evaluates a script and returns the result |
||
42 | * @param string $script |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function evaluateScript($script) { |
||
48 | |||
49 | /** |
||
50 | * Waits some time or until JS condition turns true. |
||
51 | * |
||
52 | * @param integer $timeout timeout in milliseconds |
||
53 | * @param string $condition JS condition |
||
54 | * @return boolean |
||
55 | * @throws DriverException When the operation cannot be done |
||
56 | */ |
||
57 | public function wait($timeout, $condition) { |
||
67 | |||
68 | } |
||
69 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: