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

views/default/object/widget/edit/num_display.php (1 issue)

usage of deprecated functions.

Deprecated Code Minor
1
<?php
2
/**
3
 * Widget edit num_display
4
 *
5
 * @uses $vars['entity']  ElggWidget
6
 * @uses $vars['name']    (optional) The name of the attribute, defaults to 'num_display'
7
 * @uses $vars['default'] (optional) The default value if no value is set, defaults to 4
8
 * @uses $vars['step']    (optional) The stepsize used in the number input, defaults to 1
9
 * @uses $vars['min']     (optional) The smallest value allowed, defaults to 1
10
 * @uses $vars['max']     (optional) The largest value allowed, defaults first to 'default_limit'
11
 *                        and as last straw to max(min, 20)
12
 */
13
14
$widget = elgg_extract('entity', $vars);
15
if (!($widget instanceof \ElggWidget)) {
16
	return;
17
}
18
unset($vars['widget']);
19
20
$name = elgg_extract('name', $vars, 'num_display');
21
$vars['name'] = "params[{$name}]";
22
23
if (!isset($vars['label'])) {
24
	$vars['label'] = elgg_echo('widget:numbertodisplay');
25
}
26
$vars['#label'] = $vars['label'];
27
unset($vars['label']);
28
29
$value = sanitize_int($widget->$name, false);
0 ignored issues
show
Deprecated Code introduced by Jeroen Dalsem
The function sanitize_int() has been deprecated: Use query parameters where possible ( Ignorable by Annotation )

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

29
$value = /** @scrutinizer ignore-deprecated */ sanitize_int($widget->$name, false);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
30
if (!$value) {
31
	$value = (int) elgg_extract('default', $vars, 4);
32
}
33
$vars['value'] = $value;
34
35
$vars['step'] = (int) elgg_extract('step', $vars, 1);
36
37
$min = (int) elgg_extract('min', $vars, 1);
38
$vars['min'] = max($min, 1);
39
40
$max = (int) elgg_extract('max', $vars, false);
41
if (!$max) {
42
	$max = (int) elgg_get_config('default_limit');
43
}
44
if (!$max) {
45
	$max = max($min, 20);
46
}
47
$vars['max'] = max($max, $vars['min']);
48
49
$vars['#type'] = 'number';
50
51
echo elgg_view_field($vars);
52