Download the PHP package sebastian/shaku without Composer
On this page you can find all versions of the php package sebastian/shaku. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sebastian/shaku
More information about sebastian/shaku
Files in sebastian/shaku
Package shaku
Short Description Tool to automatically generate type-safe Collection and CollectionIterator classes
License BSD-3-Clause
Homepage https://github.com/sebastianbergmann/shaku
Informations about the package shaku
Shaku, the Collection Generator
shaku
can automatically generate type-safe Collection
and CollectionIterator
classes.
Installation
The recommended way to use this tool is a PHP Archive (PHAR):
Furthermore, it is recommended to use Phive for installing and updating the tool dependencies of your project.
Alternatively, you may use Composer to download and install this tool as well as its dependencies. This is not recommended, though.
Usage
Consider you have a class named Value
(declared in src/Value.php
) and need a type-safe ValueCollection
for objects of this type:
Generating the Collection
and CollectionIterator
You can use this tool to automatically generate the code for the ValueCollection
and ValueCollectionIterator
class like so:
The above results in the generation of the code shown below:
Using the generated Collection
and CollectionIterator
Creating a collection from an array of objects
Creating a collection from a list of objects
Creating an empty collection and adding objects to it
Shaku?
This tool is named after "Shaku, the Collector", Copyright Blizzard Entertainment, Inc.