55 */
66namespace Phpmig \Migration ;
77
8+ use Symfony \Component \Console \Input \InputInterface ;
89use Symfony \Component \Console \Output \OutputInterface ;
9- use Symfony \Component \Console \Helper \DialogHelper ;
10+ use Symfony \Component \Console \Helper \QuestionHelper ;
11+ use Symfony \Component \Console \Question \Question ;
1012
1113/**
1214 * This file is part of phpmig
@@ -42,7 +44,12 @@ class Migration
4244 protected $ output = null ;
4345
4446 /**
45- * @var DialogHelper
47+ * @var InputInterface
48+ */
49+ protected $ input = null ;
50+
51+ /**
52+ * @var QuestionHelper
4653 */
4754 protected $ dialogHelper = null ;
4855
@@ -91,7 +98,7 @@ public function down()
9198 *
9299 * @return int
93100 */
94- public function getVersion ()
101+ public function getVersion (): ? int
95102 {
96103 return $ this ->version ;
97104 }
@@ -102,7 +109,7 @@ public function getVersion()
102109 * @param int $version
103110 * @return Migration
104111 */
105- public function setVersion ($ version )
112+ public function setVersion (int $ version ): Migration
106113 {
107114 $ this ->version = $ version ;
108115 return $ this ;
@@ -113,7 +120,7 @@ public function setVersion($version)
113120 *
114121 * @return string
115122 */
116- public function getName ()
123+ public function getName (): string
117124 {
118125 return get_class ($ this );
119126 }
@@ -123,7 +130,7 @@ public function getName()
123130 *
124131 * @return \ArrayAccess
125132 */
126- public function getContainer ()
133+ public function getContainer (): ? \ ArrayAccess
127134 {
128135 return $ this ->container ;
129136 }
@@ -132,9 +139,9 @@ public function getContainer()
132139 * Set Container
133140 *
134141 * @param \ArrayAccess $container
135- * @return Migrator
142+ * @return Migration
136143 */
137- public function setContainer (\ArrayAccess $ container )
144+ public function setContainer (\ArrayAccess $ container ): Migration
138145 {
139146 $ this ->container = $ container ;
140147 return $ this ;
@@ -145,45 +152,65 @@ public function setContainer(\ArrayAccess $container)
145152 *
146153 * @return OutputInterface
147154 */
148- public function getOutput ()
155+ public function getOutput (): ? OutputInterface
149156 {
150157 return $ this ->output ;
151158 }
152159
160+ /**
161+ * Get Output
162+ *
163+ * @return InputInterface
164+ */
165+ public function getInput (): ?InputInterface
166+ {
167+ return $ this ->input ;
168+ }
169+
153170 /**
154171 * Set Output
155172 *
156173 * @param OutputInterface $output
157- * @return Migrator
174+ * @return Migration
158175 */
159- public function setOutput (OutputInterface $ output )
176+ public function setOutput (OutputInterface $ output ): Migration
160177 {
161178 $ this ->output = $ output ;
162179 return $ this ;
163180 }
164181
182+ /**
183+ * Set Output
184+ *
185+ * @param InputInterface $output
186+ * @return Migration
187+ */
188+ public function setInput (InputInterface $ input ): Migration
189+ {
190+ $ this ->input = $ input ;
191+ return $ this ;
192+ }
193+
165194 /**
166195 * Ask for input
167196 *
168- * @param string $question
169- * @param mixed $default
197+ * @param Question $question
170198 * @return string The users answer
171199 */
172- public function ask ($ question , $ default = null )
200+ public function ask (Question $ question ): string
173201 {
174- return $ this ->getDialogHelper ()->ask ($ this ->getOutput (), $ question , $ default );
202+ return $ this ->getDialogHelper ()->ask ($ this ->getInput (), $ this -> getOutput () , $ question );
175203 }
176204
177205 /**
178206 * Ask for confirmation
179207 *
180- * @param string $question
181- * @param mixed $default
208+ * @param Question $question
182209 * @return string The users answer
183210 */
184- public function confirm ($ question , $ default = true )
211+ public function confirm (Question $ question ): string
185212 {
186- return $ this ->getDialogHelper ()->askConfirmation ($ this ->getOutput (), $ question , $ default );
213+ return $ this ->getDialogHelper ()->ask ($ this ->getInput (), $ this -> getOutput () , $ question );
187214 }
188215
189216 /**
@@ -201,24 +228,24 @@ public function get($key)
201228 /**
202229 * Get Dialog Helper
203230 *
204- * @return DialogHelper
231+ * @return QuestionHelper
205232 */
206- public function getDialogHelper ()
233+ public function getDialogHelper (): ? QuestionHelper
207234 {
208235 if ($ this ->dialogHelper ) {
209236 return $ this ->dialogHelper ;
210237 }
211238
212- return $ this ->dialogHelper = new DialogHelper ();
239+ return $ this ->dialogHelper = new QuestionHelper ();
213240 }
214241
215242 /**
216243 * Set Dialog Helper
217244 *
218- * @param DialogHelper $dialogHelper
245+ * @param QuestionHelper $dialogHelper
219246 * @return Migration
220247 */
221- public function setDialogHelper (DialogHelper $ dialogHelper )
248+ public function setDialogHelper (QuestionHelper $ dialogHelper ): Migration
222249 {
223250 $ this ->dialogHelper = $ dialogHelper ;
224251 return $ this ;
0 commit comments