本文整理汇总了PHP中ReflectionObject::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::getMethod方法的具体用法?PHP ReflectionObject::getMethod怎么用?PHP ReflectionObject::getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testProtectedMethods
/**
* Test Clone
*/
public function testProtectedMethods()
{
$result = ConcreteSingleton::getInstance();
$reflection = new \ReflectionObject($result);
$this->assertTrue($reflection->getMethod('__construct')->isProtected());
$this->assertTrue($reflection->getMethod('__clone')->isProtected());
}
示例2: instanceMapFrom
/**
* @param FormField $formField
* @param KForm $form
*/
public function instanceMapFrom(FormField $formField, KForm $form)
{
$attribute = $formField->getFieldName();
$method = 'mappingFromFormField' . ucfirst($attribute);
if ($this->instanceReflector->hasMethod($method)) {
$methodReflector = $this->instanceReflector->getMethod($method);
$parameters = array();
foreach ($methodReflector->getParameters() as $paramReflector) {
switch (true) {
case $paramReflector->getClass()->isSubclassOf(KForm::class):
$parameters[] = $form;
break;
case $paramReflector->getClass()->isSubclassOf(FormField::class):
$parameters[] = $formField;
break;
default:
$parameters[] = $formField;
break;
}
}
call_user_func_array(array($this->instance, $method), $parameters);
} else {
$this->instance->{$attribute} = $formField->getValue();
}
}
示例3: __call
public function __call($method, $args)
{
if (!method_exists($this->entity, $method) or !is_callable(array($this->entity, $method))) {
throw new OvoCommonException('Method ' . $method . ' not exists or is not public');
}
$value = $this->reflectionObject->getMethod($method)->invokeArgs($this->entity, $args);
if ($value == null) {
$value = $this;
}
return $value;
}
示例4: testProcessTaggedPlugins
public function testProcessTaggedPlugins()
{
$r = new \ReflectionObject($this->compiler);
$m = $r->getMethod('processTaggedDeployers');
$m->setAccessible(true);
$m->invoke($this->compiler, $this->getFakeContainer());
$m = $r->getMethod('getDeployer');
$m->setAccessible(true);
$result = $m->invoke($this->compiler, 'test');
$this->assertEquals($result, 'deployer.test');
}
示例5: testGetRedisObject
/**
* @see \Endeveit\Cache\Drivers\Redis::getRedisObject()
*/
public function testGetRedisObject()
{
$method = self::$driverReflection->getMethod('getRedisObject');
$method->setAccessible(true);
$property = self::$driverReflection->getProperty('connectionsOptions');
$property->setAccessible(true);
$options = $property->getValue(self::$driver);
$this->assertCount(2, $options);
foreach (array_keys($options) as $key) {
$this->assertInstanceOf('Redis', $method->invoke(self::$driver, $key));
}
}
示例6: runController
public function runController($cName, $aName, $params)
{
$theController = new $cName();
$reflection_object = new ReflectionObject($theController);
if ($reflection_object->hasMethod('before_action')) {
$reflection_object->getMethod('before_action')->invoke($theController);
}
call_user_func_array(array($theController, $aName), $params);
if ($reflection_object->hasMethod('after_action')) {
$reflection_object->getMethod('after_action')->invoke($theController);
}
}
示例7: remap
public function remap()
{
$ci =& get_instance();
$method = $ci->uri->rsegment(2);
$parameters = array_slice($ci->uri->rsegment_array(), 2);
$reflection = new ReflectionObject($ci);
if ($reflection->hasMethod($method)) {
$reflection->getMethod($method)->invokeArgs($ci, $parameters);
} else {
array_splice($parameters, 0, 0, $method);
$reflection->getMethod("index")->invokeArgs($ci, $parameters);
}
}
示例8: __construct
public function __construct()
{
$this->context = AgaviContext::getInstance();
$this->parser = new AppKitFormatParserUtil();
$p =& $this->parser;
$p->registerNamespace('xmlfn', AppKitFormatParserUtil::TYPE_METHOD);
$ref = new ReflectionObject($this);
// Register some methods
$p->registerMethod('xmlfn', 'author', array(&$this, $ref->getMethod('valueAuthor')));
$p->registerMethod('xmlfn', 'instance', array(&$this, $ref->getMethod('valueDefaultInstance')));
$p->registerMethod('xmlfn', 'pagerMaxItems', array(&$this, $ref->getMethod('pagerMaxItems')));
$p->registerMethod('xmlfn', 'autoRefreshTime', array(&$this, $ref->getMethod('autoRefreshTime')));
}
示例9: testLockReleased
public function testLockReleased()
{
$locker = new FileLockStrategy(__DIR__ . '/../../../../../app/cache/queue-test.bin');
$locker->clear();
$rLocker = new \ReflectionObject($locker);
$method = $rLocker->getMethod('getFile');
$method->setAccessible(true);
$file = $method->invoke($locker);
$this->assertTrue(is_resource($file), true);
$method2 = $rLocker->getMethod('releaseFile');
$method2->setAccessible(true);
$method2->invokeArgs($locker, [$file]);
$file = $method->invoke($locker);
$this->assertTrue(is_resource($file), true);
}
示例10: testNoConstructor
public function testNoConstructor()
{
$obj = Singleton::getInstance();
$refl = new \ReflectionObject($obj);
$meth = $refl->getMethod('__construct');
$this->assertTrue($meth->isPrivate());
}
示例11: testBuildPath
/**
* Test build path.
*/
public function testBuildPath()
{
$reflection_object = new \ReflectionObject($this->client);
$reflection_method = $reflection_object->getMethod('buildPath');
$reflection_method->setAccessible(TRUE);
$this->assertEquals($reflection_method->invoke($this->client), 'HNK2IC/F_jM8Zls30dL/guid/-/2849493');
}
示例12: execute
public static function execute($commande, $params)
{
session_start();
$endpoint=new static();
$commande = "API_".$commande;
$endpointReflx = new ReflectionObject($endpoint);
$methodReflx = $endpointReflx->getMethod($commande);
try{
$result =$methodReflx->invokeArgs($endpoint, $params);
$result = [
'status'=>'success',
'value'=>$result
];
}
catch(ErrorException $ex)
{
$result = [
'status'=>'error',
'value'=>$ex->getMessage()
];
}
session_commit();
return $result;
}
示例13: testFilterResponseConvertsCookies
public function testFilterResponseConvertsCookies()
{
$client = new Client(new TestHttpKernel());
$r = new \ReflectionObject($client);
$m = $r->getMethod('filterResponse');
$m->setAccessible(true);
$expected = array(
'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly',
'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly'
);
$response = new Response();
$response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$domResponse = $m->invoke($client, $response);
$this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie'));
$response = new Response();
$response->headers->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$response->headers->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')->format('U'), '/foo', 'http://example.com', true, true));
$domResponse = $m->invoke($client, $response);
$this->assertEquals($expected[0], $domResponse->getHeader('Set-Cookie'));
$this->assertEquals($expected, $domResponse->getHeader('Set-Cookie', false));
}
示例14: testCommitNeedNotification
public function testCommitNeedNotification()
{
$notifier = $this->getMock('Sismo\\Contrib\\CrossFingerNotifier');
$r = new \ReflectionObject($notifier);
$m = $r->getMethod('commitNeedNotification');
$m->setAccessible(true);
$project = new Project('Twig');
$commit = new Commit($project, '123456');
$commit->setAuthor('Fabien');
$commit->setMessage('Foo');
$commit2 = new Commit($project, '123455');
$commit2->setAuthor('Fabien');
$commit2->setMessage('Bar');
$commit2->setStatusCode('success');
$commit3 = clone $commit2;
//a failed commit should be notified
$this->assertTrue($m->invoke($notifier, $commit));
//a successful commit without predecessor should be notified
$this->assertTrue($m->invoke($notifier, $commit2));
$project->setCommits(array($commit3));
//a successful commit with a successful predecessor should NOT be notified
$this->assertFalse($m->invoke($notifier, $commit2));
$project->setCommits(array($commit2, $commit3));
//a failed commit with a successful predecessor should be notified
$this->assertTrue($m->invoke($notifier, $commit));
}
示例15: callProtectedMethod
protected function callProtectedMethod($object, $method, array $args = array())
{
$reflectedObject = new \ReflectionObject($object);
$reflectedMethod = $reflectedObject->getMethod($method);
$reflectedMethod->setAccessible(true);
return $reflectedMethod->invokeArgs($object, $args);
}