Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95076 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21221 invoked from network); 12 Aug 2016 09:43:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Aug 2016 09:43:02 -0000 Authentication-Results: pb1.pair.com header.from=peter.e.lind@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=peter.e.lind@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: peter.e.lind@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wm0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:35813] helo=mail-wm0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/9A-56950-52A9DA75 for ; Fri, 12 Aug 2016 05:43:02 -0400 Received: by mail-wm0-f43.google.com with SMTP id f65so18171707wmi.0 for ; Fri, 12 Aug 2016 02:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GKjegRlbCVq9VG4gQWNs6dzZ1XaQTEUog5sfEpevrtg=; b=Sbk3YRyNVYdDle7FW4g+XTT0uH62MJNt9ZNbWymTEGZDvyedSuEMlWE7VU7WcYzlXQ Hx7PtJDNAwbtBQj3NxiVaEJ3KBOQBRZ7EADjBYrqcL91zIwQzDIE/mInVQg41EyFibCB EyQZBYY47hTxm+xhwpEXg90NsmLzgNBJSMPSk+fPMb8EGliVEOe1I3+O+/Tj+598RIBI NuNmq7oth6E/VFtikHb4S+Z4lvLIAgpkUUjeChwhGVKVApDKlR+clZbVyUlOuou+2srJ 4QXoM/gSiIO2ZvJoBk+3fRSNzsRIJVLmATHB00NoryfD12bzIbxC12uIFA1w9uLzQNYA hhiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GKjegRlbCVq9VG4gQWNs6dzZ1XaQTEUog5sfEpevrtg=; b=fx/eA8sm8Bri183PYjjwUR1QAnfMFaoXLXGIZN9UyWXwbFy7qjI4JNk/fFsGQ4OBjT oTv03vSbBdWUIX01y3jSdEp9WMIdGI8NPiF7879g9B9DvIMdtkX2yyWYhyYG/pqczvYH B/R93fYoM1edE0w746MT+jIPmb5ZXJfEvFFSYkooNBXznIUv4RUHKm9CM0EUQeeqo406 nB3r4LmCFTOYhqDUmIZV54WLC8Ixgd0QhMhCDGdYqocmZ4CMCMlbunyaDH0i/uzNBT2Y l5Z9gkv/vlArPZ8taS4DL/DB0RBqfOEf057yxvuJtFzH1Q8EggyPcz0/z6G4P42d4OKh Nm5w== X-Gm-Message-State: AEkoouubYs77xqZ6XZHvICeD1BEPujSYnTZ3DdIBnzDjpK56+94McHZX4FyHe/MUan4X50cXkRNCnlVWMBFdMA== X-Received: by 10.194.166.37 with SMTP id zd5mr14226017wjb.170.1470994978756; Fri, 12 Aug 2016 02:42:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.123.163 with HTTP; Fri, 12 Aug 2016 02:42:38 -0700 (PDT) In-Reply-To: <1e14c4b9-65ce-4742-589f-19fe9290be0f@lsces.co.uk> References: <10fbcb03-5de8-4d9a-da1c-7e2bf77937cb@lsces.co.uk> <5657afc7-7569-5fc4-4a5a-27ed786c4fa5@gmail.com> <0825c173-5cb4-7f65-cf34-b45ca30919a3@lsces.co.uk> <8646c3ad-b929-cb0b-bad4-52a0a7160d16@gmail.com> <11ce571b-964b-5a3e-9f2f-3f69a8bc20b4@lsces.co.uk> <7d9db8d5-ae7a-4123-14f4-f76fb6d764c5@gmail.com> <1e14c4b9-65ce-4742-589f-19fe9290be0f@lsces.co.uk> Date: Fri, 12 Aug 2016 11:42:38 +0200 Message-ID: To: Lester Caine Cc: PHP internals Content-Type: multipart/alternative; boundary=089e01183a502cdbe40539dcb523 Subject: Re: [PHP-DEV] Simple variable handling. From: peter.e.lind@gmail.com (Peter Lind) --089e01183a502cdbe40539dcb523 Content-Type: text/plain; charset=UTF-8 On 12 August 2016 at 11:25, Lester Caine wrote: > On 12/08/16 10:07, Christoph M. Becker wrote: > >> > I'm thinking > >> > $var->setConstraint() > >> > $var->setEscape() > >> > $var->setReadOnly() > >> > > >> > Rather than having to build 'reflections' classes to pull out data > that > >> > a simple $var->is_valid or echo $var will output a correctly escaped > >> > piece of text. > > Actually, this is already possible; just use objects. E.g. > > > > class Container { > > function __construct() {} > > function setConstraint() {} > > function setEscape() {} > > function setReadOnly() {} > > function isValid() {} > > function __toString() {} > > } > > $var = new Container($some_value); > > This has been the problem all along. There is no overriding reason to > change what we already have, but ALL of the improvements currently being > discussed MAY be better handled with a return to the basic model of a > variable. If a variable is 'readonly' there is no need to worry about > each variable. > > Thanks for the ideas on this feature. A few thoughts. 1. The RFC for this isn't a change - it's an addition. If it gets accepted and implemented, you still would not have to change your code if you didn't want to. 2. There are differing ways of using the language. Yours is not better - merely different. So I would think a relevant question is: can the RFC in point support your style of coding along with that of others. A critical point is throwing exceptions on invalid data, which might be hard to handle. 3. Your assumption of secure intra-nets is questionable. Defense in depth is what one should strive for. 4. I think your suggestions might conflate validation and sanitation - these are not the same and cannot be handled as one That said, I generally think that built-in methods that accept Callables are a great way to go. It encourages reuse through modular composition - and could likely be a neater way around the throw exception/return error code issue. It's obviously doable from userland, but could probably be improved if implemented in the language. Regards Peter -- CV: careers.stackoverflow.com/peterlind LinkedIn: plind Twitter: kafe15 --089e01183a502cdbe40539dcb523--