In my projects written in PHP, I have namespaces UniCAT and MarC (and some other).
Each of them has class for special purposes - that originally had name of namespace. This naming of that class was not causing problems until situation when class MarC met else class from its namespace outside of that namespace.
Then other class (not MarC) could not be found - because name of class was taken as sub-namespace. From
MarC\class
was
MarC\MarC\class
I renamed those classes that had name of namespaces to Core and used
use MarC\Core as MarC;
But now, and this is what is very strange, I have (it is outside of any namespace)
$VMaX = new MarC\DTDLine(MarC\Core::MARC_CODE_XHTML1TRANS);
$VMaX -> Set_ElementList('VMaX-MarC/DTD/xhtml1-strict.dtd');
and error appears and says that class Core is not found. And it is very very strange to me - because all paths are the same (excepting that change of names of class and its file, of course).
Fatal error: Uncaught Error: Class 'Core' not found in H:\WWW\Kilometrovnik\VMaX-MarC\Base.Classes\DTDLine.Class.php:38 Stack trace: #0 H:\WWW\Kilometrovnik\test.php(9): MarC\DTDLine->__construct('<!DOCTYPE HTML ...') #1 {main} thrown in H:\WWW\Kilometrovnik\VMaX-MarC\Base.Classes\DTDLine.Class.php on line 38
On line 38 of class DTD I have used
MarC::Set_Instance();
to have prepared variables kept in class Core (alias MarC). And in heading of file of class DTDLine I have
namespace MarC;
use UniCAT\Core as UniCAT;
use UniCAT\MethodScope;
use Core as MarC;
How to solve conflict of namespace and class?
Aucun commentaire:
Enregistrer un commentaire