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
?>
ReflectionClass Sınıfı
(PHP 5)
Giriş
ReflectionClass sınıfı bir sınıf hakkında bilgi edinilmesini sağlar.
Sınıf Sözdizimi
ReflectionClass
implements
Reflector
{
/* Sabitler */
/* Özellikler */
public
$name
;
/* Yöntemler */
__construct
( string
}$değiştirge
)Özellikler
- name
-
Sınıfın ismi. Salt-okunur olup, yazılmaya çalışılırsa ReflectionException istisnası oluşur.
Öntanımlı Sabitler
İçindekiler
- ReflectionClass::__clone — Nesnenin bir kopyasını oluşturur
- ReflectionClass::__construct — Bir ReflectionClass nesnesi oluşturur
- ReflectionClass::export — Bir sınıf ihraç eder
- ReflectionClass::getConstant — Tanımlı sabitleri döndürür
- ReflectionClass::getConstants — Sabitleri döndürür
- ReflectionClass::getConstructor — Kurucuyu döndürür
- ReflectionClass::getDefaultProperties — Öntanımlı özellikleri döndürür
- ReflectionClass::getDocComment — Belgelendirici açıklamaları döndürür
- ReflectionClass::getEndLine — Son satırın numarasını döndürür
- ReflectionClass::getExtension — Eklenti bilgilerini döndürür
- ReflectionClass::getExtensionName — Eklentinin ismini döndürür
- ReflectionClass::getFileName — Bir dosya adı döndürür
- ReflectionClass::getInterfaceNames — Arayüz isimlerini döndürür
- ReflectionClass::getInterfaces — Arayüzleri döndürür
- ReflectionClass::getMethod — Bir yöntemle ilgili bir ReflectionMethod nesnesi döndürür
- ReflectionClass::getMethods — Yöntem listesini döndürür
- ReflectionClass::getModifiers — Değiştiricileri döndürür
- ReflectionClass::getName — Sınıf ismini döndürür
- ReflectionClass::getNamespaceName — İsim alanı ismini döndürür
- ReflectionClass::getParentClass — Ebeveyn sınıfı döndürür
- ReflectionClass::getProperties — Özellikleri döndürür
- ReflectionClass::getProperty — Bir özellik döndürür
- ReflectionClass::getShortName — Kısa adı döndürür
- ReflectionClass::getStartLine — Başlangıç satır numarasını döndürür
- ReflectionClass::getStaticProperties — Duruk özellikleri döndürür
- ReflectionClass::getStaticPropertyValue — Duruk özelliğin değerini döndürür
- ReflectionClass::getTraitAliases — Returns an array of trait aliases
- ReflectionClass::getTraitNames — Returns an array of names of traits used by this class
- ReflectionClass::getTraits — Returns an array of traits used by this class
- ReflectionClass::hasConstant — Sabit tanımlı mı diye bakar
- ReflectionClass::hasMethod — Yöntem tanımlı mı diye bakar
- ReflectionClass::hasProperty — Özellik tanımlı mı diye bakar
- ReflectionClass::implementsInterface — Arayüz gerçeklenmiş mi diye bakar
- ReflectionClass::inNamespace — Sınıf isim alanında mı diye bakar
- ReflectionClass::isAbstract — Sınıf soyut mu diye bakar
- ReflectionClass::isCloneable — Returns whether this class is cloneable
- ReflectionClass::isFinal — Sınıf bir final sınıf mı diye bakar
- ReflectionClass::isInstance — Sınıf bir nesne örneği mi diye bakar
- ReflectionClass::isInstantiable — Sınıf örneklenebilir mi diye bakar
- ReflectionClass::isInterface — Sınıf bir arayüz mü diye bakar
- ReflectionClass::isInternal — Sınıf yerleşik bir sınıf mı diye bakar
- ReflectionClass::isIterateable — Sınıf yinelenebilir mi diye bakar
- ReflectionClass::isSubclassOf — Sınıf bir alt sınıf mı diye bakar
- ReflectionClass::isTrait — Returns whether this is a trait
- ReflectionClass::isUserDefined — Sınıf bir kullanıcı tanımlı sınıf mı diye bakar
- ReflectionClass::newInstance — Yeni örnek
- ReflectionClass::newInstanceArgs — Yeni örnek değiştirgeleri
- ReflectionClass::newInstanceWithoutConstructor — Creates a new class instance without invoking the constructor.
- ReflectionClass::setStaticPropertyValue — Duruk özelliğe değer atar
- ReflectionClass::__toString — Dizgesel tepkiyi görselleştirir
Anonymous
11-Nov-2011 02:58
thecelavi at gmail dot com
30-Nov-2009 09:07
Right:
<?php
use AppCore as Core;
$oReflectionClass = new ReflectionClass('App\Core\Singleton');
?>
Wrong:
<?php
use AppCore as Core;
$oReflectionClass = new ReflectionClass('\App\Core\Singleton');
?>
danbettles at yahoo dot co dot uk
28-Mar-2009 08:48
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');
?>
