/** * Creates class alias from class which is defined in class map. * * @param string $sClass Class name. */ public function autoload($sClass) { $sClass = strtolower($sClass); if (array_key_exists($sClass, $this->getClassMap())) { class_alias($this->map[$sClass], $sClass); } }
class ModelLoaderTest extends \PHPUnit_Framework_TestCase { protected $project; protected function setUp() { parent::setUp(); define('MODEL_DIR', 'Test\\Model'); define('DEBUG_MODE', true); if (!class_exists('\\Test\\Model\\Project')) { $this->project = new class extends ModelEx { protected $table = 'projects'; protected $primaryKey = 'project_id'; }; class_alias(get_class($this->project), '\\Test\\Model\\Project'); } } public function testMetadataIsAppliedToParentModel() { $modelExtender = $this->getMockBuilder(ModelExtender::class)->disableOriginalConstructor()->setMethods(['extend'])->getMock(); $modelExtender->expects($this->once())->method('extend')->willReturnCallback(function ($model, $args) { $this->assertEquals(['offset' => 0, 'limit' => 2, 'conditions' => [['project', '=', '3']]], $args); return $model; }); $nodes = ['project' => ['self' => ['name' => 'Project', 'offset' => 0, 'limit' => 2, 'conditions' => [['project', '=', '3']]]]]; /** @var ModelLoader $modelLoader */ $modelLoader = (new Injector())->make('Minute\\Model\\ModelLoader', [':modelExtender' => $modelExtender]); $modelLoader->createRelations($nodes['project']); } }
/** * Autoload function for SimpleSAMLphp modules following PSR-0. * * @param string $className Name of the class. * @deprecated This method will be removed in SSP 2.0. * * TODO: this autoloader should be removed once everything has been migrated to namespaces. */ public static function autoloadPSR0($className) { $modulePrefixLength = strlen('sspmod_'); $classPrefix = substr($className, 0, $modulePrefixLength); if ($classPrefix !== 'sspmod_') { return; } $modNameEnd = strpos($className, '_', $modulePrefixLength); $module = substr($className, $modulePrefixLength, $modNameEnd - $modulePrefixLength); $path = explode('_', substr($className, $modNameEnd + 1)); if (!self::isModuleEnabled($module)) { return; } $file = self::getModuleDir($module) . '/lib/' . join('/', $path) . '.php'; if (!file_exists($file)) { return; } require_once $file; if (!class_exists($className, false)) { // the file exists, but the class is not defined. Is it using namespaces? $nspath = join('\\', $path); if (class_exists('SimpleSAML\\Module\\' . $module . '\\' . $nspath)) { // the class has been migrated, create an alias and warn about it \SimpleSAML_Logger::warning("The class '{$className}' is now using namespaces, please use 'SimpleSAML\\Module\\{$module}\\" . "{$nspath}' instead."); class_alias("SimpleSAML\\Module\\{$module}\\{$nspath}", $className); } } }
private static function registerLegacyAliases() { foreach (self::$oldToNewMap as $old => $new) { class_alias($new, $old); # bool class_alias ( string $original原类 , string $alias别名 [,bool $autoload =TRUE是否原类不存在自动加载 ])基于用户定义的类 original 创建别名 alias。 这个别名类和原有的类完全相同 } }
public function classAlias($alias) { foreach ($alias as $key => $value) { // Register Class Alias class_alias($value, $key); } }
public function load(ServiceContainer $container) { // This exists for PHP 5.3 compatibility if (!interface_exists('\\JsonSerializable')) { class_alias('Knp\\JsonSchemaBundle\\Model\\JsonSerializable', 'JsonSerializable'); } }
/** * Load the file corresponding to a given class. * * This method is registerd in the bootstrap file as an SPL auto-loader. * * @param string $class * @return void */ public static function load($class) { // First, we will check to see if the class has been aliased. If it has, // we will register the alias, which may cause the auto-loader to be // called again for the "real" class name to load its file. if (isset(static::$aliases[$class])) { class_alias(static::$aliases[$class], $class); } elseif (isset(static::$mappings[$class])) { require static::$mappings[$class]; return; } // If the class namespace is mapped to a directory, we will load the // class using the PSR-0 standards from that directory accounting // for the root of the namespace by trimming it off. foreach (static::$namespaces as $namespace => $directory) { if (starts_with($class, $namespace)) { return static::load_namespaced($class, $namespace, $directory); } } // If the class uses PEAR-ish style underscores for indicating its // directory structure we'll load the class using PSR-0 standards // standards from that directory, trimming the root. foreach (static::$underscored as $prefix => $directory) { if (starts_with($class, $prefix)) { return static::load_namespaced($class, $prefix, $directory); } } // If all else fails we will just iterator through the mapped // PSR-0 directories looking for the class. This is the last // resort and slowest loading option for the class. static::load_psr($class); }
function aliasesClass() { $config = $GLOBALS['Config']['App']; foreach ($config['Aliases'] as $class => $alias) { class_alias($class, $alias); } }
/** * Register the service provider. * * @return void */ public function register() { //set theme layout directory $paths = $this->app['config']->get('view.paths'); $themePath = $this->app['path.public'] . '/themes/'; array_push($paths, $themePath); $this->app['config']->set('view.paths', $paths); //bind themeConfig object $this->app['px.themeConfig'] = $this->app->share(function ($app) { return new ThemeConfig(); }); $this->app->bind('px.theme', function ($app) { return new ThemeManager($app['px.themeConfig']); }); //register ThemeFacade class as alias to "theme" class_alias(__NAMESPACE__ . '\\ThemeFacade', 'pxTheme'); //extend blade engine by adding @px.theme and @px.layout compile function $this->app['view.engine.resolver']->resolve('blade')->getCompiler()->extend(function ($view) { $themePattern = '/(?<!\\w)(\\s*)@px.theme(\\s*\\(.*\\))/'; $layoutPattern = '/(?<!\\w)(\\s*)@px.layout(\\s*\\(.*\\))/'; $layoutIncludePattern = '/(?<!\\w)(\\s*)@px.include(\\s*\\(.*)\\)/'; //$layoutIncludePattern = '/(?<!\w)(\s*)@px.include(\s*\(.*\))/'; $view = preg_replace($themePattern, '$1<?php pxTheme::setTheme$2;?>', $view); $view = preg_replace($layoutPattern, '$1<?php pxTheme::setLayout$2;?>', $view); $view = preg_replace($layoutIncludePattern, '$1<?php echo $__env->make(pxTheme::path$2), array_except(get_defined_vars(), array(\'__data\', \'__path\')))->render(); ?>', $view); $view = preg_replace($layoutPattern, '$1<?php pxTheme::setLayout$2;?>', $view); return $view; }); }
/** * Bootstrap any application services. * * @return void */ public function boot() { $this->app->bind('Amqp', 'Bschmitt\\Amqp\\Amqp'); if (!class_exists('Amqp')) { class_alias('Bschmitt\\Amqp\\Facades\\Amqp', 'Amqp'); } }
/** * {@inheritdoc} */ public function load(string $alias) : bool { // Skip recursive aliases if defined if (in_array($alias, $this->resolving)) { return false; } // Set it as the resolving class for when // we want to block recursive resolving $this->resolving[] = $alias; if (isset($this->cache[$alias])) { // If we already have the alias in the cache don't bother resolving again $class = $this->cache[$alias]; } elseif ($class = $this->resolveAlias($alias)) { // We've got a plain alias, now we can skip the others as this // is the most powerful one. } elseif ($class = $this->resolveNamespaceAlias($alias)) { // We've got a namespace alias, we can skip pattern matching. } elseif (!($class = $this->resolvePatternAlias($alias))) { // Lastly we'll try to resolve it through pattern matching. This is the most // expensive match type. Caching is recommended if you use this. return false; } // Remove the resolving class array_pop($this->resolving); if (!$this->exists($class)) { return false; } // Create the actual alias class_alias($class, $alias); if (!isset($this->cache[$alias])) { $this->cache[$alias] = $class; } return true; }
/** * Constructor */ public function __construct() { $this->container = Container::getInstance(); // set dependencies $this->container['hook'] = function ($c) { return new \Binocle\Core\Hook(); }; $this->container['template'] = function ($c) { return new \Binocle\Core\Template($c); }; $this->container['asset'] = function ($c) { return new \Binocle\Core\Template\Asset(); }; $this->container['config'] = function ($c) { return new \Binocle\Core\Config(); }; $this->container['posttype'] = function ($c) { return new \Binocle\Core\Posttype(); }; // set aliases class_alias('Binocle\\Core\\Facades\\Asset', 'Asset'); class_alias('Binocle\\Core\\Facades\\Hook', 'Hook'); class_alias('Binocle\\Core\\Facades\\Config', 'Config'); class_alias('Binocle\\Core\\Facades\\Posttype', 'Posttype'); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('sirgrimorum/cms'); AliasLoader::getInstance()->alias('TransArticle', 'Sirgrimorum\\Cms\\TransArticles\\Facades\\TransArticle'); AliasLoader::getInstance()->alias('Translations', 'Sirgrimorum\\Cms\\Translations\\Facades\\Translations'); AliasLoader::getInstance()->alias('CrudLoader', 'Sirgrimorum\\Cms\\CrudLoader\\Facades\\CrudLoader'); //define a constant that the rest of the package can use to conditionally use pieces of Laravel 4.1.x vs. 4.0.x $this->app['administrator.4.1'] = version_compare(\Illuminate\Foundation\Application::VERSION, '4.1') > -1; //set up an alias for the base laravel controller to accommodate >=4.1 and <4.1 if (!class_exists('AdministratorBaseController')) { // Verify alias is not already created if ($this->app['administrator.4.1']) { class_alias('Illuminate\\Routing\\Controller', 'AdministratorBaseController'); } else { class_alias('Illuminate\\Routing\\Controllers\\Controller', 'AdministratorBaseController'); } } // Registering the validator extension with the validator factory $this->app['validator']->resolver(function ($translator, $data, $rules, $messages) { return new ValidatorExtension($translator, $data, $rules, $messages); }); //include our filters, view composers, and routes include __DIR__ . '/../filters.php'; include __DIR__ . '/../routes.php'; }
public static function autoload($classname) { if(strpos($classname, "_")) { $prefix = explode("_", $classname); } else { $prefix = explode("\\", $classname); } if(!isset(self::$_Registered[$prefix[0]])) { return false; } if($prefix[1] == "SWExtension") { if(count($prefix) == 3 && $prefix[2] == sha1($prefix[0]."-GenKey")) { $origClass = $classname; $doAlias = true; $classname = str_replace("\\".$prefix[2], "\\GenKey", $classname); } else { $doAlias = false; } } $path = self::$_Registered[$prefix[0]]."/"; $classNamePath = str_replace(array("_", "\\"), "/", $classname); if(file_exists($path.$classNamePath.".php")) { require_once($path.$classNamePath.".php"); } if($prefix[1] == "SWExtension" && $doAlias) { class_alias(ltrim($classname, "\\"), ltrim($origClass, "\\")); } }
class ModelBridgeTest extends \PHPUnit_Framework_TestCase { protected function setUp() { parent::setUp(); define('MODEL_DIR', 'Test\\Model'); if (!class_exists('\\Test\\Model\\Blog')) { $blog = new class extends ModelEx { protected $table = 'blogs'; protected $primaryKey = 'blog_id'; }; class_alias(get_class($blog), '\\Test\\Model\\Blog'); } if (!class_exists('\\Test\\Model\\Post')) { $post = new class extends ModelEx { protected $table = 'posts'; protected $primaryKey = 'post_id'; }; class_alias(get_class($post), '\\Test\\Model\\Post'); } if (!class_exists('\\Test\\Model\\Comment')) { $comment = new class extends ModelEx { protected $table = 'comments'; protected $primaryKey = 'comment_id'; }; class_alias(get_class($comment), '\\Test\\Model\\Comment'); } if (!class_exists('\\Test\\Model\\User')) { $user = new class extends ModelEx { protected $table = 'users'; protected $primaryKey = 'user_id'; }; class_alias(get_class($user), '\\Test\\Model\\User'); } } public function testModelToJsClasses() { /** @var ModelParserGet $modelParser */ $models = ['blogs[2]', 'posts[blogs.blog_id][2] as stories', 'comments[blogs.blog_id] as comment', 'users[stories.post_id] as teller']; $modelParser = (new Injector())->make('Minute\\Model\\ModelParserGet', [$models]); $parents = $modelParser->getParentsWithChildren(); $this->assertArrayHasKey('blogs', $parents, 'Parents has blogs key'); /** @var ModelBridge $modelBridge */ $modelBridge = (new Injector())->make('Minute\\Model\\ModelBridge'); $template = $modelBridge->modelToJsClasses($parents['blogs']); $this->markTestSkipped('to be fixed'); $this->assertContains('BlogItem = (function (_super) {', $template, 'BlogItem is present'); $this->assertContains('this.stories = (new StoryArray(this));', $template, 'BlogItem has stories'); $this->assertContains('this.comment = (new CommentArray(this)).create();', $template, 'BlogItem has a comment item'); $this->assertContains("_super.call(this, BlogItem, parent, 'blogs', 'Blog', 'blog_id', null);", $template, 'BlogItemArray is correctly initialized'); $this->assertContains("this.teller = (new TellerArray(this)).create();", $template, 'StoryItem has teller item'); $this->assertContains("this.teller = (new TellerArray(this)).create();", $template, 'StoryItem has teller item'); $this->assertContains("_super.call(this, StoryItem, parent, 'stories', 'Post', 'post_id', 'blog_id');", $template, 'StoryItemArray is correctly initialized'); $this->assertContains("_super.call(this, CommentItem, parent, 'comment', 'Comment', 'comment_id', 'blog_id');", $template, 'CommentItemArray is correctly initialized'); } }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('vizioart/cookbook'); //define a constant that the rest of the package can use to conditionally use pieces of Laravel 4.1.x vs. 4.0.x $this->app['cookbook.4.1'] = version_compare(\Illuminate\Foundation\Application::VERSION, '4.1') > -1; //set up an alias for the base laravel controller to accommodate >=4.1 and <4.1 if (!class_exists('LaravelBaseController')) { // Verify alias is not already created if ($this->app['cookbook.4.1']) { class_alias('Illuminate\\Routing\\Controller', 'LaravelBaseController'); } else { class_alias('Illuminate\\Routing\\Controllers\\Controller', 'LaravelBaseController'); } } // Repositories // -------------------------------------------------------------- $this->bootRepositories(); // Handlebars Templates // -------------------------------------------------------------- $frontend_templates_path = public_path() . DIRECTORY_SEPARATOR . $this->app['config']->get('cookbook::cookbook.front_templates'); View::addNamespace('hbs', $frontend_templates_path); include __DIR__ . '/../../filters.php'; include __DIR__ . '/../../viewComposer.php'; include __DIR__ . '/../../routes.php'; }
public static function loadClass($class) { //优先从别名判断 //每次都要初始化一下,防止被污染 $class_alias = self::$class_alias; //如果是别名 if (isset($class_alias[$class])) { //重新注册类别名 class_alias($class_alias[$class], $class); //如果该类存在,则再次注册别名,并返回“from original class” :从原类引入 if (class_exists($class_alias[$class])) { return 'from original class'; } $class = $class_alias[$class]; } $file = strtr($class, "\\", DIRECTORY_SEPARATOR) . ".php"; //遍历root if (!empty(self::$root)) { foreach (self::$root as $ns => $path) { if (strpos($file, $ns) === 0) { $file = $path . str_replace($ns . DIRECTORY_SEPARATOR, '', $file); if (empty($path)) { throw new \Exception("loader root path is empty, namespace : {$ns}", 999); } if (self::_load($file)) { return $file; } //抛出异常警告 } } } throw new \Exception("class not found!", 999); }
/** * Load a class alias if it is registered. * 加载器,使别名跟类名达到一样的效果 如'TestJelly1' => 'Illuminate\Support\Facades\TestJelly' * @param string $alias=TestJelly1 * @return void */ public function load($alias) { if (isset($this->aliases[$alias])) { //为类创建一个别名 bool class_alias(string $original原类名, string $alias别名 [, bool $autoload = TRUE如果类不存在则调用自动加载 ] ) return class_alias($this->aliases[$alias], $alias); } }
/** * Ztal compatibility autoloading. * * @param string $legacyClassName Class name to load. * * @return bool */ public static function autoloadCompatibility($legacyClassName) { // Simply pass through requests to load the namespaced classes. if (substr($legacyClassName, 0, 5) == 'Ztal\\') { return static::autoload($legacyClassName); } // Don't attempt to load any classes but ours. if (substr($legacyClassName, 0, 5) != 'Ztal_') { return false; } if (array_key_exists($legacyClassName, static::$_compatibilityClassMap)) { // We have an entry in the class map for this class, so use it. $className = static::$_compatibilityClassMap[$legacyClassName]; } else { // Mangle namespaced classes: 'Ztal_Form' => 'Ztal\Form'. $className = str_replace('_', '\\', $legacyClassName); } // Use the normal autoloader for the actual loading. if (!static::autoload($className)) { return false; } // Alias the actual class to the legacy name that was requested. class_alias($className, $legacyClassName); return true; }
public function get_alias() { if ($this->alias === null) { class_alias(get_class($this->object), $this->alias = $this->generate_alias()); } return $this->alias; }
/** * Plugins loaded */ public static function plugins_loaded() { if (Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Membership::is_active()) { // Backwards compatibility Membership <= 3.4 $class_aliases = array('M_Gateway' => 'Membership_Gateway', 'M_Subscription' => 'Membership_Model_Subscription', 'M_Membership' => 'Membership_Model_Member'); foreach ($class_aliases as $orignal => $alias) { if (class_exists($orignal) && !class_exists($alias)) { // http://www.php.net/manual/en/function.class-alias.php class_alias($orignal, $alias); } } // Register the Membership iDEAL gateway // Membership < 3.5 if (function_exists('M_register_gateway')) { M_register_gateway('pronamic_ideal', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealGateway'); } // Membership >= 3.5 if (method_exists('Membership_Gateway', 'register_gateway')) { Membership_Gateway::register_gateway('pronamic_ideal', 'Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_IDealGateway'); } add_action('pronamic_payment_status_update_' . self::SLUG, array(__CLASS__, 'status_update'), 10, 2); add_filter('pronamic_payment_source_text_' . self::SLUG, array(__CLASS__, 'source_text'), 10, 2); if (is_admin()) { $admin = new Pronamic_WP_Pay_Extensions_WPMUDEV_Membership_Admin(); } } }
public function registerAutoload() { spl_autoload_register(function ($class) { $prefix = 'app'; $base_dir = ROOT . '/app'; // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { return; } $nsarr = explode('\\', $class); if (isset($nsarr[count($nsarr) - 2]) && $nsarr[count($nsarr) - 2] == 'controllers') { $aliases = $this->getControllersAliases(); if (isset($aliases[$nsarr[count($nsarr) - 1]])) { class_alias($aliases[$nsarr[count($nsarr) - 1]], $class); } } // get the relative class name $relative_class = substr($class, $len); $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; if (file_exists($file)) { require $file; } }); }
public function __construct() { global $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER; $this->properties = []; $this->server = $_SERVER; if (self::$handlers == null) { self::$handlers = []; } if (isset($_POST) && array_count($_POST) > 0) { foreach ($_POST as $key => $val) { $this->properties['POST'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_GET) && array_count($_GET) > 0) { foreach ($_GET as $key => $val) { $this->properties['GET'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_COOKIE) && array_count($_COOKIE) > 0) { foreach ($_COOKIE as $key => $val) { $this->properties['COOKIE'][$this->_clean_key($key)] = $this->_clean_val($val); } } if (isset($_FILES) && array_count($_FILES) > 0) { foreach ($_FILES as $key => $val) { $this->properties['FILES'][$this->_clean_key($key)] = $this->_clean_val($val); } } class_alias('\\Wasp\\Input', '\\Input'); }
/** * For given unknown class identifier, does what's necessary to make it known to PHP. Returns true if we * found a way to do that, false otherwise. * * @see http://rlm80.github.com/Glue/file_system.html * * @param string $class * * @return boolean */ public static function load_class($class) { // Uncapitalize class name : $class = strtolower($class); // Only deal with class names in the Glue namespace : if (substr($class, 0, 5) !== 'glue\\') { return FALSE; } // Load user and system classes : if (preg_match('`^glue\\\\(system|user)\\\\(db|orm)\\\\([^\\\\]*)$`', $class, $matches)) { // Build path where the class is supposed to be located : $path = ($matches[1] === 'system' ? \Glue\CLASSPATH_SYSTEM : \Glue\CLASSPATH_USER) . $matches[2] . '/' . str_replace('_', '/', $matches[3]) . '.php'; // Check if such a file exists and include it : if (is_file($path)) { include $path; return TRUE; } else { return FALSE; } } // Load alias : if (preg_match('`^glue\\\\((db|orm)\\\\[^\\\\]*)$`', $class, $matches)) { // Attempt alias to user class : if (class_exists($original = 'Glue\\User\\' . $matches[1], true)) { return class_alias($original, $class); } // Attempt alias to system class : if (class_exists($original = 'Glue\\System\\' . $matches[1], true)) { return class_alias($original, $class); } } return FALSE; }
public function sourcesProvider() { if (!class_exists("CompilerTest", false)) { class_alias("Skrz\\Templating\\Engine\\CompilerTest", "CompilerTest"); } return array(array('', '', array()), array('just some text', 'just some text', array()), array('{$foo}', '42', array("foo" => 42)), array('{$foo | strip_tags}', 'bold italic', array("foo" => '<b>bold</b> <i>italic</i>')), array('{$foo = 42}{$foo}', '42', array()), array('{capture assign=foo}bar{/capture}{$foo}', 'bar', array()), array('{capture name=foo}bar{/capture}{$smarty.capture.foo}', 'bar', array()), array('{capture append="foo"}hello, {/capture}{capture append="foo"}world!{/capture}{$x = implode("", $foo)}{$x}', 'hello, world!', array()), array('{for $x=1 to 3}{$x},{/for}', '1,2,3,', array()), array('{for $x=1 to 3}{$x},{forelse}nothing{/for}', '1,2,3,', array()), array('{for $x=3 to 1}{$x},{forelse}nothing{/for}', 'nothing', array()), array('{foreach $x as $i}{$i},{/foreach}', '1,2,3,', array("x" => array(1, 2, 3))), array('{foreach from=$x item=i}{$i},{/foreach}', '1,2,3,', array("x" => array(1, 2, 3))), array('{foreach from=$x item="i"}{$i},{/foreach}', '1,2,3,', array("x" => array(1, 2, 3))), array('{foreach from=$x item="i"}{$i},{foreachelse}nothing{/foreach}', 'nothing', array("x" => array())), array('{foreach from=$x item=i name=c}{$smarty.foreach.c.index}=>{$i},{/foreach}', '0=>1,1=>2,2=>3,', array("x" => array(1, 2, 3))), array('{foreach $x as $i}{$i@index}=>{$i},{/foreach}', '0=>1,1=>2,2=>3,', array("x" => array(1, 2, 3))), array('{foreach $x as $i}{$i@iteration}=>{$i},{/foreach}', '1=>1,2=>2,3=>3,', array("x" => array(1, 2, 3))), array('{foreach $x as $i}{$i@total}=>{$i},{/foreach}', '3=>1,3=>2,3=>3,', array("x" => array(1, 2, 3))), array('{foreach $x as $i}{$i@first}=>{$i},{/foreach}', '1=>1,=>2,=>3,', array("x" => array(1, 2, 3))), array('{foreach $x as $i}{$i@last}=>{$i},{/foreach}', '=>1,=>2,1=>3,', array("x" => array(1, 2, 3))), array('{foreach [1,2,3] as $i}{$i@index}=>{$i},{/foreach}', '0=>1,1=>2,2=>3,', array()), array('{inferno hell="BAR"}', '666 BAR 666', array()), array('{inferno hell="<b>BAR</b>"}', '666 <b>BAR</b> 666', array()), array('{inferno hell="<b>BAR</b>"|strip_tags}', '666 BAR 666', array()), array('{call inferno hell="<b>BAR</b>"}', '666 <b>BAR</b> 666', array()), array('{call name=inferno hell="<b>BAR</b>"}', '666 <b>BAR</b> 666', array()), array('{call name="inferno" hell="<b>BAR</b>"}', '666 <b>BAR</b> 666', array()), array('{if $x > 5}>5{elseif $x > 3}>3{else}<=3{/if}', '>5', array("x" => 10)), array('{if $x > 5}>5{elseif $x > 3}>3{else}<=3{/if}', '>3', array("x" => 5)), array('{if $x > 5}>5{elseif $x > 3}>3{else}<=3{/if}', '>3', array("x" => 4)), array('{if $x > 5}>5{elseif $x > 3}>3{else}<=3{/if}', '<=3', array("x" => 3)), array('{if $x > 5}>5{elseif $x > 3}>3{else}<=3{/if}', '<=3', array("x" => 1)), array("{strip}\n A \nB \n C\n{/strip}", 'ABC', array()), array('{include Includable.tpl}', "There is kinda nothin' :-(\n", array()), array('{include file=FooEcho.tpl foo="bar"}', "bar", array()), array('{$foo="bar"}{include file=FooAssign.tpl}{$foo}', "bar", array()), array('{$foo="bar"}{include file=FooAssign.tpl scope=parent}{$foo}', "foo", array()), array('{section foo 3}{$smarty.section.foo.iteration},{/section}', "1,2,3,", array()), array('{$a = array("x")}{$a[0]}', "x", array()), array('{$a = array(1, 2, 3)}{$a[2]}', "3", array()), array('{$a = array(1, 2, 3,)}{$a[2]}', "3", array()), array('{$a = array("foo" => "bar")}{$a["foo"]}', "bar", array()), array('{$a = array("foo" => "bar",)}{$a["foo"]}', "bar", array()), array('{$foo = [1, 2, 3]}{$foo[0]}', "1", array()), array('{$foo = [1, 2, 3]}{$foo[1]}', "2", array()), array('{extends Empty.tpl}', "", array()), array('{extends Includable.tpl}', "There is kinda nothin' :-(\n", array()), array('{extends Extendable.tpl}', "", array()), array('{extends Extendable.tpl} {block here}foo{/block}', "foo", array()), array('{extends ExtendableTitle.tpl}', "title", array()), array('{extends ExtendableTitle.tpl} {block title}different title{/block}', "different title", array()), array('{extends ExtendableTitle.tpl} {block title append}different {/block}', "different title", array()), array('{extends ExtendableTitle.tpl} {block title prepend} is different{/block}', "title is different", array()), array('{$x}', '<b>foo</b>', array("x" => "<b>foo</b>")), array('{$x nofilter}', '<b>foo</b>', array("x" => "<b>foo</b>")), array('{CompilerTest::formatStringPretty("foo")}', ' foo ', array()), array('{function emptyFn}{/function}', '', array()), array('{function emptyFn}{/function}{emptyFn}', '', array()), array('{function name="barbar"}barbar{/function}{call barbar}', 'barbar', array()), array('{function menu}{if $level < 3}{$level},{menu level=$level+1}{/if}{/function}{menu level=0}', '0,1,2,', array()), array('{function myFn withDefault="hey!"}{$withDefault}{/function}{myFn}', 'hey!', array()), array('{function menu level=0}{if $level < 3}{$level},{menu level=$level+1}{/if}{/function}{menu}', '0,1,2,', array()), array('{function x}{$foo}{/function}{x}', 'bar', array('foo' => 'bar')), array('{function form_widget}a{/function}{function form_widget}b{/function}{form_widget}', 'b', array())); }
/** * This temporary autoloader allows loading classes with their old-style names (SimpleSAML_Path_Something) even if they * have been migrated to namespaces, by registering an alias for the new class. If the class has not yet been migrated, * the autoloader will then try to load it. * * @param string $class The full name of the class using underscores to separate the elements of the path, and starting * with 'SimpleSAML_'. * @deprecated This function will be removed in SSP 2.0. */ function temporaryLoader($class) { if (!strstr($class, 'SimpleSAML_')) { return; // not a valid class name for old classes } $original = $class; // list of classes that have been renamed or moved $renamed = array('SimpleSAML_Metadata_MetaDataStorageHandlerMDX' => 'SimpleSAML_Metadata_Sources_MDQ', 'SimpleSAML_Logger_LoggingHandlerSyslog' => 'SimpleSAML_Logger_SyslogLoggingHandler', 'SimpleSAML_Logger_LoggingHandlerErrorLog' => 'SimpleSAML_Logger_ErrorLogLoggingHandler', 'SimpleSAML_Logger_LoggingHandlerFile' => 'SimpleSAML_Logger_FileLoggingHandler', 'SimpleSAML_Logger_LoggingHandler' => 'SimpleSAML_Logger_LoggingHandlerInterface'); if (array_key_exists($class, $renamed)) { // the class has been renamed, try to load it and create an alias $class = $renamed[$class]; } // try to load it from the corresponding file $path = explode('_', $class); $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . join(DIRECTORY_SEPARATOR, $path) . '.php'; if (file_exists($file)) { require_once $file; } // it exists, so it's not yet migrated to namespaces if (class_exists($class, false) || interface_exists($class, false)) { return; } // it didn't exist, try to see if it was migrated to namespaces $new = join('\\', $path); if (class_exists($new, false) || interface_exists($new, false)) { // do not try to autoload it if it doesn't exist! It should! class_alias($new, $original); SimpleSAML\Logger::warning("The class or interface '{$original}' is now using namespaces, please use '{$new}'."); } }
public static function mount($className = 'Guzzle', ClientInterface $client = null) { class_alias(__CLASS__, $className); if ($client) { self::$client = $client; } }
public function loader(string $class) : string { if ($alias = $this->resolve($class)) { class_alias($class, $alias); } return $alias; }
/** * @throws \Exception */ protected function init() { $this->setEnvironment(); // Load class aliases $aliases = Config::get('aliases'); foreach ($aliases as $orig => $new) { class_alias($orig, $new, true); } static::$container = new Container(); Session::init(); Request::init(); $this->initRouter(); $databaseConfig = Config::get('database'); if ($databaseConfig !== null && is_array($databaseConfig)) { $this->capsule = new Capsule(); foreach ($databaseConfig as $name => $conf) { if (array_key_exists('name', $conf) && strlen($conf['name']) > 0) { $name = $conf['name']; unset($conf['name']); } $this->capsule->addConnection($conf, $name); } $this->capsule->bootEloquent(); } $hookConfig = Config::get('hooks'); if (is_array($hookConfig)) { foreach ($hookConfig as $event => $callable) { EventHandler::addListener($event, $callable); } } EventHandler::triggerEvent('whirlpool-initialized', $this); }
function __construct() { //Setando buffer de saída ob_start('ob_gzhandler'); header('X-Powered-By: www.neosphp.org'); //Constantes define('INITIME', microtime(true)); define('DS', DIRECTORY_SEPARATOR); define('PATH', strpos(__DIR__, 'phar://') === false ? dirname(__DIR__) . DS . 'php' . DS : __DIR__ . DS); define('RPATH', strpos(PATH, 'phar://') === false ? PATH : str_replace('phar://', '', dirname(PATH) . DS)); define('CTRL', PATH . 'controller' . DS); define('VIEW', PATH . 'view' . DS); define('LIB', PATH . 'lib' . DS); define('EXTVW', '.html'); //extensão de arquivo view //if(strpos(__DIR__,'phar://') !== false) exit(PATH.'<br>'.RPATH); //iniciando o carregador automático de classes (autoLoader) \Loader::initLoader(); //alias para algumas classes class_alias('\\Main', 'o'); class_alias('\\View\\View', '_view'); class_alias('\\Loader', '_cfg'); class_alias('\\Base', 'NEOS'); //finalmente cria a constante BASE define('BASE', $this->decodeUrl()); //Tratamento de Erros self::initError(); }