Menu

Maslosoft Addendum Logo Maslosoft Addendum Documentation
Easy to use php annotations

Edit

Arrays

Arrays might be defined with curly braces or square brackets.

Keys should be quoted quoted and are assigned by using = or => operator.

Keys are optional, if not specified zero-indexed integer keys will be used.

Any type supported by addendum can be array value, including array.

To assign array keys both simplified = symbol can be used or classic => notation.

Square Brackets

With Classic => Key Notation

Example of passing array value with keys using arrow notation and square brackets:

The syntax you already know. With [] brackets and => operator.

@MyAnnotation(['one' => 1, 'two' => 2, 'three' => 3])

Array values can also written with square brackets, just like in plain PHP.

Example of passing array value to annotation:

@MyAnnotation([1, 2, 3])

Example of passing array value with keys:

@MyAnnotation(['one' = 1, 'two' = 2, 'three' = 3])

Example with class literal, and string

@MyAnnotation([MyClassLiteral, 'String value'])

Curly Braces

Example of passing array value to annotation:

@MyAnnotation({1, 2, 3})

Example of passing array value with keys:

@MyAnnotation({'one' = 1, 'two' = 2, 'three' = 3})

Example with class literal, and string

@MyAnnotation({MyClassLiteral, 'String value'})
With Classic => Key Notation

Example of passing array value with keys using classic arrow operator:

@MyAnnotation({'one' => 1, 'two' => 2, 'three' => 3})