Re: [RFC] Escaping RFC for PHP Core - Updates?

From: Date: Fri, 27 Sep 2013 00:53:34 +0000
Subject: Re: [RFC] Escaping RFC for PHP Core - Updates?
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-69369@lists.php.net to get a copy of this message
Hi, On Sun, Sep 8, 2013 at 1:36 AM, Nikita Nefedov <inefedor@gmail.com> wrote: > On Sat, 07 Sep 2013 20:08:45 +0400, Michael John Burgess < > michael@mjburgess.co.uk> wrote: > > On 07/09/2013 15:41, Levi Morrison wrote: >> >>> It looks nicer than Escaper::escapeJs(), Escaper::escapeHtml(), etc. >>>> >>>> Any comments? >>>> >>> >>> >>> Please, don't go down this route. You do not want one class to escape all >>> kinds of data; delegate each type of escaping to its own class: >>> >>> JavaScriptEscaper->escape(); >>> PhpEscaper->escape(); >>> HtmlEscaper->escape(); >>> HtmlAttributeEscaper->escape()**; >>> >>> I should not have to defend this but I am willing to explain in more >>> detail >>> if someone would like me to. >>> >>> >> >> There doesnt need to be any object-oriented version for this problem. >> It's a series of pure functions. Wraping them in one or more classes adds >> nothing. >> >> Michael >> >> > Hi, > > Wrapping those functions in methods means they can be extended in child > classes. So suppose you have some library that takes object of type > Spl_Escaper and uses its methods for escaping some data. Now if you will > need some additional escaping you just need to make child class for > Spl_Escaper and override methods which behavior you need to change. This > can't be done with pure functions (in PHP). > > I'm in favor of implementing this in ext/filter now, but extend-ability is good benefit. -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#69369) next »