Recently, PHP 7.2 has been released, and we are happy to announce that Peachpie has followed suit and is now able to compile the regular PHP 7.2 language syntax to .NET.
PHP has undergone some drastic changes from versions 5.x to 7.x, but the recently implemented changes are mostly just fixes, such as memory leaking, buffer overruns, segmentation faults, etc. In terms of our project, none of these really ever bothered us. Since Peachpie runs on .NET with completely safe and managed memory, these problems hardly even concern us and are handled by .NET.
The only change we did care about is a new `object` type hint, which can be used as a parameter type hint or function return type hint. Since version `0.8.0-CI00510`, Peachpie understands it as well.
Switching language specs
As you are most probably used to from other compilers, you can specify the PHP language version upon compilation. By default, Pachpie compiles for the latest PHP version. You can change it using the `LangVersion` property (see https://github.com/peachpiecompiler/peachpie/wiki/msbuild#langversion). If your code still depends on the old behavior of the `object` type hint or should you want to keep th compatibility with PHP 5.4 and allow for constructs like passing `new` by reference (e.g.: `$x = &new X`), you can.
Aside from adding support for PHP 7.2, we have been busy cleaning up the code and fixing some minor inconsistencies. The easiest way for us to do so is to create small test cases whenever we notice inconsistent behavior, and we would love for the community to contribute like this as well. We have had our issues on GitHub enabled for a few weeks now and the best way to submit one is like this.
In this example, the author submits an issue called
Instanceof $this converts $this to string and provides a miniature test case isolating the issue:
He then provides the expected and actual results to point to what exactly the problem is:
good (the types of $x and $this are compared)
Actual result: empty
This is by far the best way for anyone to contribute, as it isolates the problem and makes our fixing of the issue as efficient as possible.
We are glad that PHP is transforming, getting more type safety and fixes. At the same time, we would like to point out how easy it is to implement these improvements in .NET. As you all know, less code means fewer errors. We focus on Peachpie remaining as lightweight as possible while reaching a full compatibility with PHP. As always, we highly encourage anyone to experiment with Peachpie and submit questions, issues or bugs whenever possible.