Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace interface

Tags:

namespaces

php

I have struct:

/VBAL/
/VBAL/Interface/
/VBAL/Interface/Named.php
....
/VBAL/Component.php

Component.php:

namespace JV\VBAL; 
class Component implements \JV\VBAL\Interface\Named {}

Named.php:

namespace JV\VBAL\Interface;
interface Named {}

But I've got parse error:

Parse error: syntax error, unexpected '{', expecting T_STRING or T_NAMESPACE or T_NS_SEPARATOR

How do you call the directory "namespace", or place the files?

like image 349
ajile Avatar asked Aug 09 '11 10:08

ajile


People also ask

What is Interface namespace?

Interface NamespaceAn interface that contains information about a namespace. Namespaces are accessed from a StartElement.

What is the meaning of namespace?

A namespace is a declarative region that provides a scope to the identifiers (the names of types, functions, variables, etc) inside it. Namespaces are used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.

What does namespace mean in TypeScript?

The namespace is used for logical grouping of functionalities. A namespace can include interfaces, classes, functions and variables to support a single or a group of related functionalities. A namespace can be created using the namespace keyword followed by the namespace name.

What is namespace in JS?

Namespace refers to the programming paradigm of providing scope to the identifiers (names of types, functions, variables, etc) to prevent collisions between them. For instance, the same variable name might be required in a program in different contexts.


2 Answers

Interface is a reserved word in PHP. You can't use it as part of your namespace.

like image 131
Mchl Avatar answered Oct 02 '22 16:10

Mchl


As mentioned before Interface is reserved word and can not be used as part of namepsace.

Two good alternatives are:

Base - in which you can store many base classes from which you extend, for example interfaces, abstract classes, traits

or Interfaces, but this one is in my opinion used little less because of it's plular form

like image 32
LPodolski Avatar answered Oct 02 '22 16:10

LPodolski