Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37161 invoked from network); 7 Sep 2013 16:36:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2013 16:36:13 -0000 Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.169 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:42740] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/6B-00660-CF55B225 for ; Sat, 07 Sep 2013 12:36:13 -0400 Received: by mail-lb0-f169.google.com with SMTP id z5so3872420lbh.0 for ; Sat, 07 Sep 2013 09:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=Jckc0heh8Fx90KBndeHudupyQLQbFGJPOzv03VA101k=; b=K9CuidZo3BSISfu/lcGos94qZJypuHWLxVRAE5qCeQAm5BLgJlq1sOkrEkzHV8yHlK hWG2GWP78iWtp65U0dF4BU+hyrqFU+mOajy3Ce+RVr8W3maw6EuXSkzz14jzYqstgfBc L391TKQvnxDXphYrSt9DApj+n4BtSDvKY53K7EPbFINz9sb51ppI6l2xbuIZHHeQzc/h MxiB5B1FkugHZxtQdGbmc9Cl1imywSxcXyQOpLnOZd48FyTzjSUQyoRFpHOD8qrbg2za K2tlreY+V9nNyqhnnyjgW+eo48jbNpSV1ViV7Dky00oKBkpPHBVhBpTWPFSGjVuARyhi GtIQ== X-Received: by 10.112.168.35 with SMTP id zt3mr7947250lbb.11.1378571770280; Sat, 07 Sep 2013 09:36:10 -0700 (PDT) Received: from nikita-pc (95-28-221-4.broadband.corbina.ru. [95.28.221.4]) by mx.google.com with ESMTPSA id k6sm1770263lae.9.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 07 Sep 2013 09:36:09 -0700 (PDT) Content-Type: text/plain; charset=koi8-r; format=flowed; delsp=yes To: internals@lists.php.net, "Michael John Burgess" References: <522B4F8D.2040107@mjburgess.co.uk> Date: Sat, 07 Sep 2013 20:36:30 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <522B4F8D.2040107@mjburgess.co.uk> User-Agent: Opera Mail/12.16 (Win32) Subject: Re: [PHP-DEV] [RFC] Escaping RFC for PHP Core - Updates? From: inefedor@gmail.com ("Nikita Nefedov") On Sat, 07 Sep 2013 20:08:45 +0400, Michael John Burgess 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).