Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96026 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31835 invoked from network); 19 Sep 2016 08:27:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Sep 2016 08:27:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=stoller@leonex.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stoller@leonex.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain leonex.de designates 80.87.117.30 as permitted sender) X-PHP-List-Original-Sender: stoller@leonex.de X-Host-Fingerprint: 80.87.117.30 office.int.leonex.de Received: from [80.87.117.30] ([80.87.117.30:44077] helo=office.int.leonex.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/58-19521-161AFD75 for ; Mon, 19 Sep 2016 04:27:14 -0400 Received: from ex-srv1.ameusgmbh.intern ([192.168.222.212]:41368 helo=owa.int.leonex.de) by office.int.leonex.de with esmtps (TLSv1.2:AES256-SHA256:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1bltup-0002rz-2h for internals@lists.php.net; Mon, 19 Sep 2016 10:27:04 +0200 Received: from (127.0.0.1) by ex-srv1.ameusgmbh.intern (127.0.0.1) with Microsoft SMTP Server id 15.1.466.34; Mon, 19 Sep 2016 10:27:03 +0200 Received: from ex-srv1.ameusgmbh.intern (192.168.222.212) by ex-srv1.ameusgmbh.intern (192.168.222.212) with Microsoft SMTP Server (TLS) id 15.1.466.34; Mon, 19 Sep 2016 10:27:02 +0200 Received: from ex-srv1.ameusgmbh.intern ([fe80::38fc:4042:690c:8aec]) by ex-srv1.ameusgmbh.intern ([fe80::38fc:4042:690c:8aec%12]) with mapi id 15.01.0466.037; Mon, 19 Sep 2016 10:27:02 +0200 X-CTCH-RefID: str=0001.0A0C0204.57DFA158.0017,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 To: "internals@lists.php.net" Thread-Topic: Problem with overwriting private property value with ReflectionProperty Thread-Index: AdIST5jAVh9uc20uRIynwNV4UoMzrw== Date: Mon, 19 Sep 2016 08:27:02 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.222.112] x-ci-mailpolicy-key: ac9fc1b6805928ecfd0d0c5bda340b2a Content-Type: multipart/alternative; boundary="_000_MP178DCFE8005BC8ff18e01b49a14b63877b2fc2e02730a0leonexd_" MIME-Version: 1.0 Subject: Problem with overwriting private property value with ReflectionProperty From: stoller@leonex.de (Christian Stoller) --_000_MP178DCFE8005BC8ff18e01b49a14b63877b2fc2e02730a0leonexd_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I have spent several hours with a strange problem with reflection. There's an object of an external lib with a private field and I have to ove= rwrite its values. Because there is no public method I am using ReflectionP= roperty like this: $reflProp =3D new \ReflectionProperty(Extension::class, 'classes'); $reflProp->setAccessible(true); $reflProp->setValue($extension,['new', 'values']); var_export($extension->getClasses()); The field is of type array and contains several entries. The problem is, th= at the private field has not been overwritten by `$reflProp->setValue()`. I= nstead it looked like, the array of the private field has been merged with = my new array. I tried different things but nothing worked. I have tried to create a small= script which could show the problem, but it wasn't reproducible. The last thing I tried was, to call var_export($reflProp->getValue($extension)); instead of var_export($extension->getClasses()); That returns exactly the correct value. So my question is if somebody could= imagine why `$reflProp->getValue()` returns the value I am trying to set, = but accessing the field with an object member method (getClasses) returns a= merged array. I am using PHP 5.6.26 (x86, TS) on Windows 10. Best regards, Christian Mit freundlichen Gr??en aus Paderborn Christian Stoller Softwareentwicklung LEONEX Internet GmbH Technologiepark 20 33100 Paderborn Tel: 05251-14807-27 Fax: 05251-14807-30 HRB 8694 AG Paderborn Gesch?ftsf?hrer: Stephan Winter ________________________________ Erfolgreiche E-Business L?sungen von LEONEX Erfahren Sie mehr unter www.leonex.de ________________________________ --_000_MP178DCFE8005BC8ff18e01b49a14b63877b2fc2e02730a0leonexd_--