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


PHP ReflectionClass::getInterfaces方法代码示例

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


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

示例1: __construct

 /**
  * Begin defining a mock object, and setting its expectations
  * if $test is set, it will be the parent test object (tenative? is this good?)
  * @access public
  * @param string $class_name class name to create a mock of
  * @param UnitTest a unit test object that calls it (tenative)
  */
 public function __construct($class_name)
 {
     // $this->test = $test;
     $this->requires_inheritance = FALSE;
     $this->requires_magic_methods = FALSE;
     $this->requires_static_methods = FALSE;
     $this->use_extends = FALSE;
     $this->has_constructor = FALSE;
     $this->interface_names = array();
     $this->methods = array();
     $this->signatures = array();
     $this->constructor_args = array();
     $this->counters = array();
     $this->mocked_class = $class_name;
     $this->constructed_object = null;
     // do some quick reflection on the class
     $reflected_class = new ReflectionClass($this->mocked_class);
     if ($reflected_class->isInterface()) {
         $this->interface_names[] = $class_name;
     } else {
         $this->use_extends = TRUE;
     }
     if (count($reflected_class->getInterfaces()) > 0) {
         foreach ($reflected_class->getInterfaces() as $k => $interface) {
             $this->interface_names[] = $interface->getName();
         }
     }
 }
开发者ID:Jakobo,项目名称:snaptest,代码行数:35,代码来源:mock.php

示例2: getFilenames

 /**
  * Get an array of loaded file names in order of loading.
  *
  * @return array
  */
 public function getFilenames()
 {
     $files = array();
     foreach ($this->classList->getClasses() as $class) {
         // Push interfaces before classes if not already loaded
         try {
             $r = new \ReflectionClass($class);
             foreach ($r->getInterfaces() as $inf) {
                 $name = $inf->getFileName();
                 if ($name && !in_array($name, $files)) {
                     $files[] = $name;
                 }
             }
             if (!in_array($r->getFileName(), $files)) {
                 $files[] = $r->getFileName();
             }
         } catch (\ReflectionException $e) {
             // We ignore all exceptions related to reflection,
             // because in some cases class can't exists. This
             // can be if you use in your code constructions like
             //
             // if (class_exists('SomeClass')) { // <-- here will trigger autoload
             //      class SomeSuperClass extends SomeClass {
             //      }
             // }
             //
             // We ignore all problems with classes, interfaces and
             // traits.
         }
     }
     return $files;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:37,代码来源:ClassLoader.php

示例3: getExtensibleInterfaceName

 /**
  * Identify concrete extensible interface name based on the class name.
  *
  * @param string $extensibleClassName
  * @return string
  */
 public function getExtensibleInterfaceName($extensibleClassName)
 {
     $exceptionMessage = "Class '{$extensibleClassName}' must implement an interface, " . "which extends from '" . self::EXTENSIBLE_INTERFACE_NAME . "'";
     $notExtensibleClassFlag = '';
     if (isset($this->classInterfaceMap[$extensibleClassName])) {
         if ($notExtensibleClassFlag === $this->classInterfaceMap[$extensibleClassName]) {
             throw new \LogicException($exceptionMessage);
         } else {
             return $this->classInterfaceMap[$extensibleClassName];
         }
     }
     $modelReflection = new \ReflectionClass($extensibleClassName);
     if ($modelReflection->isInterface() && $modelReflection->isSubClassOf(self::EXTENSIBLE_INTERFACE_NAME) && $modelReflection->hasMethod('getExtensionAttributes')) {
         $this->classInterfaceMap[$extensibleClassName] = $extensibleClassName;
         return $this->classInterfaceMap[$extensibleClassName];
     }
     foreach ($modelReflection->getInterfaces() as $interfaceReflection) {
         if ($interfaceReflection->isSubclassOf(self::EXTENSIBLE_INTERFACE_NAME) && $interfaceReflection->hasMethod('getExtensionAttributes')) {
             $this->classInterfaceMap[$extensibleClassName] = $interfaceReflection->getName();
             return $this->classInterfaceMap[$extensibleClassName];
         }
     }
     $this->classInterfaceMap[$extensibleClassName] = $notExtensibleClassFlag;
     throw new \LogicException($exceptionMessage);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:31,代码来源:ExtensionAttributesFactory.php

示例4: fetchRecursiveDocComment

 /**
  * Fetch all doc comments for inherit values
  *
  * @return string
  */
 private function fetchRecursiveDocComment()
 {
     $currentMethodName = $this->reflection->getName();
     $docCommentList[] = $this->reflection->getDocComment();
     // fetch all doc blocks for method from parent classes
     $docCommentFetched = $this->fetchRecursiveDocBlockFromParent($this->classReflection, $currentMethodName);
     if ($docCommentFetched) {
         $docCommentList = array_merge($docCommentList, $docCommentFetched);
     }
     // fetch doc blocks from interfaces
     $interfaceReflectionList = $this->classReflection->getInterfaces();
     foreach ($interfaceReflectionList as $interfaceReflection) {
         if (!$interfaceReflection->hasMethod($currentMethodName)) {
             continue;
         }
         $docCommentList[] = $interfaceReflection->getMethod($currentMethodName)->getDocComment();
     }
     $normalizedDocCommentList = array_map(function ($docComment) {
         $docComment = str_replace('/**', '', $docComment);
         $docComment = str_replace('*/', '', $docComment);
         return $docComment;
     }, $docCommentList);
     $docComment = '/**' . implode(PHP_EOL, $normalizedDocCommentList) . '*/';
     return $docComment;
 }
开发者ID:zendframework,项目名称:zend-server,代码行数:30,代码来源:ReflectionMethod.php

示例5: convert

 /**
  *
  *
  * @param unknown_type $data
  */
 public function convert($data)
 {
     if (is_object($data)) {
         if (class_exists('Doctrine_Record') && $data instanceof Doctrine_Record) {
             $adapter = new DoctrineRecordAdapter();
         } else {
             if (class_exists('Doctrine_Collection') && $data instanceof Doctrine_Collection) {
                 $adapter = new DoctrineCollectionAdapter();
             } else {
                 $reflector = new ReflectionClass(get_class($data));
                 $interfaces = $reflector->getInterfaces();
                 if (array_key_exists("Persistent", $interfaces)) {
                     $adapter = new PropelAdapter();
                 }
             }
         }
         if (isset($adapter)) {
             return $adapter->run($data);
         } else {
             return $data;
         }
     } else {
         if (is_array($data)) {
             return $this->iterateArray($data);
         } else {
             return $data;
         }
     }
 }
开发者ID:rande,项目名称:sfAmfPlugin,代码行数:34,代码来源:sfAdapterDelegate.php

示例6: evaluate

 /**
  * @inheritdoc
  */
 public function evaluate($fqcn, $description = '', $returnResult = FALSE)
 {
     $refl = new \ReflectionClass($fqcn);
     foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC) as $meth) {
         // we skip static public and magic method
         if ($meth->isStatic() || preg_match('#^__#', $meth->name)) {
             continue;
         }
         $found = false;
         // we seek in each interface
         foreach ($refl->getInterfaces() as $interf) {
             if ($interf->hasMethod($meth->name)) {
                 $found = true;
                 break;
             }
         }
         // if not found, error or exception
         if (!$found) {
             if ($returnResult) {
                 return false;
             } else {
                 $this->fail($fqcn, $description . PHP_EOL . $meth->name . " has no declaring interface");
             }
         }
     }
     return true;
 }
开发者ID:trismegiste,项目名称:phpunit-assert-solid,代码行数:30,代码来源:NoMethodWithoutContract.php

示例7: create

 /**
  * Create extension attributes object, custom for each extensible class.
  *
  * @param string $extensibleClassName
  * @param array $data
  * @return object
  */
 public function create($extensibleClassName, $data = [])
 {
     $modelReflection = new \ReflectionClass($extensibleClassName);
     $implementsExtensibleInterface = false;
     $extensibleInterfaceName = 'Magento\\Framework\\Api\\ExtensibleDataInterface';
     foreach ($modelReflection->getInterfaces() as $interfaceReflection) {
         if ($interfaceReflection->isSubclassOf($extensibleInterfaceName) && $interfaceReflection->hasMethod('getExtensionAttributes')) {
             $implementsExtensibleInterface = true;
             break;
         }
     }
     if (!$implementsExtensibleInterface) {
         throw new \LogicException("Class '{$extensibleClassName}' must implement an interface, " . "which extends from 'Magento\\Framework\\Api\\ExtensibleDataInterface'");
     }
     $methodReflection = $interfaceReflection->getMethod('getExtensionAttributes');
     if ($methodReflection->getDeclaringClass() == $extensibleInterfaceName) {
         throw new \LogicException("Method 'getExtensionAttributes' must be overridden in the interfaces " . "which extend 'Magento\\Framework\\Api\\ExtensibleDataInterface'. " . "Concrete return type should be specified.");
     }
     $interfaceName = '\\' . $interfaceReflection->getName();
     $extensionClassName = substr($interfaceName, 0, -strlen('Interface')) . 'Extension';
     $extensionInterfaceName = $extensionClassName . 'Interface';
     /** Ensure that proper return type of getExtensionAttributes() method is specified */
     $methodDocBlock = $methodReflection->getDocComment();
     $pattern = "/@return\\s+" . str_replace('\\', '\\\\', $extensionInterfaceName) . "/";
     if (!preg_match($pattern, $methodDocBlock)) {
         throw new \LogicException("Method 'getExtensionAttributes' must be overridden in the interfaces " . "which extend 'Magento\\Framework\\Api\\ExtensibleDataInterface'. " . "Concrete return type must be specified. Please fix :" . $interfaceName);
     }
     $extensionFactoryName = $extensionClassName . 'Factory';
     $extensionFactory = $this->_objectManager->create($extensionFactoryName);
     return $extensionFactory->create($data);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:38,代码来源:ExtensionAttributesFactory.php

示例8: getInterfaces

 /**
  * Get all interfaces used by this class
  *
  * @return    Nerd\Design\Enumerable      Enumerable array of interfaces used by this class
  */
 public function getInterfaces()
 {
     $interfaces = parent::getInterfaces();
     foreach ($interfaces as $key => $interface) {
         $interfaces[$key] = new Klass($interface->getName());
     }
     return new Collection($interfaces);
 }
开发者ID:nerdsrescueme,项目名称:Core,代码行数:13,代码来源:klass.php

示例9: getInterfaces

 /**
  * Get all implemented interfaces.
  *
  * @return ReflectionClass[] An associative `array` of interfaces, with keys as interface names and
  * the array values as `ReflectionClass` objects.
  */
 public function getInterfaces()
 {
     $interfaces = array();
     foreach (parent::getInterfaces() as $name => $interface) {
         $interfaces[$name] = new ReflectionClass($interface);
     }
     return $interfaces;
 }
开发者ID:mohiva,项目名称:common,代码行数:14,代码来源:ReflectionClass.php

示例10: getInterfaces

 static function getInterfaces($name)
 {
     $reflection = new ReflectionClass($name);
     if ($reflection->isInterface()) {
         return array($name);
     }
     return self::_onlyParents($reflection->getInterfaces());
 }
开发者ID:anykey84,项目名称:YaBackup,代码行数:8,代码来源:lmbReflectionHelper.class.php

示例11: getInterfaces

 public function getInterfaces()
 {
     $result = array();
     foreach (parent::getInterfaces() as $interface) {
         $result[] = $this->createReflectionAnnotatedClass($interface);
     }
     return $result;
 }
开发者ID:mopolo,项目名称:minerest-server,代码行数:8,代码来源:ReflectionAnnotatedClass.php

示例12: testGetInstance

 /**
  * Tests the Model Singleton Factory Method 
  */
 public function testGetInstance()
 {
     // Test Factory Method
     $model = Model::getInstance();
     // test assertion - Model::getInstance() non-null
     $this->assertNotNull($model, "Expecting instance not null");
     // utilize reflection for the interface test assertion
     $this->classReflector = new ReflectionClass($model);
     $interfaces = $this->classReflector->getInterfaces();
     foreach ($interfaces as $interface) {
         $hasInterface = $interface->name == 'IModel' ? true : false;
         if ($hasInterface) {
             break;
         }
     }
     // test assertion - Model implement IModel
     $this->assertTrue($hasInterface, 'Class instance implements IModel');
 }
开发者ID:pkdevboxy,项目名称:puremvc-php-standard-unittests,代码行数:21,代码来源:ModelTest.php

示例13: getInterfaces

 /**
  * Replacement for the original getInterfaces() method which makes sure
  * that \TYPO3\Flow\Reflection\ClassReflection objects are returned instead of the
  * original ReflectionClass instances.
  *
  * @return array of \TYPO3\Flow\Reflection\ClassReflection Class reflection objects of the properties in this class
  */
 public function getInterfaces()
 {
     $extendedInterfaces = array();
     $interfaces = parent::getInterfaces();
     foreach ($interfaces as $interface) {
         $extendedInterfaces[] = new ClassReflection($interface->getName());
     }
     return $extendedInterfaces;
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:16,代码来源:ClassReflection.php

示例14: getInterfacesTagList

 /**
  * @param \ReflectionClass $reflectionClass
  *
  * @return LegacyMethodTag[]|Method[]
  */
 private function getInterfacesTagList(\ReflectionClass $reflectionClass)
 {
     $interfaces = $reflectionClass->getInterfaces();
     $tagList = array();
     foreach ($interfaces as $interface) {
         $tagList = array_merge($tagList, $this->classRetriever->getTagList($interface));
     }
     return $tagList;
 }
开发者ID:timpressive,项目名称:art-auction,代码行数:14,代码来源:ClassAndInterfaceTagRetriever.php

示例15: implementsInterface

 public static function implementsInterface($className, $interfaceName)
 {
     $r = new ReflectionClass($className);
     foreach ($r->getInterfaces() as $in) {
         if (strtolower($in->getName()) == strtolower($interfaceName)) {
             return true;
         }
     }
     return false;
 }
开发者ID:nemiah,项目名称:trinityDB,代码行数:10,代码来源:PMReflector.class.php


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