PHP self fix

Also fixed tests.