8
8
*
9
9
* @since DRUPAL-4-6
10
10
*
11
- * @license Licensed under the disjunction of the CeCILL, version 2 and General
12
- * Public License version 2 and later
11
+ * @license GPL-2.0-or-later
13
12
*
14
- * License note: QA is distributed by OSInet to its customers under the
15
- * CeCILL 2.0 license. OSInet support services only apply to the module
16
- * when distributed by OSInet, not by any third-party further down the
17
- * distribution chain.
13
+ * License note: OSInet support services only apply to the module when
14
+ * distributed by OSInet, not by any third-party further down the distribution
15
+ * chain enabled by GPL.
18
16
*
19
- * If you obtained QA from drupal.org, that site received it under the
20
- * GPLv2 license and can therefore distribute it under the GPLv2, and
21
- * so can you and just anyone down the chain as long as the GPLv2 terms
22
- * are abided by, the module distributor in that case being the
23
- * drupal.org organization or the downstream distributor, not OSInet.
17
+ * If you obtained QA from another source, that source received it under the
18
+ * GPL, and can therefore distribute it under the GPL, and so can you and just
19
+ * anyone down the chain as long as the GPL terms are abided by, the module
20
+ * distributor in that case being that source, not OSInet.
24
21
*/
25
22
26
23
use Drupal\Component\Utility\Xss;
24
+ use Drupal\Core\Form\FormStateInterface;
27
25
use Drupal\Core\Url;
28
26
use Drupal\qa\BaseControl;
29
27
use Drupal\qa\Exportable;
30
- use Drupal\qa\Variable\Variable ;
28
+ use Drupal\qa\Variable;
31
29
use Symfony\Component\HttpFoundation\RedirectResponse;
32
30
33
31
/**
34
- * Page callback for qa/dependencies
32
+ * Page callback for qa/dependencies.
35
33
*
36
- * TODO convert to native Image_GraphViz to remove dependency on graphviz_filter
37
- * XXX convert to Grafizzi to remove dependency on Image_GraphViz
34
+ * TODO convert to native Image_GraphViz to stop depending on graphviz_filter.
35
+ * XXX convert to Grafizzi to remove dependency on Image_GraphViz.
38
36
*
39
37
* @return string
38
+ * A DOT digraph file.
40
39
*/
41
40
function qa_page_dependencies() {
42
41
/** @var \Drupal\qa\Dependencies $qaDep */
43
42
$qaDep = Drupal::service('qa.dependencies');
44
- $G = $qaDep->build();
45
- // passed by reference: cannot pass a function return
46
- return graphviz_filter_render($G );
43
+ $graph = $qaDep->build();
44
+ // Passed by reference: cannot pass a function return.
45
+ return graphviz_filter_render($graph );
47
46
}
48
47
49
48
/**
50
49
* Batch conclusion callback.
51
50
*
52
- * @param boolean $success
51
+ * @param bool $success
52
+ * Did the batch succeed ?
53
53
* @param array $results
54
+ * The batch steps results.
54
55
* @param array $operations
56
+ * The operations performed during the batch.
55
57
*/
56
- function qa_report_finished($success, $results, $operations) {
58
+ function qa_report_finished(bool $success, array $results, array $operations) {
57
59
unset($results['#message']);
58
60
if ($success) {
59
61
$message = Drupal::translation()
@@ -77,7 +79,7 @@ function qa_report_results() {
77
79
if (empty($_SESSION['qa_results'])) {
78
80
return new RedirectResponse(Url::fromRoute('qa.reports'));
79
81
}
80
- // Work around incomplete classes
82
+ // Work around incomplete classes.
81
83
$results = unserialize(serialize($_SESSION['qa_results']));
82
84
83
85
$header = [
@@ -92,12 +94,12 @@ function qa_report_results() {
92
94
$data[] = [
93
95
$control->title,
94
96
$pass->status
95
- ? $r->render([
97
+ ? $r->render([
96
98
'#theme' => 'image',
97
99
'#path' => 'misc/watchdog-ok.png',
98
100
'#alt' => t('OK'),
99
101
])
100
- : $r->render([
102
+ : $r->render([
101
103
'#theme' => 'image',
102
104
'#path' => 'misc/watchdog-error.png',
103
105
'#alt' => t('Error'),
@@ -114,14 +116,15 @@ function qa_report_results() {
114
116
],
115
117
'#attached' => ['library' => ['qa/results']],
116
118
]);
117
- // unset($_SESSION['qa_results']);
119
+ // unset($_SESSION['qa_results']).
118
120
return $ret;
119
121
}
120
122
121
123
/**
122
124
* Form builder for QA packages/controls selection form.
123
125
*
124
126
* @return array
127
+ * A form array.
125
128
*/
126
129
function qa_report_form($form, $form_state) {
127
130
$form = [];
@@ -186,12 +189,14 @@ function qa_report_form($form, $form_state) {
186
189
}
187
190
188
191
/**
189
- * Submit handler for QA packages/controls selection form
192
+ * Submit handler for QA packages/controls selection form.
190
193
*
191
194
* @param array $form
192
- * @param array $form_state
195
+ * The form array.
196
+ * @param \Drupal\Core\Form\FormStateInterface $form_state
197
+ * The form state.
193
198
*/
194
- function qa_report_form_submit($form, & $form_state) {
199
+ function qa_report_form_submit(array $form, FormStateInterface $form_state) {
195
200
$controls = [];
196
201
foreach ($form_state['values'] as $item => $value) {
197
202
if (class_exists($item) && is_subclass_of($item,
@@ -218,10 +223,10 @@ function qa_report_form_submit($form, &$form_state) {
218
223
'operations' => [],
219
224
'title' => t('QA Controls running'),
220
225
'init_message' => t('QA Controls initializing'),
221
- // 'progress_message' => t('current: @current, Remaining: @remaining, Total: @total'),
226
+ 'progress_message' => t('current: @current, Remaining: @remaining, Total: @total'),
222
227
'error_message' => t('Error in QA Control'),
223
228
'finished' => 'qa_report_finished',
224
- // 'file' => '', // only if outside module file
229
+ // 'file' => '', // only if outside module file.
225
230
];
226
231
227
232
foreach ($controls as $item => $value) {
@@ -232,10 +237,8 @@ function qa_report_form_submit($form, &$form_state) {
232
237
233
238
/**
234
239
* Batch progress step.
235
- *
236
- * @return void
237
240
*/
238
- function qa_report_run_pass($class_name, &$context) {
241
+ function qa_report_run_pass($class_name, &$context): void {
239
242
$name_arg = ['@class' => $class_name];
240
243
241
244
$control = new $class_name();
@@ -263,6 +266,15 @@ function qa_report_run_pass($class_name, &$context) {
263
266
}
264
267
}
265
268
269
+ /**
270
+ * Load variable by name.
271
+ *
272
+ * @param string $name
273
+ * The name of the variable.
274
+ *
275
+ * @return \Drupal\qa\Variable|false
276
+ * The variable if it was found.
277
+ */
266
278
function qa_variable_load($name) {
267
279
$variable = new Variable($name);
268
280
if (!$variable->is_set) {
0 commit comments