Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57572 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11261 invoked from network); 30 Jan 2012 14:33:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2012 14:33:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.214.170 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.214.170 mail-tul01m020-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:47219] helo=mail-tul01m020-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/E5-53934-33AA62F4 for ; Mon, 30 Jan 2012 09:33:24 -0500 Received: by obbup3 with SMTP id up3so4410217obb.29 for ; Mon, 30 Jan 2012 06:33:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.109.106 with SMTP id hr10mr29003435obb.27.1327934000820; Mon, 30 Jan 2012 06:33:20 -0800 (PST) Received: by 10.60.20.1 with HTTP; Mon, 30 Jan 2012 06:33:20 -0800 (PST) In-Reply-To: <1327883576.6780.722.camel@guybrush> References: <1327883576.6780.722.camel@guybrush> Date: Mon, 30 Jan 2012 09:33:20 -0500 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=f46d0444ee556771d904b7bfba11 Subject: Re: [PHP-DEV] ReflectionFile missing From: rasmus@mindplay.dk (Rasmus Schultz) --f46d0444ee556771d904b7bfba11 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable From my point of view, the concept of a "file" has become semantically more important, and increasingly relevant to Reflection, with the latest PHP features added in the past couple of years. I can see what you mean though - it's probably not a small effort, and there are probably more important aspects of PHP that need attention... 2012/1/29 Johannes Schl=FCter > Hi, > > > On Sun, 2012-01-29 at 18:51 -0500, Rasmus Schultz wrote: > > I realized the other day that ReflectionFile is missing from the > Reflection > > API. > > As is ReflectionNamespace and some others one might think about. In the > end it boils down to the fact that we don't have structures internally > representing them as for PHP there is no need to keep the data and then > we're restrictive in adding such meta-data just for the purpose of > reflection. Mind that we'd have to keep all that in memory and opcode > caches have to copy it around etc. in the end the consensus was: the > effort needed doesn't seem worthwhile. > > The alternative would be to "emulate" it, something like > > class ReflectionFile { > private $filename; > private $classes =3D array(); > private $functions =3D array(); > > private initFunctions($filename) { > foreach(get_defined_functions()['user'] as $f) { > $rf =3D new ReflectionFunction($f); > if ($rf->getFilename() =3D=3D $filename) { > $this->functions[$rf->getName()] =3D $rf; > } > } > } > > private initClasses($filename) { /* ... */ } > > public __construct($filename) { > $this->filename =3D realpath($filename); > $this->initFunctions($this->filename); > /* ... */ > } > > public getFunctions() { > return $this->functions; > } > > public getFunctionNames() { > return array_keys($this->functions); > } > > /* ... */ > } > > But that feels more like a hack than a solution, too. > > johannes > > PS. Mind that the example you've given even works on files not included > by parsing files, whereas internal reflection provides information what > actually is available from engine point of view ... > > --f46d0444ee556771d904b7bfba11--