xp-framework/core — pull request #23 by thekid (2014-08-12 19:32:36+00:00)
Title: Generic methods

This pull request implements xp-framework/rfc#214 and adds generic methods:

## Declaration

```php
class Arrays extends \lang\Object {

/**
* Creates a list
*
* @param T[] $arg
* @return util.collections.IList
*/
#[@generic(self= 'T', return= 'util.collections.IList', params= 'T[]')]
public static function asList($T, $arg) {
$list= \lang\XPClass::forName('util.collections.Vector')->newGenericType([$T])->newInstance();
$list->addAll($arg);
return $list;
}
}
```

## Usage

```php
$list= Arrays::{'asList'}(['a', 'b', 'c']);
$list= Arrays::{'asList'}([1, 2, 3]); // lang.IllegalArgumentException
```