本文整理汇总了PHP中ReflectionClass::isCloneable方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::isCloneable方法的具体用法?PHP ReflectionClass::isCloneable怎么用?PHP ReflectionClass::isCloneable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::isCloneable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classData
/**
* Created by PhpStorm.
* User: raynald
* Date: 2/23/15
* Time: 8:43 AM
*/
function classData(ReflectionClass $class)
{
$details = "";
$name = $class->getName();
if ($class->isUserDefined()) {
$details .= "{$name} is user defined\n";
}
if ($class->isInternal()) {
$details .= "{$name} is built-in\n";
}
if ($class->isInterface()) {
$details .= "{$name} is interface\n";
}
if ($class->isAbstract()) {
$details .= "{$name} is an abstract class\n";
}
if ($class->isFinal()) {
$details .= "{$name} is a final class\n";
}
if ($class->isInstantiable()) {
$details .= "{$name} can be instantiated\n";
} else {
$details .= "{$name} can not be instantiated\n";
}
if ($class->isCloneable()) {
$details .= "{$name} can be cloned\n";
} else {
$details .= "{$name} can not be cloned\n";
}
return $details;
}
示例2: testIsCloneable
/**
*/
public function testIsCloneable()
{
$this->assertTrue($this->object->isCloneable());
$method = new ReflectionMethod('__clone');
$this->object->addMethod($method);
$this->assertTrue($this->object->isCloneable());
$method->setVisibility('private');
$this->assertFalse($this->object->isCloneable());
}
示例3: testThatCloningIsNotSupported
public function testThatCloningIsNotSupported()
{
$class = new \ReflectionClass('Symfony\\Component\\DependencyInjection\\Container');
$clone = $class->getMethod('__clone');
if (PHP_VERSION_ID >= 50400) {
$this->assertFalse($class->isCloneable());
}
$this->assertTrue($clone->isPrivate());
}
示例4: ReflectionClass
<?php
trait T
{
}
$r = new ReflectionClass('T');
var_dump(Reflection::getModifierNames($r->getModifiers()));
var_dump($r->isAbstract());
var_dump($r->isInstantiable());
var_dump($r->isCloneable());
示例5: isCloneable
public function isCloneable()
{
return $this->reflectionClass->isCloneable();
}
示例6: __clone
private function __clone()
{
}
}
$bar = new bar();
print "User class - private __clone\n";
$obj = new ReflectionClass($bar);
var_dump($obj->isCloneable());
$obj = new ReflectionObject($bar);
var_dump($obj->isCloneable());
$h = clone $foo;
print "Closure\n";
$closure = function () {
};
$obj = new ReflectionClass($closure);
var_dump($obj->isCloneable());
$obj = new ReflectionObject($closure);
var_dump($obj->isCloneable());
$h = clone $closure;
print "Internal class - SimpleXMLElement\n";
$obj = new ReflectionClass('simplexmlelement');
var_dump($obj->isCloneable());
$obj = new ReflectionObject(new simplexmlelement('<test></test>'));
var_dump($obj->isCloneable());
$h = clone new simplexmlelement('<test></test>');
print "Internal class - XMLWriter\n";
$obj = new ReflectionClass('xmlwriter');
var_dump($obj->isCloneable());
$obj = new ReflectionObject(new XMLWriter());
var_dump($obj->isCloneable());
$h = clone new xmlwriter();
示例7: testClone
public function testClone()
{
$reflection = new \ReflectionClass('SingletonInstance');
$this->assertFalse($reflection->isCloneable());
}
示例8: loadClassInfo
protected function loadClassInfo(\ReflectionClass $reflectedObject)
{
$this->classFile = $reflectedObject->getFileName();
if (empty($this->classFile)) {
$this->classFile = self::CLASSINFO_BUILTIN;
}
$this->classInterfaces = implode(', ', $reflectedObject->getInterfaceNames());
$this->classNamespace = $reflectedObject->getNamespaceName();
$parent = $reflectedObject->getParentClass();
if ($parent) {
$this->classParent = $parent->getName();
}
if (version_compare(phpversion(), '5.4', '>=')) {
$this->classTraits = implode(', ', $reflectedObject->getTraitNames());
}
$this->abstract = $reflectedObject->isAbstract();
$this->final = $reflectedObject->isFinal();
if (version_compare(phpversion(), '5.4', '>=')) {
$this->cloneable = $reflectedObject->isCloneable();
}
}
示例9: isCloneable
function isCloneable($class_name)
{
$info = new ReflectionClass($class_name);
return $info->isCloneable();
}