1. Go to this page and download the library: Download ddruganov/php-typed-array 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/ */
ddruganov / php-typed-array example snippets
final class SomeClass
{
public TypedArray $typedArray;
public function __construct()
{
$this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::INT));
}
}
final class SomeClass
{
public TypedArray $typedArray;
public function __construct()
{
$this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::INT));
}
public function someMethod()
{
$this->typedArray = TypedArray::of(TypeDescription::of(TypeDescription::STRING));
}
}
final class DummyArray extends TypedArray
{
public function __construct()
{
parent::__construct(new TypeDescription(DummyClass::class));
}
public function offsetGet(mixed $offset): DummyClass
{
return parent::offsetGet($offset);
}
}