1 | <?php |
||
13 | trait Executable |
||
14 | { |
||
15 | /** |
||
16 | * @var PDO |
||
17 | */ |
||
18 | protected $pdo; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $rowCount; |
||
24 | |||
25 | /** |
||
26 | * Sets the PDO instance used by this query. |
||
27 | * |
||
28 | * @param PDO $pdo |
||
29 | * |
||
30 | * @return self |
||
31 | */ |
||
32 | public function setPDO($pdo) |
||
38 | |||
39 | /** |
||
40 | * Gets the PDO instance used by this query. |
||
41 | * |
||
42 | * @return PDO |
||
43 | */ |
||
44 | public function getPDO() |
||
48 | |||
49 | /** |
||
50 | * Executes a query. |
||
51 | * |
||
52 | * @return PDOStatement|bool result |
||
53 | */ |
||
54 | public function execute() |
||
66 | |||
67 | /** |
||
68 | * Returns the number of rows affected by the last executed statement. |
||
69 | * |
||
70 | * @return int |
||
71 | */ |
||
72 | public function rowCount() |
||
76 | } |
||
77 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.