Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67426 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81126 invoked from network); 15 May 2013 04:27:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 May 2013 04:27:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:52883] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/90-10740-89E03915 for ; Wed, 15 May 2013 00:27:05 -0400 Received: by mail-la0-f48.google.com with SMTP id fs12so1308133lab.7 for ; Tue, 14 May 2013 21:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=tGb9crA+Qw9k2i0BRSjnC3SL/SqxGpg1O2B1LW9wjwE=; b=N1uwe2LTuIT+ruiSZzGHrxygQZJpusgBoy5awz8O3d4l2hC4oNpEjxXYCWX/OxrSk8 y2R/8drLlauRT7eSPKB7SicuJhW3gK9Q76dFUdWupqRcJ5k7NoUiuLLii8vvFoO+Zoxk LKoISBvpkJuU81LpL4h6w7dwYrPXPAny/1X52RfdGRDGxiMNdgubw2aHDQghcN7txaQX DV7hiA/aeW6aKZK2/i+xeUJVEqWayGJrHPIZwtALJNESuPV0AtA+LuytZnA4WaYzTT6y k5wdk6dW0QR3exKTXc6P2mGrjA7fT3sitkYZT/i33ZyPbotzOWA3dVNYbI0ZrB5GpZDa H39A== X-Received: by 10.112.156.6 with SMTP id wa6mr16357080lbb.113.1368592021385; Tue, 14 May 2013 21:27:01 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.20.228 with HTTP; Tue, 14 May 2013 21:26:21 -0700 (PDT) In-Reply-To: References: <94D5D345-4D14-4BFF-9650-15E80205A6DE@wiedler.ch> <4A468FA3-3260-463C-9D4E-FA78736447C1@wiedler.ch> Date: Wed, 15 May 2013 13:26:21 +0900 X-Google-Sender-Auth: uaR1qF4fKgntVDXSGuxUiDwZQOg Message-ID: To: Igor Wiedler Cc: Sebastian Krebs , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e01161bf4477d6f04dcba292d Subject: Re: [PHP-DEV] Re: Importing namespaced functions From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e01161bf4477d6f04dcba292d Content-Type: text/plain; charset=ISO-8859-1 Hi, Although this change may cause confusion, but it would be beneficial to many users as a security counter measure. For instance, there is CVE-2013-2065 for Ruby http://www.ruby-lang.org/en/news/2013/05/14/taint-bypass-dl-fiddle-cve-2013-2065/ I suppose this change allow us "monkey patch" PHP without upgrade if it is needed. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net 2013/5/3 Igor Wiedler > Your solution is flawed, it would not allow autoloading a function that > has the same > (namespaced) name as a builtin. > > Example: > > // autoloadable function > namespace foo { > // make arg order consistent > function array_filter($callback, $input) { > return \array_filter($input, $callback); > } > function is_positive($x) { > return $x > 0; > } > } > > namespace foo { > var_dump(array_filter('foo\is_positive', [-2, -1, 0, 1, 2])); > } > > Always triggering the autoloader is not feasible either, as it will lead > to tons of stat calls, > one per namespace that any global function is called in. > > Potential solutions: Only autoload fully qualified or imported functions. > > But there is lots of potential for bikeshedding there, plus it requires > more implementation > effort, and quite possibly more performance and cache related > considerations that I am > not aware of. > > As much as I would like to see function autoloading, I don't think > bundling the proposals > is going to be beneficial. Which is why I'd rather just focus on one issue > at a time. > > Regards, > > Igor > > On May 3, 2013, at 12:18 AM, Sebastian Krebs wrote: > > > Well, it is not as complex as it sounds > > > > This is the behaviour right now > > > > - Does X exists as namespaced function (current namespace or imported)? > > - Does X exists as global (builtin) function? > > - Trigger error > > > > The behaviour including autoloading would be more like > > > > - Does X exists as namespaced function (current namespace or imported)? > > - Does X exists as global (builtin) function? > > - Trigger autoload > > - Does X exists as namespaced function (current namespace or imported) > now? > > - Maybe: Does X exists as global function now? > > - Trigger error > > > > The autoloading itself could use parts already used for > class-autoloading. > > > > // Signature > > // spl_autoload_register($callback[, $type = AUTOLOAD_CLASS]); > > > > $autoload = function ($name, $type = AUTOLOAD_CLASS) { > > // Do something > > }; > > spl_autoload_register($autoload, AUTOLOAD_CLASS | AUTOLOAD_FUNCTION > | AUTOLOAD_CONSTANT); // "constant" here just to make it complete > > > > Namespaced functions without autoloading seems kindof incomplete, > especially because it isn't such a big deal to simply use the prefixed one, > so the benefit seems quite small to me :X > > > > use MyFoo\Bar\MathFunctions as math; > > $x = math\sin($y); > > > > > > Just saying :) > > > > > > Regards, > > Sebastian > > > > > > > > > > > > On May 2, 2013, at 11:40 PM, Sebastian Krebs > wrote: > > > > > Hi, > > > > > > Are you going to cover autoloading of functions too? > > > > > > Regards, > > > Sebastian > > > > > > > > -- > > github.com/KingCrunch > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --089e01161bf4477d6f04dcba292d--