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


PHP ReflectionClass::isAbstract方法代码示例

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


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

示例1: make

 public static function make($class, $params = array())
 {
     if (!class_exists($class)) {
         throw new \RuntimeException("Stubbed class {$class} doesn't exist. Use Stub::factory instead");
     }
     $reflection = new \ReflectionClass($class);
     $callables = array_filter($params, function ($a) {
         return is_callable($a);
     });
     if (!empty($callables)) {
         if ($reflection->isAbstract()) {
             $mock = \PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($class, array_keys($callables), '', false);
         } else {
             $mock = \PHPUnit_Framework_MockObject_Generator::getMock($class, array_keys($callables), array(), '', false);
         }
     } else {
         if ($reflection->isAbstract()) {
             $mock = \PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($class, null, '', false);
         } else {
             $mock = \PHPUnit_Framework_MockObject_Generator::getMock($class, null, array(), '', false);
         }
     }
     self::bindParameters($mock, $params);
     $mock->__mocked = $class;
     return $mock;
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:26,代码来源:Stub.php

示例2: 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

示例3: testContracts

 public function testContracts()
 {
     $this->assertTrue($this->reflectedObject->isAbstract());
     $this->assertTrue($this->reflectedObject->hasMethod('cleanVar'));
     $this->assertTrue($this->reflectedObject->hasMethod('getVar'));
     $this->assertInstanceOf('\\Xoops\\Core\\Text\\Sanitizer', \PHPUnit_Framework_Assert::readAttribute($this->object, 'ts'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:7,代码来源:DtypeAbstractTest.php

示例4: exportCode

 /**
  * Exports the PHP code
  *
  * @return string
  */
 public function exportCode()
 {
     $code_lines = array();
     $code_lines[] = '<?php';
     // Export the namespace
     if ($this->_reflection_class->getNamespaceName()) {
         $code_lines[] = '';
         $code_lines[] = 'namespace ' . $this->_reflection_class->getNamespaceName() . ';';
         $code_lines[] = '';
     }
     // Export the class' signature
     $code_lines[] = sprintf('%s%s%s %s%s%s', $this->_reflection_class->isAbstract() ? 'abstract ' : '', $this->_reflection_class->isFinal() ? 'final ' : '', $this->_reflection_class->isInterface() ? 'interface' : ($this->_reflection_class->isTrait() ? 'trait' : 'class'), $this->getClassName(), $this->_getParentClassName() ? " extends {$this->_getParentClassName()}" : '', $this->_getInterfaceNames() ? " implements " . join(', ', $this->_getInterfaceNames()) : '');
     $code_lines[] = '{';
     $code_lines[] = '';
     // Export constants
     foreach ($this->_reflection_class->getConstants() as $name => $value) {
         $reflection_constant = new ReflectionConstant($name, $value);
         $code_lines[] = "\t" . $reflection_constant->exportCode();
         $code_lines[] = '';
     }
     // Export properties
     foreach ($this->_reflection_class->getProperties() as $property) {
         $reflection_property = new ReflectionProperty($property);
         $code_lines[] = "\t" . $reflection_property->exportCode();
         $code_lines[] = '';
     }
     // Export methods
     foreach ($this->_reflection_class->getMethods() as $method) {
         $reflection_method = new ReflectionMethod($method);
         $code_lines[] = "\t" . $reflection_method->exportCode();
         $code_lines[] = '';
     }
     $code_lines[] = '}';
     return join("\n", $code_lines);
 }
开发者ID:michalkoslab,项目名称:Helpers,代码行数:40,代码来源:ReflectionClass.php

示例5: testContracts

 public function testContracts()
 {
     $this->assertTrue($this->reflectedObject->isAbstract());
     $this->assertTrue($this->reflectedObject->hasMethod('getDhtmlEditorSupport'));
     $this->assertTrue($this->reflectedObject->hasMethod('registerExtensionProcessing'));
     $this->assertTrue($this->reflectedObject->hasMethod('getEditorButtonHtml'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:7,代码来源:ExtensionAbstractTest.php

示例6: testContracts

 public function testContracts()
 {
     $this->assertTrue($this->reflectedObject->isAbstract());
     $this->assertTrue($this->reflectedObject->hasMethod('getDefaultConfig'));
     $this->assertTrue($this->reflectedObject->hasProperty('ts'));
     $this->assertTrue($this->reflectedObject->hasProperty('shortcodes'));
     $this->assertTrue($this->reflectedObject->hasProperty('config'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:8,代码来源:SanitizerComponentTest.php

示例7: loadMetadataForClass

 /**
  * Loads the metadata for the specified class into the provided container.
  *
  * @param string        $className
  * @param ClassMetadata $metadata
  *
  * @throws \Exception
  * @return void
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     if (!$metadata instanceof \Doctrine\ORM\Mapping\ClassMetadata) {
         throw new \Exception('Error: class metadata object is the wrong type');
     }
     $refClass = new \ReflectionClass($className);
     $classDocBlock = $refClass->getDocComment();
     if (!$classDocBlock || strpos($classDocBlock, '@Table') === false) {
         $metadata->setPrimaryTable(['name' => $this->_getTableName($className)]);
     }
     $needAutoGenerator = false;
     foreach ($refClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) {
         $propName = $prop->getName();
         try {
             $mapping = $metadata->getFieldMapping($propName);
         } catch (MappingException $e) {
             $mapping = null;
         }
         if (!$mapping) {
             if ($propName == 'createdAt') {
                 if (!$this->isTransient($className) && !$refClass->isAbstract() && call_user_func($className . '::useAutoTimestamp')) {
                     $metadata->mapField(['fieldName' => 'createdAt', 'columnName' => call_user_func($className . '::getCreatedAtColumn'), 'type' => 'datetime']);
                 }
             } else {
                 if ($propName == 'updatedAt') {
                     if (!$this->isTransient($className) && !$refClass->isAbstract() && call_user_func($className . '::useAutoTimestamp')) {
                         $metadata->mapField(['fieldName' => 'updatedAt', 'columnName' => call_user_func($className . '::getUpdatedAtColumn'), 'type' => 'datetime']);
                     }
                 } else {
                     $columnName = Inflector::tableize($propName);
                     $fieldMap = ['fieldName' => $propName, 'columnName' => $columnName, 'type' => $this->_getDefaultDataType($columnName)];
                     if ($columnName == 'id') {
                         $fieldMap['id'] = true;
                         $fieldMap['autoincrement'] = true;
                         $fieldMap['unsigned'] = true;
                         $needAutoGenerator = true;
                     } else {
                         if (in_array($columnName, ['price', 'tax', 'amount', 'cost', 'total'])) {
                             // DECIMAL(10,2)
                             $fieldMap['precision'] = 10;
                             $fieldMap['scale'] = 2;
                         }
                     }
                     $metadata->mapField($fieldMap);
                 }
             }
         }
     }
     if ($needAutoGenerator && !$metadata->usesIdGenerator()) {
         $metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_AUTO);
     }
 }
开发者ID:packaged,项目名称:mappers,代码行数:61,代码来源:AutoMappingDriver.php

示例8: testContracts

 public function testContracts()
 {
     $this->assertTrue($this->reflectedObject->isAbstract());
     $this->assertTrue($this->reflectedObject->hasMethod('get'));
     $this->assertTrue($this->reflectedObject->hasMethod('set'));
     $this->assertTrue($this->reflectedObject->hasMethod('getAll'));
     $this->assertTrue($this->reflectedObject->hasMethod('getNames'));
     $this->assertTrue($this->reflectedObject->hasMethod('has'));
     $this->assertTrue($this->reflectedObject->hasMethod('remove'));
     $this->assertTrue($this->reflectedObject->hasMethod('clear'));
     $this->assertTrue($this->reflectedObject->hasMethod('setAll'));
     $this->assertTrue($this->reflectedObject->hasMethod('setMerge'));
     $this->assertTrue($this->reflectedObject->hasMethod('setArrayItem'));
     $this->assertTrue($this->reflectedObject->hasMethod('getAllLike'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:15,代码来源:ConfigurationAbstractTest.php

示例9: testClassIndex

 /**
  * @param \Donquixote\HastyReflectionCommon\Canvas\ClassIndex\ClassIndexInterface $classIndex
  * @param string $class
  *
  * @dataProvider provideClassIndexArgs()
  */
 function testClassIndex(ClassIndexInterface $classIndex, $class)
 {
     $classReflection = $classIndex->classGetReflection($class);
     $reflectionClass = new \ReflectionClass($class);
     // Test identity.
     $this->assertTrue($classReflection === $classIndex->classGetReflection($class));
     // Test class type/info.
     $expectedIsClass = !$reflectionClass->isInterface() && !$reflectionClass->isTrait();
     $this->assertEquals($reflectionClass->getName(), $classReflection->getName());
     $this->assertEquals($reflectionClass->getShortName(), $classReflection->getShortName());
     $this->assertEquals($reflectionClass->getDocComment(), $classReflection->getDocComment());
     $this->assertEquals($reflectionClass->isInterface(), $classReflection->isInterface());
     $this->assertEquals($reflectionClass->isTrait(), $classReflection->isTrait());
     $this->assertEquals($expectedIsClass, $classReflection->isClass());
     $this->assertEquals($reflectionClass->isAbstract() && $expectedIsClass, $classReflection->isAbstractClass());
     // Test context.
     $this->assertEquals($reflectionClass->getNamespaceName(), $classReflection->getNamespaceUseContext()->getNamespaceName());
     // Test interfaces
     foreach ($classReflection->getOwnInterfaces() as $interfaceName => $interfaceReflection) {
         $this->assertTrue($reflectionClass->implementsInterface($interfaceName));
     }
     foreach ($reflectionClass->getInterfaceNames() as $interfaceName) {
         $this->assertTrue($classReflection->extendsOrImplementsInterface($interfaceName, FALSE));
     }
     $expectedAllInterfaceNames = $expectedAllAndSelfInterfaceNames = $reflectionClass->getInterfaceNames();
     if ($reflectionClass->isInterface()) {
         array_unshift($expectedAllAndSelfInterfaceNames, $class);
     }
     $this->assertEqualSorted($expectedAllAndSelfInterfaceNames, array_keys($classReflection->getAllInterfaces(TRUE)));
     $this->assertEqualSorted($expectedAllInterfaceNames, array_keys($classReflection->getAllInterfaces(FALSE)));
     $expectedMethodNames = array();
     $expectedOwnMethodNames = array();
     foreach ($reflectionClass->getMethods() as $method) {
         $expectedMethodNames[] = $method->getName();
         if ($method->getDeclaringClass()->getName() === $reflectionClass->getName()) {
             $expectedOwnMethodNames[] = $method->getName();
         }
     }
     $this->assertEquals($expectedOwnMethodNames, array_keys($classReflection->getOwnMethods()));
     $this->assertEqualSorted($expectedMethodNames, array_keys($classReflection->getMethods()));
     $methodReflections = $classReflection->getMethods();
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         $methodReflection = $methodReflections[$reflectionMethod->getShortName()];
         $this->assertEqualMethods($reflectionMethod, $methodReflection);
     }
     // isAbstract() is a beast, so we test it least.
     $this->assertEquals($reflectionClass->isAbstract(), $classReflection->isAbstract());
 }
开发者ID:donquixote,项目名称:hasty-reflection-common,代码行数:54,代码来源:ClassIndexTest.php

示例10: allBlocksDataProvider

 /**
  * @return array
  */
 public function allBlocksDataProvider()
 {
     $blockClass = '';
     try {
         /** @var $website \Magento\Store\Model\Website */
         \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->setWebsiteId(0);
         $enabledModules = $this->_getEnabledModules();
         $skipBlocks = $this->_getBlocksToSkip();
         $templateBlocks = [];
         $blockMods = \Magento\Framework\App\Utility\Classes::collectModuleClasses('Block');
         foreach ($blockMods as $blockClass => $module) {
             if (!isset($enabledModules[$module]) || isset($skipBlocks[$blockClass])) {
                 continue;
             }
             $class = new \ReflectionClass($blockClass);
             if ($class->isAbstract() || !$class->isSubclassOf('Magento\\Framework\\View\\Element\\Template')) {
                 continue;
             }
             $templateBlocks = $this->_addBlock($module, $blockClass, $class, $templateBlocks);
         }
         return $templateBlocks;
     } catch (\Exception $e) {
         trigger_error("Corrupted data provider. Last known block instantiation attempt: '{$blockClass}'." . " Exception: {$e}", E_USER_ERROR);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:28,代码来源:BlockInstantiationTest.php

示例11: __construct

 /**
  * Constructor
  *
  * @param string|object $base_class Class name of the base class, or an instance
  * @param array $constructor_args (Optional) Arguments to pass to the constructor of the base class
  * @param array $constants (Optional) Constants to override
  */
 public function __construct($base_class, array $constructor_args = array(), array $constants = array())
 {
     // @codeCoverageIgnoreStart
     if (PHP_VERSION_ID < 50300) {
         trigger_error(get_class() . ': This class requires PHP version 5.3 or higher.', E_USER_ERROR);
     }
     // @codeCoverageIgnoreEnd
     if (is_object($base_class) && count($constructor_args)) {
         throw new Mollie_Testing_Exception('Unused constructor arguments for passed instance of "' . get_class($base_class) . '".');
     }
     // If it's an instance, just accept it
     if (is_object($base_class)) {
         $this->_base_class = $base_class;
     } elseif (!class_exists($base_class)) {
         throw new Mollie_Testing_Exception("Base class '{$base_class}' does not exist.");
     } else {
         $ref = new ReflectionClass($base_class);
         if ($ref->isAbstract()) {
             $ref = new ReflectionClass($this->createDerivedClass($base_class));
         }
         if ($ref->getConstructor() && count($constructor_args) < $ref->getConstructor()->getNumberOfRequiredParameters()) {
             throw new Mollie_Testing_Exception($ref->getConstructor()->getNumberOfRequiredParameters() . " constructor arguments required for '{$base_class}::__construct(...)'.");
         }
         $this->_base_class = sizeof($constructor_args) ? $ref->newInstanceArgs($constructor_args) : $ref->newInstance();
     }
 }
开发者ID:javolero,项目名称:Prestashop,代码行数:33,代码来源:impostor.php

示例12: renderContent

 protected function renderContent()
 {
     $placedViewTypes = $this->getPlacedViewTypes();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module->isEnabled()) {
             $p = $module->getParentModule();
             $viewClassNames = $module::getViewClassNames();
             foreach ($viewClassNames as $className) {
                 $viewReflectionClass = new ReflectionClass($className);
                 if (!$viewReflectionClass->isAbstract()) {
                     $portletRules = PortletRulesFactory::createPortletRulesByView($className);
                     if ($portletRules != null && $portletRules->allowOnDashboard()) {
                         if ($portletRules->allowMultiplePlacementOnDashboard() && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true || !$portletRules->allowMultiplePlacementOnDashboard() && !in_array($portletRules->getType(), $placedViewTypes) && PortletsSecurityUtil::doesCurrentUserHavePermissionToAddPortlet($portletRules) === true) {
                             $metadata = $className::getMetadata();
                             $url = Yii::app()->createUrl($this->moduleId . '/defaultPortlet/add', array('uniqueLayoutId' => $this->uniqueLayoutId, 'dashboardId' => $this->dashboardId, 'portletType' => $portletRules->getType()));
                             if (isset($metadata['perUser']['title'])) {
                                 $title = $metadata['perUser']['title'];
                             } else {
                                 continue;
                             }
                             MetadataUtil::resolveEvaluateSubString($title);
                             $sortablePortlets[$title] = array('url' => $url, 'title' => $title, 'portletRules' => $portletRules);
                         }
                     }
                 }
             }
         }
     }
     return PortletUtil::renderAddPortletsContent($sortablePortlets);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:31,代码来源:HomeDashboardPortletSelectionView.php

示例13: getPresenterClass

 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found.");
     }
     $reflection = new \ReflectionClass($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     } elseif ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     $this->cache[$name] = $class;
     if ($name !== ($realName = $this->unformatPresenterClass($class))) {
         trigger_error("Case mismatch on presenter name '{$name}', correct name is '{$realName}'.", E_USER_WARNING);
         $name = $realName;
     }
     return $class;
 }
开发者ID:jave007,项目名称:test,代码行数:32,代码来源:PresenterFactory.php

示例14: makeInstanceFromClassName

 private function makeInstanceFromClassName($className, array $alreadySeen)
 {
     $className = $this->resolveClassName($className);
     try {
         $refl = new ReflectionClass($className);
     } catch (ReflectionException $re) {
         throw new Core_Foundation_IoC_Exception(sprintf('This doesn\'t seem to be a class name: `%s`.', $className));
     }
     $args = array();
     if ($refl->isAbstract()) {
         throw new Core_Foundation_IoC_Exception(sprintf('Cannot build abstract class: `%s`.', $className));
     }
     $classConstructor = $refl->getConstructor();
     if ($classConstructor) {
         foreach ($classConstructor->getParameters() as $param) {
             $paramClass = $param->getClass();
             if ($paramClass) {
                 $args[] = $this->doMake($param->getClass()->getName(), $alreadySeen);
             } elseif ($param->isDefaultValueAvailable()) {
                 $args[] = $param->getDefaultValue();
             } else {
                 throw new Core_Foundation_IoC_Exception(sprintf('Cannot build a `%s`.', $className));
             }
         }
     }
     if (count($args) > 0) {
         return $refl->newInstanceArgs($args);
     } else {
         // newInstanceArgs with empty array fails in PHP 5.3 when the class
         // doesn't have an explicitly defined constructor
         return $refl->newInstance();
     }
 }
开发者ID:ortegon000,项目名称:tienda,代码行数:33,代码来源:Core_Foundation_IoC_Container.php

示例15: __autoload

function __autoload($className)
{
    if (function_exists('smartyAutoload') and smartyAutoload($className)) {
        return true;
    }
    $className = str_replace(chr(0), '', $className);
    $classDir = dirname(__FILE__) . '/../classes/';
    $overrideDir = dirname(__FILE__) . '/../override/classes/';
    $file_in_override = file_exists($overrideDir . $className . '.php');
    $file_in_classes = file_exists($classDir . $className . '.php');
    // This is a Core class and its name is the same as its declared name
    if (substr($className, -4) == 'Core') {
        require_once $classDir . substr($className, 0, -4) . '.php';
    } else {
        if ($file_in_override && $file_in_classes) {
            require_once $classDir . str_replace(chr(0), '', $className) . '.php';
            require_once $overrideDir . $className . '.php';
        } elseif (!$file_in_override && $file_in_classes) {
            require_once $classDir . str_replace(chr(0), '', $className) . '.php';
            $classInfos = new ReflectionClass($className . ((interface_exists($className, false) or class_exists($className, false)) ? '' : 'Core'));
            if (!$classInfos->isInterface() && substr($classInfos->name, -4) == 'Core') {
                eval(($classInfos->isAbstract() ? 'abstract ' : '') . 'class ' . $className . ' extends ' . $className . 'Core {}');
            }
        } elseif ($file_in_override && !$file_in_classes) {
            require_once $overrideDir . $className . '.php';
        }
    }
}
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:28,代码来源:autoload.php


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