PHPDoc preconditions

╄→гoц情女王★ 提交于 2019-12-07 18:48:48

问题


How to tag preconditions with PHPDoc? I have an object, and before calling a function another function must have been called:

$myObject = new MyClass();
$myObject->mustDoThis();
$myObject->beforeThis();

So the documentation for beforeThis() would look like:

/**
 * @precondition mustDoThis() must be called before this function is
 */

Or is there another way around this? Perhaps a @throw clause would be enough.


回答1:


As far as I know, there's no standard @precondition or @postcondition tags for PhpDoc but I use them anyway as it is a nice way to hint the developer implementing the class/interface/trait.



来源:https://stackoverflow.com/questions/23582839/phpdoc-preconditions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!