本文整理汇总了PHP中ReflectionClass::isSubClassOf方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::isSubClassOf方法的具体用法?PHP ReflectionClass::isSubClassOf怎么用?PHP ReflectionClass::isSubClassOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::isSubClassOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* @see sfGenerator
*/
public function generate($params = array())
{
$this->params = $params;
foreach (array('index_class', 'moduleName') as $required) {
if (!isset($this->params[$required])) {
throw new xfGeneratorException('You must specify "' . $required . '".');
}
}
if (!class_exists($this->params['index_class'])) {
throw new xfGeneratorException('Unable to build interface for nonexistant index "' . $this->params['index_class'] . '"');
}
if (null !== ($form = $this->get('simple.form.class', null))) {
$reflection = new ReflectionClass($form);
if (!$reflection->isSubClassOf(new ReflectionClass('xfForm'))) {
throw new xfGeneratorException('Form class must extend xfForm');
}
}
// check to see if theme exists
if (!isset($this->params['theme'])) {
$this->params['theme'] = 'default';
}
$themeDir = $this->generatorManager->getConfiguration()->getGeneratorTemplate($this->getGeneratorClass(), $this->params['theme'], '');
$this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
$this->setModuleName($this->params['moduleName']);
$this->setTheme($this->params['theme']);
$themeFiles = sfFinder::type('file')->relative()->discard('.*')->in($themeDir);
$this->generatePhpFiles($this->generatedModuleName, $themeFiles);
$data = "require_once(sfConfig::get('sf_module_cache_dir') . '/" . $this->generatedModuleName . "/actions/actions.class.php');";
$data .= "require_once(sfConfig::get('sf_module_cache_dir') . '/" . $this->generatedModuleName . "/actions/components.class.php');";
return $data;
}
示例2: 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);
}
示例3: add
public function add($className)
{
$reflection = new ReflectionClass(new $className());
if ($reflection->isSubClassOf("Sabel_Test_TestSuite")) {
$this->addTest($reflection->getMethod("suite")->invoke(null));
} else {
$this->addTest(new self($className));
}
}
示例4: __construct
/**
* Constructor
*
* @param string $translationClass
* @param string $entityClass
* @param string $field
*
* @throws \InvalidArgumentException
*/
public function __construct($translationClass, $entityClass, $field)
{
$refl = new \ReflectionClass($translationClass);
if (!$refl->isSubClassOf('Akeneo\\Component\\Localization\\Model\\AbstractTranslation')) {
throw new \InvalidArgumentException(sprintf('The translation class "%s" must extends "%s"', $translationClass, 'Akeneo\\Component\\Localization\\Model\\AbstractTranslation'));
}
$this->translationClass = $translationClass;
$this->entityClass = $entityClass;
$this->field = $field;
}
示例5: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
if (!class_exists($arguments['class'])) {
throw new InvalidArgumentException(sprintf('The class "%s" could not be found.', $arguments['class']));
}
$r = new ReflectionClass($arguments['class']);
if (0 !== strpos($r->getFilename(), sfConfig::get('sf_lib_dir'))) {
throw new InvalidArgumentException(sprintf('The class "%s" is not located in the project lib/ directory.', $r->getName()));
}
$path = str_replace(sfConfig::get('sf_lib_dir'), '', dirname($r->getFilename()));
$test = sfConfig::get('sf_test_dir') . '/unit' . $path . '/' . $r->getName() . 'Test.php';
if (file_exists($test)) {
if ($options['force']) {
$this->getFilesystem()->remove($test);
} else {
$this->logSection('task', sprintf('A test script for the class "%s" already exists.', $r->getName()));
if (isset($options['editor-cmd'])) {
$this->getFilesystem()->sh($options['editor-cmd'] . ' ' . $test);
}
return 1;
}
}
$template = '';
$database = false;
if (!$options['disable-defaults']) {
if ($r->isSubClassOf('sfForm')) {
$options['without-methods'] = true;
if (!$r->isAbstract()) {
$template = 'Form';
}
}
if (class_exists('Propel') && ($r->isSubclassOf('BaseObject') || 'Peer' == substr($r->getName(), -4) || $r->isSubclassOf('sfFormPropel')) || class_exists('Doctrine') && ($r->isSubclassOf('Doctrine_Record') || $r->isSubclassOf('Doctrine_Table') || $r->isSubclassOf('sfFormDoctrine')) || $r->isSubclassOf('sfFormFilter')) {
$database = true;
}
}
$tests = '';
if (!$options['without-methods']) {
foreach ($r->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() == $r->getName() && $method->isPublic()) {
$type = $method->isStatic() ? '::' : '->';
$tests .= <<<EOF
// {$type}{$method->getName()}()
\$t->diag('{$type}{$method->getName()}()');
EOF;
}
}
}
$this->getFilesystem()->copy(dirname(__FILE__) . sprintf('/skeleton/test/UnitTest%s.php', $template), $test);
$this->getFilesystem()->replaceTokens($test, '##', '##', array('CLASS' => $r->getName(), 'TEST_DIR' => str_repeat('/..', substr_count($path, DIRECTORY_SEPARATOR) + 1), 'TESTS' => $tests, 'DATABASE' => $database ? "\n\$databaseManager = new sfDatabaseManager(\$configuration);\n" : ''));
if (isset($options['editor-cmd'])) {
$this->getFilesystem()->sh($options['editor-cmd'] . ' ' . $test);
}
}
示例6: supports
/**
* Inspects if current interface injector is to be used with a given class
*
* @param string $object
* @return boolean
*/
public function supports($object)
{
if (is_string($object)) {
$reflection = new \ReflectionClass($object);
return $reflection->isSubClassOf($this->class) || $object === $this->class;
}
if (!is_object($object)) {
throw new InvalidArgumentException(sprintf("%s expects class or object, %s given", __METHOD__, substr(str_replace("\n", '', var_export($object, true)), 0, 10)));
}
return is_a($object, $this->class);
}
示例7: executeIndex
public function executeIndex(dmWebRequest $request)
{
$this->charts = array();
foreach ($this->getServiceContainer()->getServiceIds() as $serviceId) {
if (substr($serviceId, -6) === '_chart') {
$reflection = new ReflectionClass($this->getServiceContainer()->getParameter($serviceId . '.class'));
if ($reflection->isSubClassOf('dmChart')) {
$this->charts[substr($serviceId, 0, strlen($serviceId) - 6)] = $this->getServiceContainer()->getParameter($serviceId . '.options');
}
}
}
$this->selectedIndex = array_search($request->getParameter('name'), array_keys($this->charts));
}
示例8: isAccept
public function isAccept($state)
{
if (is_string($state) && class_exists($state)) {
$checkClass = 'FormObject\\StateBase';
$newClass = new \ReflectionClass($state);
if ($newClass->isSubClassOf($checkClass)) {
return true;
}
} elseif ($state instanceof State) {
return true;
}
return false;
}
示例9: add
public function add($testName)
{
$dir = RUN_BASE . DS . "tests" . DS . "functional" . DS;
$parts = explode("_", $testName);
$last = array_pop($parts);
if (count($parts) > 0) {
$dir .= strtolower(implode(DS, $parts)) . DS;
}
$className = "Functional_" . $testName;
Sabel::fileUsing($dir . $last . ".php", true);
$reflection = new ReflectionClass($className);
if ($reflection->isSubClassOf("Sabel_Test_TestSuite")) {
$this->addTest($reflection->getMethod("suite")->invoke(null));
} else {
$this->addTest(new self($className));
}
}
示例10: onRegen
private function onRegen()
{
// Grabing essential data about the board
$boardType = $this->db->select("boards")->fields("boards", array("board_type"))->condition("board_name", $this->request['board'])->execute()->fetchField();
// Nope
if ($boardType === false) {
$this->errorMessage = sprintf(_gettext("Couldn't find board /%s/."), $this->request['board']);
return false;
}
//Check against our built-in board types.
if (in_array($boardType, array(0, 1, 2, 3))) {
$types = array('image', 'text', 'oekaki', 'upload');
$module_to_load = $types[$boardType];
} else {
$result = $this->db->select("modules")->fields("modules", array("module_variables", "module_directory"))->condition("module_application", 1)->execute()->fetchAll();
foreach ($result as $line) {
$varibles = unserialize($line->module_variables);
if (isset($variables['board_type_id']) && $variables['board_type_id'] == $boardType) {
$module_to_load = $line->module_directory;
}
}
}
// Module loading time!
$moduledir = kxFunc::getAppDir("board") . '/modules/public/' . $module_to_load . '/';
if (file_exists($moduledir . $module_to_load . '.php')) {
require_once $moduledir . $module_to_load . '.php';
}
// Some routine checks...
$className = "public_board_" . $module_to_load . "_" . $module_to_load;
if (class_exists($className)) {
$module_class = new ReflectionClass($className);
if ($module_class->isSubClassOf(new ReflectionClass('kxCmd'))) {
$this->_boardClass = $module_class->newInstance($this->environment);
$this->_boardClass->execute($this->environment);
} else {
$this->errorMessage = sprintf("Couldn't find module %s", $className);
return false;
}
}
$this->_boardClass->regeneratePages();
$this->_boardClass->regenerateThreads();
return true;
}
示例11: run
/**
* routing(className and methodName) by Hoimi\Request
*
* this is template method
* subclass need to implement "resolveClassName" and "resolveMethodName"
* @param Request $request
* @return array(instance of Action, methodName)
* @throws \RuntimeException
* @throws Exception\NotFoundException
*/
public function run(Request $request)
{
$url = $request->parseUrl();
if (!isset($url['path']) || !$url['path']) {
$url['path'] = '/';
}
$className = $this->resolveClassName($request);
if ($className === null || !class_exists($className)) {
throw new NotFoundException('Unsupported class:' . $className);
}
$clazz = new \ReflectionClass($className);
if (!$clazz->isSubClassOf('Hoimi\\BaseAction')) {
throw new \RuntimeException('InvalidClass:' . $className);
}
$requestMethod = $this->resolveMethodName($request);
if (!$clazz->hasMethod($requestMethod)) {
throw new NotFoundException('unsupported method :' . $requestMethod . '@' . $url['path']);
}
$action = $clazz->newInstance();
return array($action, $requestMethod);
}
示例12: _extractValidationMessages
/**
* Looks for models in the application and extracts the validation messages
* to be added to the translation map
*
* @return void
*/
protected function _extractValidationMessages()
{
if (!$this->_extractValidation) {
return;
}
App::uses('AppModel', 'Model');
$plugin = null;
if (!empty($this->params['plugin'])) {
App::uses($this->params['plugin'] . 'AppModel', $this->params['plugin'] . '.Model');
$plugin = $this->params['plugin'] . '.';
}
$models = App::objects($plugin . 'Model', null, false);
foreach ($models as $model) {
App::uses($model, $plugin . 'Model');
$reflection = new ReflectionClass($model);
if (!$reflection->isSubClassOf('Model')) {
continue;
}
$properties = $reflection->getDefaultProperties();
$validate = $properties['validate'];
if (empty($validate)) {
continue;
}
$file = $reflection->getFileName();
$domain = $this->_validationDomain;
if (!empty($properties['validationDomain'])) {
$domain = $properties['validationDomain'];
}
foreach ($validate as $field => $rules) {
$this->_processValidationRules($field, $rules, $file, $domain);
}
}
}
示例13: getLoadedTasks
public function getLoadedTasks()
{
$parent = new ReflectionClass('Doctrine_Task');
$classes = get_declared_classes();
$tasks = array();
foreach ($classes as $className) {
$class = new ReflectionClass($className);
if ($class->isSubClassOf($parent)) {
$task = str_replace('Doctrine_Task_', '', $className);
$tasks[$task] = $task;
}
}
return array_merge($this->_tasks, $tasks);
}
示例14: getPluginModels
/**
* Get all the models which are a part of a plugin and the name of the plugin.
* The array format is modelName => pluginName
*
* @todo This method is ugly and is a very weird way of finding the models which
* belong to plugins. If we could come up with a better way that'd be great
* @return array $pluginModels
*/
public function getPluginModels()
{
if (!$this->pluginModels) {
$plugins = $this->_getPlugins();
foreach ($plugins as $plugin) {
$path = sfConfig::get('sf_plugins_dir') . '/' . $plugin . '/lib/model/doctrine';
$models = sfFinder::type('file')->name('*.php')->in($path);
foreach ($models as $path) {
$info = pathinfo($path);
$e = explode('.', $info['filename']);
$modelName = substr($e[0], 6, strlen($e[0]));
if (class_exists($e[0]) && class_exists($modelName)) {
$parent = new ReflectionClass('Doctrine_Record');
$reflection = new ReflectionClass($modelName);
if ($reflection->isSubClassOf($parent)) {
$pluginName = basename(dirname(dirname(dirname($info['dirname']))));
$this->pluginModels[$modelName] = $pluginName;
$generators = Doctrine::getTable($modelName)->getGenerators();
foreach ($generators as $generator) {
$this->pluginModels[$generator->getOption('className')] = $pluginName;
}
}
}
}
}
}
return $this->pluginModels;
}
示例15: resolveCommand
function resolveCommand($cmd)
{
$classroot = $this->controllerMap->getClassroot($cmd);
$namespaceRoot = core\ApplicationRegistry::getNamespaceRoot();
$filepath = core\HelperFunctions::replaceSlashes("{$namespaceRoot}/command/{$classroot}.php");
$classname = "\\{$namespaceRoot}\\command\\{$classroot}";
if (file_exists($filepath)) {
require_once $filepath;
if (class_exists($classname)) {
$cmd_class = new \ReflectionClass($classname);
if ($cmd_class->isSubClassOf(self::$base_cmd)) {
return $cmd_class->newInstance();
}
}
}
return null;
}