zephir icon indicating copy to clipboard operation
zephir copied to clipboard

No warning or error when returning invalid response.

Open ruudboon opened this issue 5 years ago • 1 comments

See below simplified Router class.

namespace Phalcon\Mvc;

class Router
{
    protected action = null;
    
    /**
     * Returns the processed action name
     */
    public function getActionName() -> string
    {
        return this->action;
    }
}

This class will return null when getActionName() is called even when our return type specifies it as a string. I'm expecting a Fatal error: Uncaught TypeError. It would be nice if our static code analyser / compiler would detect that our member variable is incompatible.

ruudboon avatar Oct 31 '19 13:10 ruudboon

Related - https://github.com/php/php-src/blob/4034d83432a9d4b1d3c8d334d382871e4146f664/Zend/tests/return_types/internal_functions001.phpt#L16

Jeckerson avatar Apr 07 '21 22:04 Jeckerson