Any valid PHP code can be contained within a namespace. But only the folowing types of code are affected by namespaces :
- classes (including traits and abstracts)
- functions
- constantes
A file containg a namespace keyword must declare the namespace at the top of file and before any code. The only code allowed before namespace declaration is the declare statement for defining the encoding.