Minimal requirement of 5.4 is a bit overkill, actually. The only 'nice' feature in 5.4 is that they now allow for the JavaScript array notation, i.e. $a = [1, 2, 3];
So this saves code, but you know what..? With Wedge's PHP caching, I can perfectly do it 'à la Wess', use array shortcuts, and then at cache time, replace any 5.4-arrays with 5.3-arrays. That sounds silly, but it's quite easy to do with my current codebase.
While 5.3 had two features that I wanted to use, and that are hard to 'emulate': closures and namespaces. However, it's not the panacea I thought it was...
- Namespaces are actually quite useless in a SMF codebase, AFAICT. Add 'namespace Wedge' to the top of index.php... Run it. It crashes. To be clear, any functions defined inside index.php are prefixed with Wedge\, and need to be called that way (such as Wedge\loadSource(...)) when called OUTSIDE of the Wedge namespace. That's fine by me... Except for something I didn't know before: if you include/require a file, it will NOT inherit the current namespace. So, the 'solution' is not only to include a namespace Wedge at the top of ALL files that Wedge uses, but also hardcode the Wedge\ prefix into any callback strings, and other things like that. That seems awfully overkill for the use I wanted to do of it (i.e. simplify a few function names while not risking name collisions with other libraries or the main website.)
In the end, I don't think I'll be using that, then. But the good news is, now you can use Laravel next to Wedge, or something...
:P- Closures ARE the panacea for me, for sure, but I've made a few benchmarks, and didn't notice any difference with creation_function(), even though it's supposed to be about 10 times faster. Not a big deal, though -- I spent years complaining that I couldn't use closures, I'm happy enough that I can use them now...! I've already rewritten Profile-Modify.php, it saves 500 bytes of escaped quotes (!!), much easier to debug, and at last code inside these functions is easily findable through a grep.
But PHP 5.4...? I'll probably use array shortcuts, for sure. I'll just backport them to PHP 5.3, and everyone will be happy.
Posted: December 23rd, 2013, 04:04 PM
(Oh, and also: getting rid of create_function() and generally any evals will also make my PHP minifier safer to use.)