1. Go to this page and download the library: Download headsnet/collections 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/ */
headsnet / collections example snippets
final class Foo
{
public function __construct(
public string $name
) {
}
}
/**
* @extends AbstractImmutableCollection<Foo>
*
* @method self filter(callable $func)
* @method self reverse()
*/
final class FooCollection extends AbstractImmutableCollection
{
public function getItemClassName(): string
{
return Foo::class;
}
}
$foo1 = new Foo();
$foo2 = new Foo();
$allFoos = new FooCollection([$foo1, $foo2]);
foreach ($allFoos as $foo) {
$this->assertInstanceOf(Foo::class, $foo);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.