Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99930 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37377 invoked from network); 19 Jul 2017 08:11:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jul 2017 08:11:48 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.176 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.176 mail-wr0-f176.google.com Received: from [209.85.128.176] ([209.85.128.176:36216] helo=mail-wr0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/35-02884-3441F695 for ; Wed, 19 Jul 2017 04:11:47 -0400 Received: by mail-wr0-f176.google.com with SMTP id y43so55130773wrd.3 for ; Wed, 19 Jul 2017 01:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+HNfIsWYM8uFiqt52K+k92I2Dq6Z4zvjCILcNGVtZlc=; b=IsQdWsmltmL2CQLqdP0zF0oTEDvrRJgh94sfjnB47NDANfKnvom9KFcCF55QKGn3WN lQyMYOtSs4YsZ5Wt8dSEwk4vQJ4qfelxyxA1BXHEQAudG6RDTvcCn3uGZN8s2IR5adqY qtVds5mWq4bDtGqyeuvENjl3koUveHhcqNFfPmDdP/EnkQT023AQBfzFN1UEQLElUZMP 0Sd9qRVBnpTZjWifxdqQEwpqX10QdsR0/SjNcAB1l+tVDZVAC0YIeNHrSqYWIei+cEoe RoqF6Ln5GVFYe3TmMlckOcbCOjkrEKElMGhO0VzizHDARV9hZ3Bg7ApI+NUGgaZVIIlU BjjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+HNfIsWYM8uFiqt52K+k92I2Dq6Z4zvjCILcNGVtZlc=; b=OpTo9KN8PIdrEt9ErQDBgz7ThmlMyEMjr5nImthNBI9ZXBNC5w23LUlwjJKNlmAatf 2OgqNqDB/QDp+1ggDeBKK7vBEWiHywoZ+WcJHDVRHBJi4qVGQoLjjqFb/Eww8K8LXRX/ B0NPnJZs//BiFFjicjgoGWWOO9AdPebS8xxNs9rg9Ond/aG3f05rlN9y96yYSIFdnh1A RrbBUcQYaqpolKnv/T5eKklr2BRDzn8aZs9C6vCIVCexAdZRThGlaoW6OX/blOiGMMdg DUP70ijfH4D2ziCsmf47U2m0q9rIa8ejhFNWDYae4QX5NGhlsxZdw1RV/kUg+aA/nXQS lvkQ== X-Gm-Message-State: AIVw111BBDZP3hfawdDtIz/H+7TD4I7I1Sw4rvg6TAlOVrRXGkjpOaP5 gnQsqc7JB7mtLahpRFgEZBwGhuMrSg== X-Received: by 10.223.176.61 with SMTP id f58mr3722438wra.106.1500451904662; Wed, 19 Jul 2017 01:11:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.135.186 with HTTP; Wed, 19 Jul 2017 01:11:24 -0700 (PDT) In-Reply-To: References: Date: Wed, 19 Jul 2017 10:11:24 +0200 Message-ID: To: =?UTF-8?Q?Bart=C5=82omiej_Krukowski?= Cc: PHP Internals List Content-Type: multipart/alternative; boundary="001a113aa4f4c7b5890554a72eac" Subject: Re: [PHP-DEV] RFC - ReflectionProperty calls __get methods From: ocramius@gmail.com (Marco Pivetta) --001a113aa4f4c7b5890554a72eac Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 19, 2017 at 9:53 AM, Bart=C5=82omiej Krukowski < krukowski.bartlomiej@gmail.com> wrote: > Hello, > > Class *ReflectionProperty* allows to get access to private properties in > library. Unfortunately there is one unexpected (or at least undocumented) > case - *ReflectionProperty* tries execute *__call* method. In my opinion > this approach is bad, because method *__call* can change state of > application (I'd like to read value, not execute code). This is expected behavior - the reflection API does not work around the rules of the engine, just the rules of scope (like closures do). See https://bugs.php.net/bug.php?id=3D63463 for a very similar report that was discussed and marked as "not a bug" ages ago. > I'd like to suggest > different approach: > > > - Method *ReflectionProperty->getValue* will throw exception when > property is removed. > It should just call `__get` as before - see also https://bugs.php.net/bug.php?id=3D72174 and https://github.com/php/php- src/commit/a1ed4ab3caf33b59742897b43462d033864bb490 - reflection shouldn't check if the property exists upfront. > - Class *ReflectionProperty* will receive new method - *exists*. > You can already use `array_key_exists($propertyFqn, (array) $object);` for that. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a113aa4f4c7b5890554a72eac--