joomla-framework / datetime

Joomla Framework DateTime Package
GNU Lesser General Public License v2.1
3 stars 2 forks source link

Joomla\DateTime\Parser function parse() docblock return type #11

Open photodude opened 6 years ago

photodude commented 6 years ago

Steps to reproduce the issue

the Joomla\DateTime\Parser function parse() function docblock return type is DateTime https://github.com/joomla-framework/datetime/blob/master/src/Parser/DateTimeParser.php#L20-L34 But the function is just a throw

/**
 * Default implementation of the Parser interface.
 *
 * @since  2.0.0
 */
final class DateTimeParser implements ParserInterface
{
    /**
     * Parses to DateTime object.
     *
     * @param   string  $name   Name of the parser.
     * @param   mixed   $value  The value to parse.
     *
     * @return  DateTime
     *
     * @since   2.0.0
     * @throws  \BadMethodCallException
     */
    public function parse($name, $value)
    {
        throw new \BadMethodCallException("Parser method '$name' doesn't exist.");
    }
}

Expected result

correct return type or no return type

Actual result

return type listed but no return in is the method

Additional comments

I'm not sure what the correct correction is for this case. I assume we remove the return param from the docblock. (but I also assume I don't understand what is going on with this class)

mbabker commented 6 years ago

By the interface it's supposed to return an object. But the class doesn't actually do anything so it throws an Exception. So, it's a bad edge case here.

photodude commented 6 years ago

So I guess we need to ignore the Joomla.Commenting.FunctionComment.InvalidNoReturn rule for this file...