Rename Custom Post Slug using taxonomy

We have a custom posts called “Reviews” and rename the URL based on a taxonomy (manufacturers) selected for the post. For example if the MFG taxonomy called BENQ is selected the URL for the post will be

domain.com/benq/postname not domain.com/reviews/postname/

I’m getting this error: Warning: Missing argument 3 for custom_post_type_link(), called in /../wp-includes/class-wp-hook.php on line 288 and defined in /../wp-content/themes/understrap-child-theme/functions.php on line 1192

Here is the function:

add_filter(‘post_type_link’, ‘custom_post_type_link’, 10, 2);

function custom_post_type_link($ permalink, $ post, $ leavename) { if (!gettype($ post) == ‘post’) { return $ permalink; }

$  url_components = parse_url($  permalink); $  post_path = $  url_components['path']; $  post_path = trim($  post_path, '/'); $  post_name = explode('/', $  post_path); $  post_name = end($  post_name);  if (!empty($  post_name)) {      if ($  post->post_type == 'reviews') {          $  terms = get_the_terms($  post->ID, 'manufacturers');          if (is_array($  terms)) {              $  term = array_pop($  terms)->slug;         }         else {              $  terms = get_the_terms($  post->post_parent, 'manufacturers');              if (is_array($  terms)) {                 $  term = array_pop($  terms)->slug;             }             else {                 $  term = 'review';             }         }          $  permalink = str_replace($  post_path, '' . $  term . '/' . $  post_name . '', $  permalink);     } }  return $  permalink; 

}

Any idea of the issue?