Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105698 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35584 invoked from network); 14 May 2019 15:45:45 -0000 Received: from unknown (HELO mail-yw1-f67.google.com) (209.85.161.67) by pb1.pair.com with SMTP; 14 May 2019 15:45:45 -0000 Received: by mail-yw1-f67.google.com with SMTP id s5so13851632ywd.9 for ; Tue, 14 May 2019 05:51:23 -0700 (PDT) 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=1h4oBYV1YP3ou8uVtt/nMer4ONhMfUZwStnp0zMtgqg=; b=knFM3UWpjJQg8HZdbpayrQA4MK7LvM9ttgh5YUzzAvfgvrq0cl6rspO3xb3GLXgi7G HfdoVep+a4QRfw5LBQNJYpsY1wmhz8q4e+Qu+HiWdbDazMoUwblSUdvkmYrrEn4pauKp Ircq7lDg0XBZKv4QTbDRU5G8PzqNwXxeECgQDEvVtNS8Fq1C0AY/pmRT+MiRerU/ZNdy xnRs2hu8Ukn1ZT2ffJHIpVJFMT555z3sIL6I0b3Ygi10/T2cHKmY1BAPoihCJBNrMbNW 5R9mMJ8TP+3U0XS4ZUI2WowEyjQKIxnj1QPBbEjDpKH/1bgYxWzHG7Qeq6AoVomRJM+6 jmSQ== 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=1h4oBYV1YP3ou8uVtt/nMer4ONhMfUZwStnp0zMtgqg=; b=lrAZJzoAJrXY6L04cKqOIKVkNKfbSytEs6IZvmoVyOsBUqkCjMIeT1VtavP090cZz+ SoWdwopx/qofQzVAj4d/OtPLgWlbTP5Ie3uEmmd92ZlOizYa+F82QuOMMIsoFtkUkJh4 ZbAVB5P6AhNUojwrZeKm3ETQawJq4N/rSrdYhU2CmmYKk1zpOTm4U54sMPd9TauaOTvz WviH3lMVarDlNWPeBjeeXP5XAppzL+plDEeuuSDdBeQoiLp2JPE6clB6dQ5cO+t7HF7N WHIM3KmTvMEXiR2RUlI9nA4ekMHFHwrwlI4lia0mDU93ecLDYJWDGTSFI7QwmGF7Vu9Q qc8A== X-Gm-Message-State: APjAAAWlIVWjkn/+SR41A4ihZQL5Dex8o/xfcUsvtwu87pZ1HSbj2TvU AsAj+zLLkZcytho36Cavoks= X-Google-Smtp-Source: APXvYqxmrYXSVtpUjedbSw/rTMjR94w/wyLWSh2hjMNZsVujezEU2qEgKgK9Yxuv8j/+6MD96Ey+8Q== X-Received: by 2002:a81:61c6:: with SMTP id v189mr16101980ywb.158.1557838283486; Tue, 14 May 2019 05:51:23 -0700 (PDT) Received: from [192.168.86.89] (99-63-227-78.lightspeed.gnvlsc.sbcglobal.net. [99.63.227.78]) by smtp.gmail.com with ESMTPSA id s17sm4299771ywg.70.2019.05.14.05.51.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 05:51:22 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) In-Reply-To: Date: Tue, 14 May 2019 08:51:21 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Nikita Popov X-Mailer: Apple Mail (2.3445.104.8) Subject: Re: [PHP-DEV] Add get_mangled_object_properties() From: stevenwadejr@gmail.com (Steven Wade) > Inspired by the recent discussion on __toArray(), I'd like to propose = the > addition of a get_mangled_object_properties() function, implemented in > https://github.com/php/php-src/pull/4163. >=20 > This function returns the mangled object properties (duh...), which = matches > the behavior of the (array) cast, with the difference that an = overloaded > (array) cast will be ignored. To the best of my knowledge the only = internal > class currently doing this is ArrayObject. >=20 > There are a couple of motivation for this: > 1. It makes it more obvious that code operates on mangled properties. = This > allows clearly distinguishing (array) casts used for low-level object > introspection and (array) casts used for things like converting = between > stdClass and arrays. > 2. It is more robust, because it is not affected by overloading. At = least > in theory it allows us to introduce the __toArray() method proposed in = the > other thread (though I don't personally endorse this). > 3. Longer term, it would allow us to change (array) to return = non-mangled > (visibility-respecting) properties -- the current behavior is a WTF = factor > for anyone who doesn't happen to work on serialization or dumping = libraries. >=20 > Thoughts? >=20 > Regards, > Nikita I think this is a great idea. Not just because I want __toArray() to = succeed, but because some of the concerns raised by its discussions were = mainly focused on the odd behavior that current array casting exhibits = and possibly losing that. By introducing this new function, it can be a = more appropriate method of gaining insight into a class' properties. I like the idea of renaming the function to "get_mangled_object_vars()" = that was mentioned on the PR. It does bring it more in line with current = naming schemes. -- Steven Wade stevenwadejr@gmail.com