Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108372 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84516 invoked from network); 4 Feb 2020 15:01:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 15:01:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3E7E21804D1 for ; Tue, 4 Feb 2020 05:13:18 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 4 Feb 2020 05:13:17 -0800 (PST) Received: by mail-il1-f171.google.com with SMTP id f10so15775004ils.8 for ; Tue, 04 Feb 2020 05:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/W83MGC+oCdwE3+GCHEm3r7QuX+CTwqE15TyhhQzoT0=; b=lobZjnPcofJ2GmGWSNgufwvX6+QNIN6582YWmWGAOMcRkW6q7fPa75YZKDjLYY4OZT KNT4Y0WiW2H7QvhKxjPT8MMrcdi165dcd1vIOxSLdFSwuhji6hySyDdy8RJ0zLoQDUmE Tiy2W55ebjxnGtfWv6kUlPveOC6WvAWN3ti3NVrlc+mdd7T/ATwZI3TBFO+t1pxNLzXW dziUycOehNysg0Sw09LVBUtRgwZjLzsRQDmCrAfNaWG4PmPBdFNXTpVlGu29LH/9FR23 6Te6k0o7XRcsUNgZEKmx0xF5F5e4q+4e9gIJoYcBxYPkjP6xZ9fX3asbeE96RVwhAb06 98oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/W83MGC+oCdwE3+GCHEm3r7QuX+CTwqE15TyhhQzoT0=; b=Vgl5YI+wBj4YKLVA0H/lnUh2ylHXv8kzkh6jRKx5ht7+yUHtZgtPraGFYOz87rspLs OvG8hHtZjkKu7QBN9qFAdFaCFMi7d89wop3hDA8/W0paMBtHQ3MK/BFqVw5c2IO6a/oK 4rY0Vq0Tnj2zzaBgD8TWkpKMfl10H6cnf3nZ++DiEAUeDmXvxXvZb3a0HWH0m0UonACc T6T52bt8l8FiYw6IjVFSLEhe+wsm98HTT+67GY3yrUs9OBRIGpTojReOWOXvM2sYVXFv j+a9LN7JJTFihOd3u9l0ab8Hj6+Y91/vFNIftP84tlIRcSp+D7P90H142p103tTwOzxZ S+Ag== X-Gm-Message-State: APjAAAUBWF3ekFEsgTM1ch2lapHlRz1F73jEkLrAvpgDfcHVi3SW/jf/ mfrWzAe3bXOXEJMbJvXuAU/jl9czbIvh5OnCsnTHqFc1/5lX3A== X-Google-Smtp-Source: APXvYqxrKMUKayHmhHPgqqXra3CiHqFXRCCeRyvUjp52ZdaWHfObcy7STtF5sbOxTHPcCf146Nb/Zw7mEVn5sFGmfpo= X-Received: by 2002:a92:601:: with SMTP id x1mr25308139ilg.35.1580821994970; Tue, 04 Feb 2020 05:13:14 -0800 (PST) MIME-Version: 1.0 References: <1580820923.58383.2@inventis.be> In-Reply-To: <1580820923.58383.2@inventis.be> Date: Tue, 4 Feb 2020 14:13:02 +0100 Message-ID: To: Tom Gerrits Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000076a3e5059dbfcd27" Subject: Re: [PHP-DEV] What about a magic __toArray() method? From: ocramius@gmail.com (Marco Pivetta) --00000000000076a3e5059dbfcd27 Content-Type: text/plain; charset="UTF-8" Hey Tom, On Tue, Feb 4, 2020 at 1:55 PM Tom Gerrits wrote: > "(string) $var" doesn't seem a lot less explicit to me than > "$var->toString()", but if it is coerced automatically when being > passed to e.g. a function taking a string, that is of course a > different story. > `(string) $var` is less explicit because `(string)` is an operation that applies to a wide set of types, whereas any `->` applies only to `object` types, and also has a specific name (the method name) on its right. Restricting that operation to fewer supported types is not feasible at this point, since `(string) null` is very much relied upon. Coercions and implicit casting using the overloaded operators could > perhaps also be limited to non-strict mode, if desired, which is also > the case for scalar types currently, IIRC. > Is there any newly written code that doesn't use non-strict mode at all? Programming without `declare(strict_types=1)` seems anachronistic at this point. Greets, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --00000000000076a3e5059dbfcd27--