Page 1 of 1
Possible New Features in PHP 5.5
Posted: Thu Jul 12, 2012 5:34 pm
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
Re: Possible New Features in PHP 5.5
Posted: Thu Jul 12, 2012 7:07 pm
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.
Re: Possible New Features in PHP 5.5
Posted: Fri Jul 13, 2012 6:20 am
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)
Re: Possible New Features in PHP 5.5
Posted: Fri Jul 13, 2012 11:20 am
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.
Re: Possible New Features in PHP 5.5
Posted: Fri Jul 13, 2012 1:31 pm
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.