Possible New Features in PHP 5.5

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Possible New Features in PHP 5.5

Post by Christopher »

Below is a link to an article with a list of possible new features for PHP 5.5. This is a list of things being discussed on the PHP internals mailing list -- not the actual list of new features that will be in PHP 5.5. I thought it might be interesting to people here though.

http://nikic.github.com/2012/07/10/What ... -like.html
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Possible New Features in PHP 5.5

Post by requinix »

I, for one, am particularly interested in the scalar typehinting, getters/setters (aka properties), and generators (like C#'s yield return). List generators are a combination of generators + lambda functions and sound nice too, though I think a foreach+if+yield is pushing it a bit far.

Only thing I don't like in there is the proposed solution for parameter skipping: you aren't so much skipping parameters as you are using the "default" value. I'd rather something closer to

Code: Select all

create_query("deleted=0", "name", report_errors: false);
but I'm not sure I'd like to offer that as a solution to programmers who are creating functions with obscenely-long declarations. For error reporting specifically, (a) log errors somewhere, don't suppress them, (b) write it so it doesn't generate errors, or (c) promote it to a class-level (or even system-level) toggle.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Possible New Features in PHP 5.5

Post by social_experiment »

The 'A simple API for password hashing' could be useful to programmers unfamiliar with the concepts of password hashing but i think it's a double edged sword like the md5() and sha1() functions; helpful but also harmful

One of the comments is about the proposed setter method; the author suggests the first snippet to the one offered by author/s of the article

Code: Select all

<?php
public $hours {
set ($value) { $this->seconds = $value * 3600; }
}
// 
public $hours {
        get { return $this->seconds / 3600; }
        set { $this->seconds = $value * 3600; }
}
?>
The original suggestion confuses me; how would you pass an argument to the method? Would it only be applicable to class properties? (This probably isn't a thread for this type of question but i'm curious)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Possible New Features in PHP 5.5

Post by Jonah Bron »

Frankly, the most practical one I'm glad about is that empty() will work without having to pass a variable. It's quite bothersome that it's been a language construct instead of a function up to this point. I also like the idea of being able to use array access on strings and such.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Possible New Features in PHP 5.5

Post by requinix »

social_experiment wrote:

Code: Select all

<?php
public $hours {
set ($value) { $this->seconds = $value * 3600; }
}
?>
The original suggestion confuses me; how would you pass an argument to the method? Would it only be applicable to class properties?
It'd work like how magic __set works: the syntax is the same but you automagically get the rvalue as an "argument".

Code: Select all

$object->hours = 123;
// akin to $object->hours->set(123) and the magic $object->__set("hours", 123)
And yes, it's just for class variables.
Post Reply