本文整理汇总了PHP中Method类的典型用法代码示例。如果您正苦于以下问题:PHP Method类的具体用法?PHP Method怎么用?PHP Method使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public function parse($comment)
{
$lines = $this->getLines($comment);
$lines = array_map(function ($line) {
return $this->parseLine($line);
}, $lines);
$lines = array_filter($lines, function ($line) {
return $line && $this->isParam($line) && $this->hasExtra($line);
});
$lines = array_map(function ($line) {
return array_slice($line, 1);
}, $lines);
if (count($lines) > 0) {
$method = new Method();
$index = 0;
foreach ($lines as $line) {
if (count($line) == 1) {
// @param {type}
$method->addParam($index++, $line[0]);
} else {
if (count($line) >= 2) {
// @param {type} ${name} [...]
$method->addParam($index++, $line[0], ltrim($line[1], '$'));
}
}
}
return $method;
}
return false;
}
示例2: Method
public function &updateClassDetails(&$File, &$Component, &$SourceAnalyzer)
{
$MethodInstance = new Method(array('init' => false));
$MethodInstance->setConnection($this->getConnection());
$MethodInstance->init();
$parsed_details = $SourceAnalyzer->getParsedArray($File->body);
$available_classes = empty($parsed_details['classes']) ? array() : array_keys($parsed_details['classes']);
if (empty($available_classes)) {
return $available_classes;
}
$Classes = array();
foreach ($available_classes as $class_name) {
$extends = !empty($parsed_details['classes'][$class_name]['extends']) ? $parsed_details['classes'][$class_name]['extends'] : false;
if ($extends) {
$SourceAnalyzer->log('Looking for parent class: ' . $extends);
$ParentClass = $this->_addOrUpdateClassDetails($extends, $File, $Component, $SourceAnalyzer, array(), true);
}
$Class = $this->_addOrUpdateClassDetails($class_name, $File, $Component, $SourceAnalyzer, $parsed_details['classes'][$class_name]);
if (!empty($ParentClass)) {
$SourceAnalyzer->log('Setting ' . $extends . ' as the parent of ' . $class_name);
$ParentClass->tree->addChild($Class);
$ParentClass->save();
}
$Class->methods = array();
if (!empty($parsed_details['classes'][$class_name]['methods'])) {
foreach ($parsed_details['classes'][$class_name]['methods'] as $method_name => $method_details) {
$Class->methods[] = $MethodInstance->updateMethodDetails($Class, $method_name, $method_details, $SourceAnalyzer);
}
}
$Classes[] = $Class;
}
return $Classes;
}
示例3: testHasParameters
/**
* @covers Puml\Model\Method::hasParameters
*/
public function testHasParameters()
{
$this->assertFalse($this->object->hasParameters());
$parameter = $this->getMock('\\Puml\\Model\\MethodParameter');
$this->object->addParameter($parameter);
$this->assertTrue($this->object->hasParameters());
}
示例4: test___construct_returnsSelf_ifNamesIsString
/**
* __construct() should set the exception's names and message if names is string
*/
public function test___construct_returnsSelf_ifNamesIsString()
{
$name = 'foo';
$e = new Method($name);
$this->assertEquals([$name], $e->getNames());
$this->assertEquals("Method {$name} could not be found", $e->getMessage());
return;
}
示例5: testScenario1
public function testScenario1()
{
$name = 'setDoctrine';
$injectionKeys = array('doctrine');
$method = new Method();
$method->setName($name);
$method->setInjectionKeys($injectionKeys);
$this->assertEquals($name, $method->getName());
$this->assertEquals($injectionKeys, $method->getInjectionKeys());
$this->assertTrue($method->hasInjectionKeys());
$this->assertEquals($method, new Method($method->__toArray()));
$newMethod = new Method($method->__toArray());
$this->assertEquals($method->__toArray(), $newMethod->__toArray());
}
示例6: print_debug_info
function print_debug_info($method, $endpoint, $headers)
{
print "\n";
print "Method: " . Method::nameForEnumValue($method) . "\n";
print "Endpoint: " . $endpoint . "\n";
print_r($headers);
}
示例7: _createFromReflection
/**
* @load
* @param ReflectionMethod $reflection
*/
protected function _createFromReflection($reflection)
{
$this->_type = Method::SpiritMethod;
parent::_createFromReflection($reflection);
//{ Add Views
if ($this->isPublic()) {
$viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.*' . $this->controller()->name() . '.view.-' . $this->name());
if (file_exists($viewPath)) {
$dh = opendir($viewPath);
$viewsFound = array();
while (false !== ($file = readdir($dh))) {
if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
$viewFilePath = rtrim($viewPath, '/') . "/{$file}";
$viewsFound[$file] = $viewFilePath;
$this->addView(SpiritView::create($this, pathinfo($file, PATHINFO_FILENAME)));
}
}
closedir($dh);
if (array_key_exists('view.php', $viewsFound)) {
$this->setHasDefaultView();
}
}
}
//}
}
示例8: addFunctionsByNames
/**
* @param string[] $function_name_list
* A list of function names to load type information for
*/
private function addFunctionsByNames(array $function_name_list)
{
foreach ($function_name_list as $i => $function_name) {
foreach (Method::methodListFromFunctionName($this, $function_name) as $method) {
$this->addMethod($method);
}
}
}
示例9: dispatch_array
/**
* Dispatch a method, whether a filter or function
* @param Callable|string $method The method to call
* @param array $args An array of arguments to be passed to the method
* @return bool|mixed The return value from the dispatched method
*/
public static function dispatch_array($method, $args = array())
{
if (is_callable($method)) {
return call_user_func_array($method, $args);
} elseif (is_string($method)) {
array_unshift($args, $method, false);
return call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $args);
}
return false;
}
示例10: _createFromReflection
/**
* @param ReflectionClass $reflection
*/
protected function _createFromReflection($reflection)
{
$this->_className = $reflection->getName();
$this->_endLine = $reflection->getEndLine();
$this->_filePath = $reflection->getFileName();
foreach ($reflection->getMethods() as $method) {
//Method::create($this, $method);
$this->addMethod(Method::create($this, $method));
}
}
示例11: actionMethod
function actionMethod($id = null)
{
if ($id == null) {
$this->render('methods', array('methods' => Method::model()->findAll()));
} else {
$c = Method::model()->findByPk($id);
if ($c == null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$this->render('method', array('method' => $c));
}
}
示例12: forge
/**
* Gets a new instance of the Method class.
*
* @param string The name or instance of the Method to link to
* @return Method
*/
public static function forge($method = 'default')
{
if (is_string($method)) {
$set = \Method::instance($method) and $method = $set;
}
if ($method instanceof Method_Template) {
if ($method->template(false) != null) {
throw new \DomainException('Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.');
}
}
return new static($method);
}
示例13: toDocTypeString
/**
* toDocTypeString
* @param Method $method
* @return string
*/
public function toDocTypeString(Method $method)
{
$longestType = 0;
$longestName = 0;
foreach ($method->getParameters() as $parameter) {
if (strlen($parameter->getType()) > $longestType) {
$longestType = strlen($parameter->getType());
}
if (strlen($parameter->getName()) > $longestName) {
$longestName = strlen($parameter->getName());
}
}
$returnVar = ' * @param';
$returnVar .= ' ' . $this->getType() . str_repeat(' ', $longestType - strlen($this->getType()));
$returnVar .= ' $' . $this->getName();
if (strlen($this->getDescription()) > 0) {
$returnVar .= str_repeat(' ', $longestName - strlen($this->getName())) . ' ' . $this->getDescription();
}
$returnVar .= "\n";
return $returnVar;
}
示例14: campaignAction
function campaignAction()
{
$this->filter();
$pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
$models = AFActiveDataProvider::models('Pixelrate', $this->params, $pagination);
$pixelrates = $models->getAllGroupByCampaign();
$id = AF::get($this->params, 'campaign_id');
$methods = Method::model()->cache()->findAllInArray();
Assets::js('jquery.form');
$this->addToPageTitle('Pixel rates');
$this->render('campaign', array('pixelrates' => $pixelrates, 'pagination' => $pagination, 'methods' => $methods, 'campaign_id' => $id));
}
示例15: _methodNval
protected function _methodNval($name = '', $val = '', $met = '')
{
if ($met === "post") {
return Method::post($name, $val);
}
if ($met === "get") {
return Method::get($name, $val);
}
if ($met === "request") {
return Method::request($name, $val);
}
}