Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108361 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29658 invoked from network); 4 Feb 2020 12:25:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 12:25:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2378D180532 for ; Tue, 4 Feb 2020 02:37:39 -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-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 02:37:38 -0800 (PST) Received: by mail-il1-f172.google.com with SMTP id s85so11983919ill.11 for ; Tue, 04 Feb 2020 02:37:38 -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=jXgKiaMB0Zv+OdRlDq1OVNRsoOyftytRytIYQ79jNf0=; b=Nkm0HilXQWrIw1AHsKH3UOVlL5Ik+WSwwFQooYWtB7q9iBnRF1ULOJVP3qXb1jIgvn eucXWZGhwFglIcKGAFm3tUfYJM7yWBbGqmxWc0WsRSjXdC/M3+eaUTiixuU18d42nxE+ cPrC2nShrTgy+hseUGevNzKght7GBvSa+flz7V+yDopzwWoVau+7c1K0+x0BloutxSrp NzyPa8uq9AUTDtznl74Vd5qhwGH6IN+wNs/CikvGZj2AuuuaS6T5B00KjWHLfiVYFvlj xOUJZ1DvKmR43dxL0a02n9wbO3d/T33PGnlxt19EK22NHIM+iMXAG7CQgoqtKSRz64/9 eFcg== 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=jXgKiaMB0Zv+OdRlDq1OVNRsoOyftytRytIYQ79jNf0=; b=YWLpVlLDJxjEe0bEBPvyIVqvgiu4fkzSVoAtsnHB+i33+OzY3LuLdSaruAX0DvGQS7 CpZPmGnH8/Dc9//y75TCtfXG5dSePr3z3eD5r+n+65S7WWRrsehjxMacj/sgks07LwiO /Me7ZPs68Ds0PPj7UFEveKIFZEsyO458oMVAaj6Do/Nwgp3kiJpk7NM4uNuHDX6djrCc 22b5tmm7aDj564Jg4VpKzfXr9iSjcVTcbfBySpk3XP5lbHNI6oLxnsubzctxY4IrYi8G 4qbSHG8TtFztplYypz6PzVEDaIW56yqrj2uaEMWovXjz3BdnfAuMToqSmTVZKaf3q+8C RGLA== X-Gm-Message-State: APjAAAVhm4GKWJbdcv3FNoeWq/uGe6LBGBShp7Qr/bVuAOAnBsIeWfmd MnFdG89omhFx8LiHroAWTd6fqHcD6x+16/YOMjc= X-Google-Smtp-Source: APXvYqydaIrU/m/Xn+xxDJZ3ckMeqv49Zz8MGSbmTxo+OFEECQyXy5ntWLLoTwvdmFc4NLb5RBIIIE7P01jal4Tmvok= X-Received: by 2002:a92:601:: with SMTP id x1mr24760309ilg.35.1580812656835; Tue, 04 Feb 2020 02:37:36 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 4 Feb 2020 11:37:25 +0100 Message-ID: To: =?UTF-8?Q?Midori_Ko=C3=A7ak?= Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000de0331059dbda038" Subject: Re: [PHP-DEV] What about a magic __toArray() method? From: ocramius@gmail.com (Marco Pivetta) --000000000000de0331059dbda038 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Midori, On Tue, Feb 4, 2020 at 11:35 AM Midori Ko=C3=A7ak wrote= : > Marco, I've read it and your argument is strong. I think my opinion > slightly moves towards Andreas, away from magic. > > here is something I wrote some days ago: > https://github.com/midorikocak/arraytools/blob/master/src/ArrayConvertabl= eTrait.php > > I guess you were saying something like this would be enough. > > Midori > > Correct: an explicit `$foo->toArray()` call suffices. For other readers, more about `$foo->toArray()` vs `(array) $foo` is described at https://github.com/ShittySoft/symfony-live-berlin-2018-doctrine-tutorial/pu= ll/3#issuecomment-460441229 Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --000000000000de0331059dbda038--