Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108394 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46050 invoked from network); 4 Feb 2020 17:52:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 4 Feb 2020 17:52:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5279518053B for ; Tue, 4 Feb 2020 08:04:12 -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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-yw1-f42.google.com (mail-yw1-f42.google.com [209.85.161.42]) (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 08:04:11 -0800 (PST) Received: by mail-yw1-f42.google.com with SMTP id n184so18110678ywc.3 for ; Tue, 04 Feb 2020 08:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UTIjLGJXvbdQ9O2p8EIDmC0rNNEMH6EBJNlRagAA+zQ=; b=ACF+c+bBthEZ48wiTDTI7rmQSmKAbO84BgifO8TBfQR7qKhqZ0mTvD4HTKUFEh6cJq EzjvWNkUSXhcULSaSGos96c16Z29z4ntEia0NjpUl7QJuVws2cEBClUjfHxSwG67PzTn rQmwSNtdisLf68mi7wda6WIrXgxL9TA8jq6RPEr/jv23RBzTGtgxAoka/INWQB7hh+at n/On2QXQvW3p8wsqZ9OsaBkC2OEujBMwpV8EghOLmp36cSrFqlr/qJUNwioNgMn2u4yG DIeiM6PsncIw6mLYGVKssuBsIrxDlOjfYsnfHoZfubRJmBB7aHfc/VrMthofugEHjtNP lMcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=UTIjLGJXvbdQ9O2p8EIDmC0rNNEMH6EBJNlRagAA+zQ=; b=BKVD33gjgwDVK4aWQf5oLiccEDDfx+97znbTQwfZBIg9od4EY5ewMuVxzg33v8W6z2 BD8iFvwKY8lUyu/urL7v5qZOvpDszdxLbJMZAzJRRsweQDT58X1/T9OuI8a1jNzIj9wt XokTh8ISOC30NGjdmsPUdJzY3bVdrNQbpa8iJ40YoqIl+WwSvIUxL52YUCli0koqDLAa si35RKjVgBWUCdXxJfKaGcAiUBX78IgJqW5obm6Y5Cl0K8P0ZbfM865OnKRTL5jwzjuq 3gJPUYtQY4zu0RVsvQCWBuH9R+WJxc+i+bs/98xIRRkNIsbynKlB/dwN00nnZkTWCUOK jVwg== X-Gm-Message-State: APjAAAV0N/kQj+VLtTuN2dpglyB1LM7v7rKXaqp9XOQYExiFo+f2rTsN 3t965V4BWF4BtooQv9JOew4= X-Google-Smtp-Source: APXvYqwCVHYx2gzXECSHTdEet9ouA0ErmLvytCp89i4QrR0XYZ1D5uwaKs8tE2f67sWDcj+OsPef9A== X-Received: by 2002:a81:910e:: with SMTP id i14mr5785579ywg.84.1580832250151; Tue, 04 Feb 2020 08:04:10 -0800 (PST) Received: from stevensbbookpro.lan (97-95-205-109.dhcp.sffl.va.charter.com. [97.95.205.109]) by smtp.gmail.com with ESMTPSA id z12sm10084814ywl.27.2020.02.04.08.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2020 08:04:09 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) In-Reply-To: Date: Tue, 4 Feb 2020 11:04:08 -0500 Cc: Marco Pivetta , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Levi Morrison X-Mailer: Apple Mail (2.3601.0.10) Subject: Re: [PHP-DEV] [RFC - discussion] __toArray() From: stevenwadejr@gmail.com (Steven Wade) > Sorry if it's been said in the discussion so far, but I do not see why > `print_r` should convert anything to an array. It accepts multiple > kinds of types including strings, numbers, and so on, and I think > adding this behavior to `print_r` is a different thing than wanting a > standard way for objects to be converted into arrays. You=E2=80=99re right, that=E2=80=99s my bad. I swore I tested print_r() = with a class and __toString() and it cast it, but I just ran it again = and it just outputs the object. The goal would be to have __toArray() = behave on arrays like __toString() does on strings. I=E2=80=99ll update = the RFC to remove the reference to print_r(). Thanks! > And on that note, what is the motivation for wanting a magic method > for converting an object into an array? Why not make it an explicit > operation? I do not see the point of the magic here, except _maybe_ > for adding it to `ArrayObject` or something to allow it to work with > the array_* functions that work without references, in which case I > think we think this RFC is the wrong approach as it is inadequate for > that purpose. PHP=E2=80=99s pretty magical already, so adding another magic method = isn=E2=80=99t out of the question and would keep things inline with how = some things are done already. The idea for having magical casting is to = make it simpler in the user land for general array behavior when reading = or looping.=