Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php class A{} $packages = Collection::fromClassString(A::class); showType($packages); function showType(string $param): void{ echo $param; } /** * @template T */ class Collection{ /** @var array<T> $items */ protected $items = []; /** * @param array<string, T> $items */ public function __construct(array $items = []) { $this->items = $items; } /** * @template C * @param class-string<C> $classString * @param array<string, C> $elements * @return Collection<C> */ public static function fromClassString(string $classString, array $elements = []) : Collection { return new Collection($elements); } /** * @param T $item */ public function add($item) : void { $this->items[] = $item; } }
Snippet created on March 1 2020 at 15:01 UTC
Settings
Get link