3030class create extends command
3131{
3232 /** @var array user input data array */
33- protected $ data = [];
33+ protected array $ data = [];
3434
3535 /** @var QuestionHelper $helper */
36- protected $ helper ;
36+ protected QuestionHelper $ helper ;
3737
3838 /** @var InputInterface */
39- protected $ input ;
39+ protected InputInterface $ input ;
4040
4141 /** @var OutputInterface */
42- protected $ output ;
42+ protected OutputInterface $ output ;
4343
4444 /** @var language */
45- protected $ language ;
45+ protected language $ language ;
4646
4747 /** @var packager */
48- protected $ packager ;
48+ protected packager $ packager ;
4949
5050 /** @var validator */
51- protected $ validator ;
51+ protected validator $ validator ;
5252
5353 /**
5454 * Constructor
@@ -71,7 +71,7 @@ public function __construct(user $user, language $language, packager $packager,
7171 /**
7272 * {@inheritdoc}
7373 */
74- protected function configure ()
74+ protected function configure (): void
7575 {
7676 $ this
7777 ->setName ('extension:create ' )
@@ -93,7 +93,7 @@ protected function configure()
9393 *
9494 * @throws LogicException When this abstract method is not implemented
9595 */
96- protected function execute (InputInterface $ input , OutputInterface $ output )
96+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
9797 {
9898 $ this ->packager ->create_extension ($ this ->data );
9999
@@ -108,12 +108,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
108108 * @param InputInterface $input An InputInterface instance
109109 * @param OutputInterface $output An OutputInterface instance
110110 */
111- protected function interact (InputInterface $ input , OutputInterface $ output )
111+ protected function interact (InputInterface $ input , OutputInterface $ output ): void
112112 {
113113 $ this ->input = $ input ;
114114 $ this ->output = $ output ;
115115
116- $ this ->helper = $ this ->getHelper ('question ' );
116+ $ helper = $ this ->getHelper ('question ' );
117+ if (!$ helper instanceof QuestionHelper)
118+ {
119+ throw new LogicException ('Question helper must be an instance of QuestionHelper ' );
120+ }
121+ $ this ->helper = $ helper ;
117122
118123 $ output ->writeln ($ this ->language ->lang ('SKELETON_CLI_COMPOSER_QUESTIONS ' ));
119124 $ this ->get_composer_data ();
@@ -125,7 +130,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
125130 /**
126131 * Get composer data from the user
127132 */
128- protected function get_composer_data ()
133+ protected function get_composer_data (): void
129134 {
130135 $ dialog_questions = $ this ->packager ->get_composer_dialog_values ();
131136 foreach ($ dialog_questions ['extension ' ] as $ value => $ default )
@@ -155,7 +160,7 @@ protected function get_composer_data()
155160 /**
156161 * Get component data from the user
157162 */
158- protected function get_component_data ()
163+ protected function get_component_data (): void
159164 {
160165 $ components = $ this ->packager ->get_component_dialog_values ();
161166 foreach ($ components as $ component => $ details )
@@ -193,9 +198,9 @@ protected function get_component_data()
193198 *
194199 * @param string $value
195200 * @param mixed $default
196- * @return mixed|string
201+ * @return mixed
197202 */
198- protected function get_user_input ($ value , $ default )
203+ protected function get_user_input (string $ value , mixed $ default ): mixed
199204 {
200205 $ dialog = $ this ->language ->lang ('SKELETON_QUESTION_ ' . strtoupper ($ value )) . $ this ->language ->lang ('COLON ' );
201206
0 commit comments