Skip to content

Instantly share code, notes, and snippets.

@vonglasow
Created October 31, 2013 12:09
Show Gist options
  • Save vonglasow/7248626 to your computer and use it in GitHub Desktop.
Save vonglasow/7248626 to your computer and use it in GitHub Desktop.
Exception raised when try to make a reflection on class "Application\Controller\Main"
Oct 31 12:49:00 raspberrypiserver apache2: PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class Application\Controller\Main does not exist' in /home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php:411#012Stack trace:#012#0 /home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php(411): ReflectionClass->__construct('Application\Con...')#012#1 /home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php(907): Hoa\Core\Consistency\Consistency::dnew('Application\Con...', Array)#012#2 /home/pi/sohoa/vendor/hoa/dispatcher/Hoa/Dispatcher/Basic.php(193): dnew('Application\Con...', Array)#012#3 /home/pi/sohoa/vendor/hoa/dispatcher/Hoa/Dispatcher/Dispatcher.php(169): Hoa\Dispatcher\Basic->resolve(Array, Object(Hoa\Router\Http), NULL)#012#4 /home/pi/sohoa/vendor/sohoa/framework/Classes/Framework.php(76): Hoa\Dispatcher\Dispatcher->dispatch(Object(Hoa\Router\Http), NULL)#012#5 /home/pi/sohoa/Public/index.php(14): Sohoa\Framework\Framework->run()#012#6 {main}#012 thrown in /home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php on line 411
<pre>object(ReflectionException)#36 (7) {
["message":protected]=>
string(48) "Class Application\Controller\Main does not exist"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(-1)
["file":protected]=>
string(55) "/home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php"
["line":protected]=>
int(412)
["trace":"Exception":private]=>
array(6) {
[0]=>
array(6) {
["file"]=>
string(55) "/home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php"
["line"]=>
int(412)
["function"]=>
string(11) "__construct"
["class"]=>
string(15) "ReflectionClass"
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
string(27) "Application\Controller\Main"
}
}
[1]=>
array(6) {
["file"]=>
string(55) "/home/pi/sohoa/vendor/hoa/core/Hoa/Core/Consistency.php"
["line"]=>
int(910)
["function"]=>
string(4) "dnew"
["class"]=>
string(32) "Hoa\Core\Consistency\Consistency"
["type"]=>
string(2) "::"
["args"]=>
array(2) {
[0]=>
&string(27) "Application\Controller\Main"
[1]=>
&array(3) {
[0]=>
object(Hoa\Router\Http)#23 (8) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#30 (4) {
["_owner":protected]=>
string(15) "Hoa\Router\Http"
["_parameters":protected]=>
array(3) {
["prefix"]=>
NULL
["rules.public"]=>
array(0) {
}
["rules.private"]=>
array(0) {
}
}
["_keywords":protected]=>
array(0) {
}
["_cache":protected]=>
array(0) {
}
}
["_pathPrefix":protected]=>
string(6) "/sohoa"
["_httpPort":protected]=>
int(80)
["_httpsPort":protected]=>
int(443)
["_subdomainStack":protected]=>
int(8)
["_subdomainSuffix":protected]=>
NULL
["_rules":protected]=>
array(1) {
["h"]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
string(4) "Main"
[5]=>
string(5) "Index"
[6]=>
array(0) {
}
}
}
["_rule":protected]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
&string(4) "Main"
[5]=>
&string(5) "Index"
[6]=>
array(5) {
["_domain"]=>
string(9) "127.0.0.1"
["_subdomain"]=>
NULL
["_call"]=>
&string(4) "Main"
["_able"]=>
&string(5) "Index"
["_request"]=>
array(0) {
}
}
}
}
[1]=>
object(Hoa\Dispatcher\Basic)#28 (3) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#33 (4) {
["_owner":protected]=>
string(25) "Hoa\Dispatcher\Dispatcher"
["_parameters":protected]=>
array(9) {
["synchronous.controller"]=>
string(39) "Application\Controller\(:controller:U:)"
["synchronous.action"]=>
string(18) "(:action:U:)Action"
["asynchronous.controller"]=>
string(27) "(:%synchronous.controller:)"
["asynchronous.action"]=>
string(28) "(:%synchronous.action:)Async"
["variables._domain"]=>
string(9) "127.0.0.1"
["variables._subdomain"]=>
NULL
["variables._call"]=>
string(4) "Main"
["variables._able"]=>
string(5) "Index"
["variables._request"]=>
array(0) {
}
}
["_keywords":protected]=>
array(3) {
["controller"]=>
string(4) "Main"
["action"]=>
string(5) "Index"
["method"]=>
string(3) "get"
}
["_cache":protected]=>
array(2) {
["Application\Controller\(:controller:U:)"]=>
string(27) "Application\Controller\Main"
["(:action:U:)Action"]=>
string(11) "IndexAction"
}
}
["_currentView":protected]=>
NULL
["_kit":protected]=>
string(18) "Hoa\Dispatcher\Kit"
}
[2]=>
NULL
}
}
}
[2]=>
array(4) {
["file"]=>
string(61) "/home/pi/sohoa/vendor/hoa/dispatcher/Hoa/Dispatcher/Basic.php"
["line"]=>
int(193)
["function"]=>
string(4) "dnew"
["args"]=>
array(2) {
[0]=>
&string(27) "Application\Controller\Main"
[1]=>
&array(3) {
[0]=>
object(Hoa\Router\Http)#23 (8) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#30 (4) {
["_owner":protected]=>
string(15) "Hoa\Router\Http"
["_parameters":protected]=>
array(3) {
["prefix"]=>
NULL
["rules.public"]=>
array(0) {
}
["rules.private"]=>
array(0) {
}
}
["_keywords":protected]=>
array(0) {
}
["_cache":protected]=>
array(0) {
}
}
["_pathPrefix":protected]=>
string(6) "/sohoa"
["_httpPort":protected]=>
int(80)
["_httpsPort":protected]=>
int(443)
["_subdomainStack":protected]=>
int(8)
["_subdomainSuffix":protected]=>
NULL
["_rules":protected]=>
array(1) {
["h"]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
string(4) "Main"
[5]=>
string(5) "Index"
[6]=>
array(0) {
}
}
}
["_rule":protected]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
&string(4) "Main"
[5]=>
&string(5) "Index"
[6]=>
array(5) {
["_domain"]=>
string(9) "127.0.0.1"
["_subdomain"]=>
NULL
["_call"]=>
&string(4) "Main"
["_able"]=>
&string(5) "Index"
["_request"]=>
array(0) {
}
}
}
}
[1]=>
object(Hoa\Dispatcher\Basic)#28 (3) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#33 (4) {
["_owner":protected]=>
string(25) "Hoa\Dispatcher\Dispatcher"
["_parameters":protected]=>
array(9) {
["synchronous.controller"]=>
string(39) "Application\Controller\(:controller:U:)"
["synchronous.action"]=>
string(18) "(:action:U:)Action"
["asynchronous.controller"]=>
string(27) "(:%synchronous.controller:)"
["asynchronous.action"]=>
string(28) "(:%synchronous.action:)Async"
["variables._domain"]=>
string(9) "127.0.0.1"
["variables._subdomain"]=>
NULL
["variables._call"]=>
string(4) "Main"
["variables._able"]=>
string(5) "Index"
["variables._request"]=>
array(0) {
}
}
["_keywords":protected]=>
array(3) {
["controller"]=>
string(4) "Main"
["action"]=>
string(5) "Index"
["method"]=>
string(3) "get"
}
["_cache":protected]=>
array(2) {
["Application\Controller\(:controller:U:)"]=>
string(27) "Application\Controller\Main"
["(:action:U:)Action"]=>
string(11) "IndexAction"
}
}
["_currentView":protected]=>
NULL
["_kit":protected]=>
string(18) "Hoa\Dispatcher\Kit"
}
[2]=>
NULL
}
}
}
[3]=>
array(6) {
["file"]=>
string(66) "/home/pi/sohoa/vendor/hoa/dispatcher/Hoa/Dispatcher/Dispatcher.php"
["line"]=>
int(169)
["function"]=>
string(7) "resolve"
["class"]=>
string(20) "Hoa\Dispatcher\Basic"
["type"]=>
string(2) "->"
["args"]=>
array(3) {
[0]=>
&array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
&string(4) "Main"
[5]=>
&string(5) "Index"
[6]=>
array(5) {
["_domain"]=>
string(9) "127.0.0.1"
["_subdomain"]=>
NULL
["_call"]=>
&string(4) "Main"
["_able"]=>
&string(5) "Index"
["_request"]=>
array(0) {
}
}
}
[1]=>
object(Hoa\Router\Http)#23 (8) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#30 (4) {
["_owner":protected]=>
string(15) "Hoa\Router\Http"
["_parameters":protected]=>
array(3) {
["prefix"]=>
NULL
["rules.public"]=>
array(0) {
}
["rules.private"]=>
array(0) {
}
}
["_keywords":protected]=>
array(0) {
}
["_cache":protected]=>
array(0) {
}
}
["_pathPrefix":protected]=>
string(6) "/sohoa"
["_httpPort":protected]=>
int(80)
["_httpsPort":protected]=>
int(443)
["_subdomainStack":protected]=>
int(8)
["_subdomainSuffix":protected]=>
NULL
["_rules":protected]=>
array(1) {
["h"]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
string(4) "Main"
[5]=>
string(5) "Index"
[6]=>
array(0) {
}
}
}
["_rule":protected]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
&string(4) "Main"
[5]=>
&string(5) "Index"
[6]=>
array(5) {
["_domain"]=>
string(9) "127.0.0.1"
["_subdomain"]=>
NULL
["_call"]=>
&string(4) "Main"
["_able"]=>
&string(5) "Index"
["_request"]=>
array(0) {
}
}
}
}
[2]=>
&NULL
}
}
[4]=>
array(6) {
["file"]=>
string(59) "/home/pi/sohoa/vendor/sohoa/framework/Classes/Framework.php"
["line"]=>
int(76)
["function"]=>
string(8) "dispatch"
["class"]=>
string(25) "Hoa\Dispatcher\Dispatcher"
["type"]=>
string(2) "->"
["args"]=>
array(2) {
[0]=>
object(Hoa\Router\Http)#23 (8) {
["_parameters":protected]=>
object(Hoa\Core\Parameter\Parameter)#30 (4) {
["_owner":protected]=>
string(15) "Hoa\Router\Http"
["_parameters":protected]=>
array(3) {
["prefix"]=>
NULL
["rules.public"]=>
array(0) {
}
["rules.private"]=>
array(0) {
}
}
["_keywords":protected]=>
array(0) {
}
["_cache":protected]=>
array(0) {
}
}
["_pathPrefix":protected]=>
string(6) "/sohoa"
["_httpPort":protected]=>
int(80)
["_httpsPort":protected]=>
int(443)
["_subdomainStack":protected]=>
int(8)
["_subdomainSuffix":protected]=>
NULL
["_rules":protected]=>
array(1) {
["h"]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
string(4) "Main"
[5]=>
string(5) "Index"
[6]=>
array(0) {
}
}
}
["_rule":protected]=>
array(7) {
[0]=>
int(0)
[1]=>
string(1) "h"
[2]=>
array(1) {
[0]=>
string(3) "get"
}
[3]=>
string(1) "/"
[4]=>
&string(4) "Main"
[5]=>
&string(5) "Index"
[6]=>
array(5) {
["_domain"]=>
string(9) "127.0.0.1"
["_subdomain"]=>
NULL
["_call"]=>
&string(4) "Main"
["_able"]=>
&string(5) "Index"
["_request"]=>
array(0) {
}
}
}
}
[1]=>
&NULL
}
}
[5]=>
array(6) {
["file"]=>
string(31) "/home/pi/sohoa/Public/index.php"
["line"]=>
int(14)
["function"]=>
string(3) "run"
["class"]=>
string(25) "Sohoa\Framework\Framework"
["type"]=>
string(2) "->"
["args"]=>
array(0) {
}
}
}
["previous":"Exception":private]=>
NULL
}
</pre>
374 /**
375 * Dynamic new, i.e. a native factory (import + load + instance).
376 *
377 * @access public
378 * @param string $classname Classname.
379 * @param array $arguments Constructor's arguments.
380 * @return object
381 * @throw \Hoa\Core\Exception
382 */
383 public static function dnew ( $classname, Array $arguments = array() ) {
384 $classname = ltrim($classname, '\\');
385
386 if(!class_exists($classname, false)) {
387
388 $head = substr($classname, 0, $pos = strpos($classname, '\\'));
389 $tail = str_replace('\\', '.', substr($classname, $pos + 1));
390 $from = from($head);
391
392 foreach(array($tail, $tail . '.~') as $_tail)
393 foreach($from->getFroms() as $_from) {
394
395 $break = false;
396 $from->_import(
397 $_from . '.' . $_tail,
398 true,
399 function ( $_classname ) use ( &$break, &$classname ) {
400
401 $classname = $_classname;
402 $break = true;
403 }
404 );
405
406 if(true === $break)
407 break 2;
408 }
409 }
410
411 try {
412 $class = new \ReflectionClass($classname);
413 } catch (\ReflectionException $e) {
414 echo '<pre>';
415 var_dump($e);
416 echo '</pre>';
417 }
418
419 if(empty($arguments) || false === $class->hasMethod('__construct'))
420 return $class->newInstance();
421
422 return $class->newInstanceArgs($arguments);
423 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment