Kahlan\Plugin\Double::_generateMethodStubs PHP Method

_generateMethodStubs() protected static method

Creates method stubs.
protected static _generateMethodStubs ( array $methods, boolean $defaults = true ) : string
$methods array An array of method definitions.
$defaults boolean If `true`, Magic Methods will be appended.
return string The generated method definitions.
    protected static function _generateMethodStubs($methods, $defaults = true)
    {
        $result = [];
        $methods = $methods !== null ? (array) $methods : [];
        if ($defaults) {
            $methods = array_merge($methods, array_keys(static::_getMagicMethods()));
        }
        $methods = array_unique($methods);
        $magicMethods = static::_getMagicMethods();
        foreach ($methods as $name) {
            if (isset($magicMethods[$name])) {
                $result[$name] = $magicMethods[$name];
            } else {
                $static = $return = '';
                if ($name[0] === '&') {
                    $return = '$r = null; return $r;';
                }
                if (preg_match('/^&?::.*/', $name)) {
                    $static = 'static ';
                    $name = substr($name, 2);
                }
                $result[$name] = "public {$static}function {$name}() {{$return}}";
            }
        }
        return $result;
    }