Transpiling converts code from PHP 8.0 to 7.1. Then,
- The project uses PHP 8.0 for development
- The code is converted to PHP 7.1 when generating the plugins for production
For instance, PHP 8.0's union types, are converted from this code in development:
interface CustomPostTypeAPIInterface
{
public function createCustomPost(array $data): string | int | null | Error;
}
into this code for production:
interface CustomPostTypeAPIInterface
{
public function createCustomPost(array $data)
}
Transpiling PHP code enables to use the latest PHP features for development, yet release the plugin with its code converted to an older PHP version for production, as to target a bigger user base.