1. Go to this page and download the library: Download grikdotnet/generics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grikdotnet / generics example snippets
class CollectionInt extends \ArrayObject{
public function offsetSet(int $key, int $value )
{
parent::offsetSet($key,$value);
}
}
class CollectionFoo extends \ArrayObject{
public function offsetSet(int $key, \Foo $value )
{
parent::offsetSet($key,$value);
}
}
#[\Generics\T]
class Collection extends \ArrayObject{
use \grikdotnet\generics\GenericTrait;
public function offsetSet(#[\Generics\T] $key, #[\Generics\T] $value )
{
parent::offsetSet($key,$value);
}
}
class Model{
/**
* @param Collection $numeric
* @return int
*/
public function multiply(#[\Generics\T("Collection<int><float>")] $numeric): int
{
$result = 0;
for ($numeric as $key => $value) {
$value *= 2;
}
return $result;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.