PHPackages                             sebastian/shaku - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. sebastian/shaku

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

sebastian/shaku
===============

Tool to automatically generate type-safe Collection and CollectionIterator classes

1.4.0(7y ago)315666BSD-3-ClausePHPPHP ^7.2

Since Nov 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/sebastianbergmann/shaku)[ Packagist](https://packagist.org/packages/sebastian/shaku)[ Docs](https://github.com/sebastianbergmann/shaku)[ RSS](/packages/sebastian-shaku/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (6)Used By (0)

Shaku, the Collection Generator
===============================

[](#shaku-the-collection-generator)

`shaku` can automatically generate type-safe `Collection` and `CollectionIterator` classes.

Installation
------------

[](#installation)

The recommended way to use this tool is a [PHP Archive (PHAR)](https://php.net/phar):

```
$ wget https://phar.phpunit.de/shaku.phar

$ php shaku.phar --version
```

Furthermore, it is recommended to use [Phive](https://phar.io/) for installing and updating the tool dependencies of your project.

Alternatively, you may use [Composer](https://getcomposer.org/) to download and install this tool as well as its dependencies. [This is not recommended, though.](https://twitter.com/s_bergmann/status/999635212723212288)

Usage
-----

[](#usage)

Consider you have a class named `Value` (declared in `src/Value.php`) and need a type-safe `ValueCollection` for objects of this type:

```
namespace vendor;

final class Value
{
    // ...
}
```

### Generating the `Collection` and `CollectionIterator`

[](#generating-the-collection-and-collectioniterator)

You can use this tool to automatically generate the code for the `ValueCollection` and `ValueCollectionIterator` class like so:

```
$ php shaku.phar --immutable vendor Value src

```

The above results in the generation of the code shown below:

```
