'What is the return type of a method that returns Heredoc?

I have some PHP code that looks like this:

class MyClass
{
    public static function classPhpdoc($paramA)
    {
        return <<<PHP
/** @template-extends \\$baseClass */

PHP;
    }
}

It's basically a class with multiple methods that return Heredoc blocks.

I'm using phpstan tool to validate the code and it's complaining that the methods have no return-type specified.

My question is: what return type would be appropiate to specify in such cases? I was thinking either string or mixed but I'm not sure.



Solution 1:[1]

Heredoc is not a type, it's a syntax to produce strings:

var_dump(<<<PHP
Hello, World!
PHP
);
string(13) "Hello, World!"

So:

public static function classPhpdoc($paramA): string

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Álvaro González