convert php to base and add tests