1 | <?php |
||
10 | trait ConsoleInteractions { |
||
11 | |||
12 | /** |
||
13 | * @var InputInterface |
||
14 | */ |
||
15 | protected $input; |
||
16 | |||
17 | /** |
||
18 | * @var OutputInterface |
||
19 | */ |
||
20 | protected $output; |
||
21 | |||
22 | /** |
||
23 | * Ask a question |
||
24 | * |
||
25 | * @param string $question Question to ask |
||
26 | * @param mixed $default Default value |
||
27 | * @param bool $hidden Hide response |
||
28 | * @param bool $required User input is required |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public function ask($question, $default = null, $hidden = false, $required = true) { |
||
53 | |||
54 | /** |
||
55 | * Write messages to output buffer |
||
56 | * |
||
57 | * @param string|array $messages Messages |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | public function write($messages) { |
||
64 | |||
65 | /** |
||
66 | * Returns option value |
||
67 | * |
||
68 | * @param string $name Option name |
||
69 | * |
||
70 | * @return mixed |
||
71 | */ |
||
72 | public function option($name) { |
||
75 | |||
76 | /** |
||
77 | * Returns argument value |
||
78 | * |
||
79 | * @param string $name Argument name |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | public function argument($name) { |
||
86 | |||
87 | /** |
||
88 | * Question validator for required user response |
||
89 | * |
||
90 | * @param mixed $answer User answer |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function assertNotEmpty($answer) { |
||
101 | |||
102 | /** |
||
103 | * Dump and output system and error messages |
||
104 | * @return void |
||
105 | */ |
||
106 | protected function dumpRegisters() { |
||
118 | } |
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.