Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43618 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98330 invoked from network); 3 Apr 2009 20:37:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2009 20:37:53 -0000 Authentication-Results: pb1.pair.com header.from=r.borschel@gmx.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=r.borschel@gmx.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.net designates 213.165.64.20 as permitted sender) X-PHP-List-Original-Sender: r.borschel@gmx.net X-Host-Fingerprint: 213.165.64.20 mail.gmx.net Linux 2.6 Received: from [213.165.64.20] ([213.165.64.20:44679] helo=mail.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/AE-20315-0A376D94 for ; Fri, 03 Apr 2009 15:37:53 -0500 Received: (qmail invoked by alias); 03 Apr 2009 20:37:48 -0000 Received: from e178143177.adsl.alicedsl.de (EHLO [192.168.0.43]) [85.178.143.177] by mail.gmx.net (mp043) with SMTP; 03 Apr 2009 22:37:48 +0200 X-Authenticated: #13379417 X-Provags-ID: V01U2FsdGVkX1+2VwxjK3W2y0f06SwdJKcTxdcypOtcxCvR1TsZIk ByWK5jr6cAY8HL Message-ID: <2FA0A495-EC1A-4C51-9EE6-F9680D9FD114@gmx.net> To: PHP Developers Mailing List Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v930.3) Date: Fri, 3 Apr 2009 22:37:45 +0200 X-Mailer: Apple Mail (2.930.3) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.54 Subject: Private properties, Inheritance, Reflection (5.3) From: r.borschel@gmx.net (Roman Borschel) Hi, i've got a little question that involves private properties, =20 inheritance and Reflection with PHP 5.3 RC1. Given the following simple classes class Foo { private $foo =3D 'value'; public function getFoo() { return $this->foo; } } class Bar extends Foo {} Obviously, given an instance of Bar, say $bar, $bar->getFoo() returns =20= 'value'. Now the question: How do I get at this value using reflection, given =20 an instance of Bar? $class =3D new \ReflectionClass('Foo'); $fooProp =3D $class->getProperty('foo'); $fooProp->setAccessible(true); $bar =3D new Bar; $value =3D $fooProp->getValue($bar); var_dump($value); // NULL var_dump($bar); // array(1) { ["=EF=BF=BDFoo=EF=BF=BDfoo"]=3D> = string(5) "value" } How do I get at the value exposed by "var_dump($bar);" through =20 reflection? Obviously, I can't upcast like this: "$fooProp->getValue((Foo)$bar)". I'm asking here because I have the bad feeling that this is might not =20= (yet?) be possible. Thanks! Roman=