Re: Re: Improving PHP's type system
| From: | Fleshgrinder | Date: | Wed, 20 Apr 2016 19:55:41 +0000 |
| Subject: | Re: Re: Improving PHP's type system | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92568@lists.php.net to get a copy of this message | ||
I am not quoting anything because the formatting of your emails is
completely off in Thunderbird. However, I want to add one to the list:
declare(strict_types=1);
interface Stringable {
function __toString(): string;
}
function fn(string|Stringable $arg) {
$param = (string) $arg;
}
We could add a new *stringable* primitive to PHP though, but do we guys
really want to start doing so? There is pretty much an endless amount of
combinations and finding names alone is endlessly hard.
declare(strict_types=1);
function fn(int|string $maybe_bigint) {
// mysqlnd automatically creates the proper type based on the value.
// Expressing this in userland is impossible ... :(
}
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc