Stenway Developer Network

Namespaces

Root namespace of package MyLib

namespace MyLib

end

Dots are allowed in package names

namespace MyCompany.MyLib

end

A file with multiple namespaces. The first is the root namespace and the two other are sub-namespaces.

namespace MyLib

end

namespace MyLib\Utils

end

namespace MyLib\Utils.MoreUtils

end

Access Levels

Namespace entities are by default public. To define a namespace entity that is only visible inside of the package, use the internal keyword. Note, that there is no public keyword.

namespace MyLib
  class MyPublicClass
  
  end
  
  internal class MyInternalClass
  
  end
end

A namespace can contain multiple entities in one single file.