New SPL Features in PHP 5.3

Matthew Turland

Senior Engineer - Synacor, Inc.

My Name Is...

And I Work For...

Synacor HQ - Buffalo, NY

And You?

State of SPL Pre-5.3


"A container is a class, a data structure, or an abstract data type whose instances are collections of other objects. They are used to store objects in an organized way following specific access rules."

Container (data structure) - Wikipedia

Why Containers?

We already have arrays and strings!

Two Excellent Reasons

Versus traditional arrays, there's potential for:

Arrays Are (Not Always) Great

Warning: Benchmarks Ahead

The List

SplFixedArray - What

SplFixedArray - When

It's best to use this when:

SplFixedArray - Code

SplFixedArray - Executions/Second

SplFixedArray - Memory

SplDoublyLinkedList - What

SplDoublyLinkedList - When

It's best to use this when:

SplDoublyLinkedList - Code

SplDoublyLinkedList - Executions/Second

SplDoublyLinkedList - Memory

The Stack

SplStack - What

SplStack - When

It's best to use this when:

SplStack - Code (Array)

SplStack - Code (SplStack)

SplStack - Executions/Second

SplStack - Memory

The Queue

SplQueue - What

SplQueue - When

It's best to use this when:

SplQueue - Code (Array)

SplQueue - Code (SplQueue)

SplQueue - Executions/Second

SplQueue - Memory

The Heap

SplHeap - What

Heap Diagram

SplHeap - When

It's best to use this when:

SplMinHeap - Code (Array)

SplMinHeap - Code (SplMinHeap)

SplMinHeap - Executions/Second

SplMinHeap - Memory

The Priority Queue

SplPriorityQueue - What

SplPriorityQueue - When

It's best to use this when:

SplPriorityQueue - Code (Array)

SplPriorityQueue - Code (SplPriorityQueue)

SplPriorityQueue - Executions/Second

SplPriorityQueue - Memory

The Set

The Composite Hash Map

SplObjectStorage - What

SplObjectStorage - When

It's best to use this when:

SplObjectStorage - Code (Array)

SplObjectStorage - Code (SplObjectStorage)

SplObjectStorage - Executions/Second

SplObjectStorage - Memory

Thank This Guy

Etienne Kneuss did a lot of the work on the new SPL features in PHP 5.3

Some Great SPL Resources

Possible Future SPL Features

That's All, Folks