This might sound heavy handed and radical but it’s widely accepted, particularly among the testing community that statics are evil. Specifically I’m referring to static properties and methods, with exception to self
for late static binding and parent
used in inheritance.
At first glance, statics are a convenience but as your code base grows, and especially if you try to write unit tests around your code, the convenience turns into pain. Why?
Read the rest of this entry »
This was the third consecutive year I’ve attended the PHP UK conference. I bought a ticket for Friday only (this is the first year PHP UK has spanned two days). While I think the event is better organised every year, the quality of the talks for 2012, overall, was not the same standard as last year (with exception to Ian B’s, who’s always good).
Read the rest of this entry »
When writing unit tests, it’s often useful to know the code coverage you’ve achieved to see what proportion of your code you’re exercising. Typically you have to commit your code to version control, so your CI server can pull in your updates and produce coverage reports. This means you sometimes commit incomplete tests, where you might forget to test failure branches (throwing exceptions for example).
Read the rest of this entry »
I occasionally need the list of method parameter matchers when setting assertions via mocks using with()
. A completely useless example:
$foo->expects($this->once())
->method('setter')
->with($this->isType('string'));
Read the rest of this entry »
I originally added this to Wikipedia’s Luhn algorithm page but one of their editors deemed there to be too many language implementations, and so they scrubbed it.
I’m posting it here for other PHP programmers, this might save you a few minutes work.
Read the rest of this entry »
I needed to compile the latest PHP5 from source so I could enable FPM support. The following packages needed installing to successfully complete compilation. Read the rest of this entry »