Tag Archives: PHP

Closures, Anonymous Classes and an alternative approach to Test Mocking (Part 3)

I have heard people say that you shouldn’t test abstract classes or traits, only the concrete classes that implement or use them. I don’t follow that approach: unit testing is all about testing in isolation from anything that might affect those … Continue reading

Posted in PHP | Tagged , , , , , | 1 Comment

Closures, Anonymous Classes and an alternative approach to Test Mocking (Part 2)

The last time I posted here, I was writing about Anonymous Functions and how they can be bound to any object (or class) to execute as though they are a method within the scope of that class (Closure Binding as … Continue reading

Posted in PHP | Tagged , , , , , | 1 Comment

Closure Binding as an alternative to “use” variables

As a general rule when creating a Closure, arguments are passed when the function is called, but “use” variables (I’m sure that they have a formal name, but have no idea what it might be, so I just refer to … Continue reading

Posted in PHP | Tagged , , , | 14 Comments

Closures, Anonymous Classes and an alternative approach to Test Mocking (Part 1)

Since their first introduction with PHP 5.3, Closures have proven an incredibly useful feature for writing simple callback code, making it cleaner and more intuitive. Anonymous Functions can be used inline for many of the array functions $price = 100.00; … Continue reading

Posted in PHP | Tagged , , , , | 5 Comments

Musings of a PHPDiversity Rainbow Elephpant

IT’S HAPPENING! Finally, the kickstarter is happening! And I’m ecstatic. I’d so been hoping that the kickstarter would be launched last Friday, and it felt frustrating when the day ended, and I hadn’t heard anything back from the kickstarter review team. And then I … Continue reading

Posted in PHP | Tagged , , | Leave a comment

Musings of a PHPDiversity Rainbow Elephpant

I’M REAL! I’M REAL! I know that I shouldn’t shout; but I just want to tell the whole world that I’M REAL! I’M HAPPENING! I’M A REAL ELEPHPANT! When Mark got home from work this evening, he found me sitting in … Continue reading

Posted in PHP | Tagged , , | 1 Comment

PHP Generators – Sending “Gotchas”

If you’re reading this, you’re probably already aware of just how useful PHP’s Generators are for improving performance and/or reducing memory overheads while keeping your code clean and easy to read. We can use a simple foreach() in the main body … Continue reading

Posted in PHP | Tagged , | 4 Comments