Hi!

> In essence the example would be something along the lines of "$s must be 
> a string with length exactly 4 and if not, trigger_error() with the 
> given error message and error level.

OK, I see what you mean, but it is still unclear what such construct
does. At least conceptually, I do not understand what is php:Param, what
is StringLength, what is the relationship between them, which code is
called when and why, what are ErrorMessage= and ErrorLevel=. In C# I can
understand that that declaration is completely passive and is used by
some .net classes to perform their validation work. What would be
performing this work in PHP?

It also raises some future compatibility questions: if we would want to
have named parameters for functions it'd be very awkward if we had one
syntax for named parameters here and another for functions.

> A similar type of thing could occur for PHP, the recent use case of 
> Nullable for Type Hints would be a great use of such attributes, but 

I'm not sure it would be the same, as type hints are supposed to be
validated automatically on each call, and data annotations, of which you
brought the example, do not work like that, if I understand this correctly:
http://stackoverflow.com/questions/6496705/how-do-data-annotations-work

>>> class a {
>>>       [php:Param($s) = StringLength(4, ErrorMessage='Parameter $s length
>>> cannnot exceed 4.', ErrorLevel=E_USER_ERROR)]
>>>       public function foo($s) { ... ]
>>> }


-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to