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


PHP ReflectionClass::implementsInterface方法代码示例

本文整理汇总了PHP中ReflectionClass::implementsInterface方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::implementsInterface方法的具体用法?PHP ReflectionClass::implementsInterface怎么用?PHP ReflectionClass::implementsInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionClass的用法示例。


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

示例1: getResource

 public function getResource($controllerClass)
 {
     $ref = new \ReflectionClass($controllerClass);
     //Not a private resource
     if (!$ref->implementsInterface('Eva\\EvaEngine\\Mvc\\Controller\\TokenAuthorityControllerInterface') && !$ref->implementsInterface('Eva\\EvaEngine\\Mvc\\Controller\\SessionAuthorityControllerInterface')) {
         return false;
     }
     $resourceGroup = 'app';
     if ($ref->implementsInterface('Eva\\EvaEngine\\Mvc\\Controller\\TokenAuthorityControllerInterface')) {
         $resourceGroup = 'api';
     } else {
         if ($ref->isSubclassOf('Eva\\EvaEngine\\Mvc\\Controller\\AdminControllerBase')) {
             $resourceGroup = 'admin';
         }
     }
     $reader = new \Phalcon\Annotations\Adapter\Memory();
     $reflector = $reader->get($controllerClass);
     $resourceAnnotations = $reflector->getClassAnnotations();
     $resourceName = $controllerClass;
     $resourceDes = '';
     if ($resourceAnnotations && $resourceAnnotations->has('resourceName') && ($annotation = $resourceAnnotations->get('resourceName'))) {
         $resourceName = implode('', $annotation->getArguments());
     }
     if ($resourceAnnotations && $resourceAnnotations->has('resourceDescription') && ($annotation = $resourceAnnotations->get('resourceDescription'))) {
         $resourceDes = implode('', $annotation->getArguments());
     }
     $resource = array('name' => $resourceName, 'resourceKey' => $controllerClass, 'resourceGroup' => $resourceGroup, 'description' => $resourceDes);
     return $resource;
 }
开发者ID:skybird,项目名称:phalcon,代码行数:29,代码来源:Scanner.php

示例2: test_aspects

 /**
  * @coversNothing
  */
 public function test_aspects()
 {
     $subject = new \ReflectionClass(testSubject::class);
     self::assertFalse($subject->implementsInterface(P\CollectionInterface::class));
     self::assertTrue($subject->implementsInterface(P\UnaryApplicativeInterface::class));
     self::assertTrue($subject->getMethod('of')->isAbstract());
 }
开发者ID:rkgladson,项目名称:PHPixme,代码行数:10,代码来源:EitherTest.php

示例3: load

 public function load()
 {
     $files = $this->_getFiles();
     $manifestRegistry = ZendL_Tool_Rpc_Manifest_Registry::getInstance();
     $providerRegistry = ZendL_Tool_Rpc_Provider_Registry::getInstance();
     $classesLoadedBefore = get_declared_classes();
     $oldLevel = error_reporting(E_ALL | ~E_STRICT);
     // remove strict so that other packages wont throw warnings
     foreach ($files as $file) {
         require_once $file;
     }
     error_reporting($oldLevel);
     // restore old error level
     $classesLoadedAfter = get_declared_classes();
     $loadedClasses = array_diff($classesLoadedAfter, $classesLoadedBefore);
     foreach ($loadedClasses as $loadedClass) {
         $reflectionClass = new ReflectionClass($loadedClass);
         if ($reflectionClass->implementsInterface('ZendL_Tool_Rpc_Manifest_Interface') && !$reflectionClass->isAbstract()) {
             $manifestRegistry->addManifest($reflectionClass->newInstance());
         }
         if ($reflectionClass->implementsInterface('ZendL_Tool_Rpc_Provider_Interface') && !$reflectionClass->isAbstract()) {
             $providerRegistry->addProvider($reflectionClass->newInstance());
         }
     }
 }
开发者ID:lortnus,项目名称:zf1,代码行数:25,代码来源:Abstract.php

示例4: testContainer

 /**
  * @covers \PHP\Manipulator\TokenContainer
  */
 public function testContainer()
 {
     $reflection = new \ReflectionClass('PHP\\Manipulator\\TokenContainer');
     $this->assertTrue($reflection->implementsInterface('ArrayAccess'), 'Missing interface ArrayAccess');
     $this->assertTrue($reflection->implementsInterface('Countable'), 'Missing interface Countable');
     $this->assertTrue($reflection->implementsInterface('IteratorAggregate'), 'Missing interface IteratorAggregate');
 }
开发者ID:robo47,项目名称:php-manipulator,代码行数:10,代码来源:TokenContainerTest.php

示例5: generate

 /**
  * Generates a new class with the given class name
  *
  * @param string $newClassName - The name of the new class
  * @param string $mockedClassName - The name of the class being mocked
  * @param Phake_Mock_InfoRegistry $infoRegistry
  * @return NULL
  */
 public function generate($newClassName, $mockedClassName, Phake_Mock_InfoRegistry $infoRegistry)
 {
     $extends = '';
     $implements = '';
     $interfaces = array();
     $constructor = '';
     $mockedClass = new ReflectionClass($mockedClassName);
     if (!$mockedClass->isInterface()) {
         $extends = "extends {$mockedClassName}";
     } elseif ($mockedClassName != 'Phake_IMock') {
         $implements = ", {$mockedClassName}";
         if ($mockedClass->implementsInterface('Traversable') && !$mockedClass->implementsInterface('Iterator') && !$mockedClass->implementsInterface('IteratorAggregate')) {
             if ($mockedClass->getName() == 'Traversable') {
                 $implements = ', Iterator';
             } else {
                 $implements = ', Iterator' . $implements;
             }
             $interfaces = array('Iterator');
         }
     }
     $classDef = "\nclass {$newClassName} {$extends}\n\timplements Phake_IMock {$implements}\n{\n    public \$__PHAKE_info;\n\n    public static \$__PHAKE_staticInfo;\n\n\tconst __PHAKE_name = '{$mockedClassName}';\n\n\tpublic \$__PHAKE_constructorArgs;\n\n\t{$constructor}\n\n\t/**\n\t * @return void\n\t */\n\tpublic function __destruct() {}\n\n \t{$this->generateSafeConstructorOverride($mockedClass)}\n\n\t{$this->generateMockedMethods($mockedClass, $interfaces)}\n}\n";
     $this->loader->loadClassByString($newClassName, $classDef);
     $newClassName::$__PHAKE_staticInfo = $this->createMockInfo($mockedClassName, new Phake_CallRecorder_Recorder(), new Phake_Stubber_StubMapper(), new Phake_Stubber_Answers_NoAnswer());
     $infoRegistry->addInfo($newClassName::$__PHAKE_staticInfo);
 }
开发者ID:kukupigs,项目名称:Phake,代码行数:33,代码来源:MockClass.php

示例6: instantiate

 /**
  * Instantiates objects by class and id, respecting pattern implemented by given class
  * 
  * @param string $class Class name
  * @param $id
  * @return unknown_type
  */
 public static function instantiate($class, $id = null)
 {
     if (!strlen($class)) {
         require_once 'Oops/Exception.php';
         throw new Oops_Exception("Empty class name given");
     }
     if (!Oops_Loader::find($class)) {
         require_once 'Oops/Exception.php';
         throw new Oops_Exception("Class '{$class}' not found");
     }
     $reflectionClass = new ReflectionClass($class);
     if ($reflectionClass->implementsInterface('Oops_Pattern_Identifiable_Factored_Interface')) {
         /**
          * Object can be instantiated using corresponding factory
          */
         $factoryCallback = call_user_func($class, 'getFactoryCallback');
         $result = call_user_func($factoryCallback, $id);
     } elseif ($reflectionClass->implementsInterface('Oops_Pattern_Identifiable_Singleton_Interface')) {
         /**
          * This object can be instantiated using $class::getInstance($id)
          */
         $result = call_user_func(array($class, 'getInstance'), $id);
     } elseif ($reflectionClass->implementsInterface('Oops_Pattern_Singleton_Interface')) {
         /**
          * This object is the single available instance of this class, so it can be instantiated using $class::getInstance()
          */
         $result = call_user_func(array($class, 'getInstance'));
     } else {
         /**
          * This type of object should be constructed with given $id
          */
         $result = $reflectionClass->newInstance($id);
     }
     return $result;
 }
开发者ID:laiello,项目名称:oops-project,代码行数:42,代码来源:Factory.php

示例7: resolveBundleDependencies

 /**
  * Resolve bundle dependencies.
  *
  * Given a set of already loaded bundles and a set of new needed bundles,
  * build new dependencies and fill given array of loaded bundles.
  *
  * @param \Symfony\Component\HttpKernel\KernelInterface $kernel         Kernel
  * @param array                                         $bundleStack    Bundle stack, defined by Instance or Namespace
  * @param array                                         $visitedBundles Visited bundles, defined by their namespaces
  * @param array                                         $bundles        New bundles to check, defined by Instance or Namespace
  */
 private function resolveBundleDependencies(\Symfony\Component\HttpKernel\KernelInterface $kernel, array &$bundleStack, array &$visitedBundles, array $bundles)
 {
     $bundles = array_reverse($bundles);
     foreach ($bundles as $bundle) {
         /**
          * Each visited node is prioritized and placed at the beginning.
          */
         $this->prioritizeBundle($bundleStack, $bundle);
     }
     foreach ($bundles as $bundle) {
         $bundleNamespace = $this->getBundleDefinitionNamespace($bundle);
         /**
          * If have already visited this bundle, continue. One bundle can be
          * processed once.
          */
         if (isset($visitedBundles[$bundleNamespace])) {
             continue;
         }
         $visitedBundles[$bundleNamespace] = true;
         $bundleNamespaceObj = new \ReflectionClass($bundleNamespace);
         if ($bundleNamespaceObj->implementsInterface('Elcodi\\Bundle\\CoreBundle\\Interfaces\\DependentBundleInterface') || $bundleNamespaceObj->implementsInterface('Mmoreram\\SymfonyBundleDependencies\\DependentBundleInterface')) {
             /**
              * @var \Elcodi\Bundle\CoreBundle\Interfaces\DependentBundleInterface|string $bundleNamespace
              */
             $bundleDependencies = $bundleNamespace::getBundleDependencies($kernel);
             $this->resolveBundleDependencies($kernel, $bundleStack, $visitedBundles, $bundleDependencies);
         }
     }
 }
开发者ID:axelvnk,项目名称:elcodi,代码行数:40,代码来源:BundleDependenciesResolver.php

示例8: testIteratorClass

 /**
  * @covers \PHP\Manipulator\TokenContainer\Iterator
  */
 public function testIteratorClass()
 {
     $reflection = new \ReflectionClass('PHP\\Manipulator\\TokenContainer\\Iterator');
     $this->assertTrue($reflection->isIterateable());
     $this->assertTrue($reflection->implementsInterface('SeekableIterator'));
     $this->assertTrue($reflection->implementsInterface('Countable'));
     $this->assertTrue($reflection->hasMethod('previous'));
 }
开发者ID:robo47,项目名称:php-manipulator,代码行数:11,代码来源:IteratorTest.php

示例9: __construct

 /**
  * @param string $classname
  *
  * @throws InvalidArgumentException
  */
 public function __construct($classname, StrategyInterface $strategy)
 {
     $this->class = new \ReflectionClass($classname);
     $this->strategy = $strategy;
     if (!$this->class->implementsInterface(self::BALANCER_INTERFACE)) {
         throw new \InvalidArgumentException();
     }
 }
开发者ID:1001pharmacies,项目名称:geolocation-bundle,代码行数:13,代码来源:BalancerFactory.php

示例10: __construct

 /**
  * @param string $classname
  *
  * @throws InvalidArgumentException
  */
 public function __construct($classname)
 {
     $this->class = new \ReflectionClass($classname);
     /* */
     if (!$this->class->implementsInterface(self::LOCATION_INTERFACE)) {
         throw new \InvalidArgumentException();
     }
 }
开发者ID:1001pharmacies,项目名称:geolocation-bundle,代码行数:13,代码来源:Factory.php

示例11: __construct

 /**
  * Reference factory constructor
  *
  * @param string $className
  */
 public function __construct($className = 'EcomDev\\Compiler\\Storage\\Reference')
 {
     $this->reflection = new \ReflectionClass($className);
     $interface = 'EcomDev\\Compiler\\Storage\\ReferenceInterface';
     if (!$this->reflection->implementsInterface($interface)) {
         throw new \InvalidArgumentException(sprintf('%s does not implement %s', $className, $interface));
     }
 }
开发者ID:ecomdev,项目名称:compiler,代码行数:13,代码来源:ReferenceFactory.php

示例12: __construct

 /**
  * Creates a new defer object
  * @param array  $data   The data to set the properties to, as an array
  * @param string $object The full class name of the class to load. The class must implement Deferrable
  */
 public function __construct($data, $object)
 {
     $this->data = $data;
     $this->reflection = new \ReflectionClass($object);
     if (!$this->reflection->implementsInterface(__NAMESPACE__ . '\\Deferrable')) {
         throw new \LogicException($object . ' should implement Deferrable');
     }
 }
开发者ID:vierbergenlars,项目名称:gihp,代码行数:13,代码来源:Object.php

示例13: loadMetadataForClass

 /**
  * @param \ReflectionClass $class
  * @return \Metadata\ClassMetadata
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     if ($class->implementsInterface('Prezent\\Doctrine\\Translatable\\TranslatableInterface')) {
         return $this->loadTranslatableMetadata($class->name, $this->readMapping($class->name));
     }
     if ($class->implementsInterface('Prezent\\Doctrine\\Translatable\\TranslationInterface')) {
         return $this->loadTranslationMetadata($class->name, $this->readMapping($class->name));
     }
 }
开发者ID:prezent,项目名称:doctrine-translatable,代码行数:13,代码来源:FileDriver.php

示例14: getModuleType

 private function getModuleType(\ReflectionClass $reflected)
 {
     if ($reflected->implementsInterface('Thelia\\Module\\DeliveryModuleInterface')) {
         return BaseModule::DELIVERY_MODULE_TYPE;
     } elseif ($reflected->implementsInterface('Thelia\\Module\\PaymentModuleInterface')) {
         return BaseModule::PAYMENT_MODULE_TYPE;
     } else {
         return BaseModule::CLASSIC_MODULE_TYPE;
     }
 }
开发者ID:fachriza,项目名称:thelia,代码行数:10,代码来源:ModuleManagement.php

示例15: create

 /**
  * @return MetadataMinerInterface
  * @throws \InvalidArgumentException
  */
 public function create()
 {
     if ($this->oreClass->implementsInterface(MetadataMiner::GHOST_ENTITY_INTERFACE)) {
         $miner = new GhostMetadataMiner($this->metadataCache);
     } elseif ($this->oreClass->implementsInterface(MetadataMiner::RESOURCE_ENTITY_INTERFACE)) {
         $miner = new EntityMetadataMiner($this->metadataCache, $this->resourceClassPath);
     } else {
         throw new \InvalidArgumentException(self::ERROR_RESOURCE_ENTITY_EXPECTED);
     }
     return $miner;
 }
开发者ID:gointegro,项目名称:hateoas,代码行数:15,代码来源:MinerFactory.php


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