Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

views/default/input/longtext.php (1 issue)

Checks whether a method/function call has too few arguments.

Bug Minor
1
<?php
2
/**
3
 * Elgg long text input
4
 * Displays a long text input field that can use WYSIWYG editor
5
 *
6
 * @package Elgg
7
 * @subpackage Core
8
 *
9
 * @uses $vars['value']    The current value, if any - will be html encoded
10
 * @uses $vars['disabled'] Is the input field disabled?
11
 * @uses $vars['class']    Additional CSS class
12
 * @uses $vars['visual']   Activate WYSIWYG editor immediately
13
 *                         If disabled, will display a plaintext input with
14
 *                         a link to activate the visual editor
15
16
 * @uses $vars['editor']         Enable WYSIWYG support
17
 *                               Requires a plugin that implements a WYWIWYG library
18
 *                               (e.g. bundled ckeditor plugin)
19
 * @uses $vars['editor_type']    The type of editor eg. 'simple'. It determines the style of the editor (if supported).
20
 * @uses $vars['editor_options'] Additional options to pass to the editor
21
 */
22
23
$vars['class'] = elgg_extract_class($vars, 'elgg-input-longtext');
24
25
$defaults = [
26
	'value' => '',
27
	'rows' => '10',
28
	'cols' => '50',
29
	'id' => "elgg-input-" . base_convert(mt_rand(), 10, 36),
0 ignored issues
show
The call to mt_rand() has too few arguments starting with min. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
	'id' => "elgg-input-" . base_convert(/** @scrutinizer ignore-call */ mt_rand(), 10, 36),

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
30
];
31
32
$vars = array_merge($defaults, $vars);
33
34
$editor_opts = (array) elgg_extract('editor_options', $vars, []);
35
$editor_opts['disabled'] = !elgg_extract('editor', $vars, true);
36
$editor_opts['state'] = elgg_extract('visual', $vars, true) ? 'visual' : 'html';
37
38
unset($vars['editor']);
39
unset($vars['editor_options']);
40
unset($vars['editor_type']);
41
unset($vars['visual']);
42
43
$vars['data-editor-opts'] = json_encode($editor_opts);
44
45
$value = htmlspecialchars($vars['value'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
46
unset($vars['value']);
47
48
echo elgg_view_menu('longtext', [
49
	'sort_by' => 'priority',
50
	'class' => 'elgg-menu-hz',
51
	'textarea_id' => $vars['id'],
52
]);
53
54
echo elgg_format_element('textarea', $vars, $value);
55