本文整理汇总了PHP中get_class_methods函数的典型用法代码示例。如果您正苦于以下问题:PHP get_class_methods函数的具体用法?PHP get_class_methods怎么用?PHP get_class_methods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_class_methods函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: generateRoute
/**
* Add all the routes in the router in parameter
* @param $router Router
*/
public function generateRoute(Router $router)
{
foreach ($this->classes as $class) {
$classMethods = get_class_methods($this->namespace . $class . 'Controller');
$rc = new \ReflectionClass($this->namespace . $class . 'Controller');
$parent = $rc->getParentClass();
$parent = get_class_methods($parent->name);
$className = $this->namespace . $class . 'Controller';
foreach ($classMethods as $methodName) {
if (in_array($methodName, $parent) || $methodName == 'index') {
continue;
} else {
foreach (Router::getSupportedHttpMethods() as $httpMethod) {
if (strstr($methodName, $httpMethod)) {
continue 2;
}
if (in_array($methodName . $httpMethod, $classMethods)) {
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName . $httpMethod, $httpMethod);
unset($classMethods[$methodName . $httpMethod]);
}
}
$router->add('/' . strtolower($class) . '/' . $methodName, new $className(), $methodName);
}
}
$router->add('/' . strtolower($class), new $className(), 'index');
}
}
开发者ID:kazuohirai,项目名称:awayfromswag,代码行数:31,代码来源:ClassRouting.php
示例2: format_controller_methods
private function format_controller_methods($path, $file)
{
$this->load->helper("url");
$controller = array();
// only show php files
if (($extension = substr($file, strrpos($file, ".") + 1)) == "php") {
// include the class
include_once $path . "/" . $file;
$parts = explode(".", $file);
$class_lower = $parts["0"];
$class = ucfirst($class_lower);
// check if a class actually exists
if (class_exists($class) and get_parent_class($class) == "MY_Controller") {
// get a list of all methods
$controller["name"] = $class;
$controller["path"] = base_url() . $class_lower;
$controller["methods"] = array();
// get a list of all public methods
foreach (get_class_methods($class) as $method) {
$reflect = new ReflectionMethod($class, $method);
if ($reflect->isPublic()) {
// ignore some methods
$object = new $class();
if (!in_array($method, $object->internal_methods)) {
$method_array = array();
$method_array["name"] = $method;
$method_array["path"] = base_url() . $class_lower . "/" . $method;
$controller["methods"][] = $method_array;
}
}
}
}
}
return $controller;
}
开发者ID:MaizerGomes,项目名称:api,代码行数:35,代码来源:contents.php
示例3: getAccessibilityScope
/**
* Get Global Application CMS accessibility scope.
*
* @access public
* @static
* @uses Core\Config()
*
* @return array
*/
public static function getAccessibilityScope()
{
$scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php');
$builtin_scope = array('CMS\\Controllers\\CMS');
$builtin_actions = array();
$accessibility_scope = array();
foreach ($builtin_scope as $resource) {
$builtin_actions = array_merge($builtin_actions, get_class_methods($resource));
}
$builtin_actions = array_filter($builtin_actions, function ($action) {
return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true);
});
foreach ($scope as $resource) {
$resource = basename(str_replace('.php', '', $resource));
if ($resource !== 'cms') {
$controller_name = '\\CMS\\Controllers\\' . $resource;
$controller_class = new \ReflectionClass($controller_name);
if (!$controller_class->isInstantiable()) {
continue;
}
/* Create instance only if the controller class is instantiable */
$controller_object = new $controller_name();
if ($controller_object instanceof CMS\Controllers\CMS) {
$accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions);
array_push($accessibility_scope[$resource], 'index');
foreach ($accessibility_scope[$resource] as $key => $action_with_acl) {
if (in_array($action_with_acl, $controller_object->skipAclFor, true)) {
unset($accessibility_scope[$resource][$key]);
}
}
}
}
}
return $accessibility_scope;
}
开发者ID:weareathlon,项目名称:silla.io,代码行数:44,代码来源:cmsusers.php
示例4: testFormatJson
public function testFormatJson()
{
$server = ['HTTP_ACCEPT' => 'application/json', 'REQUEST_METHOD' => 'GET', 'SCRIPT_FILENAME' => 'my/base/path/my/request/uri/filename', 'REQUEST_URI' => 'my/base/path/my/request/uri', 'PHP_SELF' => 'my/base/path'];
$request = new Request(["callback" => ""], [], [], [], [], $server);
$apiResult = new Result($request);
$return = $apiResult->createResponse()->getContent();
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_STRING, $return);
$response = json_decode($return);
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response);
$this->assertObjectHasAttribute("meta", $response);
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->meta);
$this->assertObjectHasAttribute("response", $response);
$this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_OBJECT, $response->response);
$this->assertEquals(0, sizeof(get_object_vars($response->response)));
$this->assertEquals(0, sizeof(get_class_methods($response->response)));
$this->checkResponseFieldMeta($response, "api_version", V1::VERSION, \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
$this->checkResponseFieldMeta($response, "request", "GET my/base/path/my/request/uri", \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
$date = new \DateTime();
$now = $date->format('U');
$dateQuery = \DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
$nowQuery = $dateQuery->format('U');
$this->assertLessThan(1, $nowQuery - $now);
$this->assertDateAtom($response->meta->response_time);
$date = new \DateTime();
$nowU = $date->format('U');
$dateResp = \DateTime::createFromFormat(DATE_ATOM, $response->meta->response_time);
$respU = $dateResp->format('U');
$this->assertLessThan(3, abs($respU - $nowU), 'No more than 3sec between now and the query');
$this->checkResponseFieldMeta($response, "http_code", 200, \PHPUnit_Framework_Constraint_IsType::TYPE_INT);
$this->checkResponseFieldMeta($response, "charset", "UTF-8", \PHPUnit_Framework_Constraint_IsType::TYPE_STRING);
$this->assertObjectHasAttribute("error_message", $response->meta);
$this->assertNull($response->meta->error_message);
$this->assertObjectHasAttribute("error_details", $response->meta);
$this->assertNull($response->meta->error_details);
}
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:35,代码来源:ResultTest.php
示例5: setUp
public function setUp()
{
parent::setUp();
$this->subject = new ErrorHandlerCache();
$this->frontendUserMock = $this->getMock('R3H6\\Error404page\\Facade\\FrontendUser', get_class_methods('R3H6\\Error404page\\Facade\\FrontendUser'), array(), '', false);
$this->inject($this->subject, 'frontendUser', $this->frontendUserMock);
}
开发者ID:r3h6,项目名称:TYPO3.EXT.error404page,代码行数:7,代码来源:ErrorHandlerCacheTest.php
示例6: __construct
/**
* Sets up the admin environment and routes the request to the correct
* action_xxx method, while making sure the user is logged in.
*
* @return void
*/
public function __construct($action = NULL)
{
// Start a session
session_start();
// Set the correct default Content-Type header
if (ThumbsUp::is_ajax()) {
header('Content-Type: application/json; charset=utf-8');
} else {
header('Content-Type: text/html; charset=utf-8');
}
// Force the user to login
if (!self::logged_in()) {
return $this->action_login();
}
// If no action is specified, show the dashboard by default
if ($action === NULL) {
return $this->action_dashboard();
}
// Look for a corresponding action_method
if (in_array($action = 'action_' . $action, get_class_methods($this))) {
return $this->{$action}();
}
// Show an error for invalid actions
header('HTTP/1.1 404 Not Found');
exit('Page not found');
}
开发者ID:newbacknew,项目名称:owloo.com,代码行数:32,代码来源:thumbsup_admin.php
示例7: register
function register($group)
{
$group = basename($group);
$directory = DIR_FS_CATALOG . 'includes/hooks/' . $this->_site . '/' . $group;
if (file_exists($directory)) {
if ($dir = @dir($directory)) {
while ($file = $dir->read()) {
if (!is_dir($directory . '/' . $file)) {
if (substr($file, strrpos($file, '.')) == '.php') {
$code = substr($file, 0, strrpos($file, '.'));
$class = 'hook_' . $this->_site . '_' . $group . '_' . $code;
include $directory . '/' . $file;
$GLOBALS[$class] = new $class();
foreach (get_class_methods($GLOBALS[$class]) as $method) {
if (substr($method, 0, 7) == 'listen_') {
$this->_hooks[$this->_site][$group][substr($method, 7)][] = $code;
}
}
}
}
}
$dir->close();
}
}
}
开发者ID:Akofelaz,项目名称:oscommerce2,代码行数:25,代码来源:hooks.php
示例8: generateGuis
protected function generateGuis($guiController)
{
$activeTab = $this->getParam("activeTab");
$needTabs = $this->getParam("needTabs");
$gui = new $guiController($this->nodeData);
$nodeId = $this->nodeData['tree_id'];
$classMethods = get_class_methods($gui);
$tabsHeader = '<ul class="tabs">';
$addAccess = K_access::accessTree($nodeId, array('add', 'addremove'), true);
$i = 0;
foreach ($classMethods as $methodName) {
if (strpos($methodName, 'GUI') !== false && $gui->{$methodName}() !== false) {
$tabName = substr($methodName, 0, -3);
// var_dump( $this->tabAction($tabName));
// var_dump( K_access::accessTree($nodeId,$this->tabAction($tabName)));
if ($addAccess || K_access::accessTree($nodeId, $this->tabAction($tabName))) {
$i++;
if (empty($needTabs) || in_array($tabName, $needTabs)) {
echo '<div class="gui-block tab_content ' . $tabName . '" id="tab' . ($i + 1) . '" >' . $gui->{$methodName}() . '</div>';
$tabsHeader .= '<li ' . ($tabName == $activeTab ? 'class="activeTab"' : '') . '><a href="#tab' . ($i + 1) . '" id="tab-' . $tabName . '", >' . (isset($gui->tabs[substr($methodName, 0, -3)]) ? $gui->tabs[substr($methodName, 0, -3)] : '---') . '</a></li>';
}
}
if ($i == 0) {
$this->putAjax("<div style='margin:15px'>Для этого пункта доступен только просмотр");
}
}
}
$tabsHeader .= '</ul>';
echo $tabsHeader;
}
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:30,代码来源:gcontroller.php
示例9: methods
/** @test */
public function methods()
{
$needed_methods = array('toArray');
$this->assertThat(array_unique(get_class_methods(__NAMESPACE__ . '\\DbIterator')), new \PHPUnit_Framework_Constraint_Callback(function ($class_methods) use($needed_methods) {
return $needed_methods === array_intersect($needed_methods, $class_methods);
}));
}
开发者ID:neoparla,项目名称:dbescaper,代码行数:8,代码来源:DbIteratorTest.php
示例10: run
public function run()
{
if (fnmatch('*cli*', php_sapi_name())) {
$dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
if (is_dir($dir)) {
Timer::start();
Cli::show("Start of execution", 'COMMENT');
$files = glob($dir . DS . '*.php');
foreach ($files as $file) {
require_once $file;
$object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
$class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
$instance = lib('app')->make($class);
$methods = get_class_methods($instance);
Cli::show("Start schedule '{$object}'", 'COMMENT');
foreach ($methods as $method) {
$when = $this->getWhen($instance, $method);
$isDue = $this->isDue($object, $method, $when);
if (true === $isDue) {
Cli::show("Execution of {$object}->{$method}", 'INFO');
$instance->{$method}();
} else {
Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
}
}
}
Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
Cli::show("end of execution", 'COMMENT');
}
}
}
开发者ID:schpill,项目名称:standalone,代码行数:31,代码来源:schedule.php
示例11: tpl
static function tpl($group = 'home')
{
//基本配置
$tpl = self::get_instance();
self::process_view_config($group, $tpl);
//网站元信息
$tpl->assign(config(null, 'site'));
//设置目录常量
$tpl->assign('url', U_R_L);
$dir_data = system::set_url_dir(true);
$tpl->assign('dir', $dir_data);
//注册全局组件
foreach (array('function', 'modifier') as $type) {
$class = 'p_' . $type;
include PATH_ROOT . 'plugin/' . $class . '.php';
if (class_exists($class)) {
$method_data = get_class_methods($class);
foreach ($method_data as $method) {
$tpl->registerPlugin($type, $method, array($class, $method));
}
}
}
//处理分组业务
if (defined('GROUP_NAME')) {
self::process_group($tpl);
}
return $tpl;
}
开发者ID:lianren,项目名称:framework,代码行数:28,代码来源:s_smarty.php
示例12: findByArray
/**
* Finds the first child that has data matching specific values
*
* @param array $findSets
* @param boolean $caseSensitive OPTIONAL
*
* @return AbstractDataEntity
*
* @throws OutOfBoundsException if no matching child is found
*/
public function findByArray(array $findSets, $caseSensitive = false)
{
$foundChild = null;
$methods = get_class_methods($this->getChildClass());
foreach ($this as $child) {
$childMatches = true;
foreach ($findSets as $key => $value) {
$getter = $this->getFunctionName($key);
if (!in_array($getter, $methods)) {
$getter = $this->getFunctionName('get_' . $key);
}
$childValue = $child->{$getter}();
if (!$caseSensitive) {
$value = strtolower($value);
$childValue = strtolower($childValue);
}
if ($childValue != $value) {
$childMatches = false;
break;
}
}
if ($childMatches) {
$foundChild = $child;
break;
}
}
if ($foundChild === null) {
throw new OutOfBoundsException('No matching child found!');
}
return $foundChild;
}
开发者ID:janiv,项目名称:shelf,代码行数:41,代码来源:AbstractDataEntityCollection.php
示例13: __construct
/**
* 架构函数
* @access public
*/
public function __construct()
{
//控制器初始化
if (method_exists($this, '_initialize')) {
$this->_initialize();
}
//导入类库
Vendor('Hprose.HproseHttpServer');
//实例化HproseHttpServer
$server = new \HproseHttpServer();
if ($this->allowMethodList) {
$methods = $this->allowMethodList;
} else {
$methods = get_class_methods($this);
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
}
$server->addMethods($methods, $this);
if (APP_DEBUG || $this->debug) {
$server->setDebugEnabled(true);
}
// Hprose设置
$server->setCrossDomainEnabled($this->crossDomain);
$server->setP3PEnabled($this->P3P);
$server->setGetEnabled($this->get);
// 启动server
$server->start();
}
开发者ID:amaranth0203,项目名称:Sources,代码行数:31,代码来源:HproseController.class.php
示例14: run
/**
* Runs the tests
*
* @return array $results
* Returns array of results. A result consists of
*/
function run()
{
$results = array();
$this->saveState();
$class = get_class($this);
$class_methods = get_class_methods($class);
shuffle($class_methods);
// execute tests in random order!
foreach ($class_methods as $cm) {
if (substr($cm, -4) == 'Test') {
// Run the test
if (is_callable(array($this, 'setUp'))) {
$this->setUp();
}
//echo "running $class::$cm...\n";
try {
$ret = call_user_func(array($this, $cm));
// $ret is not used for now.
$results[$class][$cm] = array(self::TEST_SUCCEEDED, 'succeeded');
} catch (Pie_Exception_TestCase $e) {
// one of the predefined testcase outcomes occurred
$results[$class][$cm] = array($e->getCode(), $e->getMessage());
} catch (Exception $e) {
$results[$class][$cm] = array(self::TEST_EXCEPTION, 'exception', $e);
}
if (is_callable(array($this, 'tearDown'))) {
$this->tearDown();
}
$this->restoreState();
}
}
$this->hasToRun = false;
return $results;
}
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:40,代码来源:TestCase.php
示例15: __construct
/**
* Input construct.
*
* @param array $name
* @param mixed $value
* @param array|null $inputConfig
* @throws InvalidArgumentException
*/
public function __construct($name, $value, $inputConfig)
{
if (!is_array($value)) {
if (is_object($value) && in_array("__toString", get_class_methods($value))) {
$value = strval($value->__toString());
} else {
$value = strval($value);
}
$value = trim($value);
if ($value !== '') {
$value = str_replace('"', '"', $value);
$value = json_decode($value, true);
// strict mode
// if (json_last_error() != JSON_ERROR_NONE || !is_array($value)) {
// throw new InvalidArgumentException('Invalid string to convert to array');
// }
}
}
if (is_array($value)) {
$value = array_merge($this->defaultOptions, $value);
} else {
$value = $this->defaultOptions;
}
parent::__construct($name, $value, $inputConfig);
}
开发者ID:Top-Tech,项目名称:Top-tech,代码行数:33,代码来源:PaginationInput.php
示例16: initMethod
private static function initMethod(string $annotatedClassName, bool $onlyRouteAnnotations = false, string $methodName = null)
{
$methods = get_class_methods($annotatedClassName);
if (isset($methodName)) {
$methods = array($methodName);
}
foreach ($methods as $method) {
$reader = new \Framework\Core\Annotations\AnnotationReader($annotatedClassName, $method);
$all = $reader->getParameters();
if ($onlyRouteAnnotations === false) {
$all = array_filter($all, function ($k) {
return !in_array($k, \Framework\Core\Annotations\AnnotationConfig::ROUTE_ANNOTATIONS);
}, ARRAY_FILTER_USE_KEY);
} else {
$all = array_filter($all, function ($k) {
return in_array($k, \Framework\Core\Annotations\AnnotationConfig::ROUTE_ANNOTATIONS);
}, ARRAY_FILTER_USE_KEY);
}
foreach ($all as $anon => $anonValue) {
$className = AnnotationConfig::ANNOTATION_NAMESPACE . $anon;
if (class_exists($className)) {
$annotation = new $className(null, $annotatedClassName, $anonValue, null, null, $method);
$annotation->execute();
}
//let the app continue in case of the loader intercepting regular doc comments
}
}
}
开发者ID:pgyordanov,项目名称:PHP,代码行数:28,代码来源:AnnotationLoader.php
示例17: _get
/**
* ‘ормирует описание переменной, в соответствии с переданным шаблоном оформлени¤
* @param mixed $var переменна¤
* @param string $name заголовок описани¤
* @param array $tmpl шаблон оформлени¤
* @return string
*/
function _get($var, $name = 'INFO', $tmpl)
{
$type = gettype($var);
switch ($type) {
default:
$out = $tmpl['value'] . $var . $tmpl['/value'];
break;
case 'boolean':
$out = $tmpl['value'] . ($var ? 'true' : 'false') . $tmpl['/value'];
break;
case 'string':
$out = $tmpl['size'] . strlen($var) . $tmpl['/size'] . $tmpl['value'] . htmlspecialchars($var) . $tmpl['/value'];
break;
case 'array':
$values = Varier::_getSection($var, $tmpl, '+');
$out = $tmpl['size'] . count($var) . $tmpl['/size'] . $values;
break;
case 'object':
$class = get_class($var);
$properties = Varier::_getSection(get_object_vars($var), $tmpl, 'properties');
$methods = Varier::_getSection(get_class_methods($class), $tmpl, 'methods');
$out = $tmpl['class_name'] . $class . $tmpl['/class_name'] . $tmpl['properties'] . $properties . $tmpl['/properties'] . $tmpl['methods'] . $methods . $tmpl['/methods'];
break;
}
return $tmpl['element'] . $tmpl['name'] . $name . $tmpl['/name'] . $tmpl['type'] . $type . $tmpl['/type'] . $out . $tmpl['/element'];
}
开发者ID:space77,项目名称:mwfv3_sp,代码行数:33,代码来源:class.varier.php
示例18: load_extra_preloads
public function load_extra_preloads($dir, $name)
{
$dir = rtrim($dir, '/');
$extra = array();
if (is_dir($dir . '/events')) {
$file_list = XoopsLists::getFileListAsArray($dir . '/events');
foreach ($file_list as $file) {
if (preg_match('/(\\.php)$/i', $file)) {
$file = substr($file, 0, -4);
$extra[] = $file;
}
}
}
foreach ($extra as $preload) {
include_once $dir . '/events/' . $preload . '.php';
$class_name = ucfirst($name) . ucfirst($preload) . 'Preload';
if (!class_exists($class_name)) {
continue;
}
$class_methods = get_class_methods($class_name);
foreach ($class_methods as $method) {
if (strpos($method, 'event') === 0) {
$event_name = strtolower(str_replace('event', '', $method));
$event = array('class_name' => $class_name, 'method' => $method);
$this->_events[$event_name][] = $event;
}
}
}
}
开发者ID:txmodxoops,项目名称:rmcommon,代码行数:29,代码来源:events.php
示例19: methods
/** @test */
public function methods()
{
$needed_methods = array('isValid', 'getRealValue');
$this->assertThat(array_unique(get_class_methods(__NAMESPACE__ . '\\Binding')), new \PHPUnit_Framework_Constraint_Callback(function ($class_methods) use($needed_methods) {
return $needed_methods === array_intersect($needed_methods, $class_methods);
}));
}
开发者ID:neoparla,项目名称:dbescaper,代码行数:8,代码来源:BindingTest.php
示例20: is_callable
function is_callable($var, $syntax_only = false)
{
if ($syntax_only) {
/* from The Manual:
* If the syntax_only argument is TRUE the function only verifies
* that var might be a function or method. It will only reject simple
* variables that are not strings, or an array that does not have a
* valid structure to be used as a callback. The valid ones are
* supposed to have only 2 entries, the first of which is an object
* or a string, and the second a string
*/
return is_string($var) || is_array($var) && count($var) == 2 && is_string(end($var)) && (is_string(reset($var)) || is_object(reset($var)));
} else {
if (is_string($var)) {
return function_exists($var);
} else {
if (is_array($var) && count($var) == 2 && is_string($method = end($var))) {
$obj = reset($var);
if (is_string($obj)) {
$methods = get_class_methods($obj);
return (bool) (is_array($methods) && in_array(strtolower($method), $methods));
} else {
if (is_object($obj)) {
return method_exists($obj, $method);
}
}
}
}
return false;
}
}
开发者ID:patmark,项目名称:care2x-tz,代码行数:31,代码来源:is_callable.php
注:本文中的get_class_methods函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论