當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。