No, shelf companies are not illegal and can be purchased by anyone interested in starting a business in Portugal without going through the entire formalities. Being an entity already registered, it is in the records of the authorities, even if it has no activities.