Here is an example of how to create type safe lists in PHP 7. Influenced by Java Generics, this approach lets your code guarantee the type of data you can store and retrieve from arrays.
To change the type of objects stored in the list, update the second line of code. To change it to a scalar, replace MyType with a scalar type of choice: