This may be a silly question, but I'm new to back-end development.
I always see comments like this above various methods:
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
// ...
}
What are these called? Do they even have a name? Does the @return actually do anything, or is it just for reference?
I'm mostly asking because I have a technical interview as a junior Laravel developer coming up this week, and I want to make sure all my code is up to standards for a pair-programming session they said might happen.
CodePudding user response:
These are called "DocBlocks", or Documentation Block Comments, etc. You can read more about them here:
Additionally, if I go to use this method, I get some help:
As you can see, VSCode now knows what myMethod
is, what it expects and returns, how to use it, etc. They aren't strictly required, as some IDEs can auto-detect methods, arguments and returns, but they can help.