Musings of a PHPDiversity Rainbow Elephpant

“A week is a long time in politics”, apparently. I’m not sure what that means: every time I’ve asked Mark over the last week or so, he’s been reduced almost to tears, mumbling something about “being proud to be a European”, but “no longer allowed to say so out loud”.

But what I do know is that a lot can happen in just one week; and a lot has been happening here, as Mark starts to put together costings and estimates in spreadsheets. The pictures that I posted last week show that it’s technically feasible to create me as a real Elephpant, and prove that there will always be at least one of me. Now he’s putting some numbers and costings together to show whether or not I’m financially viable; and he tells me that it’s all looking good so far, though he needs some more numbers to be certain. And it will need at least 1,200 of me to work, because that’s the minimum run that the factory will do; but I shouldn’t cost much more than any of the other Elephpants out in the world, despite the extra overheads of the colouring process.

That’s all very good news for me. It’s important that there are lots of me all around the world, spreading the Diversity message wherever they find themselves.

Continue reading

Posted in PHP | Tagged , , | Leave a comment

Musings of a PHPDiversity Rainbow Elephpant

Mark’s away at the Dutch PHP Conference where (apparently) he’s talking to people about cats; but while he’s away, I’ve had the most incredible, incredible news. It’s really been a very busy day here.

Not only is there a new PHP User Group in Denmark, PHPJutland, that’s only just been announced today – waving “hello” to all my new Danish friends; and I have a new cousin to welcome to the family of Elephpants; but I’ve also seen the real me… I mean, I haven’t actually seen the “real” me yet (my eyesight isn’t good enough to see half way round the world, and the real me is still at the factory in China), but I have seen photographs of the real me, and that’s nearly as good, because it means that a real me now exists in the real world. I am now officially a prototype!

And I’m so excited about seeing me for the first time ever, that I just have to share some of the photographs with you all to show you what I look like.

Continue reading

Posted in PHP | Tagged , , | 4 Comments

Musings of a PHPDiversity Rainbow Elephpant

Wow! Mark is letting me write my own posts on his blog.

For those of you who don’t know me yet, I’m Enfys, the PHP Diversity Rainbow Elephpant; or at least, I shall be when I’m real. At the moment, I’m just a virtual Elephpant, an idea inpired by a photoshopped picture by  Peter Kokot (a Slovenian developer); but someday soon I hope to be a real Elephpant, and join the PHP worldwide herd.

And yesterday, my dream came a step closer to reality.

Continue reading

Posted in PHP | Tagged , , | 2 Comments

The PHP Diversity Rainbow ElePHPant

It was a picture posted by Peter Kokot (a Slovenian developer) on the PHP group on Facebook that got me thinking.

Diversity Elephpant

Together with his comment:

Hello, PHPers. A friendly reminder to spread awareness and support of equality because discrimination separates us. Today is the International Day Against Homophobia, Transphobia, and Biphobia.
Let’s not discriminate based on the race, gender, sexual orientation, gender identity, age, nationality, religion nor technology. Have a nice day. 🙂

Continue reading

Posted in PHP | Tagged , , | 5 Comments

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 how I subsequently discovered the expensive memory demands of my original factory code, and then rewrote it using a different and (hopefully) more memory-efficient approach.

Since then, I’ve run some tests for memory usage and timings to assess just how inefficient my first attempt at the factory code was, and whether the new version of the factory really was better than the original.

Continue reading

Posted in PHP | Tagged , , , , , , | Leave a comment

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; but (aside from a few very specific circumstances) I couldn’t see any real everyday benefits for coders (other than perhaps a few library developers) in Anonymous Classes.

Then back in January (as I was waiting for my flight to the continent for PHPBenelux) I was intrigued by a request to find a way of dynamically applying Traits to a class at run-time. With time on my hands as I was sitting in the airport, I considered the problem; and my first thought was to build an Anonymous class, extending the requested class (so that it would still contain all the base properties and functionality, and could be type-hinted, but also applying the requested Trait or set of Traits.

Continue reading

Posted in PHP | Tagged , , , | 13 Comments

Heroes of PHP™ #2

Following the first part of my “Heroes of PHP”™, I subsequently posted the second of my 24 “Heroes of PHP”™ on Twitter.

As with the first list, I’m reproducing that second set of Heroes here, together with some additional explanation about why these individuals mean so much to me.

Continue reading

Posted in PHP | Tagged , | 5 Comments

Heroes of PHP™ #1

Following the conclusion of the 24 Days in December series on PHP, I originally posted my own 24 “Heroes of PHP”™ on Twitter.

I’m reproducing that list here, together with some additional explanation of why these individuals mean so much to me.

Continue reading

Posted in PHP | Tagged , | 3 Comments

A Functional Guide to Cat Herding with PHP Generators

When working with arrays in PHP, three of the most useful functions available to us are array_map(), array_filter() and array_reduce(), which allow us to walk an array and manipulate the value of array elements, select a subset of values from an array, or reduce an array to a single value; all using a callback function to determine exactly what logic should be applied. The use of the callback makes them extremely flexible, and these functions can be particularly powerful, especially when combined (or chained) together.

However, these functions only work with standard PHP arrays; so if we are using Generators as a data source instead of an array, then we can’t take advantage of the functionality that they provide. Fortunately, it’s very easy to emulate that functionality and apply it to Generators (and also to other Traversable objects like SPL Iterators), giving us access to all of the flexibility and power that mapping, filtering and reducing can offer.

Continue reading

Posted in PHP | Tagged , , , , , | 8 Comments