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


PHP class_implements函数代码示例

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


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

示例1: factory

 /**
  * Create and return a StorageInterface instance
  *
  * @param  string                             $type
  * @param  array|Traversable                  $options
  * @return StorageInterface
  * @throws Exception\InvalidArgumentException for unrecognized $type or individual options
  */
 public static function factory($type, $options = array())
 {
     if (!is_string($type)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects the $type argument to be a string class name; received "%s"', __METHOD__, is_object($type) ? get_class($type) : gettype($type)));
     }
     if (!class_exists($type)) {
         $class = __NAMESPACE__ . '\\' . $type;
         if (!class_exists($class)) {
             throw new Exception\InvalidArgumentException(sprintf('%s expects the $type argument to be a valid class name; received "%s"', __METHOD__, $type));
         }
         $type = $class;
     }
     if ($options instanceof Traversable) {
         $options = ArrayUtils::iteratorToArray($options);
     }
     if (!is_array($options)) {
         throw new Exception\InvalidArgumentException(sprintf('%s expects the $options argument to be an array or Traversable; received "%s"', __METHOD__, is_object($options) ? get_class($options) : gettype($options)));
     }
     switch (true) {
         case in_array('Zend\\Session\\Storage\\AbstractSessionArrayStorage', class_parents($type)):
             return static::createSessionArrayStorage($type, $options);
             break;
         case $type === 'Zend\\Session\\Storage\\ArrayStorage':
         case in_array('Zend\\Session\\Storage\\ArrayStorage', class_parents($type)):
             return static::createArrayStorage($type, $options);
             break;
         case in_array('Zend\\Session\\Storage\\StorageInterface', class_implements($type)):
             return new $type($options);
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf('Unrecognized type "%s" provided; expects a class implementing %s\\StorageInterface', $type, __NAMESPACE__));
     }
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:41,代码来源:Factory.php

示例2: validatePackage

 private function validatePackage($packageName)
 {
     if (class_exists($packageName) && in_array('Tohmua\\IntegrationGate\\IntegrationGate', class_implements($packageName))) {
         return true;
     }
     return false;
 }
开发者ID:Tohmua,项目名称:IntegrationGate,代码行数:7,代码来源:Integrate.php

示例3: testGenerator

 public function testGenerator()
 {
     /** @var OpsWay\Test2\Solid\I $generator */
     $generator = OpsWay\Test2\Solid\Factory::create('i');
     $generator->generate();
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IGeometric.php');
     include $file;
     $this->assertTrue(interface_exists('IGeometric'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/IAngular.php');
     include $file;
     $this->assertTrue(interface_exists('IAngular'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/ISquarable.php');
     include $file;
     $this->assertTrue(interface_exists('ISquarable'));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Square.php');
     include $file;
     $this->assertTrue(class_exists('Square'));
     $this->assertTrue(in_array('IGeometric', class_implements('Square')));
     $this->assertFileExists($file = __DIR__ . '/../../test/I/Circle.php');
     include $file;
     $this->assertTrue(class_exists('Circle'));
     $this->assertTrue(in_array('IGeometric', class_implements('Circle')));
     $this->assertTrue(method_exists('IGeometric', 'square'));
     $this->assertTrue(method_exists('ISquarable', 'square'));
     $this->assertTrue(method_exists('IAngular', 'countAngles'));
 }
开发者ID:kokareff,项目名称:hr-test-2,代码行数:26,代码来源:Test_Generator_I.php

示例4: _setClass

 /**
  * Class mutator
  *
  * @param string $class Class name
  *
  * @return void
  * @throws \InvalidArgumentException If wrong class is given
  */
 private function _setClass($class)
 {
     if (!in_array(IBasket::class, class_implements($class))) {
         throw new \InvalidArgumentException('Class must implement IBasket');
     }
     $this->_class = $class;
 }
开发者ID:sp-niemand,项目名称:balls-to-the-wall,代码行数:15,代码来源:AbstractBasketFactory.php

示例5: canCreate

 public function canCreate(ContainerInterface $container, $requestedName)
 {
     $isClassExists = class_exists($requestedName);
     $isDispatchable = in_array(DispatchableInterface::class, class_implements($requestedName));
     $isController = preg_match('/^[a-z]+\\\\Controller\\\\.*Controller/i', $requestedName);
     return $isClassExists && $isDispatchable && $isController;
 }
开发者ID:jiromm,项目名称:zf3-skeleton-application,代码行数:7,代码来源:AbstractControllerFactory.php

示例6: is_multiselectable

 public static function is_multiselectable($object)
 {
     if (is_object($object)) {
         if ($object instanceof VP_MultiSelectable) {
             return true;
         }
     } elseif (is_string($object)) {
         $class = self::field_class_from_type($object);
         if (function_exists('class_implements')) {
             if (class_exists($class)) {
                 $interfaces = class_implements($class);
                 if (isset($interfaces['VP_MultiSelectable'])) {
                     return true;
                 }
             } else {
                 return false;
             }
         } else {
             $dummy = new $class();
             if ($dummy instanceof VP_MultiSelectable) {
                 return true;
             }
             unset($dummy);
         }
     }
     return false;
 }
开发者ID:rku4er,项目名称:vafpress-wp,代码行数:27,代码来源:reflection.php

示例7: dump

    /**
     * Dumps a set of routes to a PHP class.
     *
     * Available options:
     *
     *  * class:      The class name
     *  * base_class: The base class name
     *
     * @param array $options An array of options
     *
     * @return string A PHP class representing the matcher class
     */
    public function dump(array $options = array())
    {
        $options = array_replace(array('class' => 'ProjectUrlMatcher', 'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher'), $options);
        // trailing slash support is only enabled if we know how to redirect the user
        $interfaces = class_implements($options['base_class']);
        $supportsRedirections = isset($interfaces['Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface']);
        return <<<EOF
<?php

use Symfony\\Component\\Routing\\Exception\\MethodNotAllowedException;
use Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException;
use Symfony\\Component\\Routing\\RequestContext;

/**
 * {$options['class']}
 *
 * This class has been auto-generated
 * by the Symfony Routing Component.
 */
class {$options['class']} extends {$options['base_class']}
{
    /**
     * Constructor.
     */
    public function __construct(RequestContext \$context)
    {
        \$this->context = \$context;
    }

{$this->generateMatchMethod($supportsRedirections)}
}

EOF;
    }
开发者ID:ymnl007,项目名称:92five,代码行数:46,代码来源:PhpMatcherDumper.php

示例8: getDependencyInterfaces

 /**
  * Returns a list of interfaces implemented by instance
  * @param $instance
  * @return array
  */
 protected function getDependencyInterfaces($instance) : array
 {
     $interfaces = class_implements($instance);
     array_push($interfaces, get_class($instance));
     $interfaces += class_parents($instance);
     return $interfaces;
 }
开发者ID:AtanorPHP,项目名称:atanor-di,代码行数:12,代码来源:InjectionInterfaceStrategy.php

示例9: getType

 /**
  * {@inheritdoc}
  */
 public function getType($name)
 {
     if (!is_string($name)) {
         throw new UnexpectedTypeException($name, 'string');
     }
     if (!isset($this->types[$name])) {
         $type = null;
         foreach ($this->extensions as $extension) {
             if ($extension->hasType($name)) {
                 $type = $extension->getType($name);
                 break;
             }
         }
         if (!$type) {
             // Support fully-qualified class names
             if (class_exists($name) && in_array('Symfony\\Component\\Form\\FormTypeInterface', class_implements($name))) {
                 $type = new $name();
             } else {
                 throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
             }
         }
         $this->resolveAndAddType($type);
     }
     if (isset($this->legacyNames[$name])) {
         @trigger_error('Accessing types by their string name is deprecated since version 2.8 and will be removed in 3.0. Use the fully-qualified type class name instead.', E_USER_DEPRECATED);
     }
     return $this->types[$name];
 }
开发者ID:nuwe1,项目名称:symfony,代码行数:31,代码来源:FormRegistry.php

示例10: loadConfig

 /**
  * Loads the composite driver from constants
  * @param $level
  * @return \Stash\Interfaces\DriverInterface
  */
 protected function loadConfig($level)
 {
     $drivers = array();
     $driver_configs = Config::get("concrete.cache.levels.{$level}.drivers", array());
     foreach ($driver_configs as $driver_build) {
         if (!$driver_build) {
             continue;
         }
         $class = array_get($driver_build, 'class', '');
         if ($class && class_exists($class)) {
             $implements = class_implements($class);
             // Make sure that the provided class implements the DriverInterface
             if (isset($implements['Stash\\Interfaces\\DriverInterface'])) {
                 /** @type \Stash\Interfaces\DriverInterface $temp_driver */
                 $temp_driver = new $class();
                 if ($options = array_get($driver_build, 'options', null)) {
                     $temp_driver->setOptions($options);
                 }
                 $drivers[] = $temp_driver;
             } else {
                 throw new \RuntimeException('Cache driver class must implement \\Stash\\Interfaces\\DriverInterface.');
             }
         }
     }
     $count = count($drivers);
     if ($count > 1) {
         $driver = new Composite();
         $driver->setOptions(array('drivers' => $drivers));
     } elseif ($count === 1) {
         $driver = $drivers[0];
     } else {
         $driver = new BlackHole();
     }
     return $driver;
 }
开发者ID:kreativmind,项目名称:concrete5-5.7.0,代码行数:40,代码来源:Cache.php

示例11: afterSaving

 protected function afterSaving($request)
 {
     if (!in_array('LiveCMS\\Models\\Contracts\\UserOnlyInterface', class_implements($this->model))) {
         if ($request->has('permalink')) {
             $permalink = $this->model->permalink;
             if ($permalink == null) {
                 $permalink = new Permalink();
                 $permalink->postable()->associate($this->model);
             }
             $permalink->permalink = $request->get('permalink');
             $permalink->save();
         } else {
             if ($this->model->permalink) {
                 $this->model->permalink->delete();
             }
         }
     }
     if ($request->hasFile('picture') && $request->file('picture')->isValid()) {
         $object = $this->model;
         Upload::setFilenameMaker(function ($file, $object) {
             $title = $object->title ? $object->title : $object->name;
             return str_limit(str_slug($title . ' ' . date('YmdHis')), 200) . '.' . $file->getClientOriginalExtension();
         }, $object);
         Upload::model($object);
         $this->model->save();
     }
     if (empty($this->model->status)) {
         $status = Model::STATUS_DRAFT;
         $this->model->update(compact('status'));
     }
     return parent::afterSaving($request);
 }
开发者ID:livecms,项目名称:core,代码行数:32,代码来源:PostableController.php

示例12: getInstance

 /**
  * Get a new function core instance
  *
  * @param array $cfg Function core configuration for initialization
  * @param array $common Common configuration for initialization
  * @param \Facula\Framework $parent Instance of Facula Framework itself.
  *
  * @return mixed Return a instance of function core when success, false otherwise
  */
 public static final function getInstance(array $cfg, array $common, Framework $parent)
 {
     $caller = get_called_class();
     // If $cfg['Core'] has beed set, means user wants
     // to use their own core instead of default one
     if (isset($cfg['Custom'][0])) {
         $class = $cfg['Custom'];
     } elseif (isset(static::$default)) {
         $class = static::$default;
     } else {
         new Error('CLASS_NOTFOUND', array($caller), 'ERROR');
         return false;
     }
     if (!isset(self::$instances[$class])) {
         if (!class_exists($class)) {
             new Error('CLASS_NOTLOAD', array($class), 'ERROR');
             return false;
         }
         $classInterface = class_implements($class);
         if (!isset($classInterface[static::$interface])) {
             new Error('CLASS_INTERFACE', array($class, static::$interface), 'ERROR');
             return false;
         }
         if (!is_subclass_of($class, 'Facula\\Base\\Prototype\\Core')) {
             new Error('CLASS_BASE', array($class, 'Facula\\Base\\Prototype\\Core'), 'ERROR');
             return false;
         }
         return self::$instances[$class] = new $class($cfg, $common, $parent);
     }
     return self::$instances[$class];
 }
开发者ID:BGCX067,项目名称:faculaframework2-git,代码行数:40,代码来源:Core.php

示例13: sanitizeForSerialization

 /**
  * Serialize data
  *
  * @param mixed $data the data to serialize
  *
  * @return string serialized form of $data
  */
 public static function sanitizeForSerialization($data)
 {
     if (is_scalar($data) || null === $data) {
         return $data;
     } elseif ($data instanceof \DateTime) {
         return $data->format(\DateTime::ATOM);
     } elseif (is_array($data)) {
         foreach ($data as $property => $value) {
             $data[$property] = self::sanitizeForSerialization($value);
         }
         return $data;
     } elseif (is_object($data)) {
         if (!isset(class_implements($data)["ArrayAccess"])) {
             return $data;
         }
         $values = array();
         foreach (array_keys($data::swaggerTypes()) as $property) {
             $getter = $data::getters()[$property];
             if ($data->{$getter}() !== null) {
                 $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->{$getter}());
             }
         }
         return (object) $values;
     } else {
         return (string) $data;
     }
 }
开发者ID:slamby,项目名称:slamby-sdk-php,代码行数:34,代码来源:ObjectSerializer.php

示例14: class_implements

 static function class_implements($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_implements')) {
         $autoload = class_implements($c, false);
         /**/
     } else {
         if (class_exists('ReflectionClass', false)) {
             $autoload = array();
             $c = new ReflectionClass($c);
             foreach ($c->getInterfaceNames() as $c) {
                 $autoload[$c] = $c;
             }
             /**/
         } else {
             return false;
             /**/
         }
     }
     foreach ($autoload as $c) {
         isset(self::$us2ns[$a = strtolower($c)]) && ($autoload[$c] = self::$us2ns[$a]);
     }
     return $autoload;
 }
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:34,代码来源:Php530.php

示例15: create

 /**
  * @param ApiCallData $data
  *
  * @return ApiResponseInterface
  *
  * @throws \Exception
  */
 public static function create(ApiCallData $data)
 {
     $type = $data->getResponseType();
     if (!class_exists($type)) {
         throw new \Exception("Type Class '" . $type . "', could not be loaded");
     }
     $interfaces = class_implements($type);
     if ($type == '\\Exception' || $type === '\\Packaged\\Api\\Exceptions\\ApiException' || in_array('\\Packaged\\Api\\Exceptions\\ApiException', $interfaces) || array_key_exists('Exception', class_parents($type))) {
         $code = $data->getStatusCode();
         if (!is_numeric($code)) {
             $code = 500;
         }
         $exception = new $type($data->getStatusMessage(), $code);
         $rawData = $data->getRawResult();
         if (is_object($rawData)) {
             Objects::hydrate($exception, $rawData);
         }
         throw $exception;
     } else {
         if (in_array('Packaged\\Api\\Interfaces\\ApiResponseInterface', $interfaces)) {
             $class = new $type();
             /**
              * @var $class \Packaged\Api\Interfaces\ApiResponseInterface
              */
             $class->setApiCallData($data);
             return $class;
         } else {
             throw new ApiException("An invalid message type was used '" . $type . "'");
         }
     }
 }
开发者ID:packaged,项目名称:api,代码行数:38,代码来源:ResponseBuilder.php


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