KDevelop PHP: return type hinting via @retval or other way?

Milian Wolff mail at milianw.de
Wed May 28 11:30:28 BST 2014


On Wednesday 28 May 2014 11:08:30 Nicky Gerritsen wrote:
> Hi,
> 
> Imagine I have the following PHP function in a class called Obfuscated (real
> name removed for reasons):
> 
> /**
>  * Fetch the ''obfuscated'' associated with a specific (numeric) ID
>  *
>  * @param int $id
>  *   Numeric ID of the ''obfuscated'' to fetch; can be null to let this
> method return null. *
>  * @retval Obfuscated
>  *   The ''obfuscated'' with the given ID, or null if no such ''obfuscated''
> exists */
> public static function fromId($id)
> {
> 	return self::fromDatabase(array(
> 			‘ObfuscatedId' => $id,
> 		)
> 	);
> }
> 
> 
> fromDatabase does something in the lines of:
> 
> protected static function fromDatabase($filter)
> {
> 	$class = get_called_class();
> 	$obj = new $class();
> 
> 	// More code…
> 
> 	return $obj;
> }
> 
> In this case KDevelop does not correctly understand the type of the object
> returned from the fromId() function.
> 
> For example PHPStorm can use @return to specify (“force”) the return type of
> a function. However KDevelop does not seem to support such a feature.
> 
> Am I missing something or is this something that could be added?

Hey,

@return should work, no? But I'm not sure about @retval. If that's common as 
well, we could alias it to @return.

Bye
-- 
Milian Wolff
mail at milianw.de
http://milianw.de



More information about the KDevelop mailing list