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


PHP interface_exists函数代码示例

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


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

示例1: autoload

 public static function autoload($className)
 {
     $className = str_replace('.', '_', $className);
     $className = str_replace(DIRECTORY_SEPARATOR, '_', $className);
     $className = str_replace('/', '_', $className);
     if (class_exists($className, false) || interface_exists($className, false)) {
         return false;
     }
     $classFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $className . '.php';
     if (file_exists($classFile)) {
         require $classFile;
         return true;
     }
     // Search modules directories
     foreach (self::_get_modules_dirs() as $module_dir) {
         $classFile = $module_dir . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . $className . '.php';
         if (file_exists($classFile)) {
             require $classFile;
             return true;
         }
     }
     // Search templates directories
     $lang_class_path = self::_build_search_path($className . '.php', "web", self::detect_language());
     foreach (self::_build_search_path($className . '.php', "web", self::detect_language(), true) as $candidate) {
         if (file_exists($candidate)) {
             require $candidate;
             return true;
         }
     }
     return false;
 }
开发者ID:jkinner,项目名称:dogma,代码行数:31,代码来源:Dogma.php

示例2: register

 /**
  * {@inheritdoc}
  */
 public function register(Container $app)
 {
     $app['puli.factory'] = function () {
         $factoryClass = PULI_FACTORY_CLASS;
         return new $factoryClass();
     };
     $app['puli.repository'] = function ($app) {
         return $app['puli.factory']->createRepository();
     };
     $app['puli.discovery'] = function ($app) {
         return $app['puli.factory']->createDiscovery();
     };
     $app['puli.url_generator'] = function ($app) {
         return $app['puli.factory']->createUrlGenerator($app['puli.discovery']);
     };
     if (isset($app['twig'])) {
         if (interface_exists('Puli\\UrlGenerator\\Api\\UrlGenerator')) {
             $app->extend('twig', function ($twig, $app) {
                 $twig->addExtension(new PuliExtension($app['puli.repository'], $app['puli.url_generator']));
                 return $twig;
             });
         }
         $app->extend('twig.loader', function ($loader, $app) {
             $loader->addLoader(new PuliTemplateLoader($app['puli.repository']));
             return $loader;
         });
     }
 }
开发者ID:flint,项目名称:brick,代码行数:31,代码来源:PuliServiceProvider.php

示例3: _replaceAppUses

 /**
  * Replace App::uses with use <Classname>;
  *
  * @param string $contents
  * @return string
  */
 protected function _replaceAppUses($contents)
 {
     $pattern = '#App::uses\\(\\s*[\'"]([a-z0-9_]+)[\'"]\\s*,\\s*[\'"]([a-z0-9/_]+)(?:\\.([a-z0-9/_]+))?[\'"]\\)#i';
     $replacement = function ($matches) {
         $matches = $this->_mapClassName($matches);
         // Chop Lib out as locations moves those files to the top level.
         // But only if Lib is not the last folder.
         if (isset($matches[3]) && substr($matches[3], 0, 4) === 'Lib/') {
             $use = $matches[2] . '\\' . substr($matches[3], 4) . '\\' . $matches[1];
         } elseif (count($matches) === 4) {
             $use = $matches[2] . '\\' . $matches[3] . '\\' . $matches[1];
         } elseif ($matches[2] === 'Vendor') {
             $this->out(sprintf('<info>Skip %s as it is a vendor library.</info>', $matches[1]), 1, Shell::VERBOSE);
             return $matches[0];
         } else {
             $use = 'Cake\\' . $matches[2] . '\\' . $matches[1];
             if (!class_exists($use) && !interface_exists($use)) {
                 $use = 'App\\' . substr($use, 5);
             }
         }
         $use = str_replace('/', '\\', $use);
         return 'use ' . $use;
     };
     return preg_replace_callback($pattern, $replacement, $contents, -1, $count);
 }
开发者ID:cakephp,项目名称:upgrade,代码行数:31,代码来源:AppUsesTask.php

示例4: of

 /**
  * @throws WrongArgumentException
  * @return PrimitiveIdentifier
  **/
 public function of($class)
 {
     $className = $this->guessClassName($class);
     Assert::isTrue(class_exists($className, true) || interface_exists($className, true), "knows nothing about '{$className}' class/interface");
     $this->ofClassName = $className;
     return $this;
 }
开发者ID:justthefish,项目名称:hesper,代码行数:11,代码来源:PrimitiveClass.php

示例5: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->tab('tab.bruery_classification_category_general')->with('tab.group.bruery_classification_category_general', array('class' => 'col-md-8'))->end()->with('tab.group.bruery_classification_category_options', array('class' => 'col-md-4'))->end()->end();
     if ($this->hasProvider()) {
         $formMapper->tab('tab.bruery_classification_category_settings')->with('tab.group.bruery_classification_category_settings', array('class' => 'col-md-8'))->end()->end();
     }
     $formMapper->tab('tab.bruery_classification_category_general')->with('tab.group.bruery_classification_category_general')->add('name')->add('description', 'textarea', array('required' => false))->end()->end();
     if ($this->hasSubject()) {
         if ($this->getSubject()->getParent() !== null || $this->getSubject()->getId() === null) {
             // root category cannot have a parent
             $formMapper->tab('tab.bruery_classification_category_general')->with('tab.group.bruery_classification_category_general')->add('parent', 'sonata_category_selector', array('category' => $this->getSubject() ?: null, 'model_manager' => $this->getModelManager(), 'class' => $this->getClass(), 'required' => true, 'context' => $this->getSubject()->getContext() ?: $this->getDefaultContext()))->end()->end();
         }
     }
     $position = $this->hasSubject() && !is_null($this->getSubject()->getPosition()) ? $this->getSubject()->getPosition() : 0;
     $formMapper->tab('tab.bruery_classification_category_general')->with('tab.group.bruery_classification_category_options')->add('enabled', null, array('required' => false))->add('position', 'integer', array('required' => false, 'data' => $position))->end()->end();
     if (interface_exists('Sonata\\MediaBundle\\Model\\MediaInterface')) {
         $formMapper->tab('tab.bruery_classification_category_general')->with('tab.group.bruery_classification_category_general')->add('media', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('provider' => 'sonata.media.provider.image', 'context' => 'sonata_category')))->end()->end();
     }
     if ($this->hasProvider()) {
         $instance = $this->getSubject();
         if ($instance && $instance->getId()) {
             $this->provider->load($instance);
             $this->provider->buildEditForm($formMapper);
         } else {
             $this->provider->buildCreateForm($formMapper);
         }
     }
 }
开发者ID:bruery,项目名称:platform,代码行数:31,代码来源:CategoryAdmin.php

示例6: __construct

 /**
  * Construct a new mock builder.
  *
  * Each value in `$types` can be either a class name, or an ad hoc mock
  * definition. If only a single type is being mocked, the class name or
  * definition can be passed without being wrapped in an array.
  *
  * @param mixed              $types              The types to mock.
  * @param MockFactory        $factory            The factory to use.
  * @param HandleFactory      $handleFactory      The handle factory to use.
  * @param InvocableInspector $invocableInspector The invocable inspector.
  * @param FeatureDetector    $featureDetector    The feature detector to use.
  *
  * @throws MockException If invalid input is supplied.
  */
 public function __construct($types, MockFactory $factory, HandleFactory $handleFactory, InvocableInspector $invocableInspector, FeatureDetector $featureDetector)
 {
     $this->isTraitSupported = $featureDetector->isSupported('trait');
     $this->isAnonymousClassSupported = $featureDetector->isSupported('class.anonymous');
     $this->isRelaxedKeywordsSupported = $featureDetector->isSupported('parser.relaxed-keywords');
     $this->isEngineErrorExceptionSupported = $featureDetector->isSupported('error.exception.engine');
     $this->isDateTimeInterfaceSupported = interface_exists('DateTimeInterface');
     $this->factory = $factory;
     $this->handleFactory = $handleFactory;
     $this->invocableInspector = $invocableInspector;
     $this->featureDetector = $featureDetector;
     $this->types = array();
     $this->parentClassName = null;
     $this->customMethods = array();
     $this->customProperties = array();
     $this->customStaticMethods = array();
     $this->customStaticProperties = array();
     $this->customConstants = array();
     $this->isFinalized = false;
     $this->emptyCallback = function () {
     };
     if (null !== $types) {
         $this->like($types);
     }
 }
开发者ID:eloquent,项目名称:phony,代码行数:40,代码来源:MockBuilder.php

示例7: loadClass

 /**
  * Loads a class from a PHP file.  The filename must be formatted
  * as "$class.php".
  *
  * If $dirs is a string or an array, it will search the directories
  * in the order supplied, and attempt to load the first matching file.
  *
  * If $dirs is null, it will split the class name at underscores to
  * generate a path hierarchy (e.g., "Zend_Example_Class" will map
  * to "Zend/Example/Class.php").
  *
  * If the file was not found in the $dirs, or if no $dirs were specified,
  * it will attempt to load it from PHP's include_path.
  *
  * @param string $class      - The full class name of a Zend component.
  * @param string|array $dirs - OPTIONAL Either a path or an array of paths
  *                             to search.
  * @return void
  * @throws Zend_Exception
  */
 public static function loadClass($class, $dirs = null)
 {
     if (class_exists($class, false) || interface_exists($class, false)) {
         return;
     }
     if (null !== $dirs && !is_string($dirs) && !is_array($dirs)) {
         #require_once 'Zend/Exception.php';
         throw new Zend_Exception('Directory argument must be a string or an array');
     }
     $file = self::standardiseFile($class);
     if (!empty($dirs)) {
         // use the autodiscovered path
         $dirPath = dirname($file);
         if (is_string($dirs)) {
             $dirs = explode(PATH_SEPARATOR, $dirs);
         }
         foreach ($dirs as $key => $dir) {
             if ($dir == '.') {
                 $dirs[$key] = $dirPath;
             } else {
                 $dir = rtrim($dir, '\\/');
                 $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
             }
         }
         $file = basename($file);
         self::loadFile($file, $dirs, true);
     } else {
         self::loadFile($file, null, true);
     }
     if (!class_exists($class, false) && !interface_exists($class, false)) {
         #require_once 'Zend/Exception.php';
         throw new Zend_Exception("File \"{$file}\" does not exist or class \"{$class}\" was not found in the file");
     }
 }
开发者ID:par-orillonsoft,项目名称:Magento,代码行数:54,代码来源:Loader.php

示例8: _findMissingClasses

 /**
  * Find classes which are used as parameters types of the specified method and are not declared.
  *
  * @param string $file
  * @param \ReflectionClass $classReflection
  * @param string $methodName
  * @param string $entityType
  * @return string[]
  */
 protected function _findMissingClasses($file, $classReflection, $methodName, $entityType)
 {
     $missingClasses = [];
     if ($classReflection->hasMethod($methodName)) {
         $constructor = $classReflection->getMethod($methodName);
         $parameters = $constructor->getParameters();
         /** @var $parameter \ReflectionParameter */
         foreach ($parameters as $parameter) {
             preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $parameter->__toString(), $matches);
             if (isset($matches[1]) && substr($matches[1], -strlen($entityType)) == $entityType) {
                 $missingClassName = $matches[1];
                 try {
                     if (class_exists($missingClassName)) {
                         continue;
                     }
                 } catch (\Magento\Framework\Exception\LocalizedException $e) {
                 }
                 $sourceClassName = $this->getSourceClassName($missingClassName, $entityType);
                 if (!class_exists($sourceClassName) && !interface_exists($sourceClassName)) {
                     $this->_log->add(
                         Log::CONFIGURATION_ERROR,
                         $missingClassName,
                         "Invalid {$entityType} for nonexistent class {$sourceClassName} in file {$file}"
                     );
                     continue;
                 }
                 $missingClasses[] = $missingClassName;
             }
         }
     }
     return $missingClasses;
 }
开发者ID:nja78,项目名称:magento2,代码行数:41,代码来源:PhpScanner.php

示例9: loadClass

 /**
  * Load the file for a class
  *
  * @param   string  $class  The class that will be loaded
  * @return  boolean True on success
  */
 public static function loadClass($class)
 {
     // pre-empt further searching for the named class or interface.
     // do not use autoload, because this method is registered with
     // spl_autoload already.
     if (class_exists($class, false) || interface_exists($class, false)) {
         return;
     }
     // if class start with a 'Nooku' it is a Nooku class.
     // create the path and register it with the loader.
     switch (substr($class, 0, 6)) {
         case 'Picman':
             $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', substr_replace($class, '', 0, 6)));
             $parts = explode('_', $word);
             if (count($parts) > 1) {
                 $path = KInflector::pluralize(array_shift($parts)) . DS . implode(DS, $parts);
             } else {
                 $path = $word;
             }
             if (is_file(dirname(__FILE__) . DS . $path . '.php')) {
                 KLoader::register($class, dirname(__FILE__) . DS . $path . '.php');
             }
             break;
     }
     $classes = KLoader::register();
     if (array_key_exists(strtolower($class), $classes)) {
         include $classes[strtolower($class)];
         return true;
     }
     return false;
 }
开发者ID:janssit,项目名称:www.gincoprojects.be,代码行数:37,代码来源:loader.php

示例10: maxAPIAutoload

/**
 * Autoloading of maxAPI classes
 */
function maxAPIAutoload($className)
{
    if (class_exists($className, false) || interface_exists($className, false)) {
        return;
    }
    include_once $className . '.php';
}
开发者ID:krit-on,项目名称:maxPostix,代码行数:10,代码来源:autoload.php

示例11: CAS_autoload

/**
 * Autoload a class
 *
 * @param string $class Classname to load
 *
 * @return bool
 */
function CAS_autoload($class)
{
    // Static to hold the Include Path to CAS
    static $include_path;
    // Check only for CAS classes
    if (substr($class, 0, 4) !== 'CAS_') {
        return false;
    }
    // Setup the include path if it's not already set from a previous call
    if (empty($include_path)) {
        $include_path = array(dirname(dirname(__FILE__)), dirname(dirname(__FILE__)) . '/../test/');
    }
    // Declare local variable to store the expected full path to the file
    foreach ($include_path as $path) {
        $file_path = $path . '/' . str_replace('_', '/', $class) . '.php';
        $fp = @fopen($file_path, 'r', true);
        if ($fp) {
            fclose($fp);
            include $file_path;
            if (!class_exists($class, false) && !interface_exists($class, false)) {
                die(new Exception('Class ' . $class . ' was not present in ' . $file_path . ' [CAS_autoload]'));
            }
            return true;
        }
    }
    $e = new Exception('Class ' . $class . ' could not be loaded from ' . $file_path . ', file does not exist (Path="' . implode(':', $include_path) . '") [CAS_autoload]');
    $trace = $e->getTrace();
    if (isset($trace[2]) && isset($trace[2]['function']) && in_array($trace[2]['function'], array('class_exists', 'interface_exists'))) {
        return false;
    }
    if (isset($trace[1]) && isset($trace[1]['function']) && in_array($trace[1]['function'], array('class_exists', 'interface_exists'))) {
        return false;
    }
    die((string) $e);
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:42,代码来源:Autoload.php

示例12: implementsInterface

 public function implementsInterface($interface)
 {
     if (!interface_exists($interface)) {
         throw new ReflectionException("Interface " . $interface . " does not exist ");
     }
     // todo add actual checking
 }
开发者ID:cbsistem,项目名称:php.js,代码行数:7,代码来源:ReflectionClass.php

示例13: autoload

 protected static function autoload($class)
 {
     $className = $class;
     if (class_exists($className, false) || interface_exists($className, false)) {
         return true;
     }
     $directory = '';
     if (App::isCategoryType($class, self::APP_LOADER_MODEL)) {
         //this is a model
         $directory = CODE_BASE . DIRECTORY_SEPARATOR . self::APP_MODEL_DIRECTORY_NAME . DIRECTORY_SEPARATOR;
         $class = App::resolveCategory($class, self::APP_LOADER_MODEL);
     } else {
         if (App::isCategoryType($class, self::APP_LOADER_CONTROLLER)) {
             //this is a controller
             $directory = CODE_BASE . DIRECTORY_SEPARATOR . self::APP_CONTROLLER_DIRECTORY_NAME;
             $class = App::resolveCategory($class, self::APP_LOADER_CONTROLLER);
         } else {
             //this is used library
             $directory = CODE_BASE . DIRECTORY_SEPARATOR . self::APP_LIBRARY_DIRECTORY_NAME;
         }
     }
     $file = $directory . DIRECTORY_SEPARATOR . $class . '.php';
     if (is_file($file)) {
         include $file;
     }
     return true;
 }
开发者ID:sdgdsffdsfff,项目名称:data_web,代码行数:27,代码来源:App.php

示例14: __construct

 /**
  * Constructor
  *
  * @param string $interfaceName
  * @param MethodDataProviderFactory $methodDataProviderFactory
  * @param Reader $reader
  */
 public function __construct($interfaceName, MethodDataProviderFactory $methodDataProviderFactory, Reader $reader)
 {
     Tebru\assertThat(interface_exists($interfaceName), '"%s" is not a valid interface', $interfaceName);
     $this->reflectionClass = new ReflectionClass($interfaceName);
     $this->methodDataProviderFactory = $methodDataProviderFactory;
     $this->reader = $reader;
 }
开发者ID:tebru,项目名称:dynamo,代码行数:14,代码来源:InterfaceDataProvider.php

示例15: addRepository

 /**
  * {@inheritdoc}
  */
 protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $reflection = new \ReflectionClass($metadata->getClass('model'));
     $translatableInterface = TranslatableInterface::class;
     $translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
     $repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
     $repositoryClass = $translatable ? TranslatableResourceRepository::class : EntityRepository::class;
     if ($container->hasParameter($repositoryClassParameterName)) {
         $repositoryClass = $container->getParameter($repositoryClassParameterName);
     }
     if ($metadata->hasClass('repository')) {
         $repositoryClass = $metadata->getClass('repository');
     }
     $repositoryReflection = new \ReflectionClass($repositoryClass);
     $definition = new Definition($repositoryClass);
     $definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
     $definition->setLazy(!$repositoryReflection->isFinal());
     if ($metadata->hasParameter('translation')) {
         $translatableRepositoryInterface = TranslatableResourceRepositoryInterface::class;
         $translationConfig = $metadata->getParameter('translation');
         if (interface_exists($translatableRepositoryInterface) && $repositoryReflection->implementsInterface($translatableRepositoryInterface)) {
             if (isset($translationConfig['fields'])) {
                 $definition->addMethodCall('setTranslatableFields', [$translationConfig['fields']]);
             }
         }
     }
     $container->setDefinition($metadata->getServiceId('repository'), $definition);
 }
开发者ID:starspire,项目名称:eventmanager,代码行数:31,代码来源:DoctrineORMDriver.php


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