Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105697 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31540 invoked from network); 14 May 2019 15:33:12 -0000 Received: from unknown (HELO mail-lf1-f49.google.com) (209.85.167.49) by pb1.pair.com with SMTP; 14 May 2019 15:33:12 -0000 Received: by mail-lf1-f49.google.com with SMTP id u27so11732143lfg.10 for ; Tue, 14 May 2019 05:38:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=A759UP7f922vOvcvpV1NUyYDNmU2akKs+iZGowQWtxo=; b=SQ2wQMRmrOa5qHXLHH0o+kGAvEfS73U2ffXbOEHaYerREmNtmoc9FLe5brCVy44YxV Sf/zJkigH7gUIrjh2Xhm3jqYs4qoPSn2JG1nnkUD4C1l91lhNN8RPGt306vVEYGldpvb G0P6km0TPft9e+qsBCr8GXYnf0hgCMw4wa5dr5xTEo22+ITaFTU96+XOnVU6sUvr93Ob URTtogrte4pjyXrcfAAR0IfXcWoaxKGmJhxxO53v+CVho7VxBDdd3pzTvdMmYnFxD0eE NCxlDZAg6evH6uqI+UBMzoV6KSezG4weCDxn8jOyH0fT/551rEJA4QmgCTEJyE3MYynA dgzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=A759UP7f922vOvcvpV1NUyYDNmU2akKs+iZGowQWtxo=; b=uDUUbtIUda0ulg08o/wNe6RHonbg/55ee8cYjyBBrA68t66H2CKELtBJeZNE9wyo4u oWvlEqOy66BkM04t+g9AN4b66yEVbJlTmt1D55eKRllMWxOIn9ONAkZJYjZb0Ngjq700 FWa+e5W/2JFZuGDP6ZLp/jFmnv5uFzrxHE+XhAspXlQwlsk3eqcxj3s27716vUNaMlJv vIA/qvPFeCQLbhCnYtWuNj3n24LDo6knBvBSAVkwhEYT7R8oC4yj6oM+FqQx1qxY6srR 784N/MCuKNjt+GP0RHdinruJ0meAI6ote6L5ux9kEKtl0amw30fhYcXEOUBiHdSTT8mr IVAw== X-Gm-Message-State: APjAAAWZ2aSVtxVH2IE2D7Pclt2NmVS7xiCb3lmlRa2II9plCEDSsIif mjg+HNxqlFV12ChsE1roS6RkOQy1YEzccMol+KxfzCOD2JY= X-Google-Smtp-Source: APXvYqxUg+duIbFFYsUUWSZ+8KG2/5MNNsgL6OHKXuGYuHK4tqusi4Rqq3Zv2bpbxTmbdZ9VduygcZh93bp5+l6ufDI= X-Received: by 2002:ac2:4213:: with SMTP id y19mr7698552lfh.66.1557837530334; Tue, 14 May 2019 05:38:50 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 14 May 2019 14:38:33 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000009d0ad10588d85040" Subject: Add get_mangled_object_properties() From: nikita.ppv@gmail.com (Nikita Popov) --0000000000009d0ad10588d85040 Content-Type: text/plain; charset="UTF-8" Hi internals, 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. 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. 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. Thoughts? Regards, Nikita --0000000000009d0ad10588d85040--