-
Recent Posts
- 33 Years – That’s an LP in “Old Money”
- Type the List: A Proposal to support type-casting in PHP’s list language construct
- Default the List: A Proposal to support default values in PHP’s list language construct
- Splat the List: A Proposal to support Variadics in PHP’s list language construct
- List-o-mania
Recent Comments
Archives
- February 2023
- June 2022
- May 2022
- March 2022
- December 2021
- November 2021
- October 2021
- September 2021
- January 2021
- November 2020
- September 2020
- July 2020
- January 2020
- December 2019
- July 2019
- December 2018
- June 2018
- April 2018
- March 2018
- January 2018
- November 2017
- September 2017
- July 2017
- March 2017
- December 2016
- October 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- January 2016
Categories
Meta
Tag Archives: Anonymous
Using PHP Anonymous Classes as Package Private Classes
I’ve written before about the benefits of using PHP’s Anonymous Classes for test doubles; but Anonymous Classes also have potential usecases within production code as well. In this article I’m going to describe one such usecase that can be particularly … Continue reading
Closures, Anonymous Classes and an alternative approach to Test Mocking (Part 4)
In a prior article in this series, I described the use of a SpyMaster Class to create proxy spies as anonymous classes, that allow external visibility (and potentially update) of protected and private properties within an object. The same basic principle … Continue reading
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
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
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
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
Anonymous Class Factory – The Results are in
A week or so ago, I published an article entitled “In Search of an Anonymous Class Factory” about my efforts at writing a “factory” for PHP7’s new Anonymous Classes (extending a named concrete base class, and assigning Traits to it dynamically); and about … Continue reading
In Search of an Anonymous Class Factory
One of the more interesting new features introduced to PHP with the arrival of version 7 is Anonymous Classes. Anonymous Functions (or Closures) have been a part of the language since version 5.3.0, and are something that I find incredibly useful; … Continue reading