Skip to content
Advertisement

Comment method callers name above the callee method

Is there any specific standards or styles in any languages to specify which methods are calling the current method using comments in the project?

for example lets say callee method is being called from UserController@indexMethod and UserController@storeMethod, so we comment it here

/**
* calee method
*
* @callers UserController@indexMethod, UserController@storeMethod
*/
public function callee()
{
    print('callee method');
}

so if i change the callee’s parameters i can find and change the callers easily.

Advertisement

Answer

Don’t do that. Documentation tends to be out of sync rather fast. Additionally that same functionality is available in most (if not all) IDEs.

If you use PHPStorm for example there is the “Find Usages” command which lists all places the method or class your cursor is on is used. VS Code (which is free of charge) has such functionality as well.

If you missed a case, tools like Psalm or PHPStan will report missing or wrong parameters as well.

You should make use of proper tooling, this will save you a lot (!) of time.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement