Making PHP6 Better

When you work day-in day-out with PHP the API consistency can be a bit tiresome. So it was time to do something about it. This is a project to propose a better API and a more object-oriented away of writing PHP.

Thanks to the initial work by nikic we have an extension that can enable scalar object support for PHP.

This allows us to turn primitive types into objects and thus gives us a nice opportunity to create a better API that can coexist alongside the existing function syntax.

Here's an example of the new syntax:

$str = "Hello World";
echo $str->replace("World","PHP"); // Outputs: Hello PHP

$str = "Hello World";
echo $str->length();  // Outputs:  11

Array operations with a simpler syntax API are also supported...

$arr = ["k1"=>"val1","k2"=>"val2"];
print_r($arr->merge(["k3"=>"val3","k4"=>"val4"])->count());
// Outputs: 4

$array = [1,2,3,4,5];
$array->each(function(&$value) {
  $value *= 2;
});  // Outputs: [2,4,6,8,10]

There's a lot more examples to look at, the first part of this project is written in PHP which has allowed faster iteration and testing.

Once the API is finalised and thoroughly tested the next job will be to write the internals natively in C.

Find the project here on Github.