This is just an example to illustrate my issue. Quite often, I am looking for (vendor) code that executes a method, but end up in the interface (which I guess is implemented by the code I am looking for).
In a Symfony app, I have a function Example()that uses $logger, which is typehinted with LoggerInterface. I use the correct interface by adding to my file: use Psr\Log\LoggerInterface;. In my function I use $logger to log an error with the method error() like so:
public function Example(LoggerInterface $logger) { $logger->error('There was some error.') } When I open the file that contains the LoggerInterface I can see how this method:
/** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * * @param string $message * @param array $context * * @return void */ public function error($message, array $context = array()); This can be useful for the documentation and for seeing which arguments one must pass.
My question: how do I find the method that does the actual work (i.e. that is being executed) and how does the $logger 'finds' this through the interface?
In a more generic PHP example, when I need a dateTime object I will use new DateTime(); (with a use statement: use DateTime;). Then I could call the method format() on it. When I want to find out exactly what format() does, looking for it in the class DateTime, all I find is:
/** * Returns date formatted according to given format. * @param string $format * @return string * @link https://php.net/manual/en/datetime.format.php */ public function format ($format) {} Again I wonder: how to find the method doing the work?
format()method is empty. Sure, I can look at the manual to see how this works, but I prefer looking at the actual code. Finding this code is hard though.