© Christopher Pitt 2016

Christopher Pitt, Typed PHP, 10.1007/978-1-4842-2114-3_2

2. Structure

Christopher Pitt

(1)Cape Town, Western Cape, South Africa

The problems with the core function libraries are mostly about structure. In fact, we could address them by adding encapsulation (classes specifically designed for each scalar variable type), a consistent method naming scheme, and consistent parameter ordering.

In this chapter, we’re going to look at how to package a new API. We’ll create classes to decorate scalar types, discuss how we can determine the type of scalar variables we’re dealing with, and even learn how to deal with the problems introduced by null.

Decorating

Decorating is a term given to the practice of wrapping data in a class, so that ...

Get Typed PHP: Stronger Types For Cleaner Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.