Hack interface overview

  There are a number of predefined interfaces in Hack. This post is going to give you an overview about the interfaces that are a subtype of Traversable. Traversable<Tv> This is an abstract interface. Each an every class that implements this interface may...

Tuple

A tuple is very similar to a PHP array and a shape. The key feature of tuples is that they are immutable. You may not change the length or the types of the elements in a tuple. The values within the tuple are mutable. public function test(): void { $tup = tuple('3',...

Shape

Hack introduced a concept called Shapes. It is an object like the associative PHP array but with predefined array keys. If you are familiar with C you might think of a shape like a struct. So what is the use case for this? Why should we complicate things with Shapes...

Why collections?

Hack has introduced some new object to replace the PHP array. These collections are Vector, Set, Map, Pair and some more. If you are familiar with Java or C# you probably know the benefits of each of these collections already. You might be thinking: Why would you want...

Hack constructors

Hack got a lot of features and improvements of different kinds. It comes with some syntactic sugar. The constructor is a subject for a syntactic sugar improvement. The PHP-way of writing a class might look like this: <?php class Foobar { protected string $name;...

Hack modes

When you are using Hack you are running in one of 3 different modes. The modes are telling the type checker how strict (or forgiving) it should be when checking the code. The modes are strict, partial and decl. In addition to this there modes, there is a declaration...