use cache for declared function when available before falling back to stubs
use cache for declared function when available before falling back to stubs

fixes return type issues reported for the wrong file

vimeo/psalm,vimeo/psalm