Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

includes/View/InstallForm.php (15 issues)

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 function sha1;
7
use function uniqid;
8
9
/**
10
 * children class to create the install form
11
 *
12
 * @since 3.0.0
13
 *
14
 * @package Redaxscript
15
 * @category View
16
 * @author Henry Ruhs
17
 */
18
19
class InstallForm extends ViewAbstract
20
{
21
	/**
22
	 * render the view
23
	 *
24
	 * @param array $installArray
25
	 *
26
	 * @since 3.0.0
27
	 *
28
	 * @return string
29
	 */
30
31 1
	public function render(array $installArray = []) : string
32
	{
33 1
		$output = Module\Hook::trigger('installFormStart');
34
35
		/* html element */
36
37 1
		$titleElement = new Html\Element();
38
		$titleElement
39 1
			->init('h2',
40
			[
41 1
				'class' => 'rs-title-content'
42
			])
43 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...
44 1
		$formElement = new Html\Form($this->_registry, $this->_language);
45 1
		$formElement->init(
46
		[
47 1
			'form' =>
48
			[
49
				'class' => 'rs-install-js-behavior rs-component-accordion rs-form-default rs-install-form-default'
50
			],
51
			'button' =>
52
			[
53
				'submit' =>
54
				[
55
					'class' => 'rs-js-submit rs-button-default rs-is-large rs-is-full',
56
					'name' => self::class
57
				]
58
			]
59
		]);
60
61
		/* create the form */
62
63
		$formElement
64
65
			/* database */
66
67 1
			->radio(
68
			[
69 1
				'id' => self::class . '\Database',
70
				'class' => 'rs-fn-status-accordion',
71
				'name' => self::class . '\Accordion',
72
				'checked' => 'checked'
73
			])
74 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...
75
			[
76 1
				'class' => 'rs-fn-toggle-accordion rs-label-accordion',
77
				'for' => self::class . '\Database'
78
			])
79 1
			->append('<ul class="rs-fn-content-accordion rs-box-accordion"><li>');
80 1
		if ($this->_registry->get('driverArray'))
81
		{
82
			$formElement
83 1
				->append('</li><li>')
84 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...
85
				[
86 1
					'for' => 'db-type'
87
				])
88 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...
89
				[
90 1
					$installArray['dbType']
91
				],
92
				[
93 1
					'id' => 'db-type',
94
					'name' => 'db-type'
95
				])
96 1
				->append('</li><li>');
97
		}
98
		$formElement
99 1
			->append('<li>')
100 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...
101
			[
102 1
				'for' => 'db-host'
103
			])
104 1
			->text(
105
			[
106 1
				'id' => 'db-host',
107 1
				'name' => 'db-host',
108 1
				'required' => 'required',
109 1
				'value' => $installArray['dbHost']
110
			])
111 1
			->append('</li><li>')
112 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...
113
			[
114 1
				'for' => 'db-name'
115
			])
116 1
			->text(
117
			[
118 1
				'id' => 'db-name',
119 1
				'name' => 'db-name',
120 1
				'required' => 'required',
121 1
				'value' => $installArray['dbName']
122
			])
123 1
			->append('</li><li>')
124 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...
125
			[
126 1
				'for' => 'db-user'
127
			])
128 1
			->text(
129
			[
130 1
				'id' => 'db-user',
131 1
				'name' => 'db-user',
132 1
				'required' => 'required',
133 1
				'value' => $installArray['dbUser']
134
			])
135 1
			->append('</li><li>')
136 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...
137
			[
138 1
				'for' => 'db-password'
139
			])
140 1
			->password(
141
			[
142 1
				'id' => 'db-password',
143 1
				'name' => 'db-password',
144 1
				'value' => $installArray['dbPassword']
145
			])
146 1
			->append('</li><li>')
147 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...
148
			[
149 1
				'for' => 'db-prefix'
150
			])
151 1
			->text(
152
			[
153 1
				'id' => 'db-prefix',
154 1
				'name' => 'db-prefix',
155 1
				'value' => $installArray['dbPrefix']
156
			])
157 1
			->append('</li></ul>')
158
159
			/* account */
160
161 1
			->radio(
162
			[
163 1
				'id' => self::class . '\Account',
164
				'class' => 'rs-fn-status-accordion',
165
				'name' => self::class . '\Accordion'
166
			])
167 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...
168
			[
169 1
				'class' => 'rs-fn-toggle-accordion rs-label-accordion',
170
				'for' => self::class . '\Account'
171
			])
172 1
			->append('<ul class="rs-fn-content-accordion rs-box-accordion"><li>')
173 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...
174
			[
175 1
				'for' => 'name'
176
			])
177 1
			->text(
178
			[
179 1
				'id' => 'admin-name',
180 1
				'name' => 'admin-name',
181 1
				'required' => 'required',
182 1
				'value' => $installArray['adminName']
183
			])
184 1
			->append('</li><li>')
185 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...
186
			[
187 1
				'for' => 'admin-user'
188
			])
189 1
			->text(
190
			[
191 1
				'id' => 'admin-user',
192 1
				'name' => 'admin-user',
193 1
				'pattern' => '[a-zA-Z0-9]{1,30}',
194 1
				'required' => 'required',
195 1
				'value' => $installArray['adminUser']
196
			])
197 1
			->append('</li><li>')
198 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...
199
			[
200 1
				'for' => 'admin-password'
201
			])
202 1
			->password(
203
			[
204 1
				'id' => 'admin-password',
205 1
				'name' => 'admin-password',
206 1
				'pattern' => '[a-zA-Z0-9]{1,30}',
207 1
				'required' => 'required',
208 1
				'value' => $installArray['adminPassword']
209
			])
210 1
			->append('</li><li>')
211 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...
212
			[
213 1
				'for' => 'admin-email'
214
			])
215 1
			->email(
216
			[
217 1
				'id' => 'admin-email',
218 1
				'name' => 'admin-email',
219 1
				'required' => 'required',
220 1
				'value' => $installArray['adminEmail']
221
			])
222 1
			->append('</li></ul>')
223 1
			->hidden(
224
			[
225 1
				'name' => 'db-salt',
226 1
				'value' => sha1(uniqid())
227
			])
228 1
			->hidden(
229
			[
230 1
				'name' => 'refresh-connection',
231
				'value' => 1
232
			])
233 1
			->token()
234 1
			->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...
235
236
		/* collect output */
237
238 1
		$output .= $titleElement . $formElement;
239 1
		$output .= Module\Hook::trigger('installFormEnd');
240 1
		return $output;
241
	}
242
}
243