Documenting callback signature for code events is not standardized

Kirby

Well-known member
Currently code events only have a (moreless) freeform HTML description which usually contains information about the code event, the signature for the callback method and some description about the parameters.

However, the format of this HTML description is not standardized so 3rd party code events might not follow Xenforo "standard" here making it difficult for developers (and tools that need information about the signature and parameters).

My suggestion is to either
  1. Standardize the structure of this HTML (and require this to be used by Resource Standards Rules) so all necesary information is always available (and can reliably be parsed)
  2. Introduce a new entity field to keep this information in an easy to parse format (PHPDoc?)
  3. Require a stub file for code events like
    PHP:
    namespace XF;
    
    abstract class CodeEvents
    {
        /**
         * Called by the xf:db-repair command.
         *
         * Expects a \XF\Install\Data\AbstractMySQL object implementing getTables() and getData()
         * to be added to the incoming array, keyed by the addon_id,
         * to facilitate (re)creation of any missing database tables.
         *
         * @param array<string,\XF\Install\Data\AbstractMySQL> &$tableData  Array containing \XF\Install\Data\AbstractMySQL objects keyed by addon_id
         *
         */
        abstract public static function addonGetInstallData(array &$tableData): void;
    }
Implementing this would also allow XenForo to perform stricter validation when adding a code event listener.
 
Upvote 0
Back
Top Bottom