本文整理汇总了PHP中Zend_Reflection_Class::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Reflection_Class::getMethod方法的具体用法?PHP Zend_Reflection_Class::getMethod怎么用?PHP Zend_Reflection_Class::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Reflection_Class
的用法示例。
在下文中一共展示了Zend_Reflection_Class::getMethod方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDocblockTags
public function testDocblockTags()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
$this->assertEquals($classReflection->getMethod('doSomething')->getDocblock()->hasTag('return'), true);
$returnTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals(get_class($returnTag), 'Zend_Reflection_Docblock_Tag_Return');
$this->assertEquals($returnTag->getType(), 'mixed');
}
示例2: testToString
public function testToString()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass6');
$tag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('descriptionTag');
$expectedString = "Docblock Tag [ * @descriptionTag ]" . PHP_EOL;
$this->assertEquals($expectedString, (string) $tag);
}
示例3: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
if (!in_array(Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(), array('admin', 'admin_language'))) {
return;
}
$resource = new User_Model_Acl_Resource();
$resource->getAdminPrivileges();
if ($resource->admin_privileges) {
//$actionStack = Zend_Controller_Action_HelperBroker::getStaticHelper('ActionStack');
$actionStack = new Zend_Controller_Plugin_ActionStack();
foreach ($resource->admin_privileges as $module => $actions) {
$class = ucfirst($module) . '_AdminController';
if (!class_exists($class)) {
Zend_Loader::loadFile(APPLICATION_PATH . '/modules/' . $module . '/controllers/AdminController.php');
}
$reflection = new Zend_Reflection_Class($class);
$method = null;
try {
if ($method = $reflection->getMethod('menuAction')) {
$actionStack->pushStack(new Zend_Controller_Request_Simple('menu', 'admin', $module, array('admin_actions' => array_flip($actions))));
}
} catch (Exception $e) {
}
}
}
}
示例4: testNamespaceInParam
/**
* @group ZF-8307
*/
public function testNamespaceInParam()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_Docblock_Param_WithNamespace');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals('Zend\\Foo\\Bar', $paramTag->getType());
$this->assertEquals('$var', $paramTag->getVariableName());
$this->assertEquals('desc', $paramTag->getDescription());
}
示例5: _authenticateRequired
/**
* Prüft ob der Service einen Account benötigt
* @param string $classname
* @param string $methodname
* @return boolean
*/
private function _authenticateRequired($classname, $methodname)
{
try {
$reflectionClass = new Zend_Reflection_Class($classname);
return $reflectionClass->getMethod($methodname)->getDocblock()->hasTag('dragonx_account_authenticate');
} catch (Exception $exception) {
}
return false;
}
示例6: testMethodReturns
public function testMethodReturns()
{
$reflectionClass = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass2');
$methodByName = $reflectionClass->getMethod('getProp1');
$this->assertEquals('Zend_Reflection_Method', get_class($methodByName));
$methodsAll = $reflectionClass->getMethods();
$this->assertEquals(3, count($methodsAll));
$firstMethod = array_shift($methodsAll);
$this->assertEquals('getProp1', $firstMethod->getName());
}
示例7: preDispatch
/**
* Prüft bei jedem Request ist die Authentifizierung
* @param Dragon_Json_Server_Request_Http $request
*/
public function preDispatch(Dragon_Json_Server_Request_Http $request)
{
try {
list($classname, $methodname) = $request->parseMethod();
$reflectionClass = new Zend_Reflection_Class($classname);
$tagResource = $reflectionClass->getMethod($methodname)->getDocblock()->getTag('dragonx_acl_resource');
if (!$tagResource) {
return;
}
$resource = $tagResource->getDescription();
} catch (Exception $exception) {
return;
}
$resources = array();
if (Zend_Registry::isRegistered('recordAccount')) {
$logicAcl = new DragonX_Acl_Logic_Acl();
$resources = $logicAcl->getResources(Zend_Registry::get('recordAccount'));
}
if (!in_array($resource, $resources)) {
throw new Dragon_Application_Exception_System('missing resource', array('resource' => $resource));
}
}
示例8: getFirstReflectionParameter
/**
* @param string $method
* @return Zend_Reflection_Parameter
*/
private function getFirstReflectionParameter($method)
{
$reflClass = new Zend_Reflection_Class('Zend_CodeGenerator_Php_ParameterExample');
$method = $reflClass->getMethod($method);
$params = $method->getParameters();
return array_shift($params);
}
示例9: testReturnClassWithNamespace
/**
* @group ZF-8307
*/
public function testReturnClassWithNamespace()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_Docblock_Param_WithNamespace');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals('Zend\\Reflection\\Docblock', $paramTag->getType());
}
示例10: getMethod
/**
*
* @return ThemeHouse_Reflection_Method
*/
public function getMethod($name, $reflectionClass = 'ThemeHouse_Reflection_Method')
{
return parent::getMethod($name, $reflectionClass);
}
示例11: testType
public function testType()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals($paramTag->getType(), 'mixed');
}
示例12: document
/**
* Document a web service along with its response
*
* @param string $classname The service class name
* @param string $methodname The service method name
* @param string $response The server response
* @return string
* @author Mark Nielsen
*/
public function document($classname, $methodname, $response)
{
$markup = '';
if (!empty($methodname)) {
mr_bootstrap::zend();
require_once 'Zend/Reflection/Class.php';
$class = new Zend_Reflection_Class($classname);
$method = $class->getMethod($methodname);
$phpdoc = $method->getDocblock();
$params = $method->getParameters();
$description = $phpdoc->getShortDescription();
$longdesc = $phpdoc->getLongDescription();
if (!empty($longdesc)) {
$description .= "\n{$longdesc}";
}
$markup .= "h2. {$methodname}\n";
$markup .= "*Description:*\n{$description}\n\n";
$markup .= "*Parameters:*\n";
$markup .= "* _string_ *method*: (Required) Must be set to '{$methodname}'\n";
/** @var $params Zend_Reflection_Parameter[] */
foreach ($params as $param) {
$name = $param->getName();
$tags = $phpdoc->getTags('param');
if (isset($tags[$param->getPosition()])) {
$tag = $tags[$param->getPosition()];
$typestr = '_' . $tag->getType() . '_ ';
$descstr = $tag->getDescription();
} else {
$typestr = $descstr = '';
}
if ($param->isOptional() and $param->isDefaultValueAvailable()) {
$default = $param->getDefaultValue();
if (is_null($default)) {
$default = 'NULL';
} else {
if (!is_numeric($default) and is_string($default)) {
$default = "'{$default}'";
}
}
$descstr = "(Optional, default = {$default}) {$descstr}";
} else {
if ($param->isOptional()) {
$descstr = "(Optional) {$descstr}";
} else {
$descstr = "(Required) {$descstr}";
}
}
$markup .= "* {$typestr}*{$name}*: {$descstr}\n";
}
$markup .= "\n*Example Response:*\n";
if ($simplexml = @simplexml_load_string($response)) {
$dom = dom_import_simplexml($simplexml)->ownerDocument;
$dom->formatOutput = true;
$markup .= "{code:xml}\n";
$markup .= trim($dom->saveXML());
$markup .= "\n{code}\n";
} else {
if (($json = json_decode($response)) !== NULL) {
$markup .= "{noformat}\n";
$markup .= $response;
$markup .= "\n{noformat}\n\n";
$markup .= "*Example Response (decoded JSON):*\n";
$markup .= "{noformat}\n";
$markup .= trim(print_r($json, true));
$markup .= "\n{noformat}\n";
} else {
$markup .= "{noformat}\n";
$markup .= trim($response);
$markup .= "\n{noformat}\n";
}
}
$markup = $this->generalize_text($markup);
// Add to overall markup string
$this->markup .= "{$markup}\n\n";
}
return $markup;
}
示例13: testVariableName
public function testVariableName()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals($paramTag->getVariableName(), '$one');
}