Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86200 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75759 invoked from network); 13 May 2015 18:38:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2015 18:38:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=brianvanderburg2@aim.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=brianvanderburg2@aim.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain aim.com designates 64.12.143.86 as permitted sender) X-PHP-List-Original-Sender: brianvanderburg2@aim.com X-Host-Fingerprint: 64.12.143.86 omr-m10.mx.aol.com Received: from [64.12.143.86] ([64.12.143.86:48451] helo=omr-m10.mx.aol.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id ED/C3-42752-53A93555 for ; Wed, 13 May 2015 14:38:45 -0400 Received: from mtaout-aal01.mx.aol.com (mtaout-aal01.mx.aol.com [172.27.20.205]) by omr-m10.mx.aol.com (Outbound Mail Relay) with ESMTP id DA3E8705D7A6A for ; Wed, 13 May 2015 14:38:42 -0400 (EDT) Received: from [192.168.1.10] (cpe-174-108-21-154.carolina.res.rr.com [174.108.21.154]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mtaout-aal01.mx.aol.com (MUA/Third Party Client Interface) with ESMTPSA id A6DF438000090 for ; Wed, 13 May 2015 14:38:42 -0400 (EDT) Message-ID: <55539A32.3060606@aim.com> Date: Wed, 13 May 2015 14:38:42 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit x-aol-global-disposition: G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mx.aim.com; s=20140625; t=1431542322; bh=UkTxtX/QOFfndSGhO0zrEY81rHDYbCzgPevbqr6ElIQ=; h=From:To:Subject:Message-ID:Date:MIME-Version:Content-Type; b=JWQQ1hWF8AmG81i0UljBhrUxSOJbdIdukU0N/GfAVh0dD7Ul8Tp7AwfcD1eaXA2Nk 58Q0HCgtx6R/vUu7esHh7azY25i1GQTL/5AgDV6BHnZByfC9rFQqbVhwff/9NCMNUA zBnd1/v8e1/bRAgltwcuxEloChXqra22byhbVIyw= x-aol-sid: 3039ac1b14cd55539a3268a5 X-AOL-IP: 174.108.21.154 Subject: Idea for improvements to namespaces and class autoloading. From: brianvanderburg2@aim.com (Brian Allen Vanderburg II) I have an idea that could be useful with dealing with namespaces and auto-loading include files. Basically, a new function could exist, called spl_autoload_include_register, spl_autoload_namespace_register or similar. The callback passed to this function will get called whenever a class that is not currently defined is used, just like with spl_autoload_register. Instead of the callback doing the work to include the file, the callback of this function will return the filename of the file to include, or return FALSE if it elects not to handle the class name. If FALSE is returned, PHP would continue to the next registered autoloader. If a filename is returned, PHP will automatically include that file. Before the file is actually loaded/executed, PHP will set the namespace of the included file to the namespace of the class being accessed. A file loaded in this manor does not need to define an explicit namespace. If it does, it must do so at the top of the file and that will override the initial namespace. This shows what I mean: classes/myclass.php