To address the issue of static analysis tools marking your method as unused, you can use a docblock annotation to indicate that the method is used dynamically. This can help inform the static analysis tool that the method is indeed used, even though it might not be directly referenced in the code.
One common annotation for this purpose is @used-by. However, not all static analysis tools support this annotation. Another approach is to use @method or @see annotations to provide additional context.
Here's how you can modify your code with appropriate docblock annotations:
/**
* Handles customer-specified events.
*
* @param mixed $event The event to handle.
* @return void
*/
private function customerSpecifiedHandling($event)
{
$method = setting('system_events.callback', '');
if (empty($method)) return;
if (method_exists($this, $method)) {
$this->$method($event);
}
}
/**
* Moves the driver display name.
*
* @param mixed $event The event to handle.
* @return void
*
* @used-by customerSpecifiedHandling
*/
private function moveDriverDisplayName($event)
{
//
}
In this example, the @used-by annotation is added to the moveDriverDisplayName method to indicate that it is used by the customerSpecifiedHandling method. This can help some static analysis tools understand the relationship between the methods.
If your static analysis tool does not support @used-by, you might need to check its documentation for the appropriate annotation or configuration to handle dynamically called methods.