当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionMethod::isPrivate方法代码示例

本文整理汇总了PHP中ReflectionMethod::isPrivate方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::isPrivate方法的具体用法?PHP ReflectionMethod::isPrivate怎么用?PHP ReflectionMethod::isPrivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionMethod的用法示例。


在下文中一共展示了ReflectionMethod::isPrivate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(PropertyAnnotation $annotation, \ReflectionMethod $reflection)
 {
     $this->reflection = $reflection;
     $this->annotation = $annotation;
     if ($this->reflection->isPrivate() || $this->reflection->isProtected()) {
         $this->reflection->setAccessible(true);
     }
 }
开发者ID:agnetsolutions,项目名称:common,代码行数:8,代码来源:DefaultMethodMetadata.php

示例2: ReturnTypeInferer

 /**
  * @param Factory $factory
  * @param string $class
  * @param string $name
  * @param array|Argument[] $arguments
  * @param array|History[] $collected
  * @throws \ReflectionException If the method cannot be stubbed
  */
 function __construct(Factory $factory, $class, $name, array $arguments = [], array $collected = [])
 {
     $this->class = $class;
     $this->name = $name;
     $this->arguments = $arguments;
     $this->reflection = new \ReflectionMethod($class, $name);
     $this->typeHint = new ReturnTypeInferer($this->reflection, $factory);
     $this->history = new History($collected);
     if ($this->reflection->isPrivate()) {
         throw new \ReflectionException("Cannot stub private methods [{$this->class}::{$name}()]");
     } else {
         if ($this->reflection->isStatic()) {
             throw new \ReflectionException("Cannot stub static methods [{$this->class}::{$name}()]");
         }
     }
 }
开发者ID:rtens,项目名称:mockster3,代码行数:24,代码来源:Stub.php

示例3: _checkProtection

 protected function _checkProtection($protectionType)
 {
     // Check type
     if (!is_string($protectionType) || $protectionType != self::PROTECTION_CSRF && $protectionType != self::PROTECTION_CAPTCHA && $protectionType != self::PROTECTION_BRUTEFORCE && $protectionType != self::PROTECTION_XSS) {
         throw new \Exception('Invalid protection type : "' . $protectionType . '"');
     }
     // Check class
     if (class_exists('framework\\security\\form\\' . ucfirst($protectionType))) {
         $className = 'framework\\security\\form\\' . ucfirst($protectionType);
     } else {
         $className = $protectionType;
     }
     $class = new \ReflectionClass($className);
     if (!in_array('framework\\security\\IForm', $class->getInterfaceNames())) {
         throw new \Exception('Form protection drivers must be implement framework\\security\\IForm');
     }
     if ($class->isAbstract()) {
         throw new \Exception('Form protection drivers must be not abstract class');
     }
     if ($class->isInterface()) {
         throw new \Exception('Form protection drivers must be not interface');
     }
     $classInstance = $class->newInstanceWithoutConstructor();
     $constuctor = new \ReflectionMethod($classInstance, '__construct');
     if ($constuctor->isPrivate() || $constuctor->isProtected()) {
         throw new \Exception('Protection constructor must be public');
     }
     return $className;
 }
开发者ID:eric-burel,项目名称:twentyparts,代码行数:29,代码来源:Form.class.php

示例4: _invoke

 private function _invoke($clz = '', $act = '', $param, $namespace = 'Home\\Controller\\')
 {
     $clz = ucwords($clz);
     $clz_name = $namespace . $clz . 'Controller';
     try {
         $ref_clz = new \ReflectionClass($clz_name);
         if ($ref_clz->hasMethod($act)) {
             $ref_fun = new \ReflectionMethod($clz_name, $act);
             if ($ref_fun->isPrivate() || $ref_fun->isProtected()) {
                 $ref_fun->setAccessible(true);
             }
             if ($ref_fun->isStatic()) {
                 $ref_fun->invoke(null);
             } else {
                 $ref_fun_par = $ref_fun->getParameters();
                 if (!empty($param) && is_array($param)) {
                     if (is_array($ref_fun_par) && count($ref_fun_par) == count($param)) {
                         $ref_fun->invokeArgs(new $clz_name(), $param);
                     } else {
                         $ref_fun->invoke(new $clz_name());
                     }
                 } else {
                     $ref_fun->invoke(new $clz_name());
                 }
             }
         }
     } catch (\LogicException $le) {
         $this->ajaxReturn(array('status' => '500', 'info' => '服务器内部发生严重错误'));
     } catch (\ReflectionException $re) {
         $this->ajaxReturn(array('status' => '404', 'info' => '访问' . $clz . '控制器下的非法操作', 'data' => array('code' => $re->getCode())));
     }
 }
开发者ID:AInotamm,项目名称:Welcome2015,代码行数:32,代码来源:ApiController.class.php

示例5: appthemes_bad_method_visibility

/**
 * Prints warning about any hooked method with bad visibility (that are either protected or private)
 * @return void
 */
function appthemes_bad_method_visibility()
{
    global $wp_filter;
    $arguments = func_get_args();
    $tag = array_shift($arguments);
    $errors = new WP_Error();
    if (!isset($wp_filter[$tag])) {
        return;
    }
    foreach ($wp_filter[$tag] as $prioritized_callbacks) {
        foreach ($prioritized_callbacks as $callback) {
            $function = $callback['function'];
            if (is_array($function)) {
                try {
                    $method = new ReflectionMethod($function[0], $function[1]);
                    if ($method->isPrivate() || $method->isProtected()) {
                        $class = get_class($function[0]);
                        if (!$class) {
                            $class = $function[0];
                        }
                        $errors->add('visiblity', $class . '::' . $function[1] . ' was hooked into "' . $tag . '", but is either protected or private.');
                    }
                } catch (Exception $e) {
                    // Failure to replicate method. Might be magic method. Fail silently
                }
            }
        }
    }
    if ($errors->get_error_messages()) {
        foreach ($errors->get_error_messages() as $message) {
            echo $message;
        }
    }
}
开发者ID:kalushta,项目名称:darom,代码行数:38,代码来源:debug.php

示例6: reflector

 private static function reflector($method_and_params)
 {
     $class = get_called_class();
     $method = $method_and_params[0];
     $args = $method_and_params[1];
     $reflectionMethod = new \ReflectionMethod($class, $method);
     if (!$reflectionMethod->isStatic()) {
         throw new \Exception("The method: {$class}::{$method} should be static!!");
     }
     if (!$reflectionMethod->isPrivate()) {
         throw new \Exception("The static method: {$class}::{$method} should be private!!");
     }
     $params = array();
     foreach ($reflectionMethod->getParameters() as $param) {
         if (isset($args[$param->getName()])) {
             $params[] = $args[$param->getName()];
         } else {
             if ($param->isOptional()) {
                 $params[] = $param->getDefaultValue();
             } else {
                 throw new \Exception("The method: {$class}::{$method}  signature requires a \"\${$param->getName()}\" argument!!");
             }
         }
     }
     $reflectionMethod->setAccessible(true);
     return $reflectionMethod->invokeArgs(null, $params);
 }
开发者ID:hidekscorporation,项目名称:hideksframework2,代码行数:27,代码来源:Helper.php

示例7: isPrivate

 /**
  * Returns whether this method is private
  *
  * @return boolean TRUE if this method is private
  */
 public function isPrivate()
 {
     if ($this->reflectionSource instanceof ReflectionMethod) {
         return $this->reflectionSource->isPrivate();
     } else {
         return parent::isPrivate();
     }
 }
开发者ID:naderman,项目名称:ezc-reflection,代码行数:13,代码来源:method.php

示例8: testPublicize_with_private_static_method

 public function testPublicize_with_private_static_method()
 {
     $className = __FUNCTION__ . md5(uniqid());
     eval(sprintf('class %s { private static function foo() { return true; } }', $className));
     $reflectionMethod = new ReflectionMethod($className, 'foo');
     $this->assertTrue($reflectionMethod->isPrivate());
     $this->assertTrue($reflectionMethod->isStatic());
     $this->assertSame($reflectionMethod, $reflectionMethod->publicize());
     $this->assertSame(true, $reflectionMethod->invoke($className));
 }
开发者ID:suin,项目名称:php-expose,代码行数:10,代码来源:ReflectionMethodTest.php

示例9: setVisibilityFromReflection

 /**
  * @param \ReflectionMethod $reflection
  */
 public function setVisibilityFromReflection(\ReflectionMethod $reflection)
 {
     if ($reflection->isPublic()) {
         $this->setVisibility('public');
     }
     if ($reflection->isProtected()) {
         $this->setVisibility('protected');
     }
     if ($reflection->isPrivate()) {
         $this->setVisibility('private');
     }
 }
开发者ID:tomaszdurka,项目名称:codegenerator,代码行数:15,代码来源:MethodBlock.php

示例10: callPrivateMethod

 /**
  * @param object $object
  * @param string $method
  * @param array  $args
  *
  * @return mixed
  */
 protected function callPrivateMethod($object, $method, $args = array())
 {
     $reflectionMethod = new \ReflectionMethod($object, $method);
     if ($reflectionMethod->isPrivate() || $reflectionMethod->isProtected()) {
         $reflectionMethod->setAccessible(true);
         $result = $reflectionMethod->invokeArgs($reflectionMethod->isStatic() ? null : $object, $args);
         $reflectionMethod->setAccessible(false);
         return $result;
     } else {
         return call_user_func_array(array($object, $method), $args);
     }
 }
开发者ID:jaczkog,项目名称:json-rpc,代码行数:19,代码来源:AbstractTestCase.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 public function execute(MetaModel $metaModel)
 {
     $object = $this->subNode->execute($metaModel);
     if (is_null($object)) {
         throw new ExecutionException("Calling method '{$this->method}' on null");
     }
     $reflectionMethod = new \ReflectionMethod($object, $this->method);
     // God mode
     if ($reflectionMethod->isPrivate() || $reflectionMethod->isProtected()) {
         $reflectionMethod->setAccessible(true);
     }
     return $reflectionMethod->invoke($object);
 }
开发者ID:mnapoli,项目名称:metamodel,代码行数:16,代码来源:MethodCall.php

示例12: assertEqualMethods

 /**
  * @param \ReflectionMethod $reflectionMethod
  * @param \Donquixote\HastyReflectionCommon\Reflection\FunctionLike\MethodReflectionInterface $methodReflection
  */
 private function assertEqualMethods(\ReflectionMethod $reflectionMethod, MethodReflectionInterface $methodReflection)
 {
     $this->assertEquals($reflectionMethod->isAbstract(), $methodReflection->isAbstract());
     $this->assertEquals($reflectionMethod->getDeclaringClass()->getName(), $methodReflection->getDeclaringClassName());
     $this->assertEquals($reflectionMethod->getDocComment(), $methodReflection->getDocComment());
     $this->assertEquals($reflectionMethod->getShortName(), $methodReflection->getName());
     $this->assertEquals($reflectionMethod->getName(), $methodReflection->getName());
     $this->assertEquals($reflectionMethod->class . '::' . $reflectionMethod->getName(), $methodReflection->getQualifiedName());
     $this->assertEquals($reflectionMethod->returnsReference(), $methodReflection->isByReference());
     $this->assertEquals($reflectionMethod->isPrivate(), $methodReflection->isPrivate());
     $this->assertEquals($reflectionMethod->isProtected(), $methodReflection->isProtected());
     $this->assertEquals($reflectionMethod->isPublic(), $methodReflection->isPublic());
     $this->assertEquals($reflectionMethod->isStatic(), $methodReflection->isStatic());
 }
开发者ID:donquixote,项目名称:hasty-reflection-common,代码行数:18,代码来源:ClassIndexTest.php

示例13: assertIsSingleton

 protected function assertIsSingleton($class, $instance = null)
 {
     foreach (array('__construct', '__clone') as $methodName) {
         $method = new \ReflectionMethod($class, $methodName);
         $this->assertTrue($method->isProtected() || $method->isPrivate());
     }
     $getInstance = function () use($class) {
         return call_user_func(array($class, 'getInstance'));
     };
     if ($instance) {
         $this->assertEquals(spl_object_hash($instance), spl_object_hash($getInstance()));
     }
     $this->assertEquals(spl_object_hash($getInstance()), spl_object_hash($getInstance()));
 }
开发者ID:rafabrutaldrums,项目名称:casamacario,代码行数:14,代码来源:Test.php

示例14: getRunkitMethodFlags

 public static function getRunkitMethodFlags($className, $methodName)
 {
     $ref = new ReflectionMethod($className, $methodName);
     $flags = 0;
     if ($ref->isPrivate()) {
         $flags |= RUNKIT_ACC_PRIVATE;
     } elseif ($ref->isProtected()) {
         $flags |= RUNKIT_ACC_PROTECTED;
     } else {
         $flags |= RUNKIT_ACC_PUBLIC;
     }
     if ($ref->isStatic()) {
         $flags |= RUNKIT_ACC_STATIC;
     }
     return $flags;
 }
开发者ID:rsaugier,项目名称:ytest,代码行数:16,代码来源:yTest_Reflection.php

示例15: reload_method

 public static function reload_method($classname, $methodname)
 {
     $method = new ReflectionMethod($classname, $methodname);
     $visibility = RUNKIT_ACC_PUBLIC;
     if ($method->isProtected()) {
         $visibility = RUNKIT_ACC_PROTECTED;
     } else {
         if ($method->isPrivate()) {
             $visibility = RUNKIT_ACC_PRIVATE;
         }
     }
     if ($method->isStatic()) {
         $visibility = $visibility | RUNKIT_ACC_STATIC;
     }
     return runkit_method_redefine($classname, $methodname, self::getMethodArguments($classname, $methodname), self::getMethodCode($classname, $methodname), $visibility);
 }
开发者ID:linusshops,项目名称:self-modifying-code,代码行数:16,代码来源:SMC.php


注:本文中的ReflectionMethod::isPrivate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。