Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49742 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 981 invoked from network); 17 Sep 2010 01:28:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2010 01:28:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=ssufficool@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ssufficool@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.177 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ssufficool@gmail.com X-Host-Fingerprint: 209.85.216.177 mail-qy0-f177.google.com Received: from [209.85.216.177] ([209.85.216.177:41852] helo=mail-qy0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/C5-15036-A54C29C4 for ; Thu, 16 Sep 2010 21:28:59 -0400 Received: by qyk34 with SMTP id 34so2031539qyk.8 for ; Thu, 16 Sep 2010 18:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=gStO6T9hB2YYXUxLY0/Je3q2VfmpR2UHVb+nwdc2z8c=; b=B8EXv+qRvMZ1ExXQCBpogS82svZsLYYP5pLbSk9VQ6sIVzdHKQcATuVh7GHmfpagl2 EuiE39YK4mXic0mPm+Iz8qgih02Yda8LjLgsmrybdtqjMySSbkZU+mSKa+R4TBpbcrEt oyuJRo3H5eKDx63rr5+kXIQopUcc/YmmRbyTk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=w/y17gTaZGz9c4E2FYSVpndAxpZyNYiV3tXo7lkqFpWTvhTBBjQmFCk0e27yZWH0/I QAoYu7ZW6Dy4buRbMwR2bGA5By4J5vXwemvIjV1PQ0yPyjM85ujBOWwGMda/TP1H3UN/ aKlZ2iAbc8nCOFQEaWUCjDt5HNIImkuBBKWak= MIME-Version: 1.0 Received: by 10.220.93.17 with SMTP id t17mr2570771vcm.266.1284686936489; Thu, 16 Sep 2010 18:28:56 -0700 (PDT) Received: by 10.220.45.136 with HTTP; Thu, 16 Sep 2010 18:28:56 -0700 (PDT) Date: Thu, 16 Sep 2010 18:28:56 -0700 Message-ID: To: PHP Developers Mailing List Content-Type: text/plain; charset=ISO-8859-1 Subject: Annotations Alternative? From: ssufficool@gmail.com (Stanley Sufficool) 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.