Type hints for ->share() and ->protect()

PhpStorm doesn't recognize anonymous functions as "object", but it plays well with "Closure|object" as the type hint.