The PHP 7 Revolution: Return Types and Removed Artifacts

PHP’s evolution is a consequence of its popularity. If people only ever tried to write small, one-off scripts, then PHP would have stayed a small, one-off language. But people kept getting more ambitious. Wordpress, vBulletin, Wikipedia, and others. People wanted larger and more complex applications, and they often required skilled and professional programmers, as well as new language features to help manage the complexity.

But the good news for you is that you can ignore most of that if you really want to. You don’t have to use namespaces or closures, nor OOP or autoloading. You could ignore all that stuff and still write a simple, procedural, one-off script. You could even write a mostly HTML page with bits of simple PHP sprinkled in, just how Lerdorf originally intended. The new language features don’t block you from doing that.


Thanks for the reassurance Jeff. What really set me off was a post to the effect, “Thank the heavens, they are finally going to deprecate mysql_”

I can use mysqli, but there are functions I have had in place for years that use mysql and I really don’t want to spend the time to go through every file on my site and every database function to check/change them, not to mention the connecting file. I’d rather spend my time on content and stay #1 on Google! :slight_smile:

It’s literally one search and replace away, no matter the size of the codebase, and you’d improve your site’s security immeasurably.

1 Like

In case you are interested I have updated my article to include feedback obtained from this forum. You can read it at

As this is completely off-topic I do not want to respond in this forum, so I have created a new article whiuch can be viewed at

Any language should be able to be used for simple one-off scripts as well as complex applications. The language provides the basic tools, and the programmer builds what he wants with those tools. For example, with a Lego set you can use a dozen units to build a model car, or you can use a million units to build a model skyscraper.

I myself have built an enterprise application which deals with over 300 database tables, 500 relationships and 2,000+ user transactions. There is nothing in the language which stops me from doing that, so why shouldn’t I go ahead and do it?

Good example.

I would not want to live in that skyscraper. And yet, people try to… and they do all kinds of crazy things and go far out of their way to be able to.

It’s not quite as simple as that. You cannot simply replace “mysql_” with “mysqli_” as the argument order has also been altered.

Way to completely ignore people’s valid criticism. You have all of the experienced programmers here saying your code is poor quality. Objectively it is, it is full of bad practices… not all security but it’s needlessly difficult to maintain. The length of your methods is a serious indicator of problems without even digging deeper[1][2][3][4]. On inspection, it’s quick to see that your code is mixing all kinds of irrelevant logic as pointed out by Jeff Mott earlier. It mixes several concerns that really shouldn’t be. Let’s quickly deconstruct:

 $GLOBALS['task_id'] = 'logoff';

There is not even potential for debate about global variables[5][6][7][8][9][10][11][12] so this is an instant and serious red flag.


The same is true of singletons[5][13][14][15][16] so that’s another serious design flaw… and we’re only a few lines in!


Presumably the skip_validation property is in the parent class. Inheritance breaks encapsulation[17][18]. While a much more minor infraction than singletons and global state it’s still badly designed code.

if (is_True($external_auth_off)) {

You actually have a function called is_True? Redundant and pointless. I was going to carry on but I feel the more nuanced flaws will go over your head. Many of my second year students would have been able to identify several flaws in this code.

I’ll leave you with this: Ignoring the security flaws and bad practices. It’s impossible to reuse any of that code and use a postgre or mssql database. It’s also impossible to make your login class use OAUTH or similar. It’s inherently inflexible and difficult to change.

Claiming “experience” and “seniority” in your posts above and then admitting to authoring code like this instantly negates any claim you have surrounding skill and understanding.

[1] Fowler, M (2006) CodeSmell,
[2] Hevery, M (2008) Flaw: Class Does too Much.
[3] Bryton, Sérgio, Fernando Brito e Abreu, and Miguel Monteiro. (2010) Reducing Subjectivity in Code Smells Detection: Experimenting with the Long Method. Quality of Information and Communications Technology (QUATIC), 2010 Seventh International Conference. IEEE.
[4] Carneiro, F., G., Silva, M., Mara, L., Figueiredo, E., Sant’Anna, C., Garcia, A., & Mendonça, M. (2010). Identifying code smells with multiple concern views. In Software Engineering (SBES), 2010 Brazilian Symposium on(pp. 128-137). IEEE.
[5] Sayfan, M (n.d.) Avoid Global Variables, Environment Variables, and Singletons
[6] Hevery, M (2008) Flaw: Brittle Global State & Singletons.
[7] IBM (2012) Avoid modification of global and static variables
[8] Koopman, P (2010) Better Embedded System Software. ISBN: 978-0-9844490-0-2. Drumnadrochit Education LLC.
[9] Svennervberg, G (2012) Global Variables Are Evil
[10] Zakas, N (2006) Global Variables Are Evil
[11] Ferreira, G (2013) Best C Coding Practices – Global variables
[12] Crockford, D (2006) Global Domination
[13] Densmore, S (2004) Why Singletons are Evil
[14] Radford, M (2003) SINGLETON - the anti-pattern!
[15] Yegge, S (2004) Singleton Considered Stupid
[16] Hevery, M (2008) Singletons are Pathological Liars
[17] Gamma, E., Helm, R., Johnson, R., Vlissides, J. Design Patterns: Elements of Reusable Object-Oriented Software. ISBN: 0201633612. Addison Wesley. P.19-20
[18] Bloch, J Effective Java. ISBN: 0321356683

1 Like

Incorrect. That article is restricted to a discussion on BC breaks in the language. For comments on the quality of my code I suggest you look at instead.

Yes there is. They exist, therefore they can be used. This is not to be confused with over-used, mis-used or ab-used. Just because SOME people don’t like them is no reason to say that nobody must use them.

I disagree. Lots of people use them, and I have a perfectly valid use for them. In fact “them” is incorrect as I don’t have a separate singleton method in every class, I have a separate singleton class which has a “getinstance” method. The fact that some people have a problem with singletons is their problem, not mine.

Don’t be ridiculous. Encapsulation, Inheritance and Polymorphism are the fundamental principles of OO, so to now say that one of those principles breaks one of the others is laughable. Where did this idea come from? On the back of a packet of cornflakes? A joke in a Christmas Cracker?

Why not? When you consider that “true” can be represented by a selection of possible values - TRUE, “T”, “Y”, “1” - it is easier to put all those tests into a function than to write out the longhand code each time. You have heard of the DRY principle, I presume?

OAUTH is something that you can use in a public-facing website, but it is inappropriate for a business-facing enterprise application. I have options for a RADIUS or LDAP server instead.

Which is exactly what a singleton is, a single instance of one class. “Some people” here is a red-herring. Singletons (and globals) have been objectively shown to cause problems (limited flexibility being the main one). Using them introduces problems in your codebase, which don’t need to be there.

You can hammer in a screw rather than screwing it in. It’ll work but it’ll be a pain if you need to unscrew it again. A skilled tradesman will tell you it’s a bodge job, the fact that you can do something in an objectively inferior way doesn’t mean you should.

[quote]Don’t be ridiculous. Encapsulation, Inheritance and Polymorphism are the fundamental principles of OO, so to now say that one of those principles breaks one of the others is laughable. Where did this idea come from? On the back of a packet of cornflakes? A joke in a Christmas Cracker?

Programmers far more experienced than you. I provided several references, the most notable being the highly regarded Gang of Four book, but here’s a few more:

Anyway it’s clear that you’re stuck in your ways and nothing is going to change that. I’ve provided references from academia, books and the blogs of professional programmers to back up my points. I suggest you read them.

As others in this topic have discovered, trying to have a meaningful discussion with you is futile so I’m out.


It’s the 1st time I see a return type in a scripting language.
Anyway, putting the return type after the closing parenthesis. It even makes sense to me because in same languages the type is written after the word “returns”.

Well I’ve gotta say this Tony user is clearly a very unique type, browsing through his sites I find many articles that are totally opposite to the mainstream opinion on good practices, such as this one:

First time I heard DI is bad, I wonder if anyone is interested in discussing this. XD

1 Like

Continuing the discussion from The PHP 7 Revolution: Return Types and Removed Artifacts:

haha wow. That article is so full of false equivalences and things that hint at poor separation of concerns. This line is a brilliant example of a fundamental lack of understanding of basic OOP principals:

If you’re not using an object that was passed in then your class is doing too much[1] and you need to redesign the class or move some responsibilities around.

However, this actually gives us an insight into tony’s position. He’s building on top of a fundamental lack of understanding, so for the problems he’s trying to solve (that exist because he is building on top of shaky foundations) his solutions to the (wrong) problems he presents are technically along the right lines: when you have cornered yourself by making a class that does too much, then in this example, it is better to load the dependency if it’s needed. Of course that’s only true if you take his premise as true that the problem is that dependency may not be used, rather than the original class is doing too much.

If you build your water pipes out of lead then a water filter in every house sounds like a good idea. Of course most people would choose to build their pipes out of something less harmful saving them time and money.


Please let us concentrate on discussing the topic and try our best to not get into any discussion that approaches either trolling or personal attacks.

I’ll agree that this is veering off topic. I am not opposed, however, to an honest and detailed discussion about some of Tony’s work in a new topic. It feels to me like this is a dangerous situation which needs to be dealt with, and I think we should dissect the code and show the world what’s wrong with it - not as a personal attack, but followed by actual examples and references as @TomB has done in most replies here. Let’s, thus, leave Tony’s other posts be in this particular discussion.


umm this… I think it may be a good idea to split this thread into two, with one focusing on the actual PHP 7 revolution, and the other on Tony’s backward compatibility concerns and issues. Its easier to keep track this way, also makes this thread more clean and navigable.

I am not the only one to question the validity of Dependency Injection. If you look at you will see a list of links to other articles which also criticise the idea of DI.

@tony_marston404 just curious, have you had any exposure to unit testing at all? If so, how did you properly test anything without dependency injections?

I am “old school”, so I do manual testing, then send it to the QA department. This means that I do not have any need for dependency injection, so I’m not going to amend my code to incorporate a feature that I am never going to use.