Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45839 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34730 invoked from network); 18 Oct 2009 05:02:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Oct 2009 05:02:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:38591] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/46-28550-D51AADA4 for ; Sun, 18 Oct 2009 01:02:22 -0400 Received: from [83.228.56.37] (port=1089 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1MzNuM-0007li-27; Sun, 18 Oct 2009 00:02:18 -0500 Message-ID: <33BB2A493E7247BABF6ED3B3321F5357@pc> To: , "Rack-Soft security" References: <20091016143251.e95b77e5@mailro.4psa.com> Date: Sun, 18 Oct 2009 08:02:12 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002D_01CA4FC9.4C666440" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Autofunc patch (automatically loading functions like autoload) From: sv_forums@fmethod.com ("Stan Vassilev") ------=_NextPart_000_002D_01CA4FC9.4C666440 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Unfortunately there may be a problem with this path and namespaces in = 5.3. I tried to warn about this while namespaces were being implemented, = but everyone was in the "autoload will always be for classes only". Right now when you use fully qualified name of a class when inside a = namespace, you need to always prefix it with backslash: \Foo.=20 For functions, it was deemed too hard as most internal functions remain = in global space, so inside a namespace one would need to prefix every = call with a backslash. If you don't prefix with backslash, the = interpreter will try both options at runtime: if there's a local = function, it'll run, if there isn't, it'll try to find it in global = space, and only if it's not there, it'll fail. The only reason this double lookup works is because there's no autoload = for functions, and it's the reasons why classes don't have this feature. = There was a big discussion back about how to enable them both without = severe performance penalty or unintuitive behavior, but none was found.=20 I am myself a big proponent of autoload for functions, as there was = never a good reason for excluding them from autoload (except for the = artificially introduced one in 5.3). Regards,=20 Stan Vassilev=20 ----- Original Message -----=20 From: Rack-Soft security=20 To: internals@lists.php.net=20 Sent: Friday, October 16, 2009 5:32 PM Subject: [PHP-DEV] Autofunc patch (automatically loading functions = like autoload) Hello, I am submitting quite an interesting patch to PHP 5.2.11 and PHP = 5.3.0. It is used in production on hundreds of machines without any = issues. Basically the patch adds the autofunc function that performs quite in = the same way like autofunc, only that it does it for functions. As do = you know, if PHP can not find a function it will issue a fatal error. = With autofunc you can find the function somewhere and load it. = Management of large no OOP projects (or mixed OOP/procedural) is much = easier with this. I know that there are workarounds for loading = functions, like adding them static to classes, but this is not efficient = and involves important changes to code. I have attached some PHP files to test with, you must execute = index.php that will load autofunc when the loaded functions can not be = found. Let me know if you have any questions regarding the patch.=20 Best regards, Bogdan -------------------------------------------------------------------------= ----- --=20 PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php ------=_NextPart_000_002D_01CA4FC9.4C666440--