PHP code example of edumarques / typed-collections

1. Go to this page and download the library: Download edumarques/typed-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/ */

    

edumarques / typed-collections example snippets


use EduardoMarques\TypedCollections\TypedCollection;
use EduardoMarques\TypedCollections\TypedCollectionImmutable;
use EduardoMarques\TypedCollections\Enum\ScalarType;
use EduardoMarques\TypedCollections\Enum\NonScalarType;

$typedCollection1 = TypedCollection::create(ScalarType::INTEGER);
$typedCollection2 = TypedCollection::create(ScalarType::STRING);

$typedCollectionImmutable1 = TypedCollectionImmutable::create(NonScalarType::CALLABLE);
$typedCollectionImmutable2 = TypedCollectionImmutable::create(\stdClass::class);

use EduardoMarques\TypedCollections\TypedDictionary;
use EduardoMarques\TypedCollections\TypedDictionaryImmutable;
use EduardoMarques\TypedCollections\Enum\ScalarType;
use EduardoMarques\TypedCollections\Enum\NonScalarType;

$typedDictionary1 = TypedDictionary::create(ScalarType::INTEGER, ScalarType::STRING);
$typedDictionary2 = TypedDictionary::create(ScalarType::STRING, ScalarType::DOUBLE);

$typedDictionaryImmutable1 = TypedDictionaryImmutable::create(ScalarType::INTEGER, NonScalarType::CALLABLE);
$typedDictionaryImmutable2 = TypedDictionaryImmutable::create(ScalarType::STRING, \stdClass::class);