Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34255 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93079 invoked by uid 1010); 26 Dec 2007 05:04:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 93063 invoked from network); 26 Dec 2007 05:04:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2007 05:04:14 -0000 Authentication-Results: pb1.pair.com header.from=malterisio777@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=malterisio777@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.189 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: malterisio777@gmail.com X-Host-Fingerprint: 209.85.198.189 rv-out-0910.google.com Received: from [209.85.198.189] ([209.85.198.189:62218] helo=rv-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/35-43924-CC0E1774 for ; Wed, 26 Dec 2007 00:04:13 -0500 Received: by rv-out-0910.google.com with SMTP id k15so1843566rvb.23 for ; Tue, 25 Dec 2007 21:04:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=h+0//rvbDTGjALHb3WiXgAL67i5OsvVVveibLVSf12I=; b=wZOf8mKFqG/RPk9KQxlHSuOk/Co45kFb1b+0Ee3+zIEpDlfv4XUqNJ5zqFnqvrMv+QkyMT81Qj6z0qXp44YlGIm5a49IxGfZ0B1O430WSYs/RxjtdSESJPO/3HPmx3EtnR11vpc9Jj/YnGXGlNAoAxTY2A7nATSf9PkYF/r8PkI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=uc0D0+rxZ5Rqp68IudS2ZjB9fGPmnPbB2BxqCoIaBaqyP5vhyHQKEltQOGr3R27axfy4jR81dG1K6ACx0PvoBdtuWybb6w1Vobk0VDyMxcz5vP9+lm+mPrqrS08Gl/GdYUby+IHJ285An1L8jveqOYy0xJfqMXTJInKQ13Go37Y= Received: by 10.142.252.11 with SMTP id z11mr1736986wfh.50.1198645449599; Tue, 25 Dec 2007 21:04:09 -0800 (PST) Received: by 10.142.157.9 with HTTP; Tue, 25 Dec 2007 21:04:09 -0800 (PST) Message-ID: <52dbac0f0712252104l37af6feay64797ee8f3c020df@mail.gmail.com> Date: Wed, 26 Dec 2007 02:04:09 -0300 To: "PHP Developers Mailing List" , "PHP General" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_8933_29174528.1198645449589" Subject: Sayonara PHP From: malterisio777@gmail.com ("Martin Alterisio") ------=_Part_8933_29174528.1198645449589 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Please let me do a little explanation of the title first. Japanese is an interesting language where context is vital to the meaning of a word. Sayonara usually means a simple "good bye", but within a different context can mean "we'll probably never meet again". To understand this mail you'll have to know that I was just another user of PHP, an user that was probably too eager. I wanted to get more involved with the development of PHP as I do believe in all the philosophy of open-source. In the end I found my attempts ended in frustration, but, nevertheless, I learned a lot in just a few months. I don't want this mail to be one where I get to display all my frustration, instead I want to leave here all my findings, the things I researched, the few things I managed to actually code, and mostly the ideas that someone else might find useful. ---- To those who may want to involve in the php internals ---- For those in the generals list that may ever try to venture in the internals of PHP, remember that you have to back your point of view with a patch. So, sit down, remember the old days in college using the c compiler, and code like a cowboy before trying to promote anything in the internals. It's the status quo of the PHP development community, as I did learn too late. ---- Namespaces: function imports ---- Here is the patch to add function imports to 5.3. To be consistent constants imports have to be added too: http://martinalterisio.com.ar/php5.3/use.function.v2b.patch If you don't know what imports are, they are just a way to refer to a longer name with a shorter name. For example: Instead of: In the first there's no need for namespace declaration, it's declared with the class name. The same can used for functions and consts: This approach restricts namespaces to classes, functions or constants scope. If you want to execute code in a namespace you'll have to be in one of these scopes. But, I think it's a restriction one would pay in favor of all those libraries that will break because they use the fatal keyword (think of all the XML related libraries that use "namespace"). Also, using namespace:: or package:: doesn't need to take a keyword (think of self:: and parent::, they aren't keywords just special names that can't be used for naming classes). ---- Namespaces as nested classes? ---- Reading about how the previous implementation of namespaces went down the drain, one recurring though in some users and developers caught my attention. Maybe namespaces and nested classes should be one and the same thing in php. Considering that many are using classes as namespaces for functions, this is not such a illogical approach to the problem. I have not much considered the technical feasibility of this approach, but one that would be probably needed is the ability to forward declare members. Without this, all definition must be clustered. Example: other file: I can't say much about this approach. It's just one wild idea. ---- Type hints, improvements could help drastically improve performance ---- I thought much about type hints. Right now they are only seen as syntactic sugar for system designers, and something that reduces performance. Actually quite the opposite can be achieved, but not with the current implementation of type hinting. The guys behind flash 9 obtained a 10x improvement in performance thanks to type hinting. Actually doing the same with PHP is quite sensible, since one of the bottlenecks for performance is the zval. Knowing before hand that the variable is a native type, a just in time native compile can be done to drastically improve performance. For that to happen first type hinting must be improved. Here are some thoughts I shared with another user some time ago: http://martinalterisio.com.ar/php5.3/php-typehints.txt ---- Taints ---- Last but not least, I thought about taints. Since PHP6 will remove safe mode and magic quotes, as far as I know, if nothing else is there to prevent users from being users, well PHP6 might be considered too insecure. Taints should be the solution to this, but approaches copied from other languages seem not feasible in PHP. Variable level taints are not the way to go: not much can be added to zval without suffering the consequences, and a simple model of tainted/not tainted is not safe enough, as there are many taints to be considered (XSS, SQL injection, HTML injection to say the least). I think one possible approach to consider is scope taints. Instead of tracking taints on variable level, do it on scope level, ie, attach taints to functions, classes, global scope. Taints should be an arbitrarily sized list of elements, where the user can also add taints of his own (we don't know where security holes might appear in the near future, so let's leave that door open). Taints tracking is to be attached to classes, functions or global scope (methods use class scope). When function or class code refer to another scope (function call, method call, member access, global access) a pollution occurs. In a pollution the involved scopes become infected with taints from both. The pollution operation needs a new opcode that can handle a reference to scope either statically or by an object reference. For each function/class the user has to be able to mark taints that infect them, which taints they can handle/resist, and which taints they reject. A function/class ignores pollution by taints that can handle/resist. If a function/class is polluted by a taint that rejects, an error occurs. Internal functions should define also how they are affected by taints, and some defaults taints be specified for known security issues. The problem with this approach is that is not an automagical solution. It requires the user to be conscious of the security issues. If he does nothing about it an error occurs, but he can mark the scope as one that handles the taint and still do nothing about it. There's two alternatives to how keep track of taints: 1) keep a list of taints that pollute the scope 2) keep a list of taints that DO NOT pollute the scope The second alternative is harder to understand. It assumes that any scope cannot be trusted by nature. Instead of adding threats, you remove threats. I think this approach is more secure. ---- The end ---- Well that wraps it all, I think. That's as much as I can download from my brain which is related to PHP. Do whatever you want with all this, even the spam folder is fine. Anyway, it's been fun, and I learned a lot. My thanks to everyone that ever gave a hand. A former PHP user says to you all: Sayonara PHP P.S.: Please be understanding if I don't answer replies to this email. ------=_Part_8933_29174528.1198645449589--