Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49744 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33134 invoked from network); 17 Sep 2010 07:47:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2010 07:47:40 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:49674] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/92-10701-B1D139C4 for ; Fri, 17 Sep 2010 03:47:39 -0400 Received: by iwn37 with SMTP id 37so2097998iwn.29 for ; Fri, 17 Sep 2010 00:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=HZB02NHd8cr0CKJeq6Y5TDTcV2YRkC1ZMLYYXHyKZog=; b=VxFMsheUysQQ1ixWkxkV/hr9x3jjTlmq+QjNo/yYGHk30xqMl7uWlq1PqC7w5OjNPu ez+ptRpyszoMK+n81puV2qtQse4+QdgwnN06PimKYMddGG3QOa63N3ZtXOahSZi3TCLB Nzr4jY7Ymj+ScnBw8f0XvDIslKi42MqyBo3zU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=bguQ+ImHV/GUPQHrBDlVXGMiIxDRPFlTbS+zlxuhMcLhfMQyXqDC9sR25CcaY1v74h luHZ7MrhHglxEjKiZD0BIxqGkARcZZ76HQooT6ARNUD6IQO9ue0YM53fHBpYlouYRB2o mhcFk/0cNdkDQzBsAfM1BzLPGeKo19SAUU9jE= MIME-Version: 1.0 Received: by 10.231.190.9 with SMTP id dg9mr4907411ibb.54.1284709657209; Fri, 17 Sep 2010 00:47:37 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.231.153.1 with HTTP; Fri, 17 Sep 2010 00:47:37 -0700 (PDT) In-Reply-To: References: Date: Fri, 17 Sep 2010 09:47:37 +0200 X-Google-Sender-Auth: A9Y4SyAqvyUOoDfGKKpTC5kZa7o Message-ID: To: Stanley Sufficool Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary=0016367d6faec1ed3c04906fc6d0 Subject: Re: [PHP-DEV] Annotations Alternative? From: info@tyrael.hu (Ferenc Kovacs) --0016367d6faec1ed3c04906fc6d0 Content-Type: text/plain; charset=UTF-8 On Fri, Sep 17, 2010 at 3:28 AM, Stanley Sufficool wrote: > After reading a little of this back and forth of annotations, > validation and documentation (oh my). I thought, why not just abstract > the standard types (string, int, bool, etc...) to SPL classes. > > This would allow for validation, documentation, casting, and related > functions ( length, substr, etc...) to be encapsulated in the class, > rather than in some new language construct. > > This is a bit .NETish, but each instance of a variable/class could > have its own description ($int->description), constructor with built > in validation ( $int = new Int32('123456') ) and casting/conversion ( > $str = new String('12345'); $int32 = $str ). > > For custom validation, maybe: $int = new Int32(); $int->validate = > function($value) { return $value < 100 && $value > 5; }; $int->value = > 105; /* Throws error */ > > Parsers should be able to grab validations and description from the code. > > This also will solve some peoples wishes for strict typing as: > function foo(String $arg1, Int32 $arg2, $arg3); > > This is more overhead. But it is elective for those who wish to use > it. It won't burden existing application performance. And it doesn't > require learning another construct. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > http://wiki.php.net/rfc/splweaktypehintingwithautoboxing http://wiki.php.net/rfc/autoboxing Tyrael --0016367d6faec1ed3c04906fc6d0--