1 | <?php |
||
5 | trait SyncTrait |
||
6 | { |
||
7 | |||
8 | protected function displayWarn(string $string): void |
||
14 | |||
15 | /** |
||
16 | * Switch to `sync` database. |
||
17 | * |
||
18 | * @return void |
||
19 | */ |
||
20 | protected function switchToSyncDb() |
||
28 | |||
29 | /** |
||
30 | * Dump `sync` database into a SQL file and return its path. |
||
31 | * |
||
32 | * @param boolean $isPreview |
||
33 | * @return string |
||
34 | */ |
||
35 | protected function dumpSync(bool $isPreview, string $connector = 'mysql'): string |
||
49 | |||
50 | /** |
||
51 | * Dump SQL database in given file path. |
||
52 | * |
||
53 | * @param string $path |
||
54 | * @param string $connector |
||
55 | * @return void |
||
56 | */ |
||
57 | protected function dumpSql(string $path, string $connector) |
||
72 | |||
73 | protected function getConnector(bool $isPreview, string $connector = 'mysql'): string |
||
83 | |||
84 | |||
85 | /** |
||
86 | * Put previous dump in live-preview database. |
||
87 | * |
||
88 | * @param string $path |
||
89 | * @param boolean $isPreview |
||
90 | * @return void |
||
91 | */ |
||
92 | protected function putSync(string $path, bool $isPreview, string $connector = 'mysql') |
||
103 | |||
104 | /** |
||
105 | * Put SQL file into given database. |
||
106 | * |
||
107 | * @param string $path |
||
108 | * @param string $connector |
||
109 | * @return void |
||
110 | */ |
||
111 | protected function putSql(string $path, string $connector) |
||
126 | } |
||
127 |
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.