How do I create a PHP DocBlock stating an @return which states the return of a class. This is at the moment fairly simple by doing
/**
* This returns an object of the "User" class
* @return User
*/
public function getUser() { return $this->user; }
I use this to get intellisense through my IDE for these return values. (in my case Netbeans)
However I have a class that returns a class based on a variable name. (for example:)
/**
* This returns an object of the $param
* @param String $className
* @return ???
*/
public function getSomeObject($className) { return new $className(); }
and I'm trying to create intellisense for this aswell but I'm not sure if this is actually possible.
For example when I call
$someClass = new MyClass();
$var = $someClass->getSomeObject('Address');
I would like my IDE to show me intellisense for the variable $var(which will contain an Object of Address)
It would make sense to mention that the method returns an object as such:
/**
* [...]
* @return object
*/
Eventually with some details as such:
* @return object Object of class $className
See the docs for @return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With