PHP methods that work in both instantiated and static contexts?
问题 I'm trying to setup some PHP methods that are callable in instantiated and static contexts. What are some good ways to do this? For example I want to be able to do: Foo::bar($item); foo($item)->bar(); I could setup two separate classes and have each function modify the thisArg and delegate to the other, but it seems like there's got to be a better way. The only way I could think of to do it with only one class would be something like this: function foo($item = null) { return $item instanceof