We should encourage the use of Interfaces (this is exactly what they're for) instead of checking whether the method exists.
Performance wise the difference is negligible (instanceof is even slightly faster). However, instanceof more clearly communicates intent because we're looking to use the getOwner function in the way that it's defined in that interface. When using method_exists, if someone were to implement getOwner but not return an instance of UserInterface then our code would still fall apart.
Comments
Comment #2
kingdutchPR here: https://github.com/goalgorilla/open_social/pull/1314
Comment #3
ronaldtebrake commentedGreat work, will be in 5.0 :)