function loadClassFile($classname, $useCacheOnly = false) { $classpath = $this->resolveClassPath($classname, false, $useCacheOnly); if ($classpath) { try { include $classpath; return true; } catch (ExecutionContextException $e) { if ($e->getSeverity() == E_WARNING && $e->getFile() == __FILE__) { unset($this->foundClasspaths[$classname]); $this->uncache($classname); $classpath = $this->resolveClassPath($classname, true, false); if ($classpath) { include $classpath; return true; } } else { // if we do not unregister the handler then we suppress the actual error // replacing it with 'ClassNotFound' error :( Exceptionizer::getInstance()->unregister(); // if we throw an exception back to callstack than we would see // a wrong error :( trigger_error($e->getMessage(), E_USER_ERROR); } } } return false; }
static function suite() { if (isset($GLOBALS[self::GLOBALS_TEST_PATHS_INDEX])) { self::$testPaths = $GLOBALS[self::GLOBALS_TEST_PATHS_INDEX]; } Exceptionizer::getInstance()->register(E_ALL | E_STRICT, false, 'InternalOperationException'); return new PhoebiusTestSuite(self::$testPaths); }
define('SLOT_CONFIGURATION_FLAG_PRODUCTION', 0x4); define('SLOT_CONFIGURATION_SEVERITY_VERBOSE', 0x10); define('SLOT_CONFIGURATION_SEVERITY_OPTIMIZE', 0x20); define('SLOT_PRESET_DEVELOPMENT', SLOT_CONFIGURATION_FLAG_DEVELOPMENT | SLOT_CONFIGURATION_SEVERITY_VERBOSE); define('SLOT_PRESET_TEST', SLOT_CONFIGURATION_FLAG_TEST | SLOT_CONFIGURATION_SEVERITY_VERBOSE | SLOT_CONFIGURATION_SEVERITY_OPTIMIZE); define('SLOT_PRESET_PRODUCTION', SLOT_CONFIGURATION_FLAG_PRODUCTION | SLOT_CONFIGURATION_SEVERITY_OPTIMIZE); if (!defined('APP_SLOT')) { define('APP_SLOT', isset($_ENV['PHOEBIUS_APP_SLOT']) ? $_ENV['PHOEBIUS_APP_SLOT'] : (isset($_SERVER['PHOEBIUS_APP_SLOT']) ? $_SERVER['PHOEBIUS_APP_SLOT'] : 'default')); } /** * Should be appended with a dot */ define('PHOEBIUS_TYPE_EXTENSION', '.class.php'); ////////////////////////////////////////////////////////////////////////////////////////////////// // no comment set_magic_quotes_runtime(0); // Set GMT timezone for compatibility (if you forgot to do that later) if (!isset($_ENV['TZ'])) { date_default_timezone_set('Europe/London'); } ////////////////////////////////////////////////////////////////////////////////////////////////// // FIXME: wrap the linear inclusion of core files with the code that caches all those files // inside separate file, that possibly can be used both by Autoloader $classes = array('IAutoloader' => 'Core/Bootstrap', 'StaticClass' => 'Core/Patterns', 'LazySingleton' => 'Core/Patterns', 'Assert' => 'Core', 'InternalSegmentCache' => 'Core/Bootstrap', 'IClassResolver' => 'Core/Bootstrap', 'ClassResolver' => 'Core/Bootstrap', 'CSharpStyleClassResolver' => 'Core/Bootstrap', 'PathResolver' => 'Core/Bootstrap', 'Autoloader' => 'Core/Bootstrap', 'Exceptionizer' => 'Core/Bootstrap', 'IErrorExceptionFactory' => 'Core/Bootstrap', 'ApplicationException' => 'Core/Exceptions', 'ArgumentException' => 'Core/Exceptions', 'ApplicationException' => 'Core/Exceptions', 'ExecutionContextException' => 'Core/Exceptions', 'InternalOperationException' => 'Core/Exceptions', 'RecoverableErrorFactory' => 'Core/Bootstrap', 'CompilationContextException' => 'Core/Exceptions', 'TypeUtils' => 'Utils'); foreach ($classes as $classname => $classDirectory) { require PHOEBIUS_BASE_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $classDirectory . DIRECTORY_SEPARATOR . $classname . PHOEBIUS_TYPE_EXTENSION; } ////////////////////////////////////////////////////////////////////////////////////////////////// Exceptionizer::getInstance()->register(E_ALL | E_STRICT, false, 'InternalOperationException')->setException(E_USER_ERROR, 'CompilationContextException')->setException(E_RECOVERABLE_ERROR, 'RecoverableErrorFactory'); set_include_path(PHOEBIUS_BASE_ROOT . '/lib' . PATH_SEPARATOR . get_include_path()); Autoloader::getInstance()->addResolver(CSharpStyleClassResolver::create()->setExtension(PHOEBIUS_TYPE_EXTENSION))->register();
if (!defined('PHOEBIUS_TMP_ROOT')) { define('PHOEBIUS_TMP_ROOT', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'Phoebius-v' . PHOEBIUS_VERSION . '-' . PHOEBIUS_APP_ID); } if (!defined('PHOEBIUS_LOADER')) { define('PHOEBIUS_LOADER', 'ondemand'); } if (!defined('PHOEBIUS_APP_ROOT')) { define('PHOEBIUS_APP_ROOT', PHOEBIUS_BASE_ROOT); } if (!defined('PHOEBIUS_APP_VIEWS_ROOT')) { define('PHOEBIUS_APP_VIEWS_ROOT', PHOEBIUS_APP_ROOT . DIRECTORY_SEPARATOR . 'views'); } define('PHOEBIUS_SHORT_PRODUCT_NAME', 'Phoebius v' . PHOEBIUS_VERSION); define('PHOEBIUS_FULL_PRODUCT_NAME', 'Phoebius framework v' . PHOEBIUS_VERSION); date_default_timezone_set('Europe/London'); define('PHOEBIUS_TYPE_EXTENSION', '.class.php'); define('PHOEBIUS_VIEW_EXTENSION', '.view.php'); $phoebiusNamespaces = array('Core', 'Core/Exceptions', 'Core/Patterns', 'Core/Types', 'Core/Types/Complex', 'Mvc', 'Mvc/ActionResults', 'Mvc/Exceptions', 'Orm', 'Orm/Dao', 'Orm/Dao/Relationship', 'Orm/Domain', 'Orm/Domain/CodeGenerator', 'Orm/Domain/Notation', 'Orm/Domain/Notation/Xml', 'Orm/Exceptions', 'Orm/Model', 'Orm/Query', 'Orm/Query/Projections', 'Orm/Types', 'Utils', 'Utils/Cipher', 'Utils/Log', 'Utils/Net', 'Utils/Stream', 'Utils/Xml', 'Dal', 'Dal/DB', 'Dal/DB/Exceptions', 'Dal/DB/Generator', 'Dal/DB/Query', 'Dal/DB/Schema', 'Dal/DB/Sql', 'Dal/DB/Transaction', 'Dal/DB/Type', 'Dal/Expression', 'Dal/Expression/LogicalOperators', 'Dal/Cache', 'Dal/Cache/Peers', 'Web', 'Web/UrlRouting', 'Web/Exceptions'); foreach ($phoebiusNamespaces as $namespace) { set_include_path(PHOEBIUS_BASE_ROOT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . $namespace . PATH_SEPARATOR . get_include_path()); } require PHOEBIUS_BASE_ROOT . '/loader/' . PHOEBIUS_LOADER . '.loader.php'; Exceptionizer::getInstance()->register(E_ALL | E_STRICT, false, 'ExecutionContextException')->setException(E_USER_ERROR, 'CompilationContextException'); try { $result = is_dir(PHOEBIUS_TMP_ROOT); if (!$result) { mkdir(PHOEBIUS_TMP_ROOT, 0777, true); } } catch (ExecutionContextException $e) { die('Insufficient privileges to a temporary root (' . PHOEBIUS_TMP_ROOT . '): ' . $e->getMessage()); }
<?php /* *********************************************************************************************** * * Phoebius Framework * * ********************************************************************************************** * * Copyright (c) 2009 Scand Ltd. * * This program is free software; you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Foundation; * either version 3 of the License, or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public License along with * this program; if not, see <http://www.gnu.org/licenses/>. * ************************************************************************************************/ require dirname(__FILE__) . '/appless.init.php'; // This is needed because ZendPhpUnit launcher does not check the indexes of // arrays it accesses to :( any access to unexistant index throws an exception // TODO 1: add halt/unhalt() method pair to avoid direct register()/unregister() calls // (such calls are expensive) // TODO 2: add "kernel" mode - an abstraction over Exceptionizer::halt()/unhalt() Exceptionizer::getInstance()->unregister(); AllTests::$testPaths = array(PHOEBIUS_BASE_ROOT . DIRECTORY_SEPARATOR . 'tests'); set_include_path(PHOEBIUS_BASE_ROOT . DIRECTORY_SEPARATOR . 'tests' . PATH_SEPARATOR . get_include_path());