當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。