Search code examples
phpobjectphpdoc

PHPdoc does not detect object (and other properties)


I am trying to create a PHPdocument for my project with the correct information. I am trying to create information for objects, created inside a method of a class. Sadly, PHPdoc does not recognize my object inside my function.

The code is as following:

class app_controll
{
/**
  * This function starts the application. All the functionality starts here.
  * @return Objects Method returns all the objects and functions needed to build a page.
  */
public function start_application() 
     {
     /**
      * The domain_controll object contains domain information.
      * @var object domain_controll
      */
     $oDomain_controll = new domain_controll();
     }
}

What am I defining wrong?


Solution

  • I also asked the question on Github. I got a response from James Pittman:

    In this case, $oDomain_controll would be an internal variable, visible only within the start_application() function. There would be no reason to include it in API documentation, because it's not usable or viewable by a consumer of the app_controll class. If you want to make it a public member of the app_controll class, you should declare it outside of the start_application() function:

    class app_controll()
    {
        /**
         * The domain_controll object contains domain information.
         * @var domain_controll
         */
        public $oDomain_controll;
    
        public function start_application()
        {
            $oDomain_controll = new domain_controll();
        }
    }
    

    Thank you for your answer James :)