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

Nicky Gerritsen nickygerritsen at me.com
Wed May 28 10:08:30 BST 2014


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?

Regards,

Nicky Gerritsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop/attachments/20140528/d56076d8/attachment.html>


More information about the KDevelop mailing list