[prev in list] [next in list] [prev in thread] [next in thread]
List: php-internals
Subject: Re: [PHP-DEV] Annotations Alternative?
From: Ferenc Kovacs <info () tyrael ! hu>
Date: 2010-09-17 7:47:37
Message-ID: AANLkTik5O7=Z5fAgUB=q7A=n31N9KmGriAsHt3xJ92oe () mail ! gmail ! com
[Download RAW message or body]
On Fri, Sep 17, 2010 at 3:28 AM, Stanley Sufficool <ssufficool@gmail.com>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<http://wiki.php.net/rfc/autoboxing?s[]=autoboxing>
Tyrael
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic