downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ReflectionClass::__clone> <Reflection::getModifierNames
[edit] Last updated: Sat, 07 Jan 2012

view this page in

The ReflectionClass class

(PHP 5)

소개

The ReflectionClass class reports information about a class.

클래스 개요

ReflectionClass implements Reflector {
/* 상수 */
const integer IS_IMPLICIT_ABSTRACT = 16 ;
const integer IS_EXPLICIT_ABSTRACT = 32 ;
const integer IS_FINAL = 64 ;
/* 프로퍼티 */
/* 메소드 */
final private void ReflectionClass::__clone ( void )
public static string ReflectionClass::export ( mixed $argument [, bool $return = false ] )
public mixed ReflectionClass::getConstant ( string $name )
public array ReflectionClass::getConstants ( void )
public object ReflectionClass::getConstructor ( void )
public string ReflectionClass::getDocComment ( void )
public int ReflectionClass::getEndLine ( void )
public ReflectionExtension ReflectionClass::getExtension ( void )
public string ReflectionClass::getExtensionName ( void )
public string ReflectionClass::getFileName ( void )
public array ReflectionClass::getInterfaceNames ( void )
public array ReflectionClass::getInterfaces ( void )
public ReflectionMethod ReflectionClass::getMethod ( string $name )
public array ReflectionClass::getMethods ([ string $filter ] )
public int ReflectionClass::getModifiers ( void )
public string ReflectionClass::getName ( void )
public string ReflectionClass::getNamespaceName ( void )
public object ReflectionClass::getParentClass ( void )
public array ReflectionClass::getProperties ([ int $filter ] )
public ReflectionProperty ReflectionClass::getProperty ( string $name )
public string ReflectionClass::getShortName ( void )
public int ReflectionClass::getStartLine ( void )
public mixed ReflectionClass::getStaticPropertyValue ( string $name [, string $default ] )
public array ReflectionClass::getTraitAliases ( void )
public array ReflectionClass::getTraitNames ( void )
public array ReflectionClass::getTraits ( void )
public bool ReflectionClass::hasConstant ( string $name )
public bool ReflectionClass::hasMethod ( string $name )
public bool ReflectionClass::hasProperty ( string $name )
public bool ReflectionClass::implementsInterface ( string $interface )
public bool ReflectionClass::inNamespace ( void )
public bool ReflectionClass::isAbstract ( void )
public bool ReflectionClass::isCloneable ( void )
public bool ReflectionClass::isFinal ( void )
public bool ReflectionClass::isInstance ( object $object )
public bool ReflectionClass::isInstantiable ( void )
public bool ReflectionClass::isInterface ( void )
public bool ReflectionClass::isInternal ( void )
public bool ReflectionClass::isIterateable ( void )
public bool ReflectionClass::isSubclassOf ( string $class )
public bool ReflectionClass::isTrait ( void )
public bool ReflectionClass::isUserDefined ( void )
public object ReflectionClass::newInstance ( mixed $args [, mixed $... ] )
public object ReflectionClass::newInstanceArgs ([ array $args ] )
public void ReflectionClass::setStaticPropertyValue ( string $name , string $value )
public string ReflectionClass::__toString ( void )
}

프로퍼티

name

Name of the class. Read-only, throws ReflectionException in attempt to write.

예약 상수

ReflectionClass Modifiers

ReflectionClass::IS_IMPLICIT_ABSTRACT

Indicates class that is abstract because it has some abstract methods.

ReflectionClass::IS_EXPLICIT_ABSTRACT

Indicates class that is abstract because of its definition.

ReflectionClass::IS_FINAL

Indicates final class.

Table of Contents



ReflectionClass::__clone> <Reflection::getModifierNames
[edit] Last updated: Sat, 07 Jan 2012
 
add a note add a note User Contributed Notes ReflectionClass - [5 notes]
up
3
Anonymous
1 year ago
Unserialized reflection class cause error.

<?php
/**
 * abc
 */
class a{}

$ref = new ReflectionClass('a');
$ref = unserialize(serialize($ref));
var_dump($ref);
var_dump($ref->getDocComment());

// object(ReflectionClass)#2 (1) {
//   ["name"]=>
//   string(1) "a"
// }
// PHP Fatal error:  ReflectionClass::getDocComment(): Internal error: Failed to retrieve the reflection object
?>
up
1
danbettles at yahoo dot co dot uk
4 years ago
To reflect on a namespaced class in PHP 5.3, you must always specify the fully qualified name of the class - even if you've aliased the containing namespace using a "use" statement.

So instead of:

<?php
use App\Core as Core;
$oReflectionClass = new ReflectionClass('Core\Singleton');
?>

You would type:

<?php
use App\Core as Core;
$oReflectionClass = new ReflectionClass('App\Core\Singleton');
?>
up
0
Anonymous
7 days ago
Reflecting an alias will give you a reflection of the resolved class.

<?php

class X {
   
}

class_alias('X','Y');
class_alias('Y','Z');
$z = new ReflectionClass('Z');
echo
$z->getName(); // X

?>
up
-2
snx
11 months ago
if you want to use an object method as a callback parameter for any asynchronous action you have to transfer the reflection method and the object itself.

consider doing something like this:
<?php
class Callback extends ReflectionMethod{

    protected
$oObject;
   
    public function
__construct($oObject, $sMethod){
       
parent::__construct($oObject, $sMethod);
       
$this->oObject = $oObject;
       
$this->setAccessible(true); //to access even protected methods..
   
}
   
    public function
invoke(){
       
$this->invokeArgs($this->oObject, func_get_args());
    }
   
}
?>

now you can easy create an reflector for the specific object method and pass it to any function...
<?php
class ClassA{
    public function
doSomething(){
       
$oCallback = new Callback($this, '_asyncCallback');
       
doAsyncCall($oCallback);
    }
    protected function
_asyncCallback(...){
       
//...
   
}
}

function
doAsyncCall($oCallback){
   
$oCallback->invoke(...);
}
?>
up
-2
thecelavi at gmail dot com
3 years ago
Right:

<?php
use AppCore as Core;
$oReflectionClass = new ReflectionClass('App\Core\Singleton');
?>

Wrong:

<?php
use AppCore as Core;
$oReflectionClass = new ReflectionClass('\App\Core\Singleton');
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites