I have a Hacklang generic class like this:
class SomeClass<T> {
public function __construct(private T $input) {
}
public function __toString() : string {
return (string)$this->input;
}
}
I do not want to limit the variable that can be used as <T>, but I do want it to be convertible to a string.
Is there a way in Hacklang to specify a given variable should be bool, int, float, string or an object with __toString?
After doing a fair bit of digging, there is no solution to this in Hacklang at the moment. The only thing you have is
\Stringish, an undocumented interface that covers both native strings and objects with the__toStringmethod. It does not, however, coverint,floatorbool.Source: interfaces.hhi