Ok rinominando ogni file con un namespace diverso il tutto funziona, ma così non ha poco senso? E se volessi definire tutto sotto ad un unico namespace?
Il file attuale è questo:
index.php
Codice PHP:
<?php
namespace system\bootstrap;
use system\bootstrap\Blind;
use BaseException\ExceptionHandler2;
use BaseHandler\BaseHandler2;
use test\prova\lol;
set_error_handler(array('system\bootstrap\Blind', 'errorHandler'), E_ALL);
spl_autoload_register(function ($className) {
$namespaces = explode('\\', $className);
$method = array_pop($namespaces);
echo "<br>".('includes/'.implode('/', $namespaces))."<br>";
include('includes/'.implode('/', $namespaces).'.php');
});
class Blind {
public function __construct() {
echo $s;
}
public static final function errorHandler($errorNo, $message, $filename, $lineNo) {
throw new ExceptionHandler2();
}
}
new Blind;
includes/BaseHandler.php
Codice PHP:
<?php
namespace BaseHandler;
use BaseHandler\BaseHandler2;
class BaseHandler2 extends \Exception {}
includes/BaseException.php
Codice PHP:
<?php
namespace BaseException;
use BaseHandler\BaseHandler2;
use IException\IException;
class ExceptionHandler2 extends BaseHandler2 implements IException {
public function __construct($message = '', $code = 0, $description = '', \Exception $previous = null) {
echo (string) $message . "<br>" . (int) $code . "<br>" . $previous;
}
public function show() {
echo "ok";
}
}
includes/IException.php
Codice PHP:
<?php
namespace IException;
interface IException { public function show();}