Try this one:
null
will be returnreturned if the object is null.
public function canShow($product, $where = 'catalog')
{
if (is_int($product)) {
try {
$product = $this->productRepository->getById($product);
} catch (NoSuchEntityException $e) {
return false;
}
} else {
return $product ? $product->getId() : null;
}
return $product->isVisibleInCatalog() && $product->isVisibleInSiteVisibility();
}