Do you use the phpdoc in php 7?



  • We used to use phpdoc to indicate the types of arguments and the answer to the function. Now, with the advent of php support for typization, some are wondering "Is there any reason to continue using the phpdoc to indicate the types?"

    Without phpdoc:

    # Возвращает год и животное
    function animalYear (int $year, string $name) : string {
    
    return $year . ' год ' . $name;
    

    }

    echo animalYear(2016, 'Обезьяны');

    From phpdoc:

    /**

    • Возвращает год и животное

    • @param int $year

    • @param string $name

    • @return string
      */
      function animalYear (int $year, string $name) : string {

      return $year . ' год ' . $name;

    }

    echo animalYear(2016, 'Обезьяны');



  • All the things that can catch a machine don't need to be written.
    All that it cannot catch -- the direct meaning of complex methods and explanations of the values returned -- in particular, whether the argument and/or reverted value can be null -- still needs to be written. I understand there are no typified masses, and good half of the docks will remain.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2