PHP Classes

They just broke PHP

Recommend this page to a friend!

      PHP Classes blog  >  How PHP 7 Can Help Yo...  >  All threads  >  They just broke PHP  >  (Un) Subscribe thread alerts  
Subject:They just broke PHP
Summary:I believe this is the first step in breaking PHP.
Messages:7
Author:Stefan Jibrail Froelich
Date:2015-03-30 13:25:02
Update:2015-04-01 18:35:25
 

  1. They just broke PHP   Reply   Report abuse  
Picture of Stefan Jibrail Froelich Stefan Jibrail Froelich - 2015-03-30 18:50:42
Why do I have this bad taste in my mouth and this sinking feeling that PHP is getting broken?
Runtime type checking? Really? And erasing the identity of PHP itself?
There is a reason I use PHP for some things I do and C# and java and Ruby and javascript etc for the other things.
This abomination is not PHP.

I agree type hinting will greatly help especially with IDEs and development, but the fact that the checks are made at runtime is absurd and telling. This doesn't belong in production PHP period.
Personally, I'd have a build process to remove these hints before deploying. That out to make the code run faster I believe.

  2. Re: They just broke PHP   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2015-03-31 00:38:03 - In reply to message 1 from Stefan Jibrail Froelich
Hi Stefan,

I respect your opinion but I prefer to have this improvement.
Remember that you can use strict_type or not, is up to you.
If you remember the history of PHP in previous versions (<5) objects didn't exist. I think that a programming language is more or less like a natural language, it's a live entity and collects what the users want.

Anyway, thank you for comment. I like to hear all opinions.

  3. Re: They just broke PHP   Reply   Report abuse  
Picture of Stefan Jibrail Froelich Stefan Jibrail Froelich - 2015-03-31 04:33:21 - In reply to message 2 from Joseluis Laso
Laso, don't get me wrong. I love the idea of type hinting, but type hinting without polymorphism just doesn't make sense to me.
I understood why it couldn't exist in PHP 5.*, but PHP 7? It is a whole new beast. Now would be the time to put something like that in there.

Also, the idea of enforcing strict types for scalar values is absurd and contrary to the whole idea of what PHP is. I would not use PHP if it forced me to use actual integers instead of numeric strings. That is why we love PHP. The dynamic typing. If you take that away, all you'd have left is a language with a loss of identity. I would rather move on and use Ruby for my websites than stay in a language that can't decide what it wants to be

You can argue it is optional, but what if I am using a library with that enforced? What then?

  4. Re: They just broke PHP   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2015-03-31 18:48:25 - In reply to message 3 from Stefan Jibrail Froelich
Hello Stefan. I truly appreciate your comments.

It's true that the evolution of the strict type hints will promote the third-party libraries. But, it's true also that there are developments that work around legacy PHP, like for instance wordpress, that don't use any of the last advances (objects, namespaces, etc), and others, like Symfony that exploit all the language's resources. I don't know what kind of developments you do, but I'm sure you can find libraries for all flavours, now and in the future. Here, in PHPClasses you can find libraries for all levels.

Regards.

  5. Re: They just broke PHP   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-31 18:52:33 - In reply to message 3 from Stefan Jibrail Froelich
I think it is worth reinforcing that if you have an application that disables strict typing and you include a library that sets strict typing, strict typing will be disabled for that library in your application.

Still weak typing will be enabled. So if you pass a string where an array is expected, an exception is thrown right on the function call.

  6. Re: They just broke PHP   Reply   Report abuse  
Picture of Stefan Jibrail Froelich Stefan Jibrail Froelich - 2015-04-01 05:37:25 - In reply to message 5 from Manuel Lemos
Manuel, thanks. Now that is better.

  7. Re: They just broke PHP   Reply   Report abuse  
Picture of Joseluis Laso Joseluis Laso - 2015-04-01 18:35:25 - In reply to message 5 from Manuel Lemos
Hello Manuel,

You're right, the strict_type can be set to 0, (or not set, it's the same), and the behaviour it's like PHP5.x, it doesn't matter if Stefan call a third-party library that implements strict type hint or not.

Thank you for clarify this point.