tag cloud filter limit error

Hello, im trying to limit tags number in widgets but i get error with red https://prnt.sc/shq24e
this code im using :

//Register tag cloud filter callback
add_filter('widget_tag_cloud_args', 'tag_widget_limit');

//Limit number of tags inside widget
function tag_widget_limit($args){

//Check if taxonomy option inside widget is set to tags
 if(isset($args['taxonomy']) && $args['taxonomy'] == 'post_tag'){
  $args['number'] = 10; //Limit number of tags

 return $args;

Source link