Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57560 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20400 invoked from network); 30 Jan 2012 00:33:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2012 00:33:08 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:54738] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/C2-15394-245E52F4 for ; Sun, 29 Jan 2012 19:33:07 -0500 Received: from [192.168.2.230] (ppp-93-104-17-158.dynamic.mnet-online.de [93.104.17.158]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id 263C9604F9; Mon, 30 Jan 2012 01:33:02 +0100 (CET) To: Rasmus Schultz Cc: internals@lists.php.net In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Mon, 30 Jan 2012 01:32:56 +0100 Message-ID: <1327883576.6780.722.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] ReflectionFile missing From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?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 = array(); private $functions = array(); private initFunctions($filename) { foreach(get_defined_functions()['user'] as $f) { $rf = new ReflectionFunction($f); if ($rf->getFilename() == $filename) { $this->functions[$rf->getName()] = $rf; } } } private initClasses($filename) { /* ... */ } public __construct($filename) { $this->filename = 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 ...