fix possible npe in TagReference of php #331