Re: Method overload support
| From: | Ben Ramsey | Date: | Tue, 27 Apr 2021 16:26:49 +0000 |
| Subject: | Re: Method overload support | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114203@lists.php.net to get a copy of this message | ||
> On Apr 25, 2021, at 15:12, David Rodrigues <david.proweb@gmail.com> wrote:
>
> 3. Poorly typed functions or methods cannot be overloaded.
>
> function printId(User $user) { ... }
> function printId($user) { ... } // Fatal error
Since the second is the same as
Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
mixed $user, why couldn’t the engine
pick the most specific method for the signature? If a User instance
is passed, then pick the first method. Otherwise, pick the second.
Cheers,
Ben
Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc