On 4 July 1946 the Republic of the Philippines attained its independence .