What I would like to see in PHP 7

A simple list of assorted ranting. It should be noted that some of the list is already possible, but would rather they be part of the core.

  • Better Design By Contract Support (possible now)
  • Native Object Types (SPL Types?)
  • Better and more consistent security
    1. Built-in nonces (PECL extension?)
    2. OpenID as PECL extension
    3. Core Authentication functions and objects that allows extensions
  • SPL Hookable for object method consistency
  • SPL MVC classes as PECL and core.

DBC or Design by Contract is possible now with assert and assert_options, but it really should be part of the function and class method prototype. It would separate the input checking before the body is executed and if supplied, would check the output. For objects, the assertions would be inheritable.

Other items of the list are for developmental consistency between projects. I feel it would be neater, if for instance, using the SPL Hookable object, would allow for learning an hookable API once and “plugging” in multiple objects of similar functionality.

Nonces are such awesome security feature, it would be nice to have it built into the $_POST superglobal without using an HTML hidden input. Since Authentication is such a common practice it would make some sense to have a base authentication, either database or otherwise.

Possibly Related Posts:


16 Comments.

  1. Always think it’s a little cheeky to discuss stuff like this, as it’s in the hope someone will volunteer their time to do it. But anyway…

    - Eliminate non-re-entrant extensions from core distribution – in particular PCRE – allow PHP running under Apache 2 threaded mpm. In practice I guess that means switching to the ICU regex engine (http://icu.sourceforge.net/userguide/regexp.html), which claims to be at least similar to Perl regexes. What about GD (painful)?

    - Functions as first class types e.g. $myfunc = function() { #etc }, closures etc.

    - Enable / disable PHP short tags at runtime. By default pass variables output with short tags through htmlspecialchars(). Allow additional syntax for binding to functions / variables in the current scope. I.e. help PHP be a better template engine.

    - Engine level URL-mapping – as alternative to Apache / mod_rewrite. Map either to superglobal or named class

    Also re. “SPL MVC classes as PECL and core” – only if it’s done in a manner which is a fit to HTTP e.g. web.py style (http://webpy.org/) i.e. map URL’s to controller _classes_ which have fixed method names (GET, POST, etc.) _not_ map URLs to class methods(!)

  2. Well, Andrei did discuss closures in his interview, but I have mixed feelings with closures as they tend to lead to bad programming style.

    It would probably be impossible to allow the enabling or disabling of PHP short tags. It would make some sense in that case to not allow the disabling of short tags. However, the short tags do kind of interfer with XML < ?xml ?> syntax, so I think it would be better to just remove short tags.

    map URL’s to controller _classes_ which have fixed method names (GET, POST, etc.) _not_ map URLs to class methods(!)

    Can you explain this in a little bit more detail. I will probably visit webpy anyway. It seems to me that you would have a class named GET that would handle all of the GET requests. PHP already has a superglobal that does that.

    However, if want you mean is that http://www.example.com/section/action maps to a folder /controller/section/action.php, then that would make perfect sense.

    Instead of GD, I think they should introduce an extension that can handle SVG XML files for creating graphics. Or map the other graphic program to a PHP extension.

    ————-

    Oh, I do plan on trying to implement parts of the list, if I don’t see anyone else doing so.

  3. Jared "Ren" Williams

    ImageMagick as far as i’m aware is thread safe. But maybe more interesting is a cairo wrapper. http://cairo-wrapper.php-baustelle.de/trac/

  4. The Cairo wrapper meets my requirements so I look forward for further developments from them. I bookmarked the page.

  5. The first feature and only feature that I miss … would be

    Application Scope Variables, Hope Apache and PHP Devel. are working on it. :)

  6. OOP like java and C#

  7. As we’re not gonna get it in PHP 6 right at the top of my list would have to be type hinting for primitives.. That would rawk.

  8. “OOP like java and C#” – you mean namespacing? please don’t :/

    Isn’t there a patch in PHP 6 for it anyways? :/

  9. OOP Like Java and C#

    is flame baiting. Usually a reference to PHP 4 with little thought to what PHP 5 has to offer in terms of advances of the Object Model. While it can’t do everything in Java and C#, it is still meets the basic requirement of any OOP language.

    It could also be a flame towards the general Procedural and OO approach that PHP takes compared to the strict OO approach that Java and C# takes. It is generally the same arguement used against C++.

    Namespaces – Could be in PHP 6, but if it has problems like in PHP 5, then it would have to be in PHP 7. A lot of work is going into the Unicode for PHP 6, but that doesn’t mean that other features like namespaces won’t make it.

    As many awesome PECL extensions are created, they could make their way into the PHP build. I think the focus of security should be a big one. Some of which is going to be added to PHP 5.2 and PHP 6, but others need to be added so that novices can make secure code.

  10. Multithreading (free threading) like in c# and java

  11. Why not to stay compiler?

  12. I have already posted about PHP multithreading debate. Please read it as it should answer your question. If you do have other questions not answered in the post, then say so and I’ll update the post.

    What is a “stay Compiler”, all google references don’t really use it in your context, so can you further explain what you mean?

  13. “Stay Compieler” sorry for my English i mean :
    Now Php is interpreter in spite of the fact that php executing script in own “byte” code (i mean that php make byte code like VB 6 for example) and then exec it. So this is more faster then if it will be simple interpreter like old Basic language version. But how do you think is it possible to make php compieler (i mean that php will compile scripts in binary code).

  14. Oh, yes. I understand now. The “Official” PHP interpreter/compiler is built for quick execution. There does exist other compilers out there that will do what you ask.

    There is an extension that will compile and execute scripts. It barely runs well enough to be included in the standard PHP distribution.

    PHP is compiled to Opcode.

  15. Does anyone know where I can get a Php script that will interpret Basic source code?

    Thanks
    Tom

    troutdoor@charter.net

Trackbacks and Pingbacks: