Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Comments in the plugin

Comments in 'Plugin Development' started by minebuilder0110, Feb 21, 2016.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    In some of the plugin I see, there is a part which says something like:
    PHP:
    /**
    * @param $game
    * @return int
    */
    What does this mean, and do they make something better, or are they actually comments and it is just notes for developers?
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    @param means the paramaters of the function , and @return defines what the function will return. in this case it'l return int.
    AndrewBit likes this.
  3. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I do understand that, but does it affect the performance or anything?
  4. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    if you do @return int and the function under it returned string, it'll give an error.
  5. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Oh right, so it is like assert()?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No, it won't. Only return types in PHP 7 will do that.
    Return types in PHP 7 will do that.
    Doc comments are comments too, except two differences:
    • IDE understands them differently. PhpStorm uses doc comments to detect data types of some variables, actually.
    • There is a Reflection->getDocComment() method, which proves that PHP has official recognition of the existence of doc comments. This method is used in PluginManager::registerEvents().
    Legoboy0215 likes this.

Share This Page

Advertisement