当前位置: 首页>>代码示例>>PHP>>正文


PHP trait_exists函数代码示例

本文整理汇总了PHP中trait_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP trait_exists函数的具体用法?PHP trait_exists怎么用?PHP trait_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了trait_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: autoload

 function autoload($className)
 {
     global $loads;
     $classNameOld = $className;
     $className = str_replace("nextfw\\", "", strtolower(ltrim($className, '\\')));
     $fileName = '';
     if ($lastNsPos = strrpos($className, '\\')) {
         $namespace = substr($className, 0, $lastNsPos);
         $className = substr($className, $lastNsPos + 1);
         $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
     }
     $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
     if (file_exists(PATH . $fileName)) {
         require_once PATH . $fileName;
         $loads[] = PATH . $fileName;
     }
     $type = null;
     if (!class_exists($classNameOld)) {
         $type = "Class";
     } elseif (!trait_exists($classNameOld) and class_exists($classNameOld)) {
         $type = "Trait";
     } elseif (!interface_exists($classNameOld) and (trait_exists($classNameOld) and class_exists($classNameOld))) {
         $type = "Interface";
     }
     if ($type != null) {
         header('HTTP/1.0 404 Not Found');
     }
 }
开发者ID:mops1k,项目名称:NextFW,代码行数:28,代码来源:autoload.php

示例2: loadClass

 public function loadClass($class_name)
 {
     if ($this->runAutoloaders($class_name)) {
         return;
     }
     if ($this->composerAutoloader->loadClass($class_name)) {
         return;
     }
     if (is_int(strpos($class_name, '\\'))) {
         $parts = explode('\\', $class_name);
         $file = array_pop($parts);
         $class_file_path = implode('/', $parts) . '/' . $file . '.php';
     } else {
         $class_file_path = str_replace('_', '/', $class_name) . '.php';
     }
     $paths = $this->paths;
     $found = false;
     foreach ($paths as $path) {
         if ($found = is_file($class_file = $path . '/' . $class_file_path)) {
             break;
         }
     }
     if (!$found) {
         require_once __DIR__ . '/Exception/FileNotFoundException.php';
         throw new Exception\FileNotFoundException(sprintf("Couldn't find file for class %s, searched for %s in:\n%s", $class_name, $class_file_path, implode("\n", $paths)));
     }
     require $class_file;
     if (!class_exists($class_name, false) && !interface_exists($class_name, false) && !trait_exists($class_name, false)) {
         require_once __DIR__ . '/Exception/ClassNotFoundException.php';
         throw new Exception\ClassNotFoundException(sprintf("File %s doesn't contain class/interface/trait %s.", $class_file, $class_name));
     }
 }
开发者ID:railsphp,项目名称:railsphp,代码行数:32,代码来源:Loader.php

示例3: class_parents

 static function class_parents($c, $autoload = true)
 {
     if (is_object($c)) {
         $class = get_class($c);
     } else {
         if (!class_exists($c, $autoload) && !interface_exists($c, false) && !trait_exists($c, false)) {
             user_error(__FUNCTION__ . '(): Class ' . $c . ' does not exist and could not be loaded', E_USER_WARNING);
             return false;
         } else {
             $c = self::ns2us($c);
         }
     }
     /**/
     if (!function_exists('class_parents')) {
         $autoload = array();
         while (false !== ($class = get_parent_class($class))) {
             $autoload[$class] = $class;
         }
         /**/
     } else {
         $autoload = class_parents($c, false);
         /**/
     }
     foreach ($autoload as $c) {
         isset(self::$us2ns[$a = strtolower($c)]) && ($autoload[$c] = self::$us2ns[$a]);
     }
     return $autoload;
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:28,代码来源:Php530.php

示例4: __construct

 /**
  * TypeVisitor constructor.
  * @param $type
  */
 public function __construct($type)
 {
     if (!class_exists($type) || interface_exists($type) || trait_exists($type)) {
         throw new InvalidArgumentException($type . ' does not exist');
     }
     $this->type = $type;
 }
开发者ID:sysvyz,项目名称:anan,代码行数:11,代码来源:TypeVisitor.php

示例5: includeAllRecursivePsr4

 /**
  * @param string $dir
  * @param string $namespace
  * @param array $skip
  *
  * @throws \Exception
  */
 private function includeAllRecursivePsr4($dir, $namespace, array $skip)
 {
     foreach (scandir($dir) as $candidate) {
         if ('.' === $candidate || '..' === $candidate) {
             continue;
         }
         $path = $dir . '/' . $candidate;
         if (in_array($path, $skip)) {
             continue;
         }
         if (is_dir($path)) {
             $this->includeAllRecursivePsr4($dir . '/' . $candidate, $namespace . '\\' . $candidate, $skip);
         } elseif (is_file($path)) {
             if ('.php' === substr($candidate, -4)) {
                 $class = $namespace . '\\' . substr($candidate, 0, -4);
                 if (class_exists($class)) {
                     continue;
                 }
                 if (interface_exists($class)) {
                     continue;
                 }
                 if (function_exists('trait_exists') && trait_exists($class)) {
                     continue;
                 }
                 throw new \Exception("Non-existing class, trait or interface '{$class}'.");
             }
         }
     }
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:36,代码来源:BasicIntegrityTest.php

示例6: exists

 /**
  * Check whenever class or trait or interface exists.
  * It does autoload if needed.
  * @param string $class
  * @return bool True if class or trait or interface exists
  */
 public static function exists($class)
 {
     if (Blacklister::ignores($class)) {
         return false;
     }
     if (self::isConfirmed($class)) {
         return true;
     }
     try {
         if (class_exists($class)) {
             return self::confirm($class);
         }
     } catch (Exception $ex) {
         // Some class loaders throw exception if class not found
     }
     try {
         if (trait_exists($class)) {
             return self::confirm($class);
         }
     } catch (Exception $ex) {
         // Some class loaders throw exception if class not found
     }
     try {
         if (interface_exists($class)) {
             return self::confirm($class);
         }
     } catch (Exception $ex) {
         // Some class loaders throw exception if class not found
     }
     Blacklister::ignore($class);
     return false;
 }
开发者ID:maslosoft,项目名称:addendum,代码行数:38,代码来源:ClassChecker.php

示例7: tryLoad

 /**
  * Handles autoloading of classes, interfaces or traits.
  * @param  string
  * @return void
  */
 public function tryLoad($type)
 {
     $type = ltrim(strtolower($type), '\\');
     // PHP namespace bug #49143
     $info =& $this->list[$type];
     if ($this->autoRebuild && empty($this->checked[$type]) && (is_array($info) ? !is_file($info[0]) : $info < self::RETRY_LIMIT)) {
         $info = is_int($info) ? $info + 1 : 0;
         $this->checked[$type] = TRUE;
         if ($this->rebuilt) {
             $this->getCache()->save($this->getKey(), $this->list, array(Cache::CONSTS => 'Nette\\Framework::REVISION'));
         } else {
             $this->rebuild();
         }
     }
     if (isset($info[0])) {
         Nette\Utils\LimitedScope::load($info[0], TRUE);
         if ($this->autoRebuild && !class_exists($type, FALSE) && !interface_exists($type, FALSE) && (PHP_VERSION_ID < 50400 || !trait_exists($type, FALSE))) {
             $info = 0;
             $this->checked[$type] = TRUE;
             if ($this->rebuilt) {
                 $this->getCache()->save($this->getKey(), $this->list, array(Cache::CONSTS => 'Nette\\Framework::REVISION'));
             } else {
                 $this->rebuild();
             }
         }
         self::$count++;
     }
 }
开发者ID:radeksimko,项目名称:nette,代码行数:33,代码来源:RobotLoader.php

示例8: run

 public static function run($class)
 {
     // ----------------------------------------------------------------------------------------
     // ClassMap oluşturulmamış ise oluştur.
     // Sistemin çalışması için gerekli bir kontroldür.
     // ----------------------------------------------------------------------------------------
     $path = CONFIG_DIR . 'ClassMap.php';
     // ClassMap daha önce oluşturulmamış ise oluturuluyor...
     if (!file_exists($path)) {
         self::createClassMap();
     }
     // Sınıf bilgileri alınıyor...
     $classInfo = self::getClassFileInfo($class);
     // Sınıfın yolu alınıyor...
     $file = restorationPath($classInfo['path']);
     // Böyle bir sınıf varsa dahil ediliyor...
     if (file_exists($file)) {
         require_once $file;
         // Namespace olduğu halde class ismi bildirilirse
         // Sınıf haritasını yeniden oluşturmayı dene
         if (!class_exists($classInfo['namespace']) && !trait_exists($classInfo['namespace']) && !interface_exists($classInfo['namespace'])) {
             self::tryAgainCreateClassMap($class);
         }
     } else {
         // Aranılan dosya bulunamazsa 1 kereye mahsuz
         // sınıf haritasını yeniden oluşturmayı dene
         self::tryAgainCreateClassMap($class);
     }
 }
开发者ID:bytemtek,项目名称:znframework,代码行数:29,代码来源:Autoloader.php

示例9: isValid

 /**
  * Determines if a given string can resolve correctly.
  *
  * @param string $name A fully qualified class name or namespace name.
  *
  * @return boolean true if the object exists within the source tree, the libraries or PHP.
  */
 public function isValid($name)
 {
     $name = implode('\\', array_filter(explode('\\', $name), 'strlen'));
     if (class_exists($name) || interface_exists($name) || trait_exists($name)) {
         return true;
     }
     return false;
 }
开发者ID:vektah,项目名称:bugfree-dangerzone,代码行数:15,代码来源:AutoloaderResolver.php

示例10: exists

 private function exists(string $className) : bool
 {
     try {
         return class_exists($className) || interface_exists($className) || trait_exists($className);
     } catch (\Throwable $t) {
         throw new \PHPStan\Broker\ClassAutoloadingException($className, $t);
     }
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:8,代码来源:ClassTypeHelperTrait.php

示例11: __construct

 /**
  *
  */
 public function __construct()
 {
     if (!class_exists('\\Crypto\\Cipher')) {
         throw new \RuntimeException("The PHP extension 'Crypto' is required to use AES GCM based algorithms");
     }
     if (!trait_exists('\\AESKW\\AESKW')) {
         throw new \RuntimeException("The library 'spomky-labs/aes-key-wrap' is required to use Key Wrap based algorithms");
     }
 }
开发者ID:rwx-zwx-awx,项目名称:jose,代码行数:12,代码来源:AESGCMKW.php

示例12: loadClass

 /**
  * {@inheritDoc}
  */
 public function loadClass($class)
 {
     if ($file = $this->findFile($class)) {
         require $file;
         if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
             throw new RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
         }
     }
 }
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:12,代码来源:DebugUniversalClassLoader.php

示例13: __construct

 /**
  *
  */
 public function __construct()
 {
     if (!trait_exists('\\AESKW\\AESKW')) {
         throw new \RuntimeException("The library 'spomky-labs/aes-key-wrap' is required to use Key Wrap based algorithms");
     }
     if (!class_exists('\\PBKDF2\\PBKDF2')) {
         throw new \RuntimeException("The library 'spomky-labs/pbkdf2' is required to use PBES2-* based algorithms");
     }
 }
开发者ID:rwx-zwx-awx,项目名称:jose,代码行数:12,代码来源:PBES2AESKW.php

示例14: Autoload

 /**
  * @param $className
  * @throws Exception
  */
 public static function Autoload($className)
 {
     echo 'Autoload : ' . $className;
     $path = APP . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, strtolower($className)) . '.php';
     @(include $path);
     if (!class_exists($className, false) && !interface_exists($className, false) && !trait_exists($className, false)) {
         throw new Exception("Class '" . $className . "' not found in '" . $path . "' on autoload");
     }
 }
开发者ID:arouze,项目名称:koncerto,代码行数:13,代码来源:koncerto.php

示例15: classOrTraitExists

function classOrTraitExists($classOrTrait, $shouldAutoload = true)
{
    if (traitsSupported()) {
        if (trait_exists($classOrTrait, $shouldAutoload)) {
            return true;
        }
    }
    return class_exists($classOrTrait, $shouldAutoload);
}
开发者ID:Wikia,项目名称:patchwork,代码行数:9,代码来源:Utils.php


注:本文中的trait_exists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。