Completed
Push — master ( 4d87e8...6f96cd )
by Henry
06:30
created

includes/View/InstallForm.php (15 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\View;
3
4
use Redaxscript\Html;
5
use Redaxscript\Module;
6
use Redaxscript\Validator;
7
use function sha1;
8
use function uniqid;
9
10
/**
11
 * children class to create the install form
12
 *
13
 * @since 3.0.0
14
 *
15
 * @package Redaxscript
16
 * @category View
17
 * @author Henry Ruhs
18
 */
19
20
class InstallForm extends ViewAbstract
21
{
22
	/**
23
	 * render the view
24
	 *
25
	 * @param array $installArray
26
	 *
27
	 * @since 3.0.0
28
	 *
29
	 * @return string
30
	 */
31 1
32
	public function render(array $installArray = []) : string
33 1
	{
34
		$output = Module\Hook::trigger('installFormStart');
35
		$loginValidator = new Validator\Login();
36
37 1
		/* html element */
38
39 1
		$titleElement = new Html\Element();
40
		$titleElement
41 1
			->init('h2',
42
			[
43 1
				'class' => 'rs-title-content'
44 1
			])
45 1
			->text($this->_language->get('installation'));
0 ignored issues
show
It seems like $this->_language->get('installation') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
46
		$formElement = new Html\Form($this->_registry, $this->_language);
47 1
		$formElement->init(
48
		[
49
			'form' =>
50
			[
51
				'class' => 'rs-install-js-behavior rs-component-accordion rs-form-default rs-install-form-default'
52
			],
53
			'button' =>
54
			[
55
				'submit' =>
56
				[
57
					'class' => 'rs-js-submit rs-button-default rs-is-large rs-is-full',
58
					'name' => self::class
59
				]
60
			]
61
		]);
62
63
		/* create the form */
64
65
		$formElement
66
67 1
			/* database */
68
69 1
			->radio(
70
			[
71
				'id' => self::class . '\Database',
72
				'class' => 'rs-fn-status-accordion',
73
				'name' => self::class . '\Accordion',
74 1
				'checked' => 'checked'
75
			])
76 1
			->label($this->_language->get('database_setup'),
0 ignored issues
show
It seems like $this->_language->get('database_setup') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
77
			[
78
				'class' => 'rs-fn-toggle-accordion rs-label-accordion',
79 1
				'for' => self::class . '\Database'
80 1
			])
81
			->append('<ul class="rs-fn-content-accordion rs-box-accordion"><li>');
82
		if ($this->_registry->get('driverArray'))
83 1
		{
84 1
			$formElement
85
				->append('</li><li>')
86 1
				->label($this->_language->get('type'),
0 ignored issues
show
It seems like $this->_language->get('type') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
87
				[
88 1
					'for' => 'db-type'
89
				])
90 1
				->select($this->_registry->get('driverArray'),
0 ignored issues
show
It seems like $this->_registry->get('driverArray') targeting Redaxscript\Registry::get() can also be of type string; however, Redaxscript\Html\Form::select() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
91
				[
92
					$installArray['dbType']
93 1
				],
94
				[
95
					'id' => 'db-type',
96 1
					'name' => 'db-type'
97
				])
98
				->append('</li><li>');
99 1
		}
100 1
		$formElement
101
			->append('<li>')
102 1
			->label($this->_language->get('host'),
0 ignored issues
show
It seems like $this->_language->get('host') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
103
			[
104 1
				'for' => 'db-host'
105
			])
106 1
			->text(
107 1
			[
108 1
				'id' => 'db-host',
109 1
				'name' => 'db-host',
110
				'required' => 'required',
111 1
				'value' => $installArray['dbHost']
112 1
			])
113
			->append('</li><li>')
114 1
			->label($this->_language->get('name'),
0 ignored issues
show
It seems like $this->_language->get('name') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
115
			[
116 1
				'for' => 'db-name'
117
			])
118 1
			->text(
119 1
			[
120 1
				'id' => 'db-name',
121 1
				'name' => 'db-name',
122
				'required' => 'required',
123 1
				'value' => $installArray['dbName']
124 1
			])
125
			->append('</li><li>')
126 1
			->label($this->_language->get('user'),
0 ignored issues
show
It seems like $this->_language->get('user') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
127
			[
128 1
				'for' => 'db-user'
129
			])
130 1
			->text(
131 1
			[
132 1
				'id' => 'db-user',
133 1
				'name' => 'db-user',
134
				'required' => 'required',
135 1
				'value' => $installArray['dbUser']
136 1
			])
137
			->append('</li><li>')
138 1
			->label($this->_language->get('password'),
0 ignored issues
show
It seems like $this->_language->get('password') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
139
			[
140 1
				'for' => 'db-password'
141
			])
142 1
			->password(
143 1
			[
144 1
				'id' => 'db-password',
145
				'name' => 'db-password',
146 1
				'value' => $installArray['dbPassword']
147 1
			])
148
			->append('</li><li>')
149 1
			->label($this->_language->get('prefix'),
0 ignored issues
show
It seems like $this->_language->get('prefix') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
150
			[
151 1
				'for' => 'db-prefix'
152
			])
153 1
			->text(
154 1
			[
155 1
				'id' => 'db-prefix',
156
				'name' => 'db-prefix',
157 1
				'value' => $installArray['dbPrefix']
158
			])
159
			->append('</li></ul>')
160
161 1
			/* account */
162
163 1
			->radio(
164
			[
165
				'id' => self::class . '\Account',
166
				'class' => 'rs-fn-status-accordion',
167 1
				'name' => self::class . '\Accordion'
168
			])
169 1
			->label($this->_language->get('account_create'),
0 ignored issues
show
It seems like $this->_language->get('account_create') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
170
			[
171
				'class' => 'rs-fn-toggle-accordion rs-label-accordion',
172 1
				'for' => self::class . '\Account'
173 1
			])
174
			->append('<ul class="rs-fn-content-accordion rs-box-accordion"><li>')
175 1
			->label($this->_language->get('name'),
0 ignored issues
show
It seems like $this->_language->get('name') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
176
			[
177 1
				'for' => 'name'
178
			])
179 1
			->text(
180 1
			[
181 1
				'id' => 'admin-name',
182 1
				'name' => 'admin-name',
183
				'required' => 'required',
184 1
				'value' => $installArray['adminName']
185 1
			])
186
			->append('</li><li>')
187 1
			->label($this->_language->get('user'),
0 ignored issues
show
It seems like $this->_language->get('user') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
188
			[
189 1
				'for' => 'admin-user'
190
			])
191 1
			->text(
192 1
			[
193 1
				'id' => 'admin-user',
194 1
				'name' => 'admin-user',
195 1
				'pattern' => $loginValidator->getFormPattern(),
196
				'required' => 'required',
197 1
				'value' => $installArray['adminUser']
198 1
			])
199
			->append('</li><li>')
200 1
			->label($this->_language->get('password'),
0 ignored issues
show
It seems like $this->_language->get('password') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
201
			[
202 1
				'for' => 'admin-password'
203
			])
204 1
			->password(
205 1
			[
206 1
				'id' => 'admin-password',
207 1
				'name' => 'admin-password',
208 1
				'pattern' => $loginValidator->getFormPattern(),
209
				'required' => 'required',
210 1
				'value' => $installArray['adminPassword']
211 1
			])
212
			->append('</li><li>')
213 1
			->label($this->_language->get('email'),
0 ignored issues
show
It seems like $this->_language->get('email') targeting Redaxscript\Language::get() can also be of type array; however, Redaxscript\Html\Form::label() does only seem to accept null|string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
214
			[
215 1
				'for' => 'admin-email'
216
			])
217 1
			->email(
218 1
			[
219 1
				'id' => 'admin-email',
220 1
				'name' => 'admin-email',
221
				'required' => 'required',
222 1
				'value' => $installArray['adminEmail']
223 1
			])
224
			->append('</li></ul>')
225 1
			->hidden(
226 1
			[
227
				'name' => 'db-salt',
228 1
				'value' => sha1(uniqid())
229
			])
230 1
			->hidden(
231
			[
232
				'name' => 'refresh-connection',
233 1
				'value' => 1
234 1
			])
235
			->token()
236
			->submit($this->_language->get('install'));
0 ignored issues
show
It seems like $this->_language->get('install') targeting Redaxscript\Language::get() can also be of type array or null; however, Redaxscript\Html\Form::submit() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
237
238 1
		/* collect output */
239 1
240 1
		$output .= $titleElement . $formElement;
241
		$output .= Module\Hook::trigger('installFormEnd');
242
		return $output;
243
	}
244
}
245