I have been pretty busy working on a new startup for the past month or so (hence why there hasn’t been any posts, link blogging is too darn time-consuming) and one of the features I would really like to see implemented in php, I’m not even sure what to call it. I would be tempted to say it looks a lot like ActiveRecord, but for php class methods, and it doesn’t necessarily involve mysql. Here is a code example of what I would like to see done:
/* example class */
class Example
{
public $foo;
// sets the foo variable
function set_foo($value)
{
$this->foo = $value;
} //End Foo
} // End Example
/* the magic is in the implementation */
$example = new Example;
$example->foo = 'bar';
What I want the line $example->foo = ‘bar’; to run the set_foo() function and pass the assigned value. Maybe this already exists, maybe it doesn’t, but the real value of something like what I want/need is if you were working with a class that is representation of a DB object/row. When you update a value, you would be able to update the value in the database without having to call any ugly methods.
Just a thought. Leave a comment if you have an opinion.