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


PHP ReflectionMethod::isProtected方法代码示例

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


在下文中一共展示了ReflectionMethod::isProtected方法的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: 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

示例3: _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

示例4: _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

示例5: isProtected

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

示例6: testPublicize_with_protected_static_method

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

示例7: getVisibilityStyle

 /**
  * Get output style for the given method's visibility.
  *
  * @param \ReflectionMethod $method
  *
  * @return string
  */
 private function getVisibilityStyle(\ReflectionMethod $method)
 {
     if ($method->isPublic()) {
         return self::IS_PUBLIC;
     } elseif ($method->isProtected()) {
         return self::IS_PROTECTED;
     } else {
         return self::IS_PRIVATE;
     }
 }
开发者ID:saj696,项目名称:pipe,代码行数:17,代码来源:MethodEnumerator.php

示例8: 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

示例9: 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

示例10: testGetVariable

 /**
  * @dataProvider templateDataProvider
  */
 public function testGetVariable($data)
 {
     $method = new ReflectionMethod($this->parser, 'getVariable');
     $this->assertTrue($method->isProtected());
     $method->setAccessible(true);
     $this->assertEquals('Lex', $method->invoke($this->parser, 'name', $data));
     $this->assertEquals(null, $method->invoke($this->parser, 'age', $data));
     $this->assertEquals(false, $method->invoke($this->parser, 'age', $data, false));
     $this->assertEquals(true, $method->invoke($this->parser, 'filters.enable', $data));
     $this->assertEquals(null, $method->invoke($this->parser, 'filters.name', $data));
     $this->assertEquals(false, $method->invoke($this->parser, 'filters.name', $data, false));
 }
开发者ID:ivantcholakov,项目名称:lex,代码行数:15,代码来源:ParserTest.php

示例11: fromReflection

 public static function fromReflection(\ReflectionMethod $ref)
 {
     $method = new static();
     $method->setFinal($ref->isFinal())->setAbstract($ref->isAbstract())->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE))->setReferenceReturned($ref->returnsReference())->setName($ref->name);
     if ($docComment = $ref->getDocComment()) {
         $method->setDocblock(ReflectionUtils::getUnindentedDocComment($docComment));
     }
     foreach ($ref->getParameters() as $param) {
         $method->addParameter(static::createParameter($param));
     }
     // FIXME: Extract body?
     return $method;
 }
开发者ID:ingeniorweb,项目名称:symfo3cv,代码行数:13,代码来源:PhpMethod.php

示例12: 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

示例13: fromReflection

 public static function fromReflection(\ReflectionMethod $ref)
 {
     $method = new static($ref->name);
     $method->setFinal($ref->isFinal())->setAbstract($ref->isAbstract())->setStatic($ref->isStatic())->setVisibility($ref->isPublic() ? self::VISIBILITY_PUBLIC : ($ref->isProtected() ? self::VISIBILITY_PROTECTED : self::VISIBILITY_PRIVATE))->setReferenceReturned($ref->returnsReference())->setBody(ReflectionUtils::getFunctionBody($ref));
     $docblock = new Docblock($ref);
     $method->setDocblock($docblock);
     $method->setDescription($docblock->getShortDescription());
     $method->setLongDescription($docblock->getLongDescription());
     foreach ($ref->getParameters() as $param) {
         $method->addParameter(static::createParameter($param));
     }
     return $method;
 }
开发者ID:jmcclell,项目名称:php-code-generator,代码行数:13,代码来源:PhpMethod.php

示例14: 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

示例15: __construct

 public static final function getService()
 {
     $class = get_called_class();
     if (($rc = new ReflectionClass($class)) && $rc->isAbstract()) {
         throw new Exception('Class "' . $class . '", extending "Clap_ServiceInstance", cannot be called as a "Service" if it is "Abstract"');
     }
     if (!method_exists($class, '__construct')) {
         throw new Exception('Class "' . $class . '" extending "Clap_ServiceInstance", require "' . $class . '" to implement the method  "protected function __construct()"');
     }
     if (($rm = new ReflectionMethod($class, '__construct')) && !$rm->isProtected()) {
         throw new Exception('Access type for method "' . $class . '::__construct()" must be declared as "protected" to be compatible with "Clap_ServiceInstance", in "' . $rm->getFileName() . '" on line "' . $rm->getStartLine() . '"');
     }
     return new self($class);
 }
开发者ID:TristanMouchet,项目名称:Clap,代码行数:14,代码来源:ServiceInstance.php


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