I’ve been mostly avoiding PHP for a while, and was surprised to read recently that PHP7 is heading towards release. Out of curiosity I took a look at the RFCs for the new version of the language and I can only say I am gobsmacked. And not in a good way. Some of the proposals seem so absurd I can’t believe that they are serious. Some examples:

Getters and setters in a closure in the class declaration:

Whaaat? Are you joking? That’s hideous. Readability is awful and what’s with declaring these things with capital letters in the variable names? Compare with Ruby:

Overriding the generated getters and setters is as simple as:

And on this topic, some suggested Reflection methods:

getGet() !? Seriously? The mind boggles.

PHP is confusing enough already but there are some other additions that raise the confusion bar even further. New functions for checking the type of something: isInt(), isFloat(), isBool(), isClip() … not to be confused with is_int(), is_string() etc. Facepalm!

Why add a new function name for every type when you could far more easily have just one to compare types, which means also being able to test against instance of classes as it’s done in Ruby:

Then there are some new, even more ridiculous functions, with longer and stupider names than ever before:


Hello? What does safe mean? Why do I need to have a “safe” function to do the conversion? Is the current PHP internal code that converts a value of a given type to a float unsafe? Then fix that, don’t give us yet another stupidly named function!

Once again, in Ruby it’s as simple as:

There are plenty more examples but I don’t want to go on too much. Suffice to say that I find it impossible to believe that people writing these proposals are spending any significant time with better languages or they’d be coming up with some way smarter ideas.


2 thoughts on “PHP7

  1. The PHP 7 getter and setters in a closure is almost a direct rip off of C#’s getters and setters, in fact I’m pretty sure it is just a rip off.

    I don’t think the getter/setter additions are that bad, and I don’t know why they’re using capital letters to start a variable in the example, that’s frightening. Perhaps I’m just used to it because of C#. Right now getters/setters are done essentially as done in Java, just creating a method with set or get followed by the variable.

    Agreed getGet() and all of the isType() functions are just … I’ve got a headache. Things like that make it hard for me to defend PHP. The function naming is inconsistent and bizarre as it is, I feel as though if we’re going to be adding new ones it should be as a part of some sort of class instead of straight up procedural.

    Frankly I’d like to see things like strlen($var) replaced with $var->length() or something, and these could be implemented and the old ones throw a deprecation warning for now.

    I’ve never seen int_convert_to_float_safe() and couldn’t find anything about it. Though “safe” and “real” seem to be something throw into function names from time to time.

    I’m in general optimistic about the new changes, even though some are terrible, and I agree that they need to learn more from other languages. I think this will be good for PHP in the long term, because for about 5 or 6 years PHP really didn’t change at all.

  2. Dustin

    To each his own I guess. I had not seen the getter/setters in PHP7 before, and stumbled upon this article. For reference, I wrote my computer science bachelors project in C#, so I loved that language, but have since been using PHP for work. To see these getters and setters is a godsend! I’m actually in the process of wanting/needing these in a php 5.6 app, and may just upgrade to get them.

    By comparison, the Ruby comparison you posted was non-intuitive to me, and very ugly.

    I have noticed this in the past on some projects I’ve worked with my brother-in-law that uses Ruby on Rails, the difference between PHP and Ruby is quite significant, and both camps are fairly entrenched against the other.

    I appreciate your post calling out the new PHP7 features, I’m super excited.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">