Add null check for PhpModule
Minor refactoring